[PD-cvs] SF.net SVN: pure-data:[10193] trunk/externals/iem/iemmatrix

fzotter at users.sourceforge.net fzotter at users.sourceforge.net
Tue Jul 22 11:18:54 CEST 2008


Revision: 10193
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10193&view=rev
Author:   fzotter
Date:     2008-07-22 09:18:54 +0000 (Tue, 22 Jul 2008)

Log Message:
-----------
changed from mtx_rowrfft and mtx_rowrifft to 
mtx_rfft and mtx_rifft

Added Paths:
-----------
    trunk/externals/iem/iemmatrix/doc/mtx_rfft-help.pd
    trunk/externals/iem/iemmatrix/doc/mtx_rifft-help.pd
    trunk/externals/iem/iemmatrix/src/mtx_rfft.c
    trunk/externals/iem/iemmatrix/src/mtx_rifft.c

Removed Paths:
-------------
    trunk/externals/iem/iemmatrix/doc/mtx_rowrfft-help.pd
    trunk/externals/iem/iemmatrix/doc/mtx_rowrifft-help.pd
    trunk/externals/iem/iemmatrix/src/mtx_rowrfft.c
    trunk/externals/iem/iemmatrix/src/mtx_rowrifft.c

Copied: trunk/externals/iem/iemmatrix/doc/mtx_rfft-help.pd (from rev 10192, trunk/externals/iem/iemmatrix/doc/mtx_rowrfft-help.pd)
===================================================================
--- trunk/externals/iem/iemmatrix/doc/mtx_rfft-help.pd	                        (rev 0)
+++ trunk/externals/iem/iemmatrix/doc/mtx_rfft-help.pd	2008-07-22 09:18:54 UTC (rev 10193)
@@ -0,0 +1,47 @@
+#N canvas 547 150 672 515 10;
+#X text 457 17 updated for;
+#X obj 545 17 iemmatrix 0.2;
+#X obj 594 43 matrix;
+#X text 464 42 see also help for;
+#X msg 11 124 bang;
+#X text 46 34 real fft in each matrix row;
+#X text 7 60 you can calculate real ffts in column direction \; matrix
+has to have 2^k columns \; a N/2+1 columns matrix is the result \;
+;
+#X obj 11 191 mtx_cumsum;
+#X msg 11 147 1 16;
+#X obj 11 169 mtx_ones;
+#X obj 11 213 mtx_- 1;
+#X obj 49 255 mtx_* 0;
+#X floatatom 172 234 5 0 0 0 - - -;
+#X text 212 232 <-- scroll here to select frequency;
+#X obj 172 255 / 8;
+#X obj 49 306 t a a;
+#X obj 92 306 mtx_print original;
+#X obj 49 394 mtx_print rfft_realpart;
+#X obj 121 372 mtx_print rfft_imagpart;
+#X text 266 419 see also:;
+#X obj 49 280 mtx_cos;
+#X obj 103 255 * 3.14159;
+#X text 109 280 cosine wave;
+#X obj 121 352 mtx_int;
+#X obj 49 373 mtx_int;
+#X text 89 15 [mtx_rfft];
+#X obj 49 330 mtx_rfft;
+#X obj 261 438 mtx_rifft;
+#X connect 4 0 8 0;
+#X connect 7 0 10 0;
+#X connect 8 0 9 0;
+#X connect 9 0 7 0;
+#X connect 10 0 11 0;
+#X connect 11 0 20 0;
+#X connect 12 0 14 0;
+#X connect 14 0 21 0;
+#X connect 15 0 26 0;
+#X connect 15 1 16 0;
+#X connect 20 0 15 0;
+#X connect 21 0 11 1;
+#X connect 23 0 18 0;
+#X connect 24 0 17 0;
+#X connect 26 0 24 0;
+#X connect 26 1 23 0;

Copied: trunk/externals/iem/iemmatrix/doc/mtx_rifft-help.pd (from rev 10192, trunk/externals/iem/iemmatrix/doc/mtx_rowrifft-help.pd)
===================================================================
--- trunk/externals/iem/iemmatrix/doc/mtx_rifft-help.pd	                        (rev 0)
+++ trunk/externals/iem/iemmatrix/doc/mtx_rifft-help.pd	2008-07-22 09:18:54 UTC (rev 10193)
@@ -0,0 +1,43 @@
+#N canvas 547 150 672 515 10;
+#X text 457 17 updated for;
+#X obj 545 17 iemmatrix 0.2;
+#X obj 594 43 matrix;
+#X text 464 42 see also help for;
+#X msg 11 124 bang;
+#X obj 11 191 mtx_cumsum;
+#X obj 11 169 mtx_ones;
+#X obj 11 213 mtx_- 1;
+#X obj 49 255 mtx_* 0;
+#X floatatom 177 234 5 0 0 0 - - -;
+#X obj 177 255 / 8;
+#X obj 49 278 t a a;
+#X text 266 443 see also:;
+#X text 46 34 real ifft in each matrix row;
+#X text 7 60 you can calculate real inverse ffts in column direction
+\; matrix has to have 2^(k-1)+1 columns \; a 2^k columns matrix is
+the result \;;
+#X msg 11 147 1 9;
+#X obj 49 307 mtx_cos;
+#X obj 104 307 mtx_sin;
+#X text 217 232 <-- scroll here to select delay;
+#X obj 49 381 mtx_print rifft;
+#X obj 49 359 mtx_int;
+#X obj 103 255 * -3.14159;
+#X text 89 15 [mtx_rifft];
+#X obj 262 463 mtx_rfft;
+#X obj 49 336 mtx_rifft;
+#X connect 4 0 15 0;
+#X connect 5 0 7 0;
+#X connect 6 0 5 0;
+#X connect 7 0 8 0;
+#X connect 8 0 11 0;
+#X connect 9 0 10 0;
+#X connect 10 0 21 0;
+#X connect 11 0 16 0;
+#X connect 11 1 17 0;
+#X connect 15 0 6 0;
+#X connect 16 0 24 0;
+#X connect 17 0 24 1;
+#X connect 20 0 19 0;
+#X connect 21 0 8 1;
+#X connect 24 0 20 0;

