Mercurial > hg > octave-nkf
diff liboctave/DiagArray2.cc @ 7789:82be108cc558
First attempt at single precision tyeps
* * *
corrections to qrupdate single precision routines
* * *
prefer demotion to single over promotion to double
* * *
Add single precision support to log2 function
* * *
Trivial PROJECT file update
* * *
Cache optimized hermitian/transpose methods
* * *
Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sun, 27 Apr 2008 22:34:17 +0200 |
parents | a1dbe9d80eee |
children | 8b1a2555c4e2 |
line wrap: on
line diff
--- a/liboctave/DiagArray2.cc +++ b/liboctave/DiagArray2.cc @@ -34,6 +34,27 @@ #include "lo-error.h" +template <class T> +DiagArray2<T> +DiagArray2<T>::transpose (void) const +{ + DiagArray2<T> retval (*this); + retval.dimensions = dim_vector (this->dim2 (), this->dim1 ()); + return retval; +} + +template <class T> +DiagArray2<T> +DiagArray2<T>::hermitian (T (* fcn) (const T&)) const +{ + DiagArray2<T> retval (this->dim2 (), this->dim1 ()); + const T *p = this->data (); + T *q = retval.fortran_vec (); + for (octave_idx_type i = 0; i < this->length (); i++) + q [i] = fcn (p [i]); + return retval; +} + // A two-dimensional array with diagonal elements only. template <class T>