Update of /cvsroot/pure-data/externals/iem/iemmatrix/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32292
Modified Files: mtx_cumsum.c mtx_decay.c mtx_diff.c mtx_sort.c Log Message: re-newed column and row-wise operation selector. now [mode row(, [mode col( / [mode column( or [mode :( work in cumsum, decay, diff, sort, (and minmax) external. The order of creation arguments is in some kind arbitrary.
Index: mtx_cumsum.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_cumsum.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mtx_cumsum.c 19 Sep 2005 14:47:49 -0000 1.1 --- mtx_cumsum.c 22 Sep 2005 09:28:55 -0000 1.2 *************** *** 17,20 **** --- 17,23 ----
static t_class *mtx_cumsum_class; + static t_symbol *row_sym; + static t_symbol *col_sym; + static t_symbol *col_sym2;
typedef struct _MTXCumsum_ MTXCumsum; *************** *** 25,30 **** int columns; int size; - int cumsum_dimension; int cumsum_direction;
t_outlet *list_outlet; --- 28,33 ---- int columns; int size; int cumsum_direction; + t_symbol *cumsum_mode;
t_outlet *list_outlet; *************** *** 51,58 **** mtx_cumsum_obj->cumsum_direction = (direction==-1)?direction:1; } ! static void mTXSetCumsumDimension (MTXCumsum *mtx_cumsum_obj, t_float c_dim) { ! int dimension = (int) c_dim; ! mtx_cumsum_obj->cumsum_dimension = (dimension==2)?dimension:1; }
--- 54,61 ---- mtx_cumsum_obj->cumsum_direction = (direction==-1)?direction:1; } ! ! static void mTXSetCumsumMode (MTXCumsum *mtx_cumsum_obj, t_symbol *m_sym) { ! mtx_cumsum_obj->cumsum_mode = m_sym; }
*************** *** 60,75 **** { MTXCumsum *mtx_cumsum_obj = (MTXCumsum *) pd_new (mtx_cumsum_class); ! int c_dir = 1; ! int c_dim = 1; ! ! mtx_cumsum_obj->cumsum_dimension = c_dim; ! switch ((argc>2)?2:argc) { ! case 2: ! c_dir = atom_getint(argv+1); ! case 1: ! c_dim = atom_getint(argv); } - mTXSetCumsumDirection (mtx_cumsum_obj, (t_float) c_dir); - mTXSetCumsumDimension (mtx_cumsum_obj, (t_float) c_dim);
mtx_cumsum_obj->list_outlet = outlet_new (&mtx_cumsum_obj->x_obj, gensym("matrix")); --- 63,87 ---- { MTXCumsum *mtx_cumsum_obj = (MTXCumsum *) pd_new (mtx_cumsum_class); ! mTXSetCumsumMode (mtx_cumsum_obj, gensym(":")); ! mTXSetCumsumDirection (mtx_cumsum_obj, 1.0f); ! if (argc>=1) { ! if (argv[0].a_type == A_SYMBOL) { ! mTXSetCumsumMode (mtx_cumsum_obj, atom_getsymbol (argv)); ! if (argc>=2) ! if (argv[1].a_type != A_SYMBOL) ! mTXSetCumsumDirection (mtx_cumsum_obj, atom_getfloat (argv+1)); ! else ! post("mtx_cumsum: 2nd arg ignored. supposed to be float"); ! } ! else { ! mTXSetCumsumDirection (mtx_cumsum_obj, atom_getfloat (argv)); ! if (argc>=2) { ! if (argv[1].a_type == A_SYMBOL) ! mTXSetCumsumMode (mtx_cumsum_obj, atom_getsymbol (argv+1)); ! else ! post("mtx_cumsum: 2nd arg ignored. supposed to be symbolic, e.g. "row", "col", ":""); ! } ! } }
mtx_cumsum_obj->list_outlet = outlet_new (&mtx_cumsum_obj->x_obj, gensym("matrix")); *************** *** 182,186 **** // main part // reading matrix from inlet ! if (mtx_cumsum_obj->cumsum_dimension == 2) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_cumsum_obj->rows; --- 194,199 ---- // main part // reading matrix from inlet ! if ((mtx_cumsum_obj->cumsum_mode == col_sym) || ! (mtx_cumsum_obj->cumsum_mode == col_sym2)) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_cumsum_obj->rows; *************** *** 192,208 **** // calculating cumsum if (mtx_cumsum_obj->cumsum_direction == -1) { ! x += columns-1; ! y += columns-1; ! for (count = rows; count--; x += columns, y += columns) ! cumSumReverse (columns,x,y); } ! else for (count = rows; count--; x += columns, y += columns) cumSum (columns,x,y); x = mtx_cumsum_obj->x; y = mtx_cumsum_obj->y;
// writing matrix to outlet ! if (mtx_cumsum_obj->cumsum_dimension == 2) { columns = mtx_cumsum_obj->columns; rows = mtx_cumsum_obj->rows; --- 205,237 ---- // calculating cumsum if (mtx_cumsum_obj->cumsum_direction == -1) { ! if ((mtx_cumsum_obj->cumsum_mode == row_sym) || ! (mtx_cumsum_obj->cumsum_mode == col_sym) || ! (mtx_cumsum_obj->cumsum_mode == col_sym2)) { ! x += columns-1; ! y += columns-1; ! ! for (count = rows; count--; x += columns, y += columns) ! cumSumReverse (columns,x,y); ! } ! else { ! x += size-1; ! y += size-1; ! cumSumReverse (size, x, y); ! } } ! else if ((mtx_cumsum_obj->cumsum_mode == row_sym) || ! (mtx_cumsum_obj->cumsum_mode == col_sym) || ! (mtx_cumsum_obj->cumsum_mode == col_sym2)) for (count = rows; count--; x += columns, y += columns) cumSum (columns,x,y); + else + cumSum (size, x, y); + x = mtx_cumsum_obj->x; y = mtx_cumsum_obj->y;
// writing matrix to outlet ! if ((mtx_cumsum_obj->cumsum_mode == col_sym) || ! (mtx_cumsum_obj->cumsum_mode == col_sym2)) { columns = mtx_cumsum_obj->columns; rows = mtx_cumsum_obj->rows; *************** *** 229,235 **** class_addbang (mtx_cumsum_class, (t_method) mTXCumsumBang); class_addmethod (mtx_cumsum_class, (t_method) mTXCumsumMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_cumsum_class, (t_method) mTXSetCumsumDimension, gensym("dimension"), A_DEFFLOAT,0); class_addmethod (mtx_cumsum_class, (t_method) mTXSetCumsumDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_cumsum_class, gensym("iemmatrix/mtx_cumsum")); }
--- 258,267 ---- class_addbang (mtx_cumsum_class, (t_method) mTXCumsumBang); class_addmethod (mtx_cumsum_class, (t_method) mTXCumsumMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_cumsum_class, (t_method) mTXSetCumsumMode, gensym("mode"), A_DEFSYMBOL,0); class_addmethod (mtx_cumsum_class, (t_method) mTXSetCumsumDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_cumsum_class, gensym("iemmatrix/mtx_cumsum")); + row_sym = gensym("row"); + col_sym = gensym("col"); + col_sym2 = gensym("column"); }
Index: mtx_sort.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_sort.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mtx_sort.c 19 Sep 2005 14:47:50 -0000 1.1 --- mtx_sort.c 22 Sep 2005 09:28:55 -0000 1.2 *************** *** 16,19 **** --- 16,22 ----
static t_class *mtx_sort_class; + static t_symbol *row_sym; + static t_symbol *col_sym; + static t_symbol *col_sym2;
typedef struct _MTXSort_ MTXSort; *************** *** 24,28 **** int columns; int size; ! int sort_dimension; int sort_direction;
--- 27,31 ---- int columns; int size; ! t_symbol *sort_mode; int sort_direction;
*************** *** 57,66 **** mtx_sort_obj->sort_direction = (direction==-1)?direction:1; } ! static void mTXSetSortDimension (MTXSort *mtx_sort_obj, t_float s_dim) { ! int dimension = (int) s_dim; ! dimension = (dimension<2)?dimension:2; ! dimension = (dimension>0)?dimension:0; ! mtx_sort_obj->sort_dimension = dimension; }
--- 60,67 ---- mtx_sort_obj->sort_direction = (direction==-1)?direction:1; } ! ! static void mTXSetSortMode (MTXSort *mtx_sort_obj, t_symbol *m_sym) { ! mtx_sort_obj->sort_mode = m_sym; }
*************** *** 68,83 **** { MTXSort *mtx_sort_obj = (MTXSort *) pd_new (mtx_sort_class); ! int c_dir = 1; ! int c_dim = 1; ! ! mtx_sort_obj->sort_dimension = c_dim; ! switch ((argc>2)?2:argc) { ! case 2: ! c_dir = atom_getint(argv+1); ! case 1: ! c_dim = atom_getint(argv); } - mTXSetSortDirection (mtx_sort_obj, (t_float) c_dir); - mTXSetSortDimension (mtx_sort_obj, (t_float) c_dim);
mtx_sort_obj->list_outlet1 = outlet_new (&mtx_sort_obj->x_obj, gensym("matrix")); --- 69,95 ---- { MTXSort *mtx_sort_obj = (MTXSort *) pd_new (mtx_sort_class); ! ! // defaults: ! mTXSetSortMode (mtx_sort_obj, gensym(":")); ! mTXSetSortDirection (mtx_sort_obj, 1.0f); ! if (argc>=1) { ! if (argv[0].a_type == A_SYMBOL) { ! mTXSetSortMode (mtx_sort_obj, atom_getsymbol (argv)); ! if (argc>=2) ! if (argv[1].a_type != A_SYMBOL) ! mTXSetSortDirection (mtx_sort_obj, atom_getfloat (argv+1)); ! else ! post("mtx_sort: 2nd arg ignored. supposed to be float"); ! } ! else { ! mTXSetSortDirection (mtx_sort_obj, atom_getfloat (argv)); ! if (argc>=2) { ! if (argv[1].a_type == A_SYMBOL) ! mTXSetSortMode (mtx_sort_obj, atom_getsymbol (argv+1)); ! else ! post("mtx_sort: 2nd arg ignored. supposed to be symbolic, e.g. "row", "col", ":""); ! } ! } }
mtx_sort_obj->list_outlet1 = outlet_new (&mtx_sort_obj->x_obj, gensym("matrix")); *************** *** 174,177 **** --- 186,190 ---- }
+ /* static void indexingVector (int n, int m, int dimension, t_float *i) { *************** *** 196,199 **** --- 209,234 ---- } } + */ + static void indexingVector (int n, int m, t_symbol *sort_mode, t_float *i) + { + int count; + int count2; + int idx = n; + t_float *ptr; + i += n; + if ((sort_mode == col_sym)||(sort_mode == col_sym2)) { + n /= m; + for (count = m; count--;) { + ptr = --i; + for (count2 = n; count2--; ptr -= m) + *ptr = idx--; + } + } + else { + for (; idx;) + *--i = idx--; + } + } +
static void mTXSortMatrix (MTXSort *mtx_sort_obj, t_symbol *s, *************** *** 261,269 ****
// generating indexing vector ! indexingVector (size, columns, mtx_sort_obj->sort_dimension, i);
// main part // reading matrix from inlet ! if (mtx_sort_obj->sort_dimension == 2) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_sort_obj->rows; --- 296,305 ----
// generating indexing vector ! indexingVector (size, columns, mtx_sort_obj->sort_mode, i);
// main part // reading matrix from inlet ! if ((mtx_sort_obj->sort_mode == col_sym)|| ! (mtx_sort_obj->sort_mode == col_sym2)) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_sort_obj->rows; *************** *** 274,278 ****
// calculating sort ! if (mtx_sort_obj->sort_dimension == 0) sortVector (size,x,i,mtx_sort_obj->sort_direction); else --- 310,316 ----
// calculating sort ! if ((mtx_sort_obj->sort_mode != col_sym) && ! (mtx_sort_obj->sort_mode != col_sym2) && ! (mtx_sort_obj->sort_mode != row_sym)) sortVector (size,x,i,mtx_sort_obj->sort_direction); else *************** *** 283,287 ****
// writing matrix to outlet ! if (mtx_sort_obj->sort_dimension == 2) { columns = mtx_sort_obj->columns; rows = mtx_sort_obj->rows; --- 321,326 ----
// writing matrix to outlet ! if ((mtx_sort_obj->sort_mode == col_sym)|| ! (mtx_sort_obj->sort_mode == col_sym2)) { columns = mtx_sort_obj->columns; rows = mtx_sort_obj->rows; *************** *** 316,322 **** class_addbang (mtx_sort_class, (t_method) mTXSortBang); class_addmethod (mtx_sort_class, (t_method) mTXSortMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_sort_class, (t_method) mTXSetSortDimension, gensym("dimension"), A_DEFFLOAT,0); class_addmethod (mtx_sort_class, (t_method) mTXSetSortDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_sort_class, gensym("iemmatrix/mtx_sort")); }
--- 355,365 ---- class_addbang (mtx_sort_class, (t_method) mTXSortBang); class_addmethod (mtx_sort_class, (t_method) mTXSortMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_sort_class, (t_method) mTXSetSortMode, gensym("mode"), A_DEFSYMBOL,0); ! // class_addmethod (mtx_sort_class, (t_method) mTXSetSortDimension, gensym("dimension"), A_DEFFLOAT,0); class_addmethod (mtx_sort_class, (t_method) mTXSetSortDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_sort_class, gensym("iemmatrix/mtx_sort")); + row_sym = gensym("row"); + col_sym = gensym("col"); + col_sym2 = gensym("column"); }
Index: mtx_decay.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_decay.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mtx_decay.c 20 Sep 2005 08:12:38 -0000 1.1 --- mtx_decay.c 22 Sep 2005 09:28:55 -0000 1.2 *************** *** 16,19 **** --- 16,23 ----
static t_class *mtx_decay_class; + static t_symbol *row_sym; + static t_symbol *col_sym; + static t_symbol *col_sym2; +
typedef struct _MTXDecay_ MTXDecay; *************** *** 24,29 **** int columns; int size; - int decay_dimension; int decay_direction; t_float decay_parameter;
--- 28,33 ---- int columns; int size; int decay_direction; + t_symbol *decay_mode; t_float decay_parameter;
*************** *** 57,64 **** mtx_decay_obj->decay_direction = (direction==-1)?direction:1; } ! static void mTXSetDecayDimension (MTXDecay *mtx_decay_obj, t_float c_dim) { ! int dimension = (int) c_dim; ! mtx_decay_obj->decay_dimension = (dimension==2)?dimension:1; }
--- 61,67 ---- mtx_decay_obj->decay_direction = (direction==-1)?direction:1; } ! static void mTXSetDecayMode (MTXDecay *mtx_decay_obj, t_symbol *c_mode) { ! mtx_decay_obj->decay_mode = c_mode; }
*************** *** 66,85 **** { MTXDecay *mtx_decay_obj = (MTXDecay *) pd_new (mtx_decay_class); ! int c_dir = 1; ! int c_dim = 1; ! t_float c_par = 0.9f;
! mtx_decay_obj->decay_dimension = c_dim; ! switch ((argc>3)?3:argc) { case 3: ! c_dir = atom_getint(argv+2); case 2: ! c_dim = atom_getint(argv+1); case 1: ! c_par = atom_getfloat(argv); } - mTXSetDecayParameter (mtx_decay_obj, c_par); - mTXSetDecayDirection (mtx_decay_obj, (t_float) c_dir); - mTXSetDecayDimension (mtx_decay_obj, (t_float) c_dim);
mtx_decay_obj->list_outlet = outlet_new (&mtx_decay_obj->x_obj, gensym("matrix")); --- 69,109 ---- { MTXDecay *mtx_decay_obj = (MTXDecay *) pd_new (mtx_decay_class); ! int sym_count=0; ! int first_sym=argc; ! int n=0;
! mTXSetDecayMode (mtx_decay_obj, gensym(":")); ! mTXSetDecayDirection (mtx_decay_obj, 1); ! mTXSetDecayParameter (mtx_decay_obj, .9f); ! ! argc = ((argc<3)?argc:3); ! while (n < argc) { ! if (argv[n].a_type == A_SYMBOL) { ! post("postition %d",n); ! sym_count++; ! first_sym = (first_sym<n)?first_sym:n; ! } ! n++; ! } ! if (sym_count >= 1) ! mTXSetDecayMode (mtx_decay_obj, atom_getsymbol(argv+first_sym)); ! if (sym_count > 1) { ! post("mtx_decay: args after pos %d ignored. supposed to be non-symbolic",first_sym); ! argc = first_sym+1; ! } ! ! switch (argc) { case 3: ! if (first_sym < 2) ! mTXSetDecayDirection (mtx_decay_obj, atom_getfloat (argv+2)); case 2: ! if (first_sym < 1) ! mTXSetDecayParameter (mtx_decay_obj, atom_getfloat (argv+1)); ! else if (first_sym > 1) ! mTXSetDecayDirection (mtx_decay_obj, atom_getfloat(argv+1)); case 1: ! if (first_sym != 0) ! mTXSetDecayParameter (mtx_decay_obj, atom_getfloat (argv)); }
mtx_decay_obj->list_outlet = outlet_new (&mtx_decay_obj->x_obj, gensym("matrix")); *************** *** 194,198 **** // main part // reading matrix from inlet ! if (mtx_decay_obj->decay_dimension == 2) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_decay_obj->rows; --- 218,224 ---- // main part // reading matrix from inlet ! ! if ((mtx_decay_obj->decay_mode == col_sym) || ! (mtx_decay_obj->decay_mode == col_sym2)) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_decay_obj->rows; *************** *** 204,220 **** // calculating decay if (mtx_decay_obj->decay_direction == -1) { ! x += columns-1; ! y += columns-1; ! for (count = rows; count--; x += columns, y += columns) ! deCayReverse (columns,x,y,mtx_decay_obj->decay_parameter); } - else - for (count = rows; count--; x += columns, y += columns) - deCay (columns,x,y,mtx_decay_obj->decay_parameter); x = mtx_decay_obj->x; y = mtx_decay_obj->y;
// writing matrix to outlet ! if (mtx_decay_obj->decay_dimension == 2) { columns = mtx_decay_obj->columns; rows = mtx_decay_obj->rows; --- 230,262 ---- // calculating decay if (mtx_decay_obj->decay_direction == -1) { ! if ((mtx_decay_obj->decay_mode == col_sym) || ! (mtx_decay_obj->decay_mode == col_sym2) || ! (mtx_decay_obj->decay_mode == row_sym)) { ! x += columns-1; ! y += columns-1; ! for (count = rows; count--; x += columns, y += columns) ! deCayReverse (columns,x,y,mtx_decay_obj->decay_parameter); ! } ! else { ! x += size-1; ! y += size-1; ! deCayReverse (size,x,y,mtx_decay_obj->decay_parameter); ! } ! } ! else { ! if ((mtx_decay_obj->decay_mode == col_sym) || ! (mtx_decay_obj->decay_mode == col_sym2) || ! (mtx_decay_obj->decay_mode == row_sym)) ! for (count = rows; count--; x += columns, y += columns) ! deCay (columns,x,y,mtx_decay_obj->decay_parameter); ! else ! deCay (size,x,y,mtx_decay_obj->decay_parameter); } x = mtx_decay_obj->x; y = mtx_decay_obj->y;
// writing matrix to outlet ! if ((mtx_decay_obj->decay_mode == col_sym) || ! (mtx_decay_obj->decay_mode == col_sym2)) { columns = mtx_decay_obj->columns; rows = mtx_decay_obj->rows; *************** *** 242,248 **** class_addmethod (mtx_decay_class, (t_method) mTXDecayMatrix, gensym("matrix"), A_GIMME,0); class_addmethod (mtx_decay_class, (t_method) mTXSetDecayParameter, gensym("alpha"), A_DEFFLOAT,0); ! class_addmethod (mtx_decay_class, (t_method) mTXSetDecayDimension, gensym("dimension"), A_DEFFLOAT,0); class_addmethod (mtx_decay_class, (t_method) mTXSetDecayDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_decay_class, gensym("iemmatrix/mtx_decay")); }
--- 284,293 ---- class_addmethod (mtx_decay_class, (t_method) mTXDecayMatrix, gensym("matrix"), A_GIMME,0); class_addmethod (mtx_decay_class, (t_method) mTXSetDecayParameter, gensym("alpha"), A_DEFFLOAT,0); ! class_addmethod (mtx_decay_class, (t_method) mTXSetDecayMode, gensym("mode"), A_DEFSYMBOL,0); class_addmethod (mtx_decay_class, (t_method) mTXSetDecayDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_decay_class, gensym("iemmatrix/mtx_decay")); + row_sym = gensym("row"); + col_sym = gensym("col"); + col_sym2 = gensym("column"); }
Index: mtx_diff.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_diff.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mtx_diff.c 19 Sep 2005 14:47:49 -0000 1.1 --- mtx_diff.c 22 Sep 2005 09:28:55 -0000 1.2 *************** *** 15,18 **** --- 15,21 ----
static t_class *mtx_diff_class; + static t_symbol *row_sym; + static t_symbol *col_sym; + static t_symbol *col_sym2;
typedef struct _MTXdiff_ MTXdiff; *************** *** 23,28 **** int columns; int size; - int diff_dimension; int diff_direction;
t_outlet *list_outlet; --- 26,31 ---- int columns; int size; int diff_direction; + t_symbol *diff_mode;
t_outlet *list_outlet; *************** *** 49,56 **** mtx_diff_obj->diff_direction = (direction==-1)?direction:1; } ! static void mTXSetdiffDimension (MTXdiff *mtx_diff_obj, t_float c_dim) { ! int dimension = (int) c_dim; ! mtx_diff_obj->diff_dimension = (dimension==2)?dimension:1; }
--- 52,58 ---- mtx_diff_obj->diff_direction = (direction==-1)?direction:1; } ! static void mTXSetdiffMode (MTXdiff *mtx_diff_obj, t_symbol *c_mode) { ! mtx_diff_obj->diff_mode = c_mode; }
*************** *** 58,73 **** { MTXdiff *mtx_diff_obj = (MTXdiff *) pd_new (mtx_diff_class); ! int c_dir = 1; ! int c_dim = 1; ! ! mtx_diff_obj->diff_dimension = c_dim; ! switch ((argc>2)?2:argc) { ! case 2: ! c_dir = atom_getint(argv+1); ! case 1: ! c_dim = atom_getint(argv); } - mTXSetdiffDirection (mtx_diff_obj, (t_float) c_dir); - mTXSetdiffDimension (mtx_diff_obj, (t_float) c_dim);
mtx_diff_obj->list_outlet = outlet_new (&mtx_diff_obj->x_obj, gensym("matrix")); --- 60,84 ---- { MTXdiff *mtx_diff_obj = (MTXdiff *) pd_new (mtx_diff_class); ! mTXSetdiffMode (mtx_diff_obj, gensym(":")); ! mTXSetdiffDirection (mtx_diff_obj, 1.0f); ! if (argc>=1) { ! if (argv[0].a_type == A_SYMBOL) { ! mTXSetdiffMode (mtx_diff_obj, atom_getsymbol (argv)); ! if (argc>=2) ! if (argv[1].a_type != A_SYMBOL) ! mTXSetdiffDirection (mtx_diff_obj, atom_getfloat (argv+1)); ! else ! post("mtx_diff: 2nd arg ignored. supposed to be float"); ! } ! else { ! mTXSetdiffDirection (mtx_diff_obj, atom_getfloat (argv)); ! if (argc>=2) { ! if (argv[1].a_type == A_SYMBOL) ! mTXSetdiffMode (mtx_diff_obj, atom_getsymbol (argv+1)); ! else ! post("mtx_diff: 2nd arg ignored. supposed to be symbolic, e.g. "row", "col", ":""); ! } ! } }
mtx_diff_obj->list_outlet = outlet_new (&mtx_diff_obj->x_obj, gensym("matrix")); *************** *** 176,180 **** // main part // reading matrix from inlet ! if (mtx_diff_obj->diff_dimension == 2) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_diff_obj->rows; --- 187,192 ---- // main part // reading matrix from inlet ! if ((mtx_diff_obj->diff_mode == col_sym) || ! (mtx_diff_obj->diff_mode == col_sym2)) { readFloatFromListModulo (size, columns, list_ptr, x); columns = mtx_diff_obj->rows; *************** *** 186,202 **** // calculating diff if (mtx_diff_obj->diff_direction == -1) { ! x += columns-1; ! y += columns-1; ! for (count = rows; count--; x += columns, y += columns) ! diffReverse (columns,x,y); } ! else for (count = rows; count--; x += columns, y += columns) diff (columns,x,y); x = mtx_diff_obj->x; y = mtx_diff_obj->y;
// writing matrix to outlet ! if (mtx_diff_obj->diff_dimension == 2) { columns = mtx_diff_obj->columns; rows = mtx_diff_obj->rows; --- 198,229 ---- // calculating diff if (mtx_diff_obj->diff_direction == -1) { ! if ((mtx_diff_obj->diff_mode == row_sym) || ! (mtx_diff_obj->diff_mode == col_sym) || ! (mtx_diff_obj->diff_mode == col_sym2)) { ! x += columns-1; ! y += columns-1; ! for (count = rows; count--; x += columns, y += columns) ! diffReverse (columns,x,y); ! } ! else { ! x += size-1; ! y += size-1; ! diffReverse (size, x, y); ! } } ! else if ((mtx_diff_obj->diff_mode == row_sym) || ! (mtx_diff_obj->diff_mode == col_sym) || ! (mtx_diff_obj->diff_mode == col_sym2)) { for (count = rows; count--; x += columns, y += columns) diff (columns,x,y); + } + else + diff (size,x,y); x = mtx_diff_obj->x; y = mtx_diff_obj->y;
// writing matrix to outlet ! if ((mtx_diff_obj->diff_mode == col_sym) || ! (mtx_diff_obj->diff_mode == col_sym2)) { columns = mtx_diff_obj->columns; rows = mtx_diff_obj->rows; *************** *** 223,229 **** class_addbang (mtx_diff_class, (t_method) mTXdiffBang); class_addmethod (mtx_diff_class, (t_method) mTXdiffMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_diff_class, (t_method) mTXSetdiffDimension, gensym("dimension"), A_DEFFLOAT,0); class_addmethod (mtx_diff_class, (t_method) mTXSetdiffDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_diff_class, gensym("iemmatrix/mtx_diff")); }
--- 250,259 ---- class_addbang (mtx_diff_class, (t_method) mTXdiffBang); class_addmethod (mtx_diff_class, (t_method) mTXdiffMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_diff_class, (t_method) mTXSetdiffMode, gensym("mode"), A_DEFSYMBOL,0); class_addmethod (mtx_diff_class, (t_method) mTXSetdiffDirection, gensym("direction"), A_DEFFLOAT,0); class_sethelpsymbol (mtx_diff_class, gensym("iemmatrix/mtx_diff")); + row_sym = gensym("row"); + col_sym = gensym("col"); + col_sym2 = gensym("column"); }