Deleted: trunk/externals/iem/iemmatrix/doc/mtx_rowrfft-help.pd
===================================================================
--- trunk/externals/iem/iemmatrix/doc/mtx_rowrfft-help.pd	2008-07-21 21:43:36 UTC (rev 10192)
+++ trunk/externals/iem/iemmatrix/doc/mtx_rowrfft-help.pd	2008-07-22 09:18:54 UTC (rev 10193)
@@ -1,47 +0,0 @@
-#N canvas 547 150 672 515 10;
-#X text 457 17 updated for;
-#X obj 545 17 iemmatrix 0.2;
-#X obj 594 43 matrix;
-#X text 464 42 see also help for;
-#X msg 11 124 bang;
-#X text 89 15 [mtx_rowrfft];
-#X text 46 34 real fft in each matrix row;
-#X text 7 60 you can calculate real ffts in column direction \; matrix
-has to have 2^k columns \; a N/2+1 columns matrix is the result \;
-;
-#X obj 11 191 mtx_cumsum;
-#X msg 11 147 1 16;
-#X obj 11 169 mtx_ones;
-#X obj 11 213 mtx_- 1;
-#X obj 49 255 mtx_* 0;
-#X floatatom 172 234 5 0 0 0 - - -;
-#X text 212 232 <-- scroll here to select frequency;
-#X obj 172 255 / 8;
-#X obj 49 330 mtx_rowrfft;
-#X obj 49 306 t a a;
-#X obj 92 306 mtx_print original;
-#X obj 49 394 mtx_print rfft_realpart;
-#X obj 121 372 mtx_print rfft_imagpart;
-#X obj 261 438 mtx_rowrifft;
-#X text 266 419 see also:;
-#X obj 49 280 mtx_cos;
-#X obj 103 255 * 3.14159;
-#X text 109 280 cosine wave;
-#X obj 121 352 mtx_int;
-#X obj 49 373 mtx_int;
-#X connect 4 0 9 0;
-#X connect 8 0 11 0;
-#X connect 9 0 10 0;
-#X connect 10 0 8 0;
-#X connect 11 0 12 0;
-#X connect 12 0 23 0;
-#X connect 13 0 15 0;
-#X connect 15 0 24 0;
-#X connect 16 0 27 0;
-#X connect 16 1 26 0;
-#X connect 17 0 16 0;
-#X connect 17 1 18 0;
-#X connect 23 0 17 0;
-#X connect 24 0 12 1;
-#X connect 26 0 20 0;
-#X connect 27 0 19 0;

Deleted: trunk/externals/iem/iemmatrix/doc/mtx_rowrifft-help.pd
===================================================================
--- trunk/externals/iem/iemmatrix/doc/mtx_rowrifft-help.pd	2008-07-21 21:43:36 UTC (rev 10192)
+++ trunk/externals/iem/iemmatrix/doc/mtx_rowrifft-help.pd	2008-07-22 09:18:54 UTC (rev 10193)
@@ -1,43 +0,0 @@
-#N canvas 547 150 672 515 10;
-#X text 457 17 updated for;
-#X obj 545 17 iemmatrix 0.2;
-#X obj 594 43 matrix;
-#X text 464 42 see also help for;
-#X msg 11 124 bang;
-#X obj 11 191 mtx_cumsum;
-#X obj 11 169 mtx_ones;
-#X obj 11 213 mtx_- 1;
-#X obj 49 255 mtx_* 0;
-#X floatatom 177 234 5 0 0 0 - - -;
-#X obj 177 255 / 8;
-#X obj 49 278 t a a;
-#X text 266 443 see also:;
-#X text 89 15 [mtx_rowrifft];
-#X text 46 34 real ifft in each matrix row;
-#X text 7 60 you can calculate real inverse ffts in column direction
-\; matrix has to have 2^(k-1)+1 columns \; a 2^k columns matrix is
-the result \;;
-#X msg 11 147 1 9;
-#X obj 49 307 mtx_cos;
-#X obj 104 307 mtx_sin;
-#X text 217 232 <-- scroll here to select delay;
-#X obj 49 336 mtx_rowrifft;
-#X obj 49 381 mtx_print rifft;
-#X obj 261 462 mtx_rowrfft;
-#X obj 49 359 mtx_int;
-#X obj 103 255 * -3.14159;
-#X connect 4 0 16 0;
-#X connect 5 0 7 0;
-#X connect 6 0 5 0;
-#X connect 7 0 8 0;
-#X connect 8 0 11 0;
-#X connect 9 0 10 0;
-#X connect 10 0 24 0;
-#X connect 11 0 17 0;
-#X connect 11 1 18 0;
-#X connect 16 0 6 0;
-#X connect 17 0 20 0;
-#X connect 18 0 20 1;
-#X connect 20 0 23 0;
-#X connect 23 0 21 0;
-#X connect 24 0 8 1;

