51 #define max(a,b) ( (a) > (b) ? (a) : (b) )
52 #define min(a,b) ( (a) < (b) ? (a) : (b) )
55 #include "RTOp_obj_value_index_vtbl.h"
61 static int RTOp_TOp_Correct_Multipliers_apply_op(
65 , RTOp_ReductTarget reduct_obj )
72 struct RTOp_value_index_type *data_cntr = (
struct RTOp_value_index_type*)obj_data;
73 RTOp_value_type *inf_bound_limit = &data_cntr->value;
74 RTOp_index_type *lower_or_upper = &data_cntr->index;
76 RTOp_index_type sub_dim;
78 RTOp_value_type *z0_val;
81 const RTOp_value_type *v0_val;
85 register RTOp_index_type k;
90 if( num_vecs != 1 || ( num_vecs && vecs == NULL ) )
91 return RTOp_ERR_INVALID_NUM_VECS;
92 if( num_targ_vecs != 1 || ( num_targ_vecs && targ_vecs == NULL ) )
93 return RTOp_ERR_INVALID_NUM_TARG_VECS;
95 targ_vecs[0].sub_dim != vecs[0].sub_dim
97 return RTOp_ERR_INCOMPATIBLE_VECS;
104 sub_dim = vecs[0].sub_dim;
106 z0_val = targ_vecs[0].values;
107 z0_val_s = targ_vecs[0].values_stride;
109 v0_val = vecs[0].values;
110 v0_val_s = vecs[0].values_stride;
116 for( k = 0; k < sub_dim; ++k, v0_val += v0_val_s, z0_val += z0_val_s )
122 assert(*z0_val > -1e-50);
125 else if ( (*lower_or_upper) == 0 )
127 (*z0_val) = ((*v0_val) <= (*inf_bound_limit)) ? 0.0 : (*z0_val);
131 (*z0_val) = ((*v0_val) >= (*inf_bound_limit)) ? 0.0 : (*z0_val);
141 &RTOp_obj_value_index_vtbl
143 ,
"TOp_Correct_Multipliers"
145 ,RTOp_TOp_Correct_Multipliers_apply_op
152 int RTOp_TOp_Correct_Multipliers_construct( RTOp_value_type inf_bound_limit, RTOp_index_type lower_or_upper,
struct RTOp_RTOp* op )
158 op->vtbl = &RTOp_TOp_Correct_Multipliers_vtbl;
159 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
160 return RTOp_TOp_Correct_Multipliers_init(inf_bound_limit,lower_or_upper,op);
163 int RTOp_TOp_Correct_Multipliers_destroy(
struct RTOp_RTOp* op )
165 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
171 int RTOp_TOp_Correct_Multipliers_init( RTOp_value_type inf_bound_limit, RTOp_index_type lower_or_upper,
struct RTOp_RTOp* op )
173 struct RTOp_value_index_type *ptr_data_cntr = (
struct RTOp_value_index_type*)op->obj_data;
174 RTOp_value_type *ptr_inf_bound_limit = &ptr_data_cntr->value;
175 RTOp_index_type *ptr_lower_or_upper = &ptr_data_cntr->index;
176 *ptr_inf_bound_limit = inf_bound_limit;
177 *ptr_lower_or_upper = lower_or_upper;
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)