Mercurial > hg > octave-lyh
diff liboctave/Array.cc @ 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 | dd7d27461567 |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -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>