diff liboctave/dMatrix.cc @ 2676:a5a300c61159

[project @ 1997-02-14 03:16:06 by jwe]
author jwe
date Fri, 14 Feb 1997 03:16:12 +0000
parents 3723512a827a
children 14d07e4a0265
line wrap: on
line diff
--- a/liboctave/dMatrix.cc	Thu Feb 13 22:36:26 1997 +0000
+++ b/liboctave/dMatrix.cc	Fri Feb 14 03:16:12 1997 +0000
@@ -1841,32 +1841,21 @@
 // other operations.
 
 Matrix
-map (d_d_Mapper f, const Matrix& a)
-{
-  Matrix b (a);
-  b.map (f);
-  return b;
-}
-
-Matrix
-map (d_c_Mapper f, const ComplexMatrix& a)
+Matrix::map (d_d_Mapper f) const
 {
-  int a_nc = a.cols ();
-  int a_nr = a.rows ();
-  Matrix b (a_nr, a_nc);
-  for (int j = 0; j < a_nc; j++)
-    for (int i = 0; i < a_nr; i++)
-      b.elem (i, j) = f (a.elem (i, j));
-  return b;
+  Matrix b (*this);
+  return b.apply (f);
 }
 
-void
-Matrix::map (d_d_Mapper f)
+Matrix&
+Matrix::apply (d_d_Mapper f)
 {
   double *d = fortran_vec (); // Ensures only one reference to my privates!
 
   for (int i = 0; i < length (); i++)
     d[i] = f (d[i]);
+
+  return *this;
 }
 
 bool