54 #define max(a,b) ( (a) > (b) ? (a) : (b) )
55 #define min(a,b) ( (a) < (b) ? (a) : (b) )
58 #include "RTOp_obj_null_vtbl.h"
59 #include "RTOp_reduct_sum_value.h"
63 static int RTOp_ROp_sum_abs_apply_op(
67 , RTOp_ReductTarget reduct_obj )
74 RTOp_value_type *abs_sum = (RTOp_value_type*)reduct_obj;
76 RTOp_index_type sub_dim;
78 const RTOp_value_type *v0_val;
82 register RTOp_index_type k;
84 RTOp_value_type abs_sum_ith;
89 if( num_vecs != 1 || ( num_vecs && vecs == NULL ) )
90 return RTOp_ERR_INVALID_NUM_VECS;
91 if( num_targ_vecs != 0 || ( num_targ_vecs && targ_vecs == NULL ) )
92 return RTOp_ERR_INVALID_NUM_TARG_VECS;
98 sub_dim = vecs[0].sub_dim;
100 v0_val = vecs[0].values;
101 v0_val_s = vecs[0].values_stride;
106 for( k = 0; k < sub_dim; ++k, v0_val += v0_val_s )
109 abs_sum_ith = fabs((*v0_val));
111 (*abs_sum) += abs_sum_ith;
121 ,&RTOp_obj_value_vtbl
124 ,RTOp_ROp_sum_abs_apply_op
125 ,RTOp_reduct_sum_value
126 ,RTOp_get_reduct_sum_value_op
131 int RTOp_ROp_sum_abs_construct(
struct RTOp_RTOp* op )
137 op->vtbl = &RTOp_ROp_sum_abs_vtbl;
138 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
142 int RTOp_ROp_sum_abs_destroy(
struct RTOp_RTOp* op )
144 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
151 RTOp_value_type RTOp_ROp_sum_abs_val(RTOp_ReductTarget reduct_obj)
153 return *((RTOp_value_type*)reduct_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)