52 #define max(a,b) ( (a) > (b) ? (a) : (b) )
53 #define min(a,b) ( (a) < (b) ? (a) : (b) )
56 #include "RTOp_obj_null_vtbl.h"
57 #include "RTOp_reduct_max_value.h"
62 static int RTOp_ROp_max_apply_op(
66 , RTOp_ReductTarget reduct_obj )
73 RTOp_value_type *max_ele = (RTOp_value_type*)reduct_obj;
75 RTOp_index_type sub_dim;
77 const RTOp_value_type *v0_val;
81 register RTOp_index_type k;
83 RTOp_value_type max_ele_ith;
88 if( num_vecs != 1 || ( num_vecs && vecs == NULL ) )
89 return RTOp_ERR_INVALID_NUM_VECS;
90 if( num_targ_vecs != 0 || ( num_targ_vecs && targ_vecs == NULL ) )
91 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;
107 for( k = 0; k < sub_dim; ++k, v0_val += v0_val_s )
110 max_ele_ith = (*v0_val);
112 (*max_ele) = max( (*max_ele), max_ele_ith );
118 static int RTOp_ROp_max_reduct_obj_reinit(
120 ,RTOp_ReductTarget reduct_obj
123 RTOp_value_type *max_ele = (RTOp_value_type*)reduct_obj;
132 ,&RTOp_obj_value_vtbl
134 ,RTOp_ROp_max_reduct_obj_reinit
135 ,RTOp_ROp_max_apply_op
136 ,RTOp_reduct_max_value
137 ,RTOp_get_reduct_max_value_op
142 int RTOp_ROp_max_construct(
struct RTOp_RTOp* op )
148 op->vtbl = &RTOp_ROp_max_vtbl;
149 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
153 int RTOp_ROp_max_destroy(
struct RTOp_RTOp* op )
155 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
162 RTOp_value_type RTOp_ROp_max_val(RTOp_ReductTarget reduct_obj)
164 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)