Copied: trunk/externals/iem/iemmatrix/src/mtx_rfft.c (from rev 10192, trunk/externals/iem/iemmatrix/src/mtx_rowrfft.c)
===================================================================
--- trunk/externals/iem/iemmatrix/src/mtx_rfft.c	                        (rev 0)
+++ trunk/externals/iem/iemmatrix/src/mtx_rfft.c	2008-07-22 09:18:54 UTC (rev 10193)
@@ -0,0 +1,192 @@
+/*
+ *  iemmatrix
+ *
+ *  objects for manipulating simple matrices
+ *  mostly refering to matlab/octave matrix functions
+ *
+ * Copyright (c) 2005, Franz Zotter
+ * 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"
+#include <stdlib.h>
+
+static t_class *mtx_rfft_class;
+
+typedef struct _MTXRfft_ MTXRfft;
+struct _MTXRfft_
+{
+  t_object x_obj;
+  int size;
+  int size2;
+
+  t_float *f_re;
+  t_float *f_im;
+
+  t_outlet *list_re_out;
+  t_outlet *list_im_out;
+   
+  t_atom *list_re;
+  t_atom *list_im;
+};
+
+static void deleteMTXRfft (MTXRfft *x) 
+{
+  if (x->f_re)
+     free (x->f_re);
+  if (x->f_im) 
+     free (x->f_im);
+  if (x->list_re)
+     free (x->list_re);
+  if (x->list_im)
+     free (x->list_im);
+}
+
+static void *newMTXRfft (t_symbol *s, int argc, t_atom *argv)
+{
+  MTXRfft *x = (MTXRfft *) pd_new (mtx_rfft_class);
+  x->list_re_out = outlet_new (&x->x_obj, gensym("matrix"));
+  x->list_im_out = outlet_new (&x->x_obj, gensym("matrix"));
+
+  x->size=x->size2=0;
+  x->f_re=x->f_im=0;
+  x->list_re=x->list_im=0;
+  
+  return ((void *) x);
+} 
+
+static void mTXRfftBang (MTXRfft *x)
+{
+  if (x->list_im) {
+    outlet_anything(x->list_im_out, gensym("matrix"), x->size2, x->list_im);
+    outlet_anything(x->list_re_out, gensym("matrix"), x->size2, x->list_re);
+  }
+}
+
+static void fftRestoreImag (int n, t_float *re, t_float *im) 
+{
+  t_float *im2;
+  n >>= 1;
+  *im=0;
+  re += n;
+  im += n;
+  im2 = im;
+  *im=0;
+  while (--n) {
+    *--im = -*++re;
+    *++im2 = 0;
+    *re = 0;
+  }
+}
+
+static void zeroFloatArray (int n, t_float *f)
+{
+  while (n--)
+    *f++ = 0.0f;
+}
+
+static void writeFloatIntoList (int n, t_atom *l, t_float *f) 
+{
+  for (;n--;f++, l++) 
+    SETFLOAT (l, *f);
+}
+static void readFloatFromList (int n, t_atom *l, t_float *f) 
+{
+  while (n--) 
+    *f++ = atom_getfloat (l++);
+}
+
+static void mTXRfftMatrix (MTXRfft *x, t_symbol *s, 
+			      int argc, t_atom *argv)
+{
+  int rows = atom_getint (argv++);
+  int columns = atom_getint (argv++);
+  int columns_re = (columns>>1)+1; /* N/2+1 samples needed for real part of realfft */
+  int size = rows * columns;
+  int in_size = argc-2;
+  int size2 = columns_re * rows + 2; /* +2 since the list also contains matrix row+col */
+  int fft_count;
+  t_atom *list_re = x->list_re;
+  t_atom *list_im = x->list_im;
+  t_float *f_re = x->f_re;
+  t_float *f_im = x->f_im;
+
+  /* fftsize check */
+  if (!size)
+    post("mtx_rfft: invalid dimensions");
+  else if (in_size<size)
+    post("mtx_rfft: sparse matrix not yet supported: use \"mtx_check\"");
+  else if (columns < 4){
+    post("mtx_rfft: matrix must have at least 4 columns");
+  }
+  else if (columns == (1 << ilog2(columns))) {
+    /* ok, do the FFT! */
+
+    /* memory things */
+    f_re=(t_float*)realloc(f_re, sizeof(t_float)*size);
+    f_im=(t_float*)realloc(f_im, sizeof(t_float)*size);
+    list_re=(t_atom*)realloc(list_re, sizeof(t_atom)*size2);
+    list_im=(t_atom*)realloc(list_im, sizeof(t_atom)*size2);
+
+    x->size = size;
+    x->size2 = size2;
+    x->list_im = list_im;
+    x->list_re = list_re;
+    x->f_re = f_re;
+    x->f_im = f_im;
+
+    /* main part */
+    readFloatFromList (size, argv, f_re);
+
+    fft_count = rows;
+    list_re += 2;
+    list_im += 2;
+    while (fft_count--){ 
+      mayer_realfft (columns, f_re);
+      fftRestoreImag (columns, f_re, f_im);
+      writeFloatIntoList (columns_re, list_re, f_re);
+      writeFloatIntoList (columns_re, list_im, f_im);
+      f_im += columns;
+      f_re += columns;
+      list_re += columns_re;
+      list_im += columns_re;
+    }
+
+    list_re = x->list_re;
+    list_im = x->list_im;
+      
+    SETSYMBOL(list_re, gensym("matrix"));
+    SETSYMBOL(list_im, gensym("matrix"));
+    SETFLOAT(list_re, rows);
+    SETFLOAT(list_im, rows);
+    SETFLOAT(list_re+1, columns_re);
+    SETFLOAT(list_im+1, columns_re);
+    outlet_anything(x->list_im_out, gensym("matrix"), 
+		    x->size2, list_im);
+    outlet_anything(x->list_re_out, gensym("matrix"), 
+		    x->size2, list_re);
+  }
+  else
+    post("mtx_rowfft: rowvector size no power of 2!");
+
+}
+
+void mtx_rfft_setup (void)
+{
+  mtx_rfft_class = class_new 
+    (gensym("mtx_rfft"),
+     (t_newmethod) newMTXRfft,
+     (t_method) deleteMTXRfft,
+     sizeof (MTXRfft),
+     CLASS_DEFAULT, A_GIMME, 0);
+  class_addbang (mtx_rfft_class, (t_method) mTXRfftBang);
+  class_addmethod (mtx_rfft_class, (t_method) mTXRfftMatrix, gensym("matrix"), A_GIMME,0);
+}
+
+void iemtx_rfft_setup(void){
+  mtx_rfft_setup();
+}

