[PD-cvs] externals/iem/iemmatrix/src mtx_colon.c, 1.1, 1.2 mtx_find.c, 1.1, 1.2 mtx_minmax.c, 1.2, 1.3 mtx_reverse.c, 1.1, 1.2
Franz Zotter
fzotter at users.sourceforge.net
Mon Sep 26 09:57:04 CEST 2005
Update of /cvsroot/pure-data/externals/iem/iemmatrix/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11579
Modified Files:
mtx_colon.c mtx_find.c mtx_minmax.c mtx_reverse.c
Log Message:
added symbolic creation arguments or mode parameters "row" "col" ["mtx"] to below described externals.
now the operation mode of these externs can be selected by arbitrary ordered creation argumens containing above symbols, or by a "mode col" etc. command. This makes it easier/more intuitive to patch without using help patches.
Index: mtx_reverse.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_reverse.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mtx_reverse.c 19 Sep 2005 14:47:49 -0000 1.1
--- mtx_reverse.c 26 Sep 2005 07:57:02 -0000 1.2
***************
*** 17,20 ****
--- 17,23 ----
static t_class *mtx_reverse_class;
+ static t_symbol *row_sym;
+ static t_symbol *col_sym;
+ static t_symbol *col_sym2;
typedef struct _MTXreverse_ MTXreverse;
***************
*** 23,27 ****
t_object x_obj;
int size;
! int reverse_dimension;
t_outlet *list_outlet;
--- 26,31 ----
t_object x_obj;
int size;
! //int reverse_dimension;
! t_symbol *reverse_mode;
t_outlet *list_outlet;
***************
*** 36,40 ****
freebytes (mtx_reverse_obj->list_out, sizeof(t_atom)*(mtx_reverse_obj->size+2));
}
!
static void mTXSetreverseDimension (MTXreverse *mtx_reverse_obj, t_float c_dim)
{
--- 40,48 ----
freebytes (mtx_reverse_obj->list_out, sizeof(t_atom)*(mtx_reverse_obj->size+2));
}
! static void mTXSetReverseMode (MTXreverse *mtx_reverse_obj, t_symbol *c_mode)
! {
! mtx_reverse_obj->reverse_mode = c_mode;
! }
! /*
static void mTXSetreverseDimension (MTXreverse *mtx_reverse_obj, t_float c_dim)
{
***************
*** 44,52 ****
mtx_reverse_obj->reverse_dimension = dimension;
}
static void *newMTXreverse (t_symbol *s, int argc, t_atom *argv)
{
MTXreverse *mtx_reverse_obj = (MTXreverse *) pd_new (mtx_reverse_class);
! int c_dim = 0;
mtx_reverse_obj->reverse_dimension = c_dim;
--- 52,67 ----
mtx_reverse_obj->reverse_dimension = dimension;
}
+ */
+
static void *newMTXreverse (t_symbol *s, int argc, t_atom *argv)
{
MTXreverse *mtx_reverse_obj = (MTXreverse *) pd_new (mtx_reverse_class);
! mTXSetReverseMode (mtx_reverse_obj, gensym(":"));
! switch ((argc>1)?1:argc) {
! case 1:
! mTXSetReverseMode (mtx_reverse_obj, atom_getsymbol (argv));
! }
! /*int c_dim = 0;
mtx_reverse_obj->reverse_dimension = c_dim;
***************
*** 56,60 ****
}
mTXSetreverseDimension (mtx_reverse_obj, (t_float) c_dim);
!
mtx_reverse_obj->list_outlet = outlet_new (&mtx_reverse_obj->x_obj, gensym("matrix"));
return ((void *) mtx_reverse_obj);
--- 71,75 ----
}
mTXSetreverseDimension (mtx_reverse_obj, (t_float) c_dim);
! */
mtx_reverse_obj->list_outlet = outlet_new (&mtx_reverse_obj->x_obj, gensym("matrix"));
return ((void *) mtx_reverse_obj);
***************
*** 135,138 ****
--- 150,167 ----
list_out += 2;
copyList (size, argv, list_out);
+
+ if ((mtx_reverse_obj->reverse_mode == col_sym)||
+ (mtx_reverse_obj->reverse_mode == col_sym2)) {
+ for (count = columns; count--; list_out++)
+ reverseListStep (size, columns, list_out);
+ }
+ else if (mtx_reverse_obj->reverse_mode == row_sym) {
+ for (count = rows; count--; list_out += columns)
+ reverseList (columns, list_out);
+ }
+ else
+ reverseList (size, list_out);
+
+ /*
switch (mtx_reverse_obj->reverse_dimension) {
case 2:
***************
*** 148,151 ****
--- 177,181 ----
break;
}
+ */
list_out = mtx_reverse_obj->list_out;
***************
*** 168,173 ****
class_addbang (mtx_reverse_class, (t_method) mTXreverseBang);
class_addmethod (mtx_reverse_class, (t_method) mTXreverseMatrix, gensym("matrix"), A_GIMME,0);
! class_addmethod (mtx_reverse_class, (t_method) mTXSetreverseDimension, gensym("dimension"), A_DEFFLOAT,0);
class_sethelpsymbol (mtx_reverse_class, gensym("iemmatrix/mtx_reverse"));
}
--- 198,207 ----
class_addbang (mtx_reverse_class, (t_method) mTXreverseBang);
class_addmethod (mtx_reverse_class, (t_method) mTXreverseMatrix, gensym("matrix"), A_GIMME,0);
! // class_addmethod (mtx_reverse_class, (t_method) mTXSetreverseDimension, gensym("dimension"), A_DEFFLOAT,0);
! class_addmethod (mtx_reverse_class, (t_method) mTXSetReverseMode, gensym("mode"), A_DEFSYMBOL,0);
class_sethelpsymbol (mtx_reverse_class, gensym("iemmatrix/mtx_reverse"));
+ row_sym = gensym("row");
+ col_sym = gensym("col");
+ col_sym2 = gensym("column");
}
Index: mtx_colon.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_colon.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mtx_colon.c 19 Sep 2005 14:47:49 -0000 1.1
--- mtx_colon.c 26 Sep 2005 07:57:02 -0000 1.2
***************
*** 17,20 ****
--- 17,22 ----
static t_class *mtx_colon_class;
+ static t_symbol *col_sym;
+ static t_symbol *col_sym2;
typedef struct _MTXColon_ MTXColon;
***************
*** 23,26 ****
--- 25,29 ----
t_object x_obj;
int size;
+ t_symbol *colon_mode;
t_atom *list_out;
***************
*** 34,37 ****
--- 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)
{
***************
*** 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)
--- 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)
***************
*** 105,111 ****
--- 120,129 ----
CLASS_DEFAULT, A_GIMME, 0);
class_addbang (mtx_colon_class, (t_method) mTXColonBang);
+ class_addmethod (mtx_colon_class, (t_method) mTXSetColonMode, gensym("mode"), A_DEFSYMBOL, 0);
class_addlist (mtx_colon_class, (t_method) mTXColonList);
class_addcreator ((t_newmethod) newMTXColon, gensym("mtx_:"), A_GIMME, 0);
class_sethelpsymbol (mtx_colon_class, gensym("iemmatrix/mtx_colon"));
+ col_sym = gensym("col");
+ col_sym2 = gensym("column");
}
Index: mtx_find.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_find.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mtx_find.c 19 Sep 2005 14:47:49 -0000 1.1
--- mtx_find.c 26 Sep 2005 07:57:02 -0000 1.2
***************
*** 17,20 ****
--- 17,25 ----
static t_class *mtx_find_class;
+ static t_symbol *row_sym;
+ static t_symbol *col_sym;
+ static t_symbol *col_sym2;
+ static t_symbol *mtx_sym;
+ static t_symbol *mtx_sym2;
typedef struct _MTXfind_ MTXfind;
***************
*** 24,28 ****
int size;
int outsize;
! int find_dimension;
int find_direction;
--- 29,34 ----
int size;
int outsize;
! //int find_dimension;
! t_symbol *find_mode;
int find_direction;
***************
*** 46,50 ****
mtx_find_obj->find_direction = direction;
}
!
static void mTXSetFindDimension (MTXfind *mtx_find_obj, t_float c_dim)
{
--- 52,56 ----
mtx_find_obj->find_direction = direction;
}
! /*
static void mTXSetFindDimension (MTXfind *mtx_find_obj, t_float c_dim)
{
***************
*** 54,64 ****
mtx_find_obj->find_dimension = dimension;
}
static void *newMTXFind (t_symbol *s, int argc, t_atom *argv)
{
MTXfind *mtx_find_obj = (MTXfind *) pd_new (mtx_find_class);
! int c_dim = 0;
! int c_dir = 1;
switch ((argc>2)?2:argc) {
case 2:
--- 60,97 ----
mtx_find_obj->find_dimension = dimension;
}
+ */
+ static void mTXSetFindMode (MTXfind *mtx_find_obj, t_symbol *c_dim)
+ {
+ mtx_find_obj->find_mode = c_dim;
+ }
static void *newMTXFind (t_symbol *s, int argc, t_atom *argv)
{
MTXfind *mtx_find_obj = (MTXfind *) pd_new (mtx_find_class);
! // int c_dim = 0;
! // int c_dir = 1;
+ mTXSetFindMode (mtx_find_obj, gensym(":"));
+ mTXSetFindDirection (mtx_find_obj, 1);
+ if (argc>=1) {
+ if (argv[0].a_type == A_SYMBOL) {
+ mTXSetFindMode (mtx_find_obj, atom_getsymbol (argv));
+ if (argc>=2)
+ if (argv[1].a_type != A_SYMBOL)
+ mTXSetFindDirection (mtx_find_obj, atom_getfloat (argv+1));
+ else
+ post("mtx_find: 2nd arg ignored. supposed to be float");
+ }
+ else {
+ mTXSetFindDirection (mtx_find_obj, atom_getfloat (argv));
+ if (argc>=2) {
+ if (argv[1].a_type == A_SYMBOL)
+ mTXSetFindMode (mtx_find_obj, atom_getsymbol (argv+1));
+ else
+ post("mtx_find: 2nd arg ignored. supposed to be symbolic, e.g. \"row\", \"col\", \":\", \"mtx\"");
+ }
+ }
+ }
+ /*
switch ((argc>2)?2:argc) {
case 2:
***************
*** 69,72 ****
--- 102,106 ----
mTXSetFindDimension (mtx_find_obj, (t_float) c_dim);
mTXSetFindDirection (mtx_find_obj, (t_float) c_dir);
+ */
mtx_find_obj->list_outlet = outlet_new (&mtx_find_obj->x_obj, gensym("matrix"));
***************
*** 230,233 ****
--- 264,295 ----
//copyList (size, argv, list_out);
rows_out = 1;
+ if (mtx_find_obj->find_mode == row_sym) {
+ if (mtx_find_obj->find_direction == -1)
+ findLastNonZeroRow (rows, columns, list_in, list_out);
+ else
+ findFirstNonZeroRow (rows, columns, list_in, list_out);
+ rows_out = rows;
+ columns_out = 1;
+ }
+ else if ((mtx_find_obj->find_mode == col_sym)||
+ (mtx_find_obj->find_mode == col_sym2)) {
+ if (mtx_find_obj->find_direction == -1)
+ findLastNonZeroColumn (rows, columns, list_in, list_out);
+ else
+ findFirstNonZeroColumn (rows, columns, list_in, list_out);
+ columns_out = columns;
+ rows_out = 1;
+ }
+ else if ((mtx_find_obj->find_mode == mtx_sym)||
+ (mtx_find_obj->find_mode == mtx_sym2)) {
+ findReplaceNonZerosWithIndex (size, list_in, list_out);
+ rows_out = rows;
+ columns_out = columns;
+ }
+ else {
+ columns_out = findAllNonZeros (size, list_in, list_out);
+ rows_out = 1;
+ }
+ /*
switch (mtx_find_obj->find_dimension) {
case 0:
***************
*** 257,260 ****
--- 319,323 ----
break;
}
+ */
mtx_find_obj->outsize = columns_out * rows_out;
list_out = mtx_find_obj->list_out;
***************
*** 277,283 ****
class_addbang (mtx_find_class, (t_method) mTXFindBang);
class_addmethod (mtx_find_class, (t_method) mTXFindMatrix, gensym("matrix"), A_GIMME,0);
! class_addmethod (mtx_find_class, (t_method) mTXSetFindDimension, gensym("dimension"), A_DEFFLOAT,0);
class_addmethod (mtx_find_class, (t_method) mTXSetFindDirection, gensym("direction"), A_DEFFLOAT,0);
class_sethelpsymbol (mtx_find_class, gensym("iemmatrix/mtx_find"));
}
--- 340,352 ----
class_addbang (mtx_find_class, (t_method) mTXFindBang);
class_addmethod (mtx_find_class, (t_method) mTXFindMatrix, gensym("matrix"), A_GIMME,0);
! // class_addmethod (mtx_find_class, (t_method) mTXSetFindDimension, gensym("dimension"), A_DEFFLOAT,0);
! class_addmethod (mtx_find_class, (t_method) mTXSetFindMode, gensym("mode"), A_DEFSYMBOL,0);
class_addmethod (mtx_find_class, (t_method) mTXSetFindDirection, gensym("direction"), A_DEFFLOAT,0);
class_sethelpsymbol (mtx_find_class, gensym("iemmatrix/mtx_find"));
+ row_sym = gensym("row");
+ col_sym = gensym("col");
+ col_sym2 = gensym("columns");
+ mtx_sym = gensym("mtx");
+ mtx_sym2 = gensym ("matrix");
}
Index: mtx_minmax.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_minmax.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** mtx_minmax.c 20 Sep 2005 13:26:48 -0000 1.2
--- mtx_minmax.c 26 Sep 2005 07:57:02 -0000 1.3
***************
*** 50,61 ****
{
MTXminmax *mtx_minmax_obj = (MTXminmax *) pd_new (mtx_minmax_class);
! t_symbol *c_mode = 0;
switch ((argc>1)?1:argc) {
case 1:
! c_mode = atom_getsymbol (argv);
}
mtx_minmax_obj->operator_minimum = 1;
- mTXSetMinMaxMode (mtx_minmax_obj, c_mode);
mtx_minmax_obj->list_outlet = outlet_new (&mtx_minmax_obj->x_obj, gensym("matrix"));
--- 50,60 ----
{
MTXminmax *mtx_minmax_obj = (MTXminmax *) pd_new (mtx_minmax_class);
! mTXSetMinMaxMode (mtx_minmax_obj, gensym(":"));
switch ((argc>1)?1:argc) {
case 1:
! mTXSetMinMaxMode (mtx_minmax_obj, atom_getsymbol (argv));
}
mtx_minmax_obj->operator_minimum = 1;
mtx_minmax_obj->list_outlet = outlet_new (&mtx_minmax_obj->x_obj, gensym("matrix"));
***************
*** 65,76 ****
{
MTXminmax *mtx_minmax_obj = (MTXminmax *) pd_new (mtx_minmax_class);
! t_symbol *c_mode = 0;
switch ((argc>1)?1:argc) {
case 1:
! c_mode = atom_getsymbol (argv);
}
mtx_minmax_obj->operator_minimum = 0;
- mTXSetMinMaxMode (mtx_minmax_obj, c_mode);
mtx_minmax_obj->list_outlet = outlet_new (&mtx_minmax_obj->x_obj, gensym("matrix"));
--- 64,74 ----
{
MTXminmax *mtx_minmax_obj = (MTXminmax *) pd_new (mtx_minmax_class);
! mTXSetMinMaxMode (mtx_minmax_obj, gensym(":"));
switch ((argc>1)?1:argc) {
case 1:
! mTXSetMinMaxMode (mtx_minmax_obj, atom_getsymbol (argv));
}
mtx_minmax_obj->operator_minimum = 0;
mtx_minmax_obj->list_outlet = outlet_new (&mtx_minmax_obj->x_obj, gensym("matrix"));
More information about the Pd-cvs
mailing list