changeset 1561:ffee86c37931

[project @ 1995-10-12 08:08:25 by jwe]
author jwe
date Thu, 12 Oct 1995 08:12:14 +0000
parents 27a03373de41
children 1cff14ab83a4
files liboctave/Array-idx.h liboctave/Array.cc liboctave/Array.h liboctave/CMatrix.cc liboctave/dMatrix.cc
diffstat 5 files changed, 27 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array-idx.h	Thu Oct 12 07:24:52 1995 +0000
+++ b/liboctave/Array-idx.h	Thu Oct 12 08:12:14 1995 +0000
@@ -536,13 +536,15 @@
 		}
 	      else if (rhs_nr == 1 && rhs_nc == 1)
 		{
+		  RT scalar = rhs.elem (0, 0);
+
 		  for (int j = 0; j < m; j++)
 		    {
 		      int jj = idx_j.elem (j);
 		      for (int i = 0; i < n; i++)
 			{
 			  int ii = idx_i.elem (i);
-			  lhs.elem (ii, jj) = rhs.elem (0, 0);
+			  lhs.elem (ii, jj) = scalar;
 			}
 		    }
 		}
--- a/liboctave/Array.cc	Thu Oct 12 07:24:52 1995 +0000
+++ b/liboctave/Array.cc	Thu Oct 12 08:12:14 1995 +0000
@@ -395,6 +395,26 @@
     delete old_rep;
 }
 
+template <class T>
+Array2<T>&
+Array2<T>::insert (const Array2<T>& a, int r, int c)
+{
+  int a_rows = a.rows ();
+  int a_cols = a.cols ();
+  if (r < 0 || r + a_rows - 1 > rows ()
+      || c < 0 || c + a_cols - 1 > cols ())
+    {
+      (*current_liboctave_error_handler) ("range error for insert");
+      return *this;
+    }
+
+  for (int j = 0; j < a_cols; j++)
+    for (int i = 0; i < a_rows; i++)
+      elem (r+i, c+j) = a.elem (i, j);
+
+  return *this;
+}
+
 // Three dimensional array class.
 
 template <class T>
--- a/liboctave/Array.h	Thu Oct 12 07:24:52 1995 +0000
+++ b/liboctave/Array.h	Thu Oct 12 08:12:14 1995 +0000
@@ -330,6 +330,8 @@
   void resize (int n, int m);
   void resize (int n, int m, const T& val);
 
+  Array2<T>& insert (const Array2<T>& a, int r, int c);
+
 #ifdef HEAVYWEIGHT_INDEXING
   void maybe_delete_elements (idx_vector& i, idx_vector& j);
 
--- a/liboctave/CMatrix.cc	Thu Oct 12 07:24:52 1995 +0000
+++ b/liboctave/CMatrix.cc	Thu Oct 12 08:12:14 1995 +0000
@@ -191,18 +191,7 @@
 ComplexMatrix&
 ComplexMatrix::insert (const ComplexMatrix& a, int r, int c)
 {
-  int a_nr = a.rows ();
-  int a_nc = a.cols ();
-  if (r < 0 || r + a_nr - 1 > rows () || c < 0 || c + a_nc - 1 > cols ())
-    {
-      (*current_liboctave_error_handler) ("range error for insert");
-      return *this;
-    }
-
-  for (int j = 0; j < a_nc; j++)
-    for (int i = 0; i < a_nr; i++)
-      elem (r+i, c+j) = a.elem (i, j);
-
+  Array2<Complex>::insert (a, r, c);
   return *this;
 }
 
--- a/liboctave/dMatrix.cc	Thu Oct 12 07:24:52 1995 +0000
+++ b/liboctave/dMatrix.cc	Thu Oct 12 08:12:14 1995 +0000
@@ -111,19 +111,7 @@
 Matrix&
 Matrix::insert (const Matrix& a, int r, int c)
 {
-  int a_rows = a.rows ();
-  int a_cols = a.cols ();
-  if (r < 0 || r + a_rows - 1 > rows ()
-      || c < 0 || c + a_cols - 1 > cols ())
-    {
-      (*current_liboctave_error_handler) ("range error for insert");
-      return *this;
-    }
-
-  for (int j = 0; j < a_cols; j++)
-    for (int i = 0; i < a_rows; i++)
-      elem (r+i, c+j) = a.elem (i, j);
-
+  Array2<double>::insert (a, r, c);
   return *this;
 }