Copied: trunk/externals/iem/iemmatrix/src/mtx_rifft.c (from rev 10192, trunk/externals/iem/iemmatrix/src/mtx_rowrifft.c)
===================================================================
--- trunk/externals/iem/iemmatrix/src/mtx_rifft.c	                        (rev 0)
+++ trunk/externals/iem/iemmatrix/src/mtx_rifft.c	2008-07-22 09:18:54 UTC (rev 10193)
@@ -0,0 +1,226 @@
+/*
+ *  iemmatrix
+ *
+ *  objects for manipulating simple matrices
+ *  mostly refering to matlab/octave matrix functions
+ *
+ * Copyright (c) 2005, Franz Zotter
+ * 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"
+#include <stdlib.h>
+
+static t_class *mtx_rifft_class;
+
+typedef struct _MTXRifft_
+{
+  t_object x_obj;
+  int rows;
+  int columns;
+  int columns_re;
+  int size;
+  int size2;
+  t_float renorm_fac;
+
+  t_float *f_re;
+  t_float *f_im;
+
+  t_outlet *list_re_out;
+  t_outlet *list_im_out;
+   
+  t_atom *list_re;
+  t_atom *list_im;
+} MTXRifft;
+
+
+/* helper functions: these should really go into a separate file! */
+
+
+static void zeroFloatArray (int n, t_float *f)
+{
+  while (n--)
+    *f++ = 0.0f;
+}
+
+static void writeFloatIntoList (int n, t_atom *l, t_float *f) 
+{
+  for (;n--;f++, l++) 
+    SETFLOAT (l, *f);
+}
+static void readFloatFromList (int n, t_atom *l, t_float *f) 
+{
+  while (n--) 
+    *f++ = atom_getfloat (l++);
+}
+
+/*--------------inverse real fft */
+
+static void multiplyVector (int n, t_float *f, t_float fac)
+{
+  while (n--)
+    *f++ *= fac;
+}
+
+
+static void ifftPrepareReal (int n, t_float *re, t_float *im) 
+{
+  n >>= 1;
+  re += n;
+  im += n;
+   
+  while (--n) 
+    *++re = -*--im;
+}
+
+
+static void *newMTXRifft (t_symbol *s, int argc, t_atom *argv)
+{
+  MTXRifft *x = (MTXRifft *) pd_new (mtx_rifft_class);
+  inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("matrix"),gensym(""));
+  x->list_re_out = outlet_new (&x->x_obj, gensym("matrix"));
+  return ((void *) x);
+} 
+
+
+static void mTXRifftMatrixCold (MTXRifft *x, t_symbol *s, 
+				   int argc, t_atom *argv)
+{
+    int rows = atom_getint (argv++);
+  int columns_re = atom_getint (argv++);
+  int in_size = argc-2;
+  int columns = (columns_re-1)<<1;
+  int size2 = columns_re * rows;
+  int size = rows * columns;
+  int ifft_count;
+  t_atom *list_re = x->list_re;
+  t_float *f_re = x->f_re;
+  t_float *f_im = x->f_im;
+
+  /* ifftsize check */
+  if (columns_re < 3)
+    post("mtx_rifft: matrix must have at least 3 columns");
+  else if (!size) 
+    post("mtx_rifft: invalid dimensions");
+  else if (in_size < size2)
+    post("mtx_rifft: sparse matrix not yet supported: use \"mtx_check\"");
+  else if (columns<4)
+    post("mtx_rifft: too small matrices");
+  else if (columns == (1 << ilog2(columns))) {
+
+    /* memory things */
+    f_re=(t_float*)realloc(f_re, sizeof(t_float)*size);
+    f_im=(t_float*)realloc(f_im, sizeof(t_float)*size);
+    list_re=(t_atom*)realloc(list_re, sizeof(t_atom)*(size+2));
+
+    x->size = size;
+    x->size2 = size2;
+    x->rows = rows;
+    x->columns = columns;
+    x->columns_re = columns_re;
+    x->list_re = list_re;
+    x->f_re = f_re;
+    x->f_im = f_im;
+      
+    /* main part: reading imaginary part */
+    ifft_count = rows;
+    x->renorm_fac = 1.0f / columns;
+    while (ifft_count--) {
+      readFloatFromList (columns_re, argv, f_im);
+      argv += columns_re;
+      f_im += columns;
+    }
+    /* do nothing else! */
+  }
+  else
+    post("mtx_rifft: rowvector 2*(size+1) no power of 2!");
+}
+
+static void mTXRifftMatrixHot (MTXRifft *x, t_symbol *s, 
+				  int argc, t_atom *argv)
+{
+  int rows = atom_getint (argv++);
+  int columns_re = atom_getint (argv++);
+  int columns = x->columns;
+  int size = x->size;
+  int in_size = argc-2;
+  int size2 = x->size2;
+  int ifft_count;
+  t_atom *ptr_re = x->list_re;
+  t_float *f_re = x->f_re;
+  t_float *f_im = x->f_im;
+  t_float renorm_fac = x->renorm_fac;
+
+  /* ifftsize check */
+  if ((rows != x->rows) || 
+      (columns_re != x->columns_re))
+    post("mtx_rifft: matrix dimensions do not match");
+  else if (in_size<size2)
+    post("mtx_rifft: sparse matrix not yet supported: use \"mtx_check\"");
+  else if (!x->size2)
+    post("mtx_rifft: invalid right side matrix");
+  else { /* main part */
+    ifft_count = rows;
+    ptr_re += 2;
+    while (ifft_count--){ 
+      readFloatFromList (columns_re, argv, f_re);
+      ifftPrepareReal (columns, f_re, f_im);
+      mayer_realifft (columns, f_re);
+      multiplyVector (columns, f_re, renorm_fac);
+      f_im += columns;
+      f_re += columns;
+      ptr_re += columns;
+      argv += columns_re;
+    }
+    ptr_re = x->list_re;
+    f_re = x->f_re;
+    size2 = x->size2;
+
+    SETSYMBOL(ptr_re, gensym("matrix"));
+    SETFLOAT(ptr_re, rows);
+    SETFLOAT(&ptr_re[1], x->columns);
+    writeFloatIntoList (size, ptr_re+2, f_re);
+    outlet_anything(x->list_re_out, gensym("matrix"), size+2, ptr_re);
+  }
+}
+
+static void mTXRifftBang (MTXRifft *x)
+{
+  if (x->list_re)
+    outlet_anything(x->list_re_out, gensym("matrix"), 
+		    x->size+2, x->list_re);
+}
+
+
+static void deleteMTXRifft (MTXRifft *x) 
+{
+  if (x->f_re)
+     free(x->f_re);
+  if (x->f_im)
+     free(x->f_im);
+  if (x->list_re)
+     free(x->list_re);
+  if (x->list_im)
+     free(x->list_im);
+}
+
+static void mtx_rifft_setup (void)
+{
+  mtx_rifft_class = class_new 
+    (gensym("mtx_rifft"),
+     (t_newmethod) newMTXRifft,
+     (t_method) deleteMTXRifft,
+     sizeof (MTXRifft),
+     CLASS_DEFAULT, A_GIMME, 0);
+  class_addbang (mtx_rifft_class, (t_method) mTXRifftBang);
+  class_addmethod (mtx_rifft_class, (t_method) mTXRifftMatrixHot, gensym("matrix"), A_GIMME,0);
+  class_addmethod (mtx_rifft_class, (t_method) mTXRifftMatrixCold, gensym(""), A_GIMME,0);
+}
+
+void iemtx_rifft_setup(void){
+  mtx_rifft_setup();
+}

