[Top][All Lists]

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

Re: new types and INSTALL_BINOP

From: adler
Subject: Re: new types and INSTALL_BINOP
Date: Thu, 1 Mar 2001 20:22:55 -0500 (EST)

On Wed, 28 Feb 2001, John W. Eaton wrote:
> On 28-Feb-2001, address@hidden <address@hidden> wrote:
> | It's going fairly well, except I seem to be 
> | required to add an enourmous amount of binary
> | operators for each type combination

> | Is there some way to simplify this.
> Yes, you can define a conversion operator for the sparse classes
> (presumably it would convert the sparse matrix to a full matrix).  The
> conversion operator is applied whenever there is no matching operator
> for the exact types.  This is handled in do_binary_op in src/
> The logic is

Great, that makes a lot of sense for my case, because this
is the best way to handle most operators.

For example:
   sparse_matrix + 1
is best handled by converting it to a "full" matrix   

Unfortunately, I don't understand the details of how to make
this work.

I have conversion methods for this, eg:
   Matrix octave_sparse::matrix_value (bool = false) const {
      Matrix M= oct_sparse_to_full( X );
      return M;

How do I register this with do_binary_op so that it can
call my function?

> I don't think Octave's method of handling this is the best.  It
> doesn't seem like an easy problem to me, but then I may be missing
> something (clues welcome).

This seems like a good approach to me. 

I'm not much of a C++ guy, but does c++ automatically
do some of this type conversion logic? 
I guess that even if C++ could do it, it would be better
to control conversion at the application level.

Andy Adler,                address@hidden

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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