diff options
author | Franz Zotter <fzotter@users.sourceforge.net> | 2006-08-09 16:16:12 +0000 |
---|---|---|
committer | Franz Zotter <fzotter@users.sourceforge.net> | 2006-08-09 16:16:12 +0000 |
commit | f08fb52aac042d9a01126a726d556bedb595bee1 (patch) | |
tree | 88cb6c0045403506fcaac9bb65de9d06ee17468c /src | |
parent | f1fd678167fe3a2774674db51ab08d0dde796a8f (diff) |
i added a "size" command to the base object that resizes the matrix
atombuffer silently (no output), or shows the matrix dimensions.
[size r c(, [size r(, and [size(
are allowed, making a rectangular or square matrix, or answering with the
size of the matrix, respectively.
svn path=/trunk/externals/iem/iemmatrix/; revision=5538
Diffstat (limited to 'src')
-rw-r--r-- | src/mtx_matrix.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mtx_matrix.c b/src/mtx_matrix.c index 42b14d5..1df3db4 100644 --- a/src/mtx_matrix.c +++ b/src/mtx_matrix.c @@ -163,6 +163,27 @@ void matrix_set(t_matrix *x, t_float f) if(x->atombuffer)while(size--)SETFLOAT(&buf[size], f); } +void matrix_size(t_matrix *x, t_symbol *s, int argc, t_atom *argv) +{ + int col, row, size=x->row*x->col; + + switch(argc) { + case 0: /* size */ + outlet_list(x->x_obj.ob_outlet, gensym("size"), 2, x->atombuffer); + break; + case 1: + row=atom_getfloat(argv); + adjustsize(x, row, row); + matrix_set(x, 0); + break; + default: + row=atom_getfloat(argv++); + col=atom_getfloat(argv); + adjustsize(x, row, col); + matrix_set(x, 0); + } +} + void matrix_zeros(t_matrix *x, t_symbol *s, int argc, t_atom *argv) { int col, row; @@ -582,6 +603,7 @@ void matrix_setup(void) class_addmethod (matrix_class, (t_method)matrix_matrix2, gensym(""), A_GIMME, 0); /* the basics : functions for creation */ + class_addmethod (matrix_class, (t_method)matrix_size, gensym("size"), A_GIMME, 0); class_addmethod (matrix_class, (t_method)matrix_eye, gensym("eye"), A_GIMME, 0); class_addmethod (matrix_class, (t_method)matrix_diag, gensym("diag"), A_GIMME, 0); class_addmethod (matrix_class, (t_method)matrix_ones, gensym("ones"), A_GIMME, 0); |