#include #include #include // necessary for the call to feval #include // necessary for conversion to double DEFUN_DLD (rm_compile_1, args, , "Input is a column vector, output is median vector. This is a test of compiling Octave median function") { octave_value_list retval_list; if (args.length () < 1) { error ("Invalid arguments"); return retval_list; } ColumnVector rm_compile_1_input = args(0).column_vector_value (); // input vector ColumnVector rm_compile_1_output = rm_compile_1_input; // copy of input vector to hold median of input vector as an output vector if (error_state) { error ("Invalid arguments"); return retval_list; } octave_value_list median_list; // declare an octave value to hold output of feval call to Octave median function double double_median; // declare a double value to hold conversion of octave_value feval call to a double median_list = feval ( "median", octave_value (rm_compile_1_input) ); // call Octave's median function with "feval" double_median = median_list(0).double_value (); // convert "feval" output to double value for assignment to output column_vector for (octave_idx_type ii (0); ii < args(0).length (); ii++) // loop to fill output column_vector with converted-to-double median value { rm_compile_1_output(ii) = double_median; } retval_list(0) = rm_compile_1_output; return retval_list; }