Umut,
take a look at the assignment operator:

http://svn.boost.org/svn/boost/trunk/libs/numeric/ublas/doc/samples/assignment_examples.cpp
http://svn.boost.org/svn/boost/trunk/libs/numeric/ublas/test/test_assignment.cpp

There are a lot of options of assigning to matrices with scalars, vectors, or choosing the way sparse matrices are filled. The default behavior though will do what you normally expect.

In general you can do things like:
matrix<double> A(3,3);
A <<= 0, 1, 2,
     3, 4, 5,
     6, 7, 8;
or like:
A <<= 0, 1, 2,
     3, 4, 5,
     a;
(with "a" a 3-vector).

I wanted to write some documentation but I think the examples and tests expose almost all the features of the assignment functionality.

You should be aware though that this is not an initialization but an assignment.

Best,
Nasos

On Mar 29, 2011, at 6:46 PM, Oscar Vargas wrote:

It's the first time I use uBLAS, and I want to know the right way to initialize a matrix.

Example:
        | 3      2|
M =  | 1     5|
        | 3      4|

How can I create such a matrix?

For example, in Matlab, you can type:
>> M = [3, 2; 1, 5; 3, 4]

I haven't found documentation for something as simple as that!!! I need help!
_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: athanasios.iliopoulos.ctr.gr@nrl.navy.mil