[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sparse functions for octave
From: |
John W. Eaton |
Subject: |
Re: Sparse functions for octave |
Date: |
Mon, 15 Nov 1999 19:41:33 -0600 (CST) |
On 15-Nov-1999, A+A Adler <address@hidden> wrote:
| On Sat, 13 Nov 1999, John W. Eaton wrote:
| > | Now, I need to add indexing to sparse matrices, to that you can
| > | do:
| > | x(1:2,1:2) for sparse x.
| >
| > You need to define a function called do_index_op() with the following
| > signature:
| >
| > octave_value do_index_op (const octave_value_list& idx)
| >
| > For example, look at ov-base-mat.cc.
|
| Unfortunately, I don't seem to be able to get this to work.
| For example, I added the following code to the public
| methods of make_int.cc:
|
| octave_value do_index_op (const octave_value_list& idx) {
| if (idx.length() == 1)
| return (double) scalar;
| else
| error("idx !=1");
| }
|
| But I still get the following error
| octave-2.1.19:1> x=make_int(1);
| installing integer type at type-id = 18
| octave-2.1.19:2> x(1)
| error: can't perform indexing operations for integer type
Sorry, it looks like I picked out the wrong do_index_op function. I
should have said to write a function for your class called do_index_op
with the following signature:
octave_value_list
octave_integer::do_index_op (int, const octave_value_list& idx)
Here's an example for the integer class defined in make_int.cc:
octave_value_list
octave_integer::do_index_op (int, const octave_value_list& idx)
{
octave_value retval;
if (idx.length () == 1 && idx(0).nint_value () == 1)
retval = octave_value (new octave_integer (scalar));
else
error ("idx != 1");
return retval;
}
jwe
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------
- Re: Sparse functions for octave, A+A Adler, 1999/11/13
- Re: Sparse functions for octave, John W. Eaton, 1999/11/13
- Re: Sparse functions for octave, A+A Adler, 1999/11/15
- Re: Sparse functions for octave,
John W. Eaton <=
- Re: Sparse functions for octave, A+A Adler, 1999/11/16
- Re: Sparse functions for octave, John W. Eaton, 1999/11/16
- Re: Sparse functions for octave, A+A Adler, 1999/11/26
- Re: Sparse functions for octave, Mike Miller, 1999/11/27
- Re: Sparse functions for octave, John W. Eaton, 1999/11/28