45 #include "RTOp_obj_value_vtbl.h"
46 #include "RTOp_reduct_sum_value.h"
57 static int RTOp_ROp_num_bounded_apply_op(
61 , RTOp_ReductTarget targ_obj )
63 RTOp_value_type inf_bnd;
64 RTOp_index_type sub_dim;
65 const RTOp_value_type *xl_val;
67 const RTOp_value_type *xu_val;
69 RTOp_index_type num_bounded = 0;
70 register RTOp_index_type k;
76 return RTOp_ERR_INVALID_NUM_VECS;
78 if( num_targ_vecs != 0 )
79 return RTOp_ERR_INVALID_NUM_TARG_VECS;
80 if( vecs[0].sub_dim != vecs[1].sub_dim )
81 return RTOp_ERR_INCOMPATIBLE_VECS;
88 inf_bnd = *((RTOp_value_type*)obj_data);
90 sub_dim = vecs[0].sub_dim;
92 xl_val = vecs[0].values;
93 xl_val_s = vecs[0].values_stride;
95 xu_val = vecs[1].values;
96 xu_val_s = vecs[1].values_stride;
101 for( k = 0; k < sub_dim; ++k, xl_val += xl_val_s, xu_val += xu_val_s ) {
102 if( *xl_val > -inf_bnd || *xu_val < +inf_bnd )
109 *((RTOp_value_type*)targ_obj) += num_bounded;
118 ,&RTOp_obj_value_vtbl
121 ,RTOp_ROp_num_bounded_apply_op
122 ,RTOp_reduct_sum_value
123 ,RTOp_get_reduct_sum_value_op
128 int RTOp_ROp_num_bounded_construct( RTOp_value_type inf_bnd,
struct RTOp_RTOp* op )
130 op->vtbl = &RTOp_ROp_num_bounded_vtbl;
131 op->vtbl->obj_data_vtbl->
obj_create( NULL, NULL, &op->obj_data );
132 *((RTOp_value_type*)op->obj_data) = inf_bnd;
136 int RTOp_ROp_num_bounded_destroy(
struct RTOp_RTOp* op )
138 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
143 int RTOp_ROp_num_bounded_set_inf_bnd( RTOp_value_type inf_bnd,
struct RTOp_RTOp* op )
145 *((RTOp_value_type*)op->obj_data) = inf_bnd;
149 RTOp_index_type RTOp_ROp_num_bounded_val(RTOp_ReductTarget targ_obj)
151 return (RTOp_index_type)*((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)