Deleted: trunk/externals/iem/iemmatrix/src/mtx_rowrfft.c
===================================================================
--- trunk/externals/iem/iemmatrix/src/mtx_rowrfft.c	2008-07-21 21:43:36 UTC (rev 10192)
+++ trunk/externals/iem/iemmatrix/src/mtx_rowrfft.c	2008-07-22 09:18:54 UTC (rev 10193)
@@ -1,192 +0,0 @@
-/*
- *  iemmatrix
- *
- *  objects for manipulating simple matrices
- *  mostly refering to matlab/octave matrix functions
- *
- * Copyright (c) 2005, Franz Zotter
- * 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"
-#include <stdlib.h>
-
-static t_class *mtx_rowrfft_class;
-
-typedef struct _MTXRowrfft_ MTXRowrfft;
-struct _MTXRowrfft_
-{
-  t_object x_obj;
-  int size;
-  int size2;
-
-  t_float *f_re;
-  t_float *f_im;
-
-  t_outlet *list_re_out;
-  t_outlet *list_im_out;
-   
-  t_atom *list_re;
-  t_atom *list_im;
-};
-
-static void deleteMTXRowrfft (MTXRowrfft *x) 
-{
-  if (x->f_re)
-     free (x->f_re);
-  if (x->f_im) 
-     free (x->f_im);
-  if (x->list_re)
-     free (x->list_re);
-  if (x->list_im)
-     free (x->list_im);
-}
-
-static void *newMTXRowrfft (t_symbol *s, int argc, t_atom *argv)
-{
-  MTXRowrfft *x = (MTXRowrfft *) pd_new (mtx_rowrfft_class);
-  x->list_re_out = outlet_new (&x->x_obj, gensym("matrix"));
-  x->list_im_out = outlet_new (&x->x_obj, gensym("matrix"));
-
-  x->size=x->size2=0;
-  x->f_re=x->f_im=0;
-  x->list_re=x->list_im=0;
-  
-  return ((void *) x);
-} 
-
-static void mTXrowrfftBang (MTXRowrfft *x)
-{
-  if (x->list_im) {
-    outlet_anything(x->list_im_out, gensym("matrix"), x->size2, x->list_im);
-    outlet_anything(x->list_re_out, gensym("matrix"), x->size2, x->list_re);
-  }
-}
-
-static void fftRestoreImag (int n, t_float *re, t_float *im) 
-{
-  t_float *im2;
-  n >>= 1;
-  *im=0;
-  re += n;
-  im += n;
-  im2 = im;
-  *im=0;
-  while (--n) {
-    *--im = -*++re;
-    *++im2 = 0;
-    *re = 0;
-  }
-}
-
-static void zeroFloatArray (int n, t_float *f)
-{
-  while (n--)
-    *f++ = 0.0f;
-}
-
-static void writeFloatIntoList (int n, t_atom *l, t_float *f) 
-{
-  for (;n--;f++, l++) 
-    SETFLOAT (l, *f);
-}
-static void readFloatFromList (int n, t_atom *l, t_float *f) 
-{
-  while (n--) 
-    *f++ = atom_getfloat (l++);
-}
-
-static void mTXrowrfftMatrix (MTXRowrfft *x, t_symbol *s, 
-			      int argc, t_atom *argv)
-{
-  int rows = atom_getint (argv++);
-  int columns = atom_getint (argv++);
-  int columns_re = (columns>>1)+1; /* N/2+1 samples needed for real part of realfft */
-  int size = rows * columns;
-  int in_size = argc-2;
-  int size2 = columns_re * rows + 2; /* +2 since the list also contains matrix row+col */
-  int fft_count;
-  t_atom *list_re = x->list_re;
-  t_atom *list_im = x->list_im;
-  t_float *f_re = x->f_re;
-  t_float *f_im = x->f_im;
-
-  /* fftsize check */
-  if (!size)
-    post("mtx_rowrfft: invalid dimensions");
-  else if (in_size<size)
-    post("mtx_rowrfft: sparse matrix not yet supported: use \"mtx_check\"");
-  else if (columns < 4){
-    post("mtx_rowrfft: matrix must have at least 4 columns");
-  }
-  else if (columns == (1 << ilog2(columns))) {
-    /* ok, do the FFT! */
-
-    /* memory things */
-    f_re=(t_float*)realloc(f_re, sizeof(t_float)*size);
-    f_im=(t_float*)realloc(f_im, sizeof(t_float)*size);
-    list_re=(t_atom*)realloc(list_re, sizeof(t_atom)*size2);
-    list_im=(t_atom*)realloc(list_im, sizeof(t_atom)*size2);
-
-    x->size = size;
-    x->size2 = size2;
-    x->list_im = list_im;
-    x->list_re = list_re;
-    x->f_re = f_re;
-    x->f_im = f_im;
-
-    /* main part */
-    readFloatFromList (size, argv, f_re);
-
-    fft_count = rows;
-    list_re += 2;
-    list_im += 2;
-    while (fft_count--){ 
-      mayer_realfft (columns, f_re);
-      fftRestoreImag (columns, f_re, f_im);
-      writeFloatIntoList (columns_re, list_re, f_re);
-      writeFloatIntoList (columns_re, list_im, f_im);
-      f_im += columns;
-      f_re += columns;
-      list_re += columns_re;
-      list_im += columns_re;
-    }
-
-    list_re = x->list_re;
-    list_im = x->list_im;
-      
-    SETSYMBOL(list_re, gensym("matrix"));
-    SETSYMBOL(list_im, gensym("matrix"));
-    SETFLOAT(list_re, rows);
-    SETFLOAT(list_im, rows);
-    SETFLOAT(list_re+1, columns_re);
-    SETFLOAT(list_im+1, columns_re);
-    outlet_anything(x->list_im_out, gensym("matrix"), 
-		    x->size2, list_im);
-    outlet_anything(x->list_re_out, gensym("matrix"), 
-		    x->size2, list_re);
-  }
-  else
-    post("mtx_rowfft: rowvector size no power of 2!");
-
-}
-
-void mtx_rowrfft_setup (void)
-{
-  mtx_rowrfft_class = class_new 
-    (gensym("mtx_rowrfft"),
-     (t_newmethod) newMTXRowrfft,
-     (t_method) deleteMTXRowrfft,
-     sizeof (MTXRowrfft),
-     CLASS_DEFAULT, A_GIMME, 0);
-  class_addbang (mtx_rowrfft_class, (t_method) mTXrowrfftBang);
-  class_addmethod (mtx_rowrfft_class, (t_method) mTXrowrfftMatrix, gensym("matrix"), A_GIMME,0);
-}
-
-void iemtx_rowrfft_setup(void){
-  mtx_rowrfft_setup();
-}

