52 #define max(a,b) ( (a) > (b) ? (a) : (b) )
53 #define min(a,b) ( (a) < (b) ? (a) : (b) )
56 #include "RTOp_obj_value_value_vtbl.h"
62 static int RTOp_TOp_multiplier_step_apply_op(
66 , RTOp_ReductTarget reduct_obj )
73 struct RTOp_value_value_type *data_cntr = (
struct RTOp_value_value_type*)obj_data;
74 RTOp_value_type *mu = &data_cntr->value1;
75 RTOp_value_type *alpha = &data_cntr->value2;
77 RTOp_index_type sub_dim;
79 RTOp_value_type *z0_val;
82 const RTOp_value_type *v0_val;
85 const RTOp_value_type *v1_val;
88 const RTOp_value_type *v2_val;
92 register RTOp_index_type k;
97 if( num_vecs != 3 || ( num_vecs && vecs == NULL ) )
98 return RTOp_ERR_INVALID_NUM_VECS;
99 if( num_targ_vecs != 1 || ( num_targ_vecs && targ_vecs == NULL ) )
100 return RTOp_ERR_INVALID_NUM_TARG_VECS;
102 vecs[1].sub_dim != vecs[0].sub_dim
103 || vecs[2].sub_dim != vecs[0].sub_dim
104 || targ_vecs[0].sub_dim != vecs[0].sub_dim
106 return RTOp_ERR_INCOMPATIBLE_VECS;
112 sub_dim = vecs[0].sub_dim;
114 z0_val = targ_vecs[0].values;
115 z0_val_s = targ_vecs[0].values_stride;
117 v0_val = vecs[0].values;
118 v0_val_s = vecs[0].values_stride;
120 v1_val = vecs[1].values;
121 v1_val_s = vecs[1].values_stride;
123 v2_val = vecs[2].values;
124 v2_val_s = vecs[2].values_stride;
129 for( k = 0; k < sub_dim; ++k, v0_val += v0_val_s, v1_val += v1_val_s, v2_val += v2_val_s, z0_val += z0_val_s )
132 (*z0_val) = -(*v1_val) + (*mu)*(*v0_val) + (*alpha)*(*v0_val)*(*v1_val)*(*v2_val);
141 &RTOp_obj_value_value_vtbl
143 ,
"TOp_multiplier_step"
145 ,RTOp_TOp_multiplier_step_apply_op
152 int RTOp_TOp_multiplier_step_construct( RTOp_value_type mu, RTOp_value_type alpha,
struct RTOp_RTOp* op )
158 op->vtbl = &RTOp_TOp_multiplier_step_vtbl;
159 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
160 return RTOp_TOp_multiplier_step_init(mu,alpha,op);
163 int RTOp_TOp_multiplier_step_destroy(
struct RTOp_RTOp* op )
165 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
171 int RTOp_TOp_multiplier_step_init( RTOp_value_type mu, RTOp_value_type alpha,
struct RTOp_RTOp* op )
173 struct RTOp_value_value_type *ptr_data_cntr = (
struct RTOp_value_value_type*)op->obj_data;
174 RTOp_value_type *ptr_mu = &ptr_data_cntr->value1;
175 RTOp_value_type *ptr_alpha = &ptr_data_cntr->value2;
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)