Update of /cvsroot/pure-data/externals/iem/iemmatrix/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12635/src
Modified Files: mtx_colon.c Log Message: added help for mtx_: and abstractions for lin/logspace.
mtx_colon.c: added simple octave functionality (see help).
Index: mtx_colon.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_colon.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mtx_colon.c 6 Jun 2006 09:55:22 -0000 1.4 --- mtx_colon.c 26 Jul 2006 09:57:07 -0000 1.5 *************** *** 17,22 ****
static t_class *mtx_colon_class; - static t_symbol *col_sym; - static t_symbol *col_sym2;
typedef struct _MTXColon_ MTXColon; --- 17,20 ---- *************** *** 25,29 **** t_object x_obj; int size; - t_symbol *colon_mode;
t_atom *list_out; --- 23,26 ---- *************** *** 37,45 **** }
- static void mTXSetColonMode (MTXColon *mtx_colon_obj, t_symbol *c_mode) - { - mtx_colon_obj->colon_mode = c_mode; - } - static void *newMTXColon (t_symbol *s, int argc, t_atom *argv) { --- 34,37 ---- *************** *** 94,106 **** mtx_colon_obj->list_out = list_out;
! if ((mtx_colon_obj->colon_mode == col_sym)|| ! (mtx_colon_obj->colon_mode == col_sym2)) { ! SETFLOAT (&list_out[1],1.0f); ! SETFLOAT (&list_out[0],(t_float)size); ! } ! else { ! SETFLOAT (&list_out[0],1.0f); ! SETFLOAT (&list_out[1],(t_float)size); ! } list_out += 2; for (;size--;list_out++,startval+=step) --- 86,91 ---- mtx_colon_obj->list_out = list_out;
! SETFLOAT (&list_out[0],1.0f); ! SETFLOAT (&list_out[1],(t_float)size); list_out += 2; for (;size--;list_out++,startval+=step) *************** *** 111,114 **** --- 96,142 ---- }
+ static void mTXColonMtx (MTXColon *mtx_colon_obj, t_symbol *s, + int argc, t_atom *argv) + { + int rows = atom_getint (argv++); + int columns = atom_getint (argv++); + int size = rows * columns; + int list_size = argc - 2; + t_atom *list_ptr = argv; + t_atom *list_out = mtx_colon_obj->list_out; + + if (!size) { + post("mtx_colon: invalid matrix dimensions"); + return; + } + else if (list_size<size) { + post("mtx_colon: sparse matrix not yet supported: use "mtx_check""); + return; + } + else if (!list_out) { + list_out = (t_atom*) getbytes (sizeof (t_atom) * (size+2)); + } + else if (size != mtx_colon_obj->size) + { + list_out = (t_atom*) resizebytes (list_out, + sizeof (t_atom) * (mtx_colon_obj->size+2), + sizeof (t_atom) * (size+2)); + } + mtx_colon_obj->list_out = list_out; + mtx_colon_obj->size = size; + + list_out+=2; + while (size--) + *list_out++ = *list_ptr++; + + list_out = mtx_colon_obj->list_out; + size = mtx_colon_obj->size; + + SETSYMBOL(list_out, gensym("matrix")); + SETFLOAT(list_out, 1); + SETFLOAT(&list_out[1], size); + mTXColonBang (mtx_colon_obj); + } + void mtx_colon_setup (void) { *************** *** 120,124 **** CLASS_DEFAULT, A_GIMME, 0); class_addbang (mtx_colon_class, (t_method) mTXColonBang); ! class_addmethod (mtx_colon_class, (t_method) mTXSetColonMode, gensym("mode"), A_SYMBOL, 0); class_addlist (mtx_colon_class, (t_method) mTXColonList); class_addcreator ((t_newmethod) newMTXColon, gensym("mtx_:"), A_GIMME, 0); --- 148,152 ---- CLASS_DEFAULT, A_GIMME, 0); class_addbang (mtx_colon_class, (t_method) mTXColonBang); ! class_addmethod (mtx_colon_class, (t_method) mTXColonMtx, gensym("matrix"), A_GIMME, 0); class_addlist (mtx_colon_class, (t_method) mTXColonList); class_addcreator ((t_newmethod) newMTXColon, gensym("mtx_:"), A_GIMME, 0);