 # Ublas :

Subject: Re: [ublas] different size for matrix addition
From: David Bellot (david.bellot_at_[hidden])
Date: 2010-06-16 03:34:57

better to give the same size to x and y, filling x with extra zeros.
here z takes the size of y but is filled with wrong indices due to x having
a smaller size.

By the way, I have never been so confortable with the idea of assuming zeros
when adding 2 matrices of different sizes :-)

On Wed, Jun 16, 2010 at 09:29, Kraus Philipp <philipp.kraus_at_[hidden]>wrote:

> Hi,
>
> I have written this short code:
> blas::matrix<int> x(2, 2, 2);
> blas::matrix<int> y(3, 3, 0);
>
>
> blas::matrix<int> z = y+x;
> std::cout << y << std::endl;
> std::cout << x << std::endl;
> std::cout << z << std::endl;
>
> with this output
> [3,3]((0,0,0),(0,0,0),(0,0,0))
> [2,2]((2,2),(2,2))
> [3,3]((2,2,2),(2,2,0),(0,0,0))
>
> on my mathematical thinking my z (third output) should be:
> [3,3]((2,2,0),(2,2,0),(0,0,0))
>
> Do I misunderstood the + operation?
>
> Thanks
>
> Phil
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]

> Sent to: david.bellot_at_[hidden]
>

```--
David Bellot, PhD
david.bellot_at_[hidden]
http://david.bellot.free.fr
```