diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-05-11 14:31:27 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-05-11 14:31:27 +0000 |
commit | b0f1e61341b464e6ad1f4f6f7fcff5afd8250979 (patch) | |
tree | 546dc10c18b2f2e8a3e25bc231b279d002ed80ca | |
parent | 637c0a02f96ae3262337ff836a8c336a136f496a (diff) |
output a righthand bang if inversion fails
svn path=/trunk/externals/iem/iemmatrix/; revision=2952
-rw-r--r-- | src/mtx_inverse.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mtx_inverse.c b/src/mtx_inverse.c index 20339e3..9b8939b 100644 --- a/src/mtx_inverse.c +++ b/src/mtx_inverse.c @@ -89,6 +89,8 @@ static void mtx_inverse_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv) int row=atom_getfloat(argv); int col=atom_getfloat(argv+1); + int error=0; + t_matrixfloat *original, *inverted; if(row*col+2>argc){ @@ -104,7 +106,7 @@ static void mtx_inverse_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv) if (row==col){ /* fine, the matrix is square */ - inverted=mtx_doInvert(original, row, 0); + inverted=mtx_doInvert(original, row, &error); } else { /* we'll have to do the pseudo-inverse: * P=A'*inv(A*A') if row<col @@ -116,11 +118,11 @@ static void mtx_inverse_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv) if(row>col){ inverteeCol=col; invertee =mtx_doMultiply(col, transposed, row, original, col); - inverted =mtx_doMultiply(col, mtx_doInvert(invertee, col, 0), col, transposed, row); + inverted =mtx_doMultiply(col, mtx_doInvert(invertee, col, &error), col, transposed, row); } else { inverteeCol=row; invertee =mtx_doMultiply(row, original, col, transposed, row); - inverted =mtx_doMultiply(col, transposed, row, mtx_doInvert(invertee, row, 0), row); + inverted =mtx_doMultiply(col, transposed, row, mtx_doInvert(invertee, row, &error), row); } freebytes(transposed, sizeof(t_matrixfloat)*col*row); freebytes(invertee , sizeof(t_matrixfloat)*inverteeCol*inverteeCol); @@ -132,6 +134,8 @@ static void mtx_inverse_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv) /* 3b destroy the buffers */ freebytes(original, sizeof(t_matrixfloat)*row*col); + if(error)outlet_bang(x->x_outlet); + /* 3c output the atombuf; */ matrix_bang(x); } @@ -142,6 +146,7 @@ static void *mtx_inverse_new(t_symbol *s, int argc, t_atom *argv) outlet_new(&x->x_obj, 0); x->col=x->row=0; x->atombuffer=0; + x->x_outlet=outlet_new(&x->x_obj, 0); return (x); } |