# HG changeset patch # User jwe # Date 820982417 0 # Node ID 0c6d3b73bf69f17e363d2c5dba977578957aad11 # Parent 0892abda7553a8178fe53b679d8d96a0aac5fb86 [project @ 1996-01-07 02:36:50 by jwe] diff -r 0892abda7553 -r 0c6d3b73bf69 liboctave/CColVector.cc --- 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; diff -r 0892abda7553 -r 0c6d3b73bf69 liboctave/CMatrix.cc --- 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); diff -r 0892abda7553 -r 0c6d3b73bf69 liboctave/CRowVector.cc --- 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; diff -r 0892abda7553 -r 0c6d3b73bf69 liboctave/dColVector.cc --- 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; diff -r 0892abda7553 -r 0c6d3b73bf69 liboctave/dRowVector.cc --- 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;