diff liboctave/MatrixType.cc @ 10713:0e05ed9f2a62

improve some MatrixType code
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 17 Jun 2010 08:44:39 +0200
parents 4d1fc073fbb7
children 331fcc41ca23
line wrap: on
line diff
--- a/liboctave/MatrixType.cc	Wed Jun 16 21:19:23 2010 -0700
+++ b/liboctave/MatrixType.cc	Thu Jun 17 08:44:39 2010 +0200
@@ -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]);
             }
         }