Update of /cvsroot/pure-data/externals/iem/iemmatrix/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20289/src
Modified Files: iemmatrix_sources.c iemmatrix_sources.h Added Files: mtx_atan.c mtx_dbtopow.c mtx_powtodb.c Log Message: added a few element wise operations
Index: iemmatrix_sources.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/iemmatrix_sources.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** iemmatrix_sources.c 25 Jul 2006 14:14:38 -0000 1.8 --- iemmatrix_sources.c 28 Aug 2006 16:48:51 -0000 1.9 *************** *** 11,14 **** --- 11,15 ---- iemtx_add_setup(); /* mtx_add.c */ iemtx_and_setup(); /* mtx_and.c */ + iemtx_atan_setup(); /* mtx_atan.c */ iemtx_binops_setup(); /* mtx_binops.c */ iemtx_bitand_setup(); /* mtx_bitand.c */ *************** *** 25,28 **** --- 26,30 ---- iemtx_cos_setup(); /* mtx_cos.c */ iemtx_cumsum_setup(); /* mtx_cumsum.c */ + iemtx_dbtopow_setup(); /* mtx_dbtopow.c */ iemtx_dbtorms_setup(); /* mtx_dbtorms.c */ iemtx_decay_setup(); /* mtx_decay.c */ *************** *** 52,57 **** iemtx_min2_setup(); /* mtx_min2.c */ iemtx_minmax_setup(); /* mtx_minmax.c */ - iemtx_mul__setup(); /* mtx_mul~.c */ iemtx_mul_setup(); /* mtx_mul.c */ iemtx_neq_setup(); /* mtx_neq.c */ iemtx_not_setup(); /* mtx_not.c */ --- 54,59 ---- iemtx_min2_setup(); /* mtx_min2.c */ iemtx_minmax_setup(); /* mtx_minmax.c */ iemtx_mul_setup(); /* mtx_mul.c */ + iemtx_mul__setup(); /* mtx_mul~.c */ iemtx_neq_setup(); /* mtx_neq.c */ iemtx_not_setup(); /* mtx_not.c */ *************** *** 60,63 **** --- 62,66 ---- iemtx_pivot_setup(); /* mtx_pivot.c */ iemtx_pow_setup(); /* mtx_pow.c */ + iemtx_powtodb_setup(); /* mtx_powtodb.c */ iemtx_print_setup(); /* mtx_print.c */ iemtx_prod_setup(); /* mtx_prod.c */
Index: iemmatrix_sources.h =================================================================== RCS file: /cvsroot/pure-data/externals/iem/iemmatrix/src/iemmatrix_sources.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** iemmatrix_sources.h 25 Jul 2006 14:14:38 -0000 1.8 --- iemmatrix_sources.h 28 Aug 2006 16:48:51 -0000 1.9 *************** *** 9,12 **** --- 9,13 ---- void iemtx_add_setup(void); /* mtx_add.c */ void iemtx_and_setup(void); /* mtx_and.c */ + void iemtx_atan_setup(void); /* mtx_atan.c */ void iemtx_binops_setup(void); /* mtx_binops.c */ void iemtx_bitand_setup(void); /* mtx_bitand.c */ *************** *** 23,26 **** --- 24,28 ---- void iemtx_cos_setup(void); /* mtx_cos.c */ void iemtx_cumsum_setup(void); /* mtx_cumsum.c */ + void iemtx_dbtopow_setup(void); /* mtx_dbtopow.c */ void iemtx_dbtorms_setup(void); /* mtx_dbtorms.c */ void iemtx_decay_setup(void); /* mtx_decay.c */ *************** *** 50,55 **** void iemtx_min2_setup(void); /* mtx_min2.c */ void iemtx_minmax_setup(void); /* mtx_minmax.c */ - void iemtx_mul__setup(void); /* mtx_mul~.c */ void iemtx_mul_setup(void); /* mtx_mul.c */ void iemtx_neq_setup(void); /* mtx_neq.c */ void iemtx_not_setup(void); /* mtx_not.c */ --- 52,57 ---- void iemtx_min2_setup(void); /* mtx_min2.c */ void iemtx_minmax_setup(void); /* mtx_minmax.c */ void iemtx_mul_setup(void); /* mtx_mul.c */ + void iemtx_mul__setup(void); /* mtx_mul~.c */ void iemtx_neq_setup(void); /* mtx_neq.c */ void iemtx_not_setup(void); /* mtx_not.c */ *************** *** 58,61 **** --- 60,64 ---- void iemtx_pivot_setup(void); /* mtx_pivot.c */ void iemtx_pow_setup(void); /* mtx_pow.c */ + void iemtx_powtodb_setup(void); /* mtx_powtodb.c */ void iemtx_print_setup(void); /* mtx_print.c */ void iemtx_prod_setup(void); /* mtx_prod.c */
--- NEW FILE: mtx_powtodb.c --- /* * iemmatrix * * objects for manipulating simple matrices * mostly refering to matlab/octave matrix functions * * Copyright (c) IOhannes m zmölnig, forum::für::umläute * IEM, Graz, Austria * * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. * */ #include "iemmatrix.h"
#define LOGTEN 2.302585092994
/* mtx_powtodb: B=log(A); B[n,m]=e^A[n,m] */
static t_class *mtx_powtodb_class;
static void mtx_powtodb_matrix(t_mtx_binmtx *x, t_symbol *s, int argc, t_atom *argv) { int row=atom_getfloat(argv++); int col=atom_getfloat(argv++); t_atom *m; int n = argc-2;
if (argc<2){ post("mtx_powtodb: crippled matrix"); return; } if ((col<1)||(row<1)) { post("mtx_powtodb: invalid dimensions"); return; } if (col*row>argc-2){ post("sparse matrix not yet supported : use "mtx_check""); return; }
adjustsize(&x->m, row, col); m = x->m.atombuffer+2;
while(n--){ t_float f=atom_getfloat(argv++); t_float v=(f<0)?0.:(100+10./LOGTEN * log(f)); SETFLOAT(m, (v<0)?0:v); m++; }
outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), argc, x->m.atombuffer); }
static void mtx_powtodb_list(t_mtx_binscalar *x, t_symbol *s, int argc, t_atom *argv) { int n=argc; t_atom *m;
adjustsize(&x->m, 1, argc); m = x->m.atombuffer;
while(n--){ t_float f=atom_getfloat(argv++); t_float v=(f<0)?0.:(100+10./LOGTEN * log(f)); SETFLOAT(m, (v<0)?0:v); m++; }
outlet_list(x->x_obj.ob_outlet, gensym("list"), argc, x->m.atombuffer); }
static void *mtx_powtodb_new(t_symbol *s) { /* element log */ t_matrix *x = (t_matrix *)pd_new(mtx_powtodb_class); outlet_new(&x->x_obj, 0); x->col = x->row = 0; x->atombuffer = 0; return(x); }
void mtx_powtodb_setup(void) { mtx_powtodb_class = class_new(gensym("mtx_powtodb"), (t_newmethod)mtx_powtodb_new, (t_method)mtx_binmtx_free, sizeof(t_mtx_binmtx), 0, A_GIMME, 0); class_addmethod(mtx_powtodb_class, (t_method)mtx_powtodb_matrix, gensym("matrix"), A_GIMME, 0); class_addlist (mtx_powtodb_class, mtx_powtodb_list); class_addbang (mtx_powtodb_class, mtx_binmtx_bang);
}
void iemtx_powtodb_setup(void) { mtx_powtodb_setup(); }
--- NEW FILE: mtx_dbtopow.c --- /* * iemmatrix * * objects for manipulating simple matrices * mostly refering to matlab/octave matrix functions * * Copyright (c) IOhannes m zmölnig, forum::für::umläute * IEM, Graz, Austria * * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. * */ #include "iemmatrix.h"
#define LOGTEN 2.302585092994
/* mtx_dbtopow: B=log(A); B[n,m]=e^A[n,m] */
static t_class *mtx_dbtopow_class;
static void mtx_dbtopow_matrix(t_mtx_binmtx *x, t_symbol *s, int argc, t_atom *argv) { int row=atom_getfloat(argv++); int col=atom_getfloat(argv++); t_atom *m; int n = argc-2;
if (argc<2){ post("mtx_dbtopow: crippled matrix"); return; } if ((col<1)||(row<1)) { post("mtx_dbtopow: invalid dimensions"); return; } if (col*row>argc-2){ post("sparse matrix not yet supported : use "mtx_check""); return; }
adjustsize(&x->m, row, col); m = x->m.atombuffer+2;
while(n--){ t_float f=atom_getfloat(argv++); t_float v=0; f=(f>485)?485:f; v=(f<=0)?0:exp((LOGTEN*0.1) * (f-100.)); SETFLOAT(m, (v<0)?0:v); m++; }
outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), argc, x->m.atombuffer); }
static void mtx_dbtopow_list(t_mtx_binscalar *x, t_symbol *s, int argc, t_atom *argv) { int n=argc; t_atom *m;
adjustsize(&x->m, 1, argc); m = x->m.atombuffer;
while(n--){ t_float f=atom_getfloat(argv++); t_float v=0; f=(f>485)?485:f; v=(f<=0)?0:exp((LOGTEN*0.1) * (f-100.)); SETFLOAT(m, (v<0)?0:v); m++; }
outlet_list(x->x_obj.ob_outlet, gensym("list"), argc, x->m.atombuffer); }
static void *mtx_dbtopow_new(t_symbol *s) { /* element log */ t_matrix *x = (t_matrix *)pd_new(mtx_dbtopow_class); outlet_new(&x->x_obj, 0); x->col = x->row = 0; x->atombuffer = 0; return(x); }
void mtx_dbtopow_setup(void) { mtx_dbtopow_class = class_new(gensym("mtx_dbtopow"), (t_newmethod)mtx_dbtopow_new, (t_method)mtx_binmtx_free, sizeof(t_mtx_binmtx), 0, A_GIMME, 0); class_addmethod(mtx_dbtopow_class, (t_method)mtx_dbtopow_matrix, gensym("matrix"), A_GIMME, 0); class_addlist (mtx_dbtopow_class, mtx_dbtopow_list); class_addbang (mtx_dbtopow_class, mtx_binmtx_bang);
}
void iemtx_dbtopow_setup(void) { mtx_dbtopow_setup(); }
--- NEW FILE: mtx_atan.c --- /* * iemmatrix * * objects for manipulating simple matrices * mostly refering to matlab/octave matrix functions * * Copyright (c) IOhannes m zmölnig, forum::für::umläute * IEM, Graz, Austria * * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. * */ #include "iemmatrix.h"
/* mtx_atan: B=atan(A); */
static t_class *mtx_atan_class;
static void mtx_atan_matrix(t_mtx_binmtx *x, t_symbol *s, int argc, t_atom *argv) { int row=atom_getint(argv++); int col=atom_getint(argv++); t_atom *m; int n = row*col;
if (argc<2){ post("mtx_atan: crippled matrix"); return; } if ((col<1)||(row<1)) { post("mtx_atan: invalid dimensions"); return; } if (col*row>argc-2){ post("sparse matrix not yet supported : use "mtx_check""); return; }
adjustsize(&x->m, row, col); m = x->m.atombuffer+2;
while(n--){ t_float f = atom_getfloat(argv++); SETFLOAT(m, (t_float)atanf(f)); m++; }
outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), argc, x->m.atombuffer); }
static void mtx_atan_list(t_mtx_binscalar *x, t_symbol *s, int argc, t_atom *argv) { int n=argc; t_atom *m;
adjustsize(&x->m, 1, argc); m = x->m.atombuffer;
while(n--){ m->a_type = A_FLOAT; (m++)->a_w.w_float = (t_float)atanf(atom_getfloat(argv++)); }
outlet_list(x->x_obj.ob_outlet, gensym("list"), argc, x->m.atombuffer); }
static void *mtx_atan_new(t_symbol *s) { /* element atan */ t_matrix *x = (t_matrix *)pd_new(mtx_atan_class); outlet_new(&x->x_obj, 0); x->col = x->row = 0; x->atombuffer = 0; return(x); }
void mtx_atan_setup(void) { mtx_atan_class = class_new(gensym("mtx_atan"), (t_newmethod)mtx_atan_new, (t_method)mtx_binmtx_free, sizeof(t_mtx_binmtx), 0, A_GIMME, 0); class_addmethod(mtx_atan_class, (t_method)mtx_atan_matrix, gensym("matrix"), A_GIMME, 0); class_addlist (mtx_atan_class, mtx_atan_list); class_addbang (mtx_atan_class, mtx_binmtx_bang);
}
void iemtx_atan_setup(void) { mtx_atan_setup(); }