Boost logo

Ublas :

From: Michael Lehn (michael.lehn_at_[hidden])
Date: 2007-07-17 15:25:43


Hi Vardan,

is that you? How are you doing? I hope you and your family are
doing fine!

I am still at the University of Ulm and hopefully I will finish my
PhD this year. As you know me I always waste my life with two
things: time consuming not bringing me towards my degree and women
making my life a pain. So nothing really change and I am really
fine (I don't like changes). Maybe you are interested to have a look
at a library I wrote (that's a completely new design and
implementation not comparable with any previous release of FLENS):

http://flens.sf.net

I really would be interested in your opinion. But don't bash me too
much. I know its not as mature as other libraries. And I did not
spend too much effort in documentation.

So I really hope this is the one an only Vardan I am writing to,

yours Michael

Am 17.07.2007 um 08:40 schrieb Vardan Akopian:

> On 7/11/07, Nico Galoppo <nico_at_[hidden]> wrote:
>> Hi,
>>
>> what is the best way to construct a diagonal matrix from a vector
>> (where the
>> vector should be the diagonal).
>>
>> I think I can use banded_matrix<> for diagonal matrices, but there
>> seems to be
>> no explicit constructors except for maybe assigning the vector to
>> a slice of the
>> banded_matrix<>? In this case, what are the performance implications?
>
> diagonal_matrix (which is in banded.hpp) has a constructor which takes
> the storage array as an argument. You could use that and copy the data
> from your vector into the diagonal matrix. E.g.
>
> vector<double> v; // your vector containing the diagonal elements
> diagonal_matrix<double> diagMatrix(v.size(), v.data());
>
> If you need to share the data between the vector and the diagonal
> matrix, that's also possible, but not very straightforward (nor safe).
> If you are careful with it (see
> http://lists.boost.org/MailArchives/ublas/2007/06/2162.php ), you can
> use the shallow_array_adaptor to represent the vector as a diagonal
> matrix. Do read the link above, and make sure that all the potential
> issues Gunter pointed out are ok in your application. If it's all ok,
> here is how you would do it:
>
> vector<double> v; // your vector containing the diagonal elements
> shallow_array_adaptor<double> share(v.size(), v.data().begin());
> diagonal_matrix<double, row_major, shallow_array_adaptor<double> >
> diagMatrix(v.size(), share);
>
> Note that this will only work for dense vectors.
>
> -Vardan
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas