Boost logo

Ublas :

From: Dima Sorkin (dsorkin_at_[hidden])
Date: 2006-03-07 02:57:07


Quoting Alion Sci :
> Question 2: How do I use a "complex" matrix?
> If I make a 3x3 matrix and fill it with values it looks like this:
> //matrix 1
> [3,3]((0,1,2),(3,4,5),(6,7,8))
>
> However if I make a complex 3x3 matrix and fill it with values it looks like
> this:
> //matrix 2
> [3,3](((0,0),(1,0),(2,0)),((3,0),(4,0),(5,0)),((6,0),(7,0),(8,0)))
>
> In the second matrix each ( ) was replaced with ( , )
> So, here are my question: How do you assign a value to both elements and
> not just first one?

I think here your problem is more with C++ , than with uBLAS.
You just assign a complex value to the entry:

std::complex<double> z(1,2);
matrix2(1,1) = z;

It will assign both to real and imaginary parts.

Regards,
 Dima.