Mercurial > hg > octave-lojdl
changeset 8308:5fe0f4dfdbec
use std::vector as a simple linear container in oct-norm.cc to avoid problems with instantiating Array<T>
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 09 Nov 2008 12:59:42 +0100 |
parents | ec969f3b8955 |
children | 05b7a8ffec65 |
files | liboctave/ChangeLog liboctave/oct-norm.cc |
diffstat | 2 files changed, 20 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,13 @@ +2008-11-09 Jaroslav Hajek <highegg@gmail.com> + + * oct-norm.cc: Don't include Array.cc. + (column_norms (const MArray2<T>&, ...)): Use std::vector instead of Array<T> for + accumulator containers. Use empty constructor instead of + Array<T>::resize. + (row_norms (const MArray2<T>&, ...)): Dtto. + (column_norms (const MSparse2<T>&, ...)): Dtto. + (row_norms (const MSparse2<T>&, ...)): Dtto. + 2008-10-31 Jaroslav Hajek <highegg@gmail.com> * oct-norm.h: New header file.
--- a/liboctave/oct-norm.cc +++ b/liboctave/oct-norm.cc @@ -31,12 +31,12 @@ #include <cmath> #include <iostream> +#include <vector> #include "oct-cmplx.h" #include "lo-error.h" #include "lo-ieee.h" #include "Array.h" -#include "Array.cc" #include "Array-util.h" #include "CMatrix.h" #include "dMatrix.h" @@ -224,7 +224,7 @@ template <class T, class R, class ACC> void column_norms (const MArray2<T>& m, MArray<R>& res, ACC acc) { - res.resize (m.columns ()); + res = MArray2<R> (1, m.columns ()); for (octave_idx_type j = 0; j < m.columns (); j++) { ACC accj = acc; @@ -238,23 +238,23 @@ template <class T, class R, class ACC> void row_norms (const MArray2<T>& m, MArray<R>& res, ACC acc) { - res.resize (m.rows ()); - Array<ACC> acci (m.rows (), acc); + res = MArray2<R> (m.rows (), 1); + std::vector<ACC> acci (m.rows (), acc); for (octave_idx_type j = 0; j < m.columns (); j++) { for (octave_idx_type i = 0; i < m.rows (); i++) - acci.xelem (i).accum (m(i, j)); + acci[i].accum (m(i, j)); } for (octave_idx_type i = 0; i < m.rows (); i++) - res.xelem (i) = acci(i); + res.xelem (i) = acci[i]; } // sparse versions template <class T, class R, class ACC> void column_norms (const MSparse<T>& m, MArray<R>& res, ACC acc) { - res.resize (m.columns ()); + res = MArray2<R> (1, m.columns ()); for (octave_idx_type j = 0; j < m.columns (); j++) { ACC accj = acc; @@ -268,12 +268,12 @@ template <class T, class R, class ACC> void row_norms (const MSparse<T>& m, MArray<R>& res, ACC acc) { - res.resize (m.rows ()); - Array<ACC> acci (m.rows (), acc); + res = MArray2<R> (m.rows (), 1); + std::vector<ACC> acci (m.rows (), acc); for (octave_idx_type j = 0; j < m.columns (); j++) { for (octave_idx_type k = m.cidx (j); k < m.cidx (j+1); k++) - acci(m.ridx (k)).accum (m.data (k)); + acci[m.ridx (k)].accum (m.data (k)); } for (octave_idx_type i = 0; i < m.rows (); i++)