Tell me more ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I currently searching for a subroutine from BLAS or LAPACK which realizes the following operation

A = alpha*A + beta * B

where A and B have different leading dimensions, i.e. A is stored as

 REAL*8 A(N,N)

and B is stored as

 REAL*B B(LDB,N)

with LDB > N.

Is there a way to use existing BLAS or LAPACK operation to compute this or must I create an own subroutine for this kind of problems?

share|improve this question
What does it mean to add two matrices with different dimensions? – hardmath Jul 10 '12 at 13:19
It is only the leading dimension, the means the length of a column in the Fortran storage format, i.e. the in memory distance between two elements of the same row – Grisu Jul 10 '12 at 13:40
I'm aware that Fortran stores 2D arrays in column major order. Wouldn't the question be clearer if A = alpha*A + beta * B were replaced by the nested do-loop that tells which expressions are to be added to assign A(I,J)? – hardmath Jul 10 '12 at 14:16
Replacing this by a nested do-loop or the quick-and-dirty Fortran-code which does the same job, does not help understanding the problem. The leading dimension problem can be handle by Fortran directly so the code does not point out the problem. Currently I use such a code but I'm interested if there is a efficient way using the standard linalg libraries. – Grisu Jul 10 '12 at 14:31
1  
I'm suggesting the nested do-loop not as a solution, but as a meaningful way to phrase the question. A = alpha*A + beta * B doesn't convey what you mean, though I'm sure the meaning is so clear in your mind you have difficulty seeing that it becomes a guessing game for me. – hardmath Jul 10 '12 at 15:19
show 1 more comment

1 Answer

The best you can do is to use the BLAS AXPY on each column, but that doesn't let you apply beta. You really might as well write your own since this is basically a level 1 or 2 BLAS operation, which for large matrices is memory bandwidth limited.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.