Re: [Lapackpp-devel] Matrix Multiplication to return only diagonal?
Status: Beta
Brought to you by:
cstim
|
From: Christian S. <sti...@tu...> - 2004-09-03 09:15:12
|
Dear Jack, I have searched through all of the available BLAS documentation but I did not find any such routine. You could write one by yourself that will calculate the dot product between all rows of the left and columns of the right matrix: // calculate only the diagonal of A times B int msize = std::min(A.size(0), B.size(1)); LaGenVectorDouble result(msize); assert(A.size(1) == B.size(0)); for (int i=0; i < msize; i++) result(i) = Blas_Dot_Prod(A(LaIndex(i), LaIndex(0,A.size(1)), B(LaIndex(0,B.size(0)), LaIndex(i))); As always, you would need to check whether this code really does the right thing. I'm always unsure whether I got the indices right and I don't confuse the "beginning with 0" or the last index. Christian Jacob (Jack) Gryn schrieb: > Hi, > > > > I was wondering if you know of any functions that will do a matrix > multiplication only to obtain the diagonal of the resulting > multiplication (that avoids the excess computations and temporary space > needed)? > > > > Jack > |