Re: [eigen] matrix / scalar

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


On 04.12.2010 08:50, Andy Somogyi wrote:
> Hi. I was just thinking that it might be nicer to do
> MatrixXi mat = ...;
> mat = 5;
> 
> instead of
> 
> mat.setConstant(5);
> 
> and
> 
> mat += 5;
> 
> is nicer than
> 
> mat.array() += 5;
> 
> The matrix interface supports scalar multiply but not scalar add/sub. To get scalar add/sub, I have to pull out the array class. 
> 
> No big deal either way, just thought it would be nicer syntax.

I'm against that, because if it was implemented I'd expect + and * to be
somewhat distributive, i.e.,
  MatrixXd A, B;
  double s;
  (A + s) * B == A*B + s*B;

That means for matrices I would prefer A + d == A + d*eye(), but as this
might be confusing I rather prefer not to have Matrix + scalar
implemented at all. (Just my 0.02€ ...)

If you need this a lot, why not use Array in the first place?

Christoph

-- 
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: (+49) 421-218-64252
----------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/