help-octave
[Top][All Lists]
Advanced

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

Re: Sparse functions for octave


From: A+A Adler
Subject: Re: Sparse functions for octave
Date: Mon, 25 Oct 1999 23:29:18 -0400 (EDT)

On Wed, 20 Oct 1999, John W. Eaton wrote:
> On 18-Oct-1999, A+A Adler <address@hidden> wrote:
> |    I have defined a sparse_value inside my octave_sparse Class, but
> |    I can't see how to get a sparse_value of an octave_value.
> 
> Oops.  It's not easy with anything before 2.1.18.  But with that, you
> can use something like this (from the new make_int.cc distributed with
> 2.1.18):
>  [EXAMPLE DELETED]
> The octave_value class is just a handle.  The member rep points to the
> actual representation.  Yes, rep is declared as
> 
>   octave_value *rep;
> 
> but it really only points to a derived type.  So, once you extract a
> reference to rep, you can cast it to the actual type (don't get it
> wrong, or bad things will happen).

Thanks for the answer. I'll try to implement it under 2.1.18 later.
But for now I'd like to get it working under the stable version.

Is there any way to get the "rep" from an octave value
in previous versions?


Additional questions that I've come across are:

1. I need to define the following functions on sparse matrices:

   s1       = s0(v1,v2)       -> this seems to be sparse.extract
   s(v1,v2) = s2              -> I'm not sure what this is called

   I've defined these methods, but there is no example of how
   get octave to use them in the make_int.cc example.

Question: How can you define extract for a new type?


2. The == operator

   The == operator is defined to return a matrix result. For
   sparse matrices this is very inefficient as 
      sparse1 == sparse2 
   will give a nearly full matrix result.

   However, most of the time, what the user wants to do is
      all ( all ( s1 == s2 ))
   so the intermediate full matrix is unneccesary.

   Additionally, there are efficient ways of calculating
   the boolean equality of two sparse matrices, if there
   was some way to know that that was what the user wants.

   (I've checked with Matlab, and it gives a full matrix for
    sparse == sparse)

   Questions:

    1. Is there a way to get at whether the user wants to
         do all ( all ( s1 == s2 )) ?   
       Is it possible to define another operator?

      (Unfortunately eq(a,b) is already defined by Matlab
         and means the same as a==b for matrices a , b )

    2. Is it possible to define the != operator instead, and
       define == in terms of !=.

       The advantage is that sparse1 != sparse2 will tend
       to be a sparse matrix as well, and efficient code
       can be written for this.


  (As an aside, there are many operators that I've chosen
   not to define on sparse matrices, such as s++, 
   which create mostly full matrices,

   since I can't think of a situation where that could
   be used in a well written algorithm.

   Comments?)

      

I've put a version of my sparse functions at
   http://www.mondenet.com/~adler/octave/spfun-wSuperLU-0.31.tar.gz
It has most of the functionality I could get working 
beside the questions I have here.

Comments / bug reports are welcome.
______________________________________________________________
Andy Adler,                               address@hidden




---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------



reply via email to

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