This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Matrix smobs in guile


Hi Y'all,

I apologize if any of this is old hat: I've only just linked in to this
list.

[[As an aside, since the current official guile dist is over a year old
many people must be itching for the next one.  Hence it might be worth
adding a ballpark indication to the web page as to when a further stable
or semi-stable version will be available.  In particular, the
documentation is way off now, with C functions mentioned but not
there.]]



Question: is there a standard smob for matrices?

Motivation:
1) Matrices are a vital part of much numerical computation;
2) In numerical apps which indicates the use of a smob which is a
collection of matrices, a matrix building block would be handy;
2) It's useful to let guile do most of the work such as thru uniform
arrays;
3) The uniform array is not esp convenient from C;
4) Why not define a smob which record which contains a uniform array
with some other information, such as the type and dimensions?

Supplementary issues:  When transferring data to and from octave, what
structure is passed?  What about plotting with gnuplot as one can in
Octave?


Alex
/enc: example


portion of my gmat.h pilot version
/*********************************************************************/

/* Types of supported uniform array */
typedef enum {
  GMAT_SIGNED, GMAT_UNSIGNED, GMAT_FLOAT, GMAT_DOUBLE, GMAT_LASTTYPE
} gmat_types;

long gmat_tag;
/* A list of prototype SCM objects for checking purposes */
SCM gmat_prototypes[GMAT_LASTTYPE];

/* The main gmat smob structure.  This basically points to a standard
SCM
 * uniform array, but we keep the dimensions, type and data pointer
 * to hand.
 */
struct gmat {
  gmat_types type;
  long rows, cols;
  char *mat_data;
  SCM mat_uarray;
};

/* :*** Function Prototypes, primarily internal ***:
 *
 * :!!!!! Use init_gmat_smob(); in your main_prog !!!!!
*/

void
init_gmat_smob ();

/* Return the gmat_types value for a given array-prototype */
gmat_types
gmat_findtype (SCM Sptype);

/* Return pointer to gmat structure for smob */
struct gmat *
gmat_findstruct (SCM gmat_smob);

/* :*** Function Prototypes, scheme procedures ***:

*/

/* Smob create */
SCM
create_gmat (SCM Sptype, SCM Srows, SCM Scols);

/* Get the uniform array object for smob */
SCM
gmat_getarray (SCM gmat_smob);


/*********************************************************************/


-- 
Dr Alex Stark,                             mailto:stark@niss.org
Post-doctoral Fellow, National Institute of Statistical Sciences  
   P.O. Box 14006, Research Triangle Park, NC 27709-4006, USA
http://www.niss.org/~stark            919-685-9328 Tel; 9310 Fax