
Ublas : 
From: nate (nate_at_[hidden])
Date: 20070711 14:53:07
>
> what is the best way to construct a diagonal matrix from a vector (where the
> vector should be the diagonal).
>
Take a look here.
http://article.gmane.org/gmane.comp.lib.boost.ublas/3274
This is my initial attempt at a diagonal adaptor for vectors.
Since there aren't any special dispatch mechanisms for this type things are
probably going to be slower
than necessary. For example
ublas::matrix<double> A(4,4);
ublas::vector<double> B(4);
prod(A,diagm(B))
probably won't be as fast as just scaling each column. Maybe someone else can
say more about this.
As I said before, I'm no expert. There may already be a better way to do this
implemented in the
library.
Nate