45 #include "RTOp_obj_value_vtbl.h"
46 #include "RTOp_obj_null_vtbl.h"
50 static int RTOp_TOp_axpy_apply_op(
54 , RTOp_ReductTarget targ_obj )
56 RTOp_value_type alpha;
57 RTOp_index_type z_sub_dim;
58 RTOp_value_type *z_val;
60 RTOp_index_type v0_sub_dim;
61 const RTOp_value_type *v0_val;
63 register RTOp_index_type k;
64 RTOp_value_type *z_val_tmp = NULL;
72 if( num_vecs != 1 || vecs == NULL )
73 return RTOp_ERR_INVALID_NUM_VECS;
74 if( num_targ_vecs != 1 || targ_vecs == NULL )
75 return RTOp_ERR_INVALID_NUM_TARG_VECS;
76 if( targ_vecs[0].sub_dim != vecs[0].sub_dim )
77 return RTOp_ERR_INCOMPATIBLE_VECS;
84 alpha = *((RTOp_value_type*)obj_data);
87 z_sub_dim = targ_vecs[0].sub_dim;
88 z_val = targ_vecs[0].values;
89 z_val_s = targ_vecs[0].values_stride;
92 v0_sub_dim = vecs[0].sub_dim;
93 v0_val = vecs[0].values;
94 v0_val_s = vecs[0].values_stride;
103 if( z_val_s == 1 && v0_val_s == 1 ) {
105 for( k = 0; k < z_sub_dim; ++k )
106 *z_val++ += alpha * (*v0_val++);
110 for( k = 0; k < z_sub_dim; ++k, z_val += z_val_s, v0_val += v0_val_s )
111 *z_val += alpha * (*v0_val);
124 ,RTOp_TOp_axpy_apply_op
131 int RTOp_TOp_axpy_construct( RTOp_value_type alpha,
struct RTOp_RTOp* op )
133 op->vtbl = &RTOp_TOp_axpy_vtbl;
134 op->vtbl->obj_data_vtbl->
obj_create(NULL,NULL,&op->obj_data);
135 *((RTOp_value_type*)op->obj_data) = alpha;
139 int RTOp_TOp_axpy_destroy(
struct RTOp_RTOp* op )
141 op->vtbl->obj_data_vtbl->
obj_free(NULL,NULL,&op->obj_data);
146 int RTOp_TOp_axpy_set_alpha( RTOp_value_type alpha,
struct RTOp_RTOp* op )
148 *((RTOp_value_type*)op->obj_data) = alpha;
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)