|
Ublas : |
Subject: Re: [ublas] Questions about prod(prod(A,B),C)
From: Peter Schmitteckert (peter_at_[hidden])
Date: 2008-11-26 15:13:00
Salut,
Chris Rodgers schrieb:
> Hi,
>
> I'm trying to get to grips with uBLAS.
>
> I attach a .cpp file that illustrates my problems with five quick
> questions inside.
>
> Can someone explain to me why some of the ways of doing matrix products
> are allowed and others are not?
// Question 1: Is there a neater syntax to set all elements of a matrix to zero?
A.clear(); // maybe not cneater, but shorter
// Question 2: Is there a better way to pretty-print a matrix for debugging?
You may wrtie your own manipulator, e.g. to get octave like syntax.
// Question 3: Is this syntax the "correct" way to call geev?
Sorry, I'm not using the bindings as I have my own, non-portable ones.
// Question 4: Why does this next line fail?
//std::cout << "vecs4 * A4 = " << prod<matrix<std::complex<double>, column_major>>(vecs4,A4) << std::endl;
std::cout << "vecs4 * A4 = " << prod<matrix<std::complex<double>, column_major>>(herm(vecs4),A4) << std::endl;
// Question 5: Why can I not do prod(prod(...)) like in this next line?
It fails on purpose, as it would be ~ dim^4, instead ~dim^3 plus a temporary matrix.
You have to specify the result type of the inner prod.
Best regads,
Peter
-- ---------------------------------------------------------------------------------- Dr. Peter Schmitteckert Institut für Nanotechnologie Forschungszentrum Karlsruhe Karlsruhe Institute of Technology Postfach 3640 D-76021 Karlsruhe Room : O-320 Phone: ++49 (0) 7247 82 3362