Boost logo

Ublas :

Subject: Re: [ublas] Questions about prod(prod(A,B),C)
From: Peter Schmitteckert (peter_at_[hidden])
Date: 2008-12-04 05:02:08

Dear Chris,

ublas_at_[hidden] schrieb:
> Thank you to Peter and Gunter for their replies.
> I have a couple of follow up questions if I may...
> Q1:
>> // 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.
> Yes, Matlab/octave-like output is what I am aiming for. Do you mean
> something like this the prettyprint(...) function that I have now
> written (see attached .cpp file)?

In principle yes, however, I'd write it using manipulators and standard ostreams,
or a simple function innhte spirit of

std::ostream& pretty_print( std::ostream & Out, const matrix_type& A) { ....; return Out; }

Mixing C stdio and C++ streams in a programme might be a bad idea, there could be a problem
of synchronization of non-flushed data, I'm not sure.

> Q2:
>> // 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;
>> what is the compiler output?
> I'm confused by this. I don't want to calculate vecs4^\dagger A4, but
> just the straight matrix product. Is that not possible??

Well, the sizes of the inner summation have to fit. Since a vector is a matrix
of type size() \times 1 you need to transpose it. Note, there is no memory moving involved
in this, it only tells the evaluation routine what it is supposed to do.

> Here is the compiler output:
Please excuse, I am refusing to look at Visual studio compiler output.
I've wasted too much time of my life doing this.

Best regards,