Re: [eigen] How to resize a partially fixed matrix |

[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]

On 24 Jun, Gael Guennebaud wrote:
> On Wed, Jun 24, 2009 at 10:37 AM, Helmut
> Jarausch<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
>> Hi,
>>
>> I wonder how I can resize a matrix where one of the dimension is fixed,
>> like
>>
>> Matrix<double,4,Eigen::Dynamic> MS_BC;
>>
>> ....
>>
>> MS_BC.resize(5); // this fails
>
> yes it fails because resize(int size) is for vector only.
>
>> but this works
>> MS_BC.resize(4,5);
>> but it's not logical?
>
> well that depends. First of all it is very clear that
> MS_BC.resize(4,5) *must* work. Now about allowing resize(int size) to
> work on such matrices why not. I guess that the main use case for such
> matrices is to use a Matrix to store a collection of small vectors,
> and so the matrix can be seen as a std::vector, and so having
> resize(int size) working makes sense. On the other hand, in that case
> the parameter "size" will mean either the number of rows or the number
> of cols depending on the context that is not very nice. So there are
> pro and cons, but eventually I'm 51% ok to extend resize to partially
> dynamic matrices. or, we add an explicit partial_resize(int size)
> function ?
That'll be nice - thanks.
And please add to my personal wish list
namespace Eigen {
template<typename Derived>
std::istream & operator >>(std::istream & Inp, MatrixBase<Derived> & m) {
for (int i = 0; i < m.rows(); ++i)
for (int j = 0; j < m.cols(); j++)
Inp >> m(i,j);
return Inp;
}
}
My students need to input Vectors / Matrices in a simple way.
Helmut.
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany