better to have a sparse matrix in that case of the highest size.
By the way, ff you keep bound checkings on in ublas, you will have an exception raised at runtime while adding 2 matrices of different size like this:

    //symmetric_matrix<double,lower> m1 (2,2), m2(3,0);
    matrix<double> m1 (2,2,2), m2(3,3,0);

    cout << m1 << endl;
    cout << m2 << endl;
    cout << m1+m2 << endl;


you get :

Check failed in file /usr/local/include/boost/numeric/ublas/matrix_expression.hpp at line 1712:
size1 == size2
terminate called after throwing an instance of 'boost::numeric::ublas::bad_argument'
what():  bad argument
Aborted


I know bound checkings can be time consuming but they are helpful while debugging.
you can play with NDEBUG and BOOST_UBLAS_CHECK_ENABLE to configure this: check http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS for more information.

Cheers,
David




On Wed, Jun 16, 2010 at 09:43, Kraus Philipp <philipp.kraus@flashpixx.de> wrote:
Hi David, thanks for the fast answer.

Am 16.06.2010 um 09:34 schrieb David Bellot:

better to give the same size to x and y, filling x with extra zeros.

I can't do this, because I need a "grow up" for my matrix. I have a symmetric matrix with NxN
elements and in a next step the matrix must grow up to (N+1)x(N+1)

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 :-)

That's only a test and my elements of x and y aren't be zero in reality

_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: david.bellot@gmail.com



--
David Bellot, PhD
david.bellot@gmail.com
http://david.bellot.free.fr