Deleted: trunk/externals/iem/iemmatrix/src/mtx_rowrifft.c
===================================================================
--- trunk/externals/iem/iemmatrix/src/mtx_rowrifft.c	2008-07-21 21:43:36 UTC (rev 10192)
+++ trunk/externals/iem/iemmatrix/src/mtx_rowrifft.c	2008-07-22 09:18:54 UTC (rev 10193)
@@ -1,226 +0,0 @@
-/*
- *  iemmatrix
- *
- *  objects for manipulating simple matrices
- *  mostly refering to matlab/octave matrix functions
- *
- * Copyright (c) 2005, Franz Zotter
- * 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"
-#include <stdlib.h>
-
-static t_class *mtx_rowrifft_class;
-
-typedef struct _MTXRowrifft_
-{
-  t_object x_obj;
-  int rows;
-  int columns;
-  int columns_re;
-  int size;
-  int size2;
-  t_float renorm_fac;
-
-  t_float *f_re;
-  t_float *f_im;
-
-  t_outlet *list_re_out;
-  t_outlet *list_im_out;
-   
-  t_atom *list_re;
-  t_atom *list_im;
-} MTXRowrifft;
-
-
-/* helper functions: these should really go into a separate file! */
-
-
-static void zeroFloatArray (int n, t_float *f)
-{
-  while (n--)
-    *f++ = 0.0f;
-}
-
-static void writeFloatIntoList (int n, t_atom *l, t_float *f) 
-{
-  for (;n--;f++, l++) 
-    SETFLOAT (l, *f);
-}
-static void readFloatFromList (int n, t_atom *l, t_float *f) 
-{
-  while (n--) 
-    *f++ = atom_getfloat (l++);
-}
-
-/*--------------inverse real fft */
-
-static void multiplyVector (int n, t_float *f, t_float fac)
-{
-  while (n--)
-    *f++ *= fac;
-}
-
-
-static void ifftPrepareReal (int n, t_float *re, t_float *im) 
-{
-  n >>= 1;
-  re += n;
-  im += n;
-   
-  while (--n) 
-    *++re = -*--im;
-}
-
-
-static void *newMTXRowrifft (t_symbol *s, int argc, t_atom *argv)
-{
-  MTXRowrifft *x = (MTXRowrifft *) pd_new (mtx_rowrifft_class);
-  inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("matrix"),gensym(""));
-  x->list_re_out = outlet_new (&x->x_obj, gensym("matrix"));
-  return ((void *) x);
-} 
-
-
-static void mTXrowrifftMatrixCold (MTXRowrifft *x, t_symbol *s, 
-				   int argc, t_atom *argv)
-{
-    int rows = atom_getint (argv++);
-  int columns_re = atom_getint (argv++);
-  int in_size = argc-2;
-  int columns = (columns_re-1)<<1;
-  int size2 = columns_re * rows;
-  int size = rows * columns;
-  int ifft_count;
-  t_atom *list_re = x->list_re;
-  t_float *f_re = x->f_re;
-  t_float *f_im = x->f_im;
-
-  /* ifftsize check */
-  if (columns_re < 3)
-    post("mtx_rowrifft: matrix must have at least 3 columns");
-  else if (!size) 
-    post("mtx_rowrifft: invalid dimensions");
-  else if (in_size < size2)
-    post("mtx_rowrifft: sparse matrix not yet supported: use \"mtx_check\"");
-  else if (columns<4)
-    post("mtx_rowrifft: too small matrices");
-  else if (columns == (1 << ilog2(columns))) {
-
-    /* memory things */
-    f_re=(t_float*)realloc(f_re, sizeof(t_float)*size);
-    f_im=(t_float*)realloc(f_im, sizeof(t_float)*size);
-    list_re=(t_atom*)realloc(list_re, sizeof(t_atom)*(size+2));
-
-    x->size = size;
-    x->size2 = size2;
-    x->rows = rows;
-    x->columns = columns;
-    x->columns_re = columns_re;
-    x->list_re = list_re;
-    x->f_re = f_re;
-    x->f_im = f_im;
-      
-    /* main part: reading imaginary part */
-    ifft_count = rows;
-    x->renorm_fac = 1.0f / columns;
-    while (ifft_count--) {
-      readFloatFromList (columns_re, argv, f_im);
-      argv += columns_re;
-      f_im += columns;
-    }
-    /* do nothing else! */
-  }
-  else
-    post("mtx_rowrifft: rowvector 2*(size+1) no power of 2!");
-}
-
-static void mTXrowrifftMatrixHot (MTXRowrifft *x, t_symbol *s, 
-				  int argc, t_atom *argv)
-{
-  int rows = atom_getint (argv++);
-  int columns_re = atom_getint (argv++);
-  int columns = x->columns;
-  int size = x->size;
-  int in_size = argc-2;
-  int size2 = x->size2;
-  int ifft_count;
-  t_atom *ptr_re = x->list_re;
-  t_float *f_re = x->f_re;
-  t_float *f_im = x->f_im;
-  t_float renorm_fac = x->renorm_fac;
-
-  /* ifftsize check */
-  if ((rows != x->rows) || 
-      (columns_re != x->columns_re))
-    post("mtx_rowrifft: matrix dimensions do not match");
-  else if (in_size<size2)
-    post("mtx_rowrifft: sparse matrix not yet supported: use \"mtx_check\"");
-  else if (!x->size2)
-    post("mtx_rowrifft: invalid right side matrix");
-  else { /* main part */
-    ifft_count = rows;
-    ptr_re += 2;
-    while (ifft_count--){ 
-      readFloatFromList (columns_re, argv, f_re);
-      ifftPrepareReal (columns, f_re, f_im);
-      mayer_realifft (columns, f_re);
-      multiplyVector (columns, f_re, renorm_fac);
-      f_im += columns;
-      f_re += columns;
-      ptr_re += columns;
-      argv += columns_re;
-    }
-    ptr_re = x->list_re;
-    f_re = x->f_re;
-    size2 = x->size2;
-
-    SETSYMBOL(ptr_re, gensym("matrix"));
-    SETFLOAT(ptr_re, rows);
-    SETFLOAT(&ptr_re[1], x->columns);
-    writeFloatIntoList (size, ptr_re+2, f_re);
-    outlet_anything(x->list_re_out, gensym("matrix"), size+2, ptr_re);
-  }
-}
-
-static void mTXrowrifftBang (MTXRowrifft *x)
-{
-  if (x->list_re)
-    outlet_anything(x->list_re_out, gensym("matrix"), 
-		    x->size+2, x->list_re);
-}
-
-
-static void deleteMTXRowrifft (MTXRowrifft *x) 
-{
-  if (x->f_re)
-     free(x->f_re);
-  if (x->f_im)
-     free(x->f_im);
-  if (x->list_re)
-     free(x->list_re);
-  if (x->list_im)
-     free(x->list_im);
-}
-
-static void mtx_rowrifft_setup (void)
-{
-  mtx_rowrifft_class = class_new 
-    (gensym("mtx_rowrifft"),
-     (t_newmethod) newMTXRowrifft,
-     (t_method) deleteMTXRowrifft,
-     sizeof (MTXRowrifft),
-     CLASS_DEFAULT, A_GIMME, 0);
-  class_addbang (mtx_rowrifft_class, (t_method) mTXrowrifftBang);
-  class_addmethod (mtx_rowrifft_class, (t_method) mTXrowrifftMatrixHot, gensym("matrix"), A_GIMME,0);
-  class_addmethod (mtx_rowrifft_class, (t_method) mTXrowrifftMatrixCold, gensym(""), A_GIMME,0);
-}
-
-void iemtx_rowrifft_setup(void){
-  mtx_rowrifft_setup();
-}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list