Re: [eigen] matrix / scalar

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


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.

thanks


On Dec 4, 2010, at 1:05 AM, Thomas Capricelli wrote:

erm... have you read the tutorial ?

depending on the version of eigen you use:
http://eigen.tuxfamily.org/dox/TutorialCore.html
or

greetings,
Thomas

--
Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>

On Saturday 04 December 2010 06:51:55 Andy Somogyi wrote:
> Hey Guys,
>
> what do you think about adding some operators to ease operating on a matrix with a scalar, i.e. what I'm thinking about is something like:
>
> MatrixXi mat = ...;
>
> // set all matrix values to scalar
> mat = 1;
>
> // add scalar to all matrix values
> mat = mat + 1; // or optionally
> mat += 1;
>
>



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