[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert double to octave_value for assignment to column vector
From: |
babelproofreader |
Subject: |
Re: Convert double to octave_value for assignment to column vector |
Date: |
Fri, 4 Jun 2010 06:49:23 -0700 (PDT) |
I still can't get this to work. My code now, heavily commented, is
#include <octave/oct.h>
#include <octave/dColVector.h>
#include <octave/parse.h> // necessary for the call to feval
#include <octave/ov.h> // 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;
ColumnVector rm_compile_1_input = args(0).column_vector_value (); // input
vector
ColumnVector rm_compile_1_output = args(0).column_vector_value (); // copy
of input vector to hold median of input vector as an output vector
octave_value input_median; // declare an octave value to hold output of
feval call to Octave median function
double double_input_median; // declare a double value to hold conversion of
octave_value feval call to a double
// *** octave_value_list my_retval; // declare an octave value to hold
conversion of loop output vector for passing as return value "retval"
input_median = feval ( "median", octave_value (rm_compile_1_input) ); //
call Octave's median function with "feval"
double_input_median = input_median.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_input_median;
}
// *** my_retval = octave_value (rm_compile_1_output); // convert loop
output to an octave value for passing to retval
// *** retval = my_retval;
retval = rm_compile_1_output;
return retval;
}
which fails with cc:26: error: no match for ‘operator=’ in ‘retval =
rm_compile_1_output’ and I don't understand why this should be so.
An alternative version is to uncomment the lines // *** and use my_retval as
retval, which does compile without error, but when the function is called it
produces
error: octave_base_value::double_value (): wrong type argument `list'
I am really at a loss to understand why, after converting input_median to a
double and assigning it to the output column_vector in the loop, that this
loop output does not seem to be recognised.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Convert-double-to-octave-value-for-assignment-to-column-vector-tp2239451p2243261.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Convert double to octave_value for assignment to column vector, babelproofreader, 2010/06/01
- Re: Convert double to octave_value for assignment to column vector, David Grundberg, 2010/06/02
- Re: Convert double to octave_value for assignment to column vector,
babelproofreader <=
- Re: Convert double to octave_value for assignment to column vector, David Grundberg, 2010/06/04
- Re: Convert double to octave_value for assignment to column vector, David Grundberg, 2010/06/04
- Re: Convert double to octave_value for assignment to column vector, babelproofreader, 2010/06/06
- Re: Convert double to octave_value for assignment to column vector, David Grundberg, 2010/06/07
- Re: Convert double to octave_value for assignment to column vector, babelproofreader, 2010/06/07
- Re: Convert double to octave_value for assignment to column vector, Jaroslav Hajek, 2010/06/07
- Re: Convert double to octave_value for assignment to column vector, David Grundberg, 2010/06/07
- Re: Convert double to octave_value for assignment to column vector, babelproofreader, 2010/06/07
- Re: Convert double to octave_value for assignment to column vector, Jaroslav Hajek, 2010/06/08
- Re: Convert double to octave_value for assignment to column vector, babelproofreader, 2010/06/08