45 #include "RTOp_obj_value_index_vtbl.h"
46 #include "RTOp_obj_null_vtbl.h"
50 static int RTOp_TOp_set_ele_apply_op(
54 , RTOp_ReductTarget targ_obj )
56 const struct RTOp_value_index_type *val_ind = NULL;
57 RTOp_value_type alpha;
59 RTOp_index_type global_offset;
60 RTOp_index_type z_sub_dim;
61 RTOp_value_type *z_val = NULL;
67 if( num_vecs != 0 || vecs != NULL )
68 return RTOp_ERR_INVALID_NUM_VECS;
69 if( num_targ_vecs != 1 || targ_vecs == NULL )
70 return RTOp_ERR_INVALID_NUM_TARG_VECS;
77 val_ind = (
const struct RTOp_value_index_type*)obj_data;
78 alpha = val_ind->value;
82 global_offset = targ_vecs[0].global_offset;
83 z_sub_dim = targ_vecs[0].sub_dim;
84 z_val = targ_vecs[0].values;
85 z_val_s = targ_vecs[0].values_stride;
91 if( i < global_offset + 1 || global_offset + z_sub_dim < i )
95 z_val[(ptrdiff_t)(z_val_s * (i-global_offset-1))] = alpha;
103 &RTOp_obj_value_index_vtbl
107 ,RTOp_TOp_set_ele_apply_op
115 int RTOp_TOp_set_ele_construct( RTOp_index_type i, RTOp_value_type alpha
118 struct RTOp_value_index_type *val_ind = NULL;
119 op->vtbl = &RTOp_TOp_set_ele_vtbl;
120 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
121 val_ind = (
struct RTOp_value_index_type*)op->obj_data;
122 val_ind->value = alpha;
127 int RTOp_TOp_set_ele_destroy(
struct RTOp_RTOp* op )
129 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
134 int RTOp_TOp_set_ele_set_i_alpha( RTOp_index_type i, RTOp_value_type alpha
137 struct RTOp_value_index_type
138 *val_ind = (
struct RTOp_value_index_type*)op->obj_data;
139 val_ind->value = alpha;
int(* obj_create)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void **obj)
int(* obj_free)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void **obj)