51 #define max(a,b) ( (a) > (b) ? (a) : (b) )
52 #define min(a,b) ( (a) < (b) ? (a) : (b) )
55 #include "RTOp_obj_null_vtbl.h"
56 #include "RTOp_reduct_sum_value.h"
62 static int RTOp_ROp_log_bound_barrier_apply_op(
66 , RTOp_ReductTarget reduct_obj )
73 RTOp_value_type *log_result = (RTOp_value_type*)reduct_obj;
75 RTOp_index_type sub_dim;
77 const RTOp_value_type *v0_val;
80 const RTOp_value_type *v1_val;
83 const RTOp_value_type *v2_val;
86 register RTOp_index_type k;
91 if( num_vecs != 3 || ( num_vecs && vecs == NULL ) )
92 return RTOp_ERR_INVALID_NUM_VECS;
93 if( num_targ_vecs != 0 || ( num_targ_vecs && targ_vecs == NULL ) )
94 return RTOp_ERR_INVALID_NUM_TARG_VECS;
96 vecs[1].sub_dim != vecs[0].sub_dim
97 || vecs[2].sub_dim != vecs[0].sub_dim
99 return RTOp_ERR_INCOMPATIBLE_VECS;
106 sub_dim = vecs[0].sub_dim;
108 v0_val = vecs[0].values;
109 v0_val_s = vecs[0].values_stride;
111 v1_val = vecs[1].values;
112 v1_val_s = vecs[1].values_stride;
114 v2_val = vecs[2].values;
115 v2_val_s = vecs[2].values_stride;
123 for( k = 0; k < sub_dim; ++k, v0_val += v0_val_s, v1_val += v1_val_s, v2_val += v2_val_s )
126 (*log_result) += log((*v0_val) - (*v1_val)) + log((*v2_val) - (*v0_val));
136 ,&RTOp_obj_value_vtbl
137 ,
"ROp_log_bound_barrier"
139 ,RTOp_ROp_log_bound_barrier_apply_op
140 ,RTOp_reduct_sum_value
141 ,RTOp_get_reduct_sum_value_op
146 int RTOp_ROp_log_bound_barrier_construct(
struct RTOp_RTOp* op )
152 op->vtbl = &RTOp_ROp_log_bound_barrier_vtbl;
153 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
157 int RTOp_ROp_log_bound_barrier_destroy(
struct RTOp_RTOp* op )
159 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
166 RTOp_value_type RTOp_ROp_log_bound_barrier_val(RTOp_ReductTarget reduct_obj)
168 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)