Automatic Type Conversion

John W. Eaton jwe at octave.org
Fri Jul 17 11:33:48 CDT 2009


On 16-Jul-2009, r-j-k wrote:

| I have a special matrix type, my_matrix, defined in an oct file. I want my
| my_matrix to be automatically converted to an octave matrix when a function
| is called expecting an octave matrix. Is this possible? I have implemented
| the matrix_value() and is_real_matrix() methods. Currently, I get the
| following when I attempt to use such functions:
| 
| octave:6> x = my_matrix(1);
| octave:7> log(x);
| error: mapper: wrong type argument `my_matrix'
| octave:7> eig(x);
| error: eig: wrong type argument `matrix'
| 
| Any tips?

Look at the octave_base_value::numeric_conversion_function method.
There are examples in several of the classes that are part of Octave.

jwe


More information about the Help-octave mailing list