changeset 1699:0c6d3b73bf69

[project @ 1996-01-07 02:36:50 by jwe]
author jwe
date Sun, 07 Jan 1996 02:40:17 +0000
parents 0892abda7553
children e4d94a757f01
files liboctave/CColVector.cc liboctave/CMatrix.cc liboctave/CRowVector.cc liboctave/dColVector.cc liboctave/dRowVector.cc
diffstat 5 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CColVector.cc	Sun Jan 07 02:31:40 1996 +0000
+++ b/liboctave/CColVector.cc	Sun Jan 07 02:40:17 1996 +0000
@@ -78,7 +78,7 @@
 ComplexColumnVector::insert (const ColumnVector& a, int r)
 {
   int a_len = a.length ();
-  if (r < 0 || r + a_len - 1 > length ())
+  if (r < 0 || r + a_len > length ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -94,7 +94,7 @@
 ComplexColumnVector::insert (const ComplexColumnVector& a, int r)
 {
   int a_len = a.length ();
-  if (r < 0 || r + a_len - 1 > length ())
+  if (r < 0 || r + a_len > length ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
--- a/liboctave/CMatrix.cc	Sun Jan 07 02:31:40 1996 +0000
+++ b/liboctave/CMatrix.cc	Sun Jan 07 02:40:17 1996 +0000
@@ -136,7 +136,8 @@
 {
   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 ())
+
+  if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -153,7 +154,7 @@
 ComplexMatrix::insert (const RowVector& a, int r, int c)
 {
   int a_len = a.length ();
-  if (r < 0 || r >= rows () || c < 0 || c + a_len - 1 > cols ())
+  if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -169,7 +170,7 @@
 ComplexMatrix::insert (const ColumnVector& a, int r, int c)
 {
   int a_len = a.length ();
-  if (r < 0 || r + a_len - 1 > rows () || c < 0 || c >= cols ())
+  if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -184,13 +185,17 @@
 ComplexMatrix&
 ComplexMatrix::insert (const DiagMatrix& a, int r, int c)
 {
-  if (r < 0 || r + a.rows () - 1 > rows ()
-      || c < 0 || c + a.cols () - 1 > cols ())
+  int a_nr = a.rows ();
+  int a_nc = a.cols ();
+
+  if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
     }
 
+  fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
+
   for (int i = 0; i < a.length (); i++)
     elem (r+i, c+i) = a.elem (i, i);
 
@@ -208,7 +213,7 @@
 ComplexMatrix::insert (const ComplexRowVector& a, int r, int c)
 {
   int a_len = a.length ();
-  if (r < 0 || r >= rows () || c < 0 || c + a_len - 1 > cols ())
+  if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -224,7 +229,7 @@
 ComplexMatrix::insert (const ComplexColumnVector& a, int r, int c)
 {
   int a_len = a.length ();
-  if (r < 0 || r + a_len - 1 > rows () || c < 0 || c >= cols ())
+  if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -239,13 +244,17 @@
 ComplexMatrix&
 ComplexMatrix::insert (const ComplexDiagMatrix& a, int r, int c)
 {
-  if (r < 0 || r + a.rows () - 1 > rows ()
-      || c < 0 || c + a.cols () - 1 > cols ())
+  int a_nr = a.rows ();
+  int a_nc = a.cols ();
+
+  if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
     }
 
+  fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
+
   for (int i = 0; i < a.length (); i++)
     elem (r+i, c+i) = a.elem (i, i);
 
--- a/liboctave/CRowVector.cc	Sun Jan 07 02:31:40 1996 +0000
+++ b/liboctave/CRowVector.cc	Sun Jan 07 02:40:17 1996 +0000
@@ -78,7 +78,7 @@
 ComplexRowVector::insert (const RowVector& a, int c)
 {
   int a_len = a.length ();
-  if (c < 0 || c + a_len - 1 > length ())
+  if (c < 0 || c + a_len > length ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -94,7 +94,7 @@
 ComplexRowVector::insert (const ComplexRowVector& a, int c)
 {
   int a_len = a.length ();
-  if (c < 0 || c + a_len - 1 > length ())
+  if (c < 0 || c + a_len > length ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
--- a/liboctave/dColVector.cc	Sun Jan 07 02:31:40 1996 +0000
+++ b/liboctave/dColVector.cc	Sun Jan 07 02:40:17 1996 +0000
@@ -69,7 +69,7 @@
 ColumnVector::insert (const ColumnVector& a, int r)
 {
   int a_len = a.length ();
-  if (r < 0 || r + a_len - 1 > length ())
+  if (r < 0 || r + a_len > length ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
--- a/liboctave/dRowVector.cc	Sun Jan 07 02:31:40 1996 +0000
+++ b/liboctave/dRowVector.cc	Sun Jan 07 02:40:17 1996 +0000
@@ -72,7 +72,7 @@
 RowVector::insert (const RowVector& a, int c)
 {
   int a_len = a.length ();
-  if (c < 0 || c + a_len - 1 > length ())
+  if (c < 0 || c + a_len > length ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;