Disclaimer: I have not used AlgLib; I just understand what the documentation says. I would be glad if someone else had corrected me.
In any case, I'm afraid the answer seems like you need to use cmatrixgemm or rmatrixgemm (which depends on whether your matrices are real or complex), for example:
rmatrixgemm(m,n,k, 1, A,0,0,0, B,0,0,0, 0, C,0,0);
Where:
m , n , k - matrix sizes ( A - m by k , B - k by n , C is m by n )1 is that to multiply the product by (if you want, say, 3AB instead of AB, put 3 there)- groups
A,0,0,0 and B,0,0,0 are: matrix, row offset, column offset, type of operation- the type of operation is 0 to use A or B as is, 1 to use transpose and 2 to use a transponder pairing (of course, you cannot use 2 for
rmatrixgemm )
- the next
0 says add 0 * C to the result (if you put 0 here, then the initial values ββin C are completely ignored) - two
0 after C - row and column offset
Perhaps you might think that this level of generality is redundant, and that there should be a simpler function providing these default values. I would not agree with this, but as far as I can see, AlgLib does not have such a simpler function. You might want to write your own (which just calls rmatrixgemm or cmatrixgemm ).
(Why is there so much generality? Since effective matrix multiplication requires quite complex code, and it is essentially the same rather complicated code as for the more general operation C=af(A).g(B)+bC , which *matrixgemm does , and sometimes a larger general operation is useful.)
EDITED add some more comments that may be helpful.
- Offsets are that you can do something with sub-matrices. The ability to do this is useful in some numerical algorithms. I assume that
m , n , k are the sizes of the submatrices you use; in general, they will be the same as the sizes of your arrays, and the offsets will be zero. - When
rmatrixgemm or cmatrixgemm the arrays themselves must exist and be sized accordingly. At least A and B course; C is passed as ref , so it is possible that these functions will create it if it is null on entry. - You can think from the signature of
rmatrixgemm or cmatrixgemm that A and B get copy, while C is passed by reference, but if I'm not completely confused by the C # semantics, they are all effectively passed by reference (object).
source share