[Top][All Lists]

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

Re: Help with [] for defined types

From: David Bateman
Subject: Re: Help with [] for defined types
Date: Wed, 28 Jul 2004 00:57:35 +0200
User-agent: Mutt/1.4.1i


Ok, I'll answer the questions

Question 1

To get a reasonable speed the concatenation function precalcuates the
size of the return type and then dimensions the return value before
inserting the data into it. As the functions in pt-mat.cc
(tree_matrix::rvalue) and data.cc (do_cat) know nothing of the types
its concatenations (it hands that role off to do_catop), it uses a
resize of the octave_value itself. For this reason you have to define
in make_sparse.h something like

octave_sparse::resize (const dim_vector& dv) const
  if (dv.length() > 2)
      error ("Can not resize sparse matrix to NDArray");
      return octave_value ();
  SuperMatrix retval (*this);

  // Do the magic needed to change the number of rows and columns while
  // leaving the elements of retval alone //

  return new octave_sparse (retval);

where I haven't defined what magic you use to get Sparse LU to resize
a matrix. You'll also need appropriate definitions in the class header
files I imagine.

You'll also need to register the concat functions. For the galois field type
I used macros, and these modified for your use might look like

#define DEFCATOP_SPARSE_FN(name, t1, t2, f) \
  CATOPDECL (name, a1, a2)           \
  { \
    CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
    return new octave_sparse (f (v1.t1 ## _value (), v2.t2 ## _value (), 
ra_idx)); \

#define INSTALL_SPARSE_CATOP(t1, t2, f) INSTALL_CATOP(t1, t2, f) 
#define DEFCATOP_SPARSE_FN(name, t1, t2, f) 
#define INSTALL_SPARSE_CATOP(t1, t2, f)

You should then add

DEFCATOP_SPARSE_FN (sm_sm, sparse, sparse, concat)
DEFCATOP_SPARSE_FN (sm_csm, sparse, complex_sparse, concat)
DEFCATOP_SPARSE_FN (csm_sm, complex_sparse, sparse, concat)
DEFCATOP_SPARSE_FN (csm_csm, complex_sparse, complex_sparse, concat)

and the install functions

INSTALL_SPARSE_CATOP (octave_sparse, octave_sparse, sm_sm);
INSTALL_SPARSE_CATOP (octave_sparse, octave_complex_sparse, sm_csm);
INSTALL_SPARSE_CATOP (octave_complex_sparse, octave_sparse, csm_sm);
INSTALL_SPARSE_CATOP (octave_complex_sparse, octave_complex_sparse, csm_csm);

to sparse_ops.cc. If you want to be able to concatenate with normal
matrices you'll need to register other appropriate functions to do
this. The concat and insert functions you've already committed seem
like they are going in the right direct and are the rest of the


No this isn't related to question. I made a comment in the comms toolbox and
fixed point toolox documentation on the issue. The important statement is

To reload the variable within
octave, the Galois type must be installed prior to a call to
@dfn{load}. That is

octave:1> dummy = gf(1);
octave:2> load a.mat
@end example

The problem is until you call the octave_sparse::register_type() function,
Octave knows nothing about this type, and thus the "unknown type" message.
Make a dummy call to sparse and everything should be fine. 


The load_binary and save_binary functions are for the octave binary
format (i.e. save -binary ) and have nothing to do with the
-mat-binary format. We have no control over the Matlab file formats
and so there is no way to extend them and thus splitting their functioning
into the octave_value as was done for the ascii, binary and hdf5 formats
makes less sense. This might be done however, with new save_mat_ascii,
save_mat4_binary and save_mat5_binary methods of the octave_value class.
But my feeling is that is pretty ugly.

So unfortunately as it stands unless sparse actually goes into octave
you'll have difficulties using the -mat-binary or even -mat-ascii
formats.  You should be able to use an HDF5 format to exchange data
with matlab however.


Did you run autogen.sh to regenerate configure from configure.base?


David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

reply via email to

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