Update of /cvsroot/pure-data/externals/iem/iemmatrix/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18925
Modified Files: mtx_minmax.c Log Message: changed the formerly called "dimension" to "mode". Now following modes are available: "col"/"column", "row" or anything else, e.g. "whole". This should be done for mtx_cumsum and mtx_sort too. perhaps this could be a more unifying definition for "row-wise" and "column-wise" operation modes.
Index: mtx_minmax.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/mtx_minmax.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mtx_minmax.c 19 Sep 2005 14:47:49 -0000 1.1 --- mtx_minmax.c 20 Sep 2005 13:26:48 -0000 1.2 *************** *** 17,20 **** --- 17,23 ----
static t_class *mtx_minmax_class; + static t_symbol *row_sym; + static t_symbol *col_sym; + static t_symbol *col_sym2;
typedef struct _MTXminmax_ MTXminmax; *************** *** 24,30 **** int size; int outsize; ! int minmax_dimension; ! int minmax_direction; ! int operator_minimum; // 1 if we are [mtx_min], 0 if we are [mtx_max]
t_outlet *list_outlet; --- 27,32 ---- int size; int outsize; ! t_symbol *minmax_mode; ! int operator_minimum; // 1 if we are [mtx_min], 0 if we are [mtx_max]
t_outlet *list_outlet; *************** *** 40,57 **** }
! static void mTXSetMinMaxDirection (MTXminmax *mtx_minmax_obj, t_float c_dir) ! { ! int direction = (int) c_dir; ! if ((direction != -1) && (direction != 1)) ! direction = 1; ! mtx_minmax_obj->minmax_direction = direction; ! } ! ! static void mTXSetMinMaxDimension (MTXminmax *mtx_minmax_obj, t_float c_dim) { ! int dimension = (int) c_dim; ! dimension = (dimension > 0)?dimension:0; ! dimension = (dimension < 3)?dimension:3; ! mtx_minmax_obj->minmax_dimension = dimension; }
--- 42,48 ---- }
! static void mTXSetMinMaxMode (MTXminmax *mtx_minmax_obj, t_symbol *m_sym) { ! mtx_minmax_obj->minmax_mode = m_sym; }
*************** *** 59,74 **** { MTXminmax *mtx_minmax_obj = (MTXminmax *) pd_new (mtx_minmax_class); ! int c_dim = 1; ! int c_dir = 1;
! switch ((argc>2)?2:argc) { ! case 2: ! c_dir = atom_getint(argv+1); case 1: ! c_dim = atom_getint(argv); } mtx_minmax_obj->operator_minimum = 1; ! mTXSetMinMaxDimension (mtx_minmax_obj, (t_float) c_dim); ! mTXSetMinMaxDirection (mtx_minmax_obj, (t_float) c_dir);
mtx_minmax_obj->list_outlet = outlet_new (&mtx_minmax_obj->x_obj, gensym("matrix")); --- 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")); *************** *** 78,93 **** { MTXminmax *mtx_minmax_obj = (MTXminmax *) pd_new (mtx_minmax_class); ! int c_dim = 1; ! int c_dir = 1;
! switch ((argc>2)?2:argc) { ! case 2: ! c_dir = atom_getint(argv+1); case 1: ! c_dim = atom_getint(argv); } mtx_minmax_obj->operator_minimum = 0; ! mTXSetMinMaxDimension (mtx_minmax_obj, (t_float) c_dim); ! mTXSetMinMaxDirection (mtx_minmax_obj, (t_float) c_dir);
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")); *************** *** 228,241 **** list_out += 2; //copyList (size, argv, list_out); ! switch (mtx_minmax_obj->minmax_dimension) { ! case 0: ! columns_out = 1; ! rows_out = 1; ! if (mtx_minmax_obj->operator_minimum) ! minListRows (1, size, list_in, list_out); ! else ! maxListRows (1, size, list_in, list_out); ! break; ! case 1: rows_out = rows; columns_out = 1; --- 211,215 ---- list_out += 2; //copyList (size, argv, list_out); ! if (mtx_minmax_obj->minmax_mode == row_sym) { rows_out = rows; columns_out = 1; *************** *** 244,249 **** else maxListRows (rows, columns, list_in, list_out); ! break; ! case 2: rows_out = 1; columns_out = columns; --- 218,224 ---- else maxListRows (rows, columns, list_in, list_out); ! } ! else if ((mtx_minmax_obj->minmax_mode == col_sym) || ! (mtx_minmax_obj->minmax_mode == col_sym2)) { rows_out = 1; columns_out = columns; *************** *** 252,256 **** else maxListColumns (rows, columns, list_in, list_out); ! break; } mtx_minmax_obj->outsize = columns_out * rows_out; --- 227,238 ---- else maxListColumns (rows, columns, list_in, list_out); ! } ! else { ! columns_out = 1; ! rows_out = 1; ! if (mtx_minmax_obj->operator_minimum) ! minListRows (1, size, list_in, list_out); ! else ! maxListRows (1, size, list_in, list_out); } mtx_minmax_obj->outsize = columns_out * rows_out; *************** *** 274,281 **** class_addbang (mtx_minmax_class, (t_method) mTXMinMaxBang); class_addmethod (mtx_minmax_class, (t_method) mTXMinMaxMatrix, gensym("matrix"), A_GIMME,0); ! class_addmethod (mtx_minmax_class, (t_method) mTXSetMinMaxDimension, gensym("dimension"), A_DEFFLOAT,0); ! class_addmethod (mtx_minmax_class, (t_method) mTXSetMinMaxDirection, gensym("direction"), A_DEFFLOAT,0); class_addcreator ((t_newmethod) newMTXMax, gensym("mtx_max"), A_GIMME,0); class_sethelpsymbol (mtx_minmax_class, gensym("iemmatrix/mtx_minmax")); }
--- 256,266 ---- class_addbang (mtx_minmax_class, (t_method) mTXMinMaxBang); class_addmethod (mtx_minmax_class, (t_method) mTXMinMaxMatrix, gensym("matrix"), A_GIMME,0); ! // class_addmethod (mtx_minmax_class, (t_method) mTXSetMinMaxDimension, gensym("dimension"), A_DEFFLOAT,0); ! class_addmethod (mtx_minmax_class, (t_method) mTXSetMinMaxMode, gensym("mode"), A_DEFSYMBOL ,0); class_addcreator ((t_newmethod) newMTXMax, gensym("mtx_max"), A_GIMME,0); class_sethelpsymbol (mtx_minmax_class, gensym("iemmatrix/mtx_minmax")); + row_sym = gensym("row"); + col_sym = gensym("col"); + col_sym2 = gensym("column"); }