Mercurial > hg > octave-lyh
diff liboctave/CMatrix.cc @ 3248:68259f410026
[project @ 1999-07-13 03:34:54 by jwe]
author | jwe |
---|---|
date | Tue, 13 Jul 1999 03:40:17 +0000 |
parents | 98d0ee053ba4 |
children | 13cdcb7e5066 |
line wrap: on
line diff
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -1928,14 +1928,29 @@ Matrix ComplexMatrix::map (d_c_Mapper f) const { - const Complex *d = data (); - - Matrix retval (rows (), columns ()); - - double *r = retval.fortran_vec (); - - for (int i = 0; i < length (); i++) - r[i] = f (d[i]); + int nr = rows (); + int nc = cols (); + + Matrix retval (nr, nc); + + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + retval(i,j) = f (elem(i,j)); + + return retval; +} + +boolMatrix +ComplexMatrix::map (b_c_Mapper f) const +{ + int nr = rows (); + int nc = cols (); + + boolMatrix retval (nr, nc); + + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + retval(i,j) = f (elem(i,j)); return retval; }