Boost logo

Ublas :

From: Peter Schmitteckert (peter_at_[hidden])
Date: 2007-09-25 03:00:13


Dear Georg,

Georg Baum wrote:

>>> for (unsigned i = 0; i < 4; ++i)
>>>
>>> {
>>>
>>> ublas::matrix<double> um(n1, n2);
>>>
>>> um.clear();
>>>
>>> outputVec.push_back(um);
>>>
>>> }
>
> is uneeded, one would get the same result with the single statement
>
> std::vector< ublas::matrix<double> > outputVec(4);

Well, there is no guarantee that a matrix gets initialized to zero.
(Or is a guarantee introduced recently?)

However

std::vector< ublas::matrix<double> > outputVec;

ublas::matrix<double> um(n1, n2);
um.clear();

for (unsigned i = 0; i < 4; ++i)
   outputVec.push_back(um);

should work, due to copying in the constructor.

Best wishes,
Peter

-- 
--------------------------------------------------------------------------------------------
Dr. Peter Schmitteckert                                 Center for Functional Nanostructures
Institut für Theorie der Kondensierten Materie          Karlsruhe Institute of Technology
Universität Karlsruhe
Wolfgang-Gaede Str. 1
D-76128 Karlsruhe