45 #include "RTOp_obj_null_vtbl.h"
46 #include "RTOp_obj_value_index_vtbl.h"
48 #include "RTOp_get_reduct_op.hpp"
52 static int RTOp_ROp_find_nan_inf_apply_op(
56 , RTOp_ReductTarget targ_obj )
58 struct RTOp_value_index_type
60 RTOp_index_type global_offset;
61 RTOp_index_type sub_dim;
62 const RTOp_value_type *v0_val;
70 return RTOp_ERR_INVALID_NUM_VECS;
71 if( num_targ_vecs != 0 )
72 return RTOp_ERR_INVALID_NUM_TARG_VECS;
81 targ = (
struct RTOp_value_index_type*)targ_obj;
84 global_offset = vecs[0].global_offset;
85 sub_dim = vecs[0].sub_dim;
86 v0_val = vecs[0].values;
87 v0_val_s = vecs[0].values_stride;
93 for( i = global_offset + 1; i <= global_offset + sub_dim; ++i, v0_val += v0_val_s ) {
94 if( RTOp_is_nan_inf(*v0_val) && ( targ->index == 0 || i < targ->index ) ) {
95 targ->value = *v0_val;
104 static int reduce_reduct_objs(
106 , RTOp_ReductTarget in_reduct_obj, RTOp_ReductTarget inout_reduct_obj )
108 const struct RTOp_value_index_type
109 *i_targ = (
const struct RTOp_value_index_type*)in_reduct_obj;
110 struct RTOp_value_index_type
111 *io_targ = (
struct RTOp_value_index_type*)inout_reduct_obj;
112 if( io_targ->index == 0 || ( i_targ->index != 0 && i_targ->index < io_targ->index ) ) {
113 io_targ->index = i_targ->index;
114 io_targ->value = i_targ->value;
119 INSERT_GET_REDUCT_OP_FUNCS(
120 1,1,0,RTOp_value_index_type,reduce_reduct_objs
123 ,external_reduct_op,get_reduct_op)
129 ,&RTOp_obj_value_index_vtbl
132 ,RTOp_ROp_find_nan_inf_apply_op
139 int RTOp_ROp_find_nan_inf_construct(
struct RTOp_RTOp* op )
142 op->vtbl = &RTOp_ROp_find_nan_inf_vtbl;
146 int RTOp_ROp_find_nan_inf_destroy(
struct RTOp_RTOp* op )
153 struct RTOp_ROp_find_nan_inf_reduct_obj_t
156 const struct RTOp_value_index_type *value_index;
157 struct RTOp_ROp_find_nan_inf_reduct_obj_t return_obj;
159 assert(targ_obj != RTOp_REDUCT_OBJ_NULL);
161 value_index = (
const struct RTOp_value_index_type*)targ_obj;
162 return_obj.v0_i = value_index->value;
163 return_obj.i = value_index->index;
int(* extract_state)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void *obj, int num_values, RTOp_value_type value_data[], int num_indexes, RTOp_index_type index_data[], int num_chars, RTOp_char_type char_data[])
int(* load_state)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, int num_values, const RTOp_value_type value_data[], int num_indexes, const RTOp_index_type index_data[], int num_chars, const RTOp_char_type char_data[], void **obj)
struct RTOp_ROp_find_nan_inf_reduct_obj_t RTOp_ROp_find_nan_inf_val(RTOp_ReductTarget targ_obj)