52 #define max(a,b) ( (a) > (b) ? (a) : (b) )
53 #define min(a,b) ( (a) < (b) ? (a) : (b) )
56 #include "RTOp_obj_value_vtbl.h"
60 static int RTOp_TOp_max_vec_scalar_apply_op(
64 , RTOp_ReductTarget reduct_obj )
71 RTOp_value_type *min_ele = (RTOp_value_type*)obj_data;
73 RTOp_index_type sub_dim;
75 RTOp_value_type *z0_val;
79 register RTOp_index_type k;
84 if( num_vecs != 0 || ( num_vecs && vecs == NULL ) )
85 return RTOp_ERR_INVALID_NUM_VECS;
86 if( num_targ_vecs != 1 || ( num_targ_vecs && targ_vecs == NULL ) )
87 return RTOp_ERR_INVALID_NUM_TARG_VECS;
93 sub_dim = targ_vecs[0].sub_dim;
95 z0_val = targ_vecs[0].values;
96 z0_val_s = targ_vecs[0].values_stride;
101 for( k = 0; k < sub_dim; ++k, z0_val += z0_val_s )
104 (*z0_val) = max((*z0_val),(*min_ele));
115 ,
"TOp_max_vec_scalar"
117 ,RTOp_TOp_max_vec_scalar_apply_op
124 int RTOp_TOp_max_vec_scalar_construct( RTOp_value_type min_ele,
struct RTOp_RTOp* op )
130 op->vtbl = &RTOp_TOp_max_vec_scalar_vtbl;
131 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
132 return RTOp_TOp_max_vec_scalar_init(min_ele,op);
135 int RTOp_TOp_max_vec_scalar_destroy(
struct RTOp_RTOp* op )
137 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
143 int RTOp_TOp_max_vec_scalar_init( RTOp_value_type min_ele,
struct RTOp_RTOp* op )
145 RTOp_value_type *ptr_min_ele = (RTOp_value_type*)op->obj_data;
146 *ptr_min_ele = min_ele;
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)