45 #include "RTOp_obj_index_vtbl.h"
46 #include "RTOp_obj_value_vtbl.h"
47 #include "RTOp_reduct_sum_value.h"
51 static int RTOp_ROp_get_ele_apply_op(
55 , RTOp_ReductTarget targ_obj )
58 RTOp_index_type global_offset;
59 RTOp_index_type sub_dim;
60 const RTOp_value_type *v0_val;
67 return RTOp_ERR_INVALID_NUM_VECS;
68 if( num_targ_vecs != 0 )
69 return RTOp_ERR_INVALID_NUM_TARG_VECS;
78 i = *((RTOp_index_type*)obj_data);
81 global_offset = vecs[0].global_offset;
82 sub_dim = vecs[0].sub_dim;
83 v0_val = vecs[0].values;
84 v0_val_s = vecs[0].values_stride;
90 if( i < global_offset + 1 || global_offset + sub_dim < i )
93 *((RTOp_value_type*)targ_obj) = *(v0_val+v0_val_s*(i-global_offset-1));
102 ,&RTOp_obj_value_vtbl
105 ,RTOp_ROp_get_ele_apply_op
106 ,RTOp_reduct_sum_value
107 ,RTOp_get_reduct_sum_value_op
112 int RTOp_ROp_get_ele_construct( RTOp_index_type i,
struct RTOp_RTOp* op )
114 op->vtbl = &RTOp_ROp_get_ele_vtbl;
115 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
116 *((RTOp_index_type*)op->obj_data) = i;
120 int RTOp_ROp_get_ele_set_i( RTOp_index_type i,
struct RTOp_RTOp* op )
122 *((RTOp_index_type*)op->obj_data) = i;
126 int RTOp_ROp_get_ele_destroy(
struct RTOp_RTOp* op )
128 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
133 RTOp_value_type RTOp_ROp_get_ele_val(RTOp_ReductTarget targ_obj)
135 return *((RTOp_value_type*)targ_obj);
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)