help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatic Type Conversion


From: r-j-k
Subject: Re: Automatic Type Conversion
Date: Fri, 17 Jul 2009 17:29:21 -0700 (PDT)

Thanks for the reply. I implemented this method however it only seems to
perform the conversion for operators, not built-in functions:

octave:13> x = my_matrix([1 2; 3 4]);
octave:14> y = [5 6; 7 8];
octave:15> x + y
ans =

    6    8
   10   12

octave:16> log(x);
error: mapper: wrong type argument `my_matrix'
octave:16> eig(x);
error: eig: wrong type argument `matrix'

Is it possible for the conversion to occur for functions as well or is this
impossible?

Thanks.





John W. Eaton-3 wrote:
> 
> 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
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Automatic-Type-Conversion-tp24537852p24543527.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]