Mercurial > hg > octave-lojdl
changeset 10713:0e05ed9f2a62
improve some MatrixType code
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 17 Jun 2010 08:44:39 +0200 |
parents | 6a5a0c9df5d7 |
children | 600bdfb08540 |
files | liboctave/ChangeLog liboctave/MatrixType.cc |
diffstat | 2 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2010-06-17 Jaroslav Hajek <highegg@gmail.com> + + * MatrixType.cc (matrix_real_probe): Use OCTAVE_LOCAL_BUFFER for + temporary array. + (matrix_complex_probe): Parametrize by real type. Use + OCTAVE_LOCAL_BUFFER for temporary array. + 2010-06-16 Rik <octave@nomad.inbox5.com> * DASSL-opts.in: Periodic grammar check on documentation.
--- a/liboctave/MatrixType.cc +++ b/liboctave/MatrixType.cc @@ -74,7 +74,7 @@ bool hermitian = true; // do the checks for lower/upper/hermitian all in one pass. - ColumnVector diag(ncols); + OCTAVE_LOCAL_BUFFER(T, diag, ncols); for (octave_idx_type j = 0; j < ncols && upper; j++) @@ -83,7 +83,7 @@ upper = upper && (d != zero); lower = lower && (d != zero); hermitian = hermitian && (d > zero); - diag(j) = d; + diag[j] = d; } for (octave_idx_type j = 0; @@ -95,7 +95,7 @@ lower = lower && (aij == zero); upper = upper && (aji == zero); hermitian = hermitian && (aij == aji - && aij*aij < diag(i)*diag(j)); + && aij*aij < diag[i]*diag[j]); } } @@ -116,13 +116,14 @@ template<class T> MatrixType::matrix_type -matrix_complex_probe (const MArray<T>& a) +matrix_complex_probe (const MArray<std::complex<T> >& a) { MatrixType::matrix_type typ; octave_idx_type nrows = a.rows (); octave_idx_type ncols = a.cols (); - const typename T::value_type zero = 0; + const T zero = 0; + // get the real type if (ncols == nrows) { @@ -131,16 +132,16 @@ bool hermitian = true; // do the checks for lower/upper/hermitian all in one pass. - ColumnVector diag(ncols); + OCTAVE_LOCAL_BUFFER(T, diag, ncols); for (octave_idx_type j = 0; j < ncols && upper; j++) { - T d = a.elem (j,j); + std::complex<T> d = a.elem (j,j); upper = upper && (d != zero); lower = lower && (d != zero); hermitian = hermitian && (d.real() > zero && d.imag() == zero); - diag (j) = d.real(); + diag[j] = d.real(); } for (octave_idx_type j = 0; @@ -148,11 +149,11 @@ { for (octave_idx_type i = 0; i < j; i++) { - T aij = a.elem (i,j), aji = a.elem (j,i); + std::complex<T> aij = a.elem (i,j), aji = a.elem (j,i); lower = lower && (aij == zero); upper = upper && (aji == zero); hermitian = hermitian && (aij == std::conj (aji) - && std::norm (aij) < diag(i)*diag(j)); + && std::norm (aij) < diag[i]*diag[j]); } }