45 #include "RTOp_obj_null_vtbl.h"
46 #include "RTOp_obj_value_vtbl.h"
47 #include "RTOp_reduct_sum_value.h"
51 static int RTOp_ROp_dot_prod_apply_op(
55 , RTOp_ReductTarget targ_obj )
62 RTOp_index_type v0_sub_dim;
63 const RTOp_value_type *v0_val;
67 RTOp_index_type v1_sub_dim;
68 const RTOp_value_type *v1_val;
72 RTOp_value_type dot_prod = 0.0;
75 register RTOp_index_type k;
76 RTOp_index_type sub_dim;
82 return RTOp_ERR_INVALID_NUM_VECS;
83 if( num_targ_vecs != 0 )
84 return RTOp_ERR_INVALID_NUM_TARG_VECS;
85 if( vecs[0].sub_dim != vecs[1].sub_dim )
86 return RTOp_ERR_INCOMPATIBLE_VECS;
93 v0_sub_dim = vecs[0].sub_dim;
94 v0_val = vecs[0].values;
95 v0_val_s = vecs[0].values_stride;
98 v1_sub_dim = vecs[1].sub_dim;
99 v1_val = vecs[1].values;
100 v1_val_s = vecs[1].values_stride;
102 sub_dim = v0_sub_dim;
108 for( k = 0; k < sub_dim; ++k, v0_val += v0_val_s, v1_val += v1_val_s )
109 dot_prod += (*v0_val) * (*v1_val);
114 *((RTOp_value_type*)targ_obj) += dot_prod;
123 ,&RTOp_obj_value_vtbl
126 ,RTOp_ROp_dot_prod_apply_op
127 ,RTOp_reduct_sum_value
128 ,RTOp_get_reduct_sum_value_op
133 int RTOp_ROp_dot_prod_construct(
struct RTOp_RTOp* op )
136 op->vtbl = &RTOp_ROp_dot_prod_vtbl;
140 int RTOp_ROp_dot_prod_destroy(
struct RTOp_RTOp* op )
147 RTOp_value_type RTOp_ROp_dot_prod_val(RTOp_ReductTarget targ_obj)
149 return *((RTOp_value_type*)targ_obj);