![]() |
Blitz Support : |
From: Xavier WARIN(Compte LOCAL) - I23 (xavier.warin_at_[hidden])
Date: 2004-07-15 06:21:49
Hi Olivier,
Which compiler do you use ? on which OS? Which option do you use ?
An obvious problem : you always create a new objet D that you fill in
and then copy (return D) : that's very slow. You could perhaps create
your object outside the class and give a reference to it as an argument :
void product(const dipolarMatrix & A, const dipolarMatrix &B,
dipolarMatrix & D)
Another problem : you'd better write :
for(int i=0; i<5; ++i)
for(int j=0; j<5; ++j)
{
complex<double> x =0;
for(int p=0; p<5; ++p)
x +=A(i,p)*B(p,j);
D(i,j) = x ;
}
I would interested in knowing the improvement with my suggestions
Xavier
> Hello,
>
> in my program I use the type Array<TinyMatrix<complex<double>,5,5,2> to
> represent a density matrix. I access an element by (rho(y,z))(i,j)
> where 0<=i,j<=4. Given a couple (y,z), I do a lot of products
> TinyMatrix<complex<double>, 5,5> times TinyMatrix<complex<double>, 5,5>
> (==dipolarMatrix) using the method
>
> dipolarMatrix product(const dipolarMatrix & A, const dipolarMatrix &B) {
> dipolarMatrix D;
>
> for(int i=0; i<5; i++)
> for(int j=0; j<5; j++) {
> D(i,j)=0;
> for(int p=0; p<5; p++)
> D(i,j)+=A(i,p)*B(p,j);
> }
> return D;
> }
>
> I am a bit disappointed by the speed (compared to f90), is there any
> chance I could speed up my program by changing this type to
> Array<complex<double>,4>?
>
> Should I use the CVS version instead of 0.7?
>
> Thanks a lot,
> - Olivier
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>
>