Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to compute matmul(transpose(A),A)? #375

Open
Beliavsky opened this issue Apr 4, 2021 · 1 comment
Open

Function to compute matmul(transpose(A),A)? #375

Beliavsky opened this issue Apr 4, 2021 · 1 comment
Labels
topic: mathematics linear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ...

Comments

@Beliavsky
Copy link

Beliavsky commented Apr 4, 2021

Stdlib has corr and cov functions that compute the correlation and covariance matrices of the columns of an array. Computing the correlation matrix of the columns of array A, assuming that the elements of each column have been shifted by the column mean, involves calculating

matmul(transpose(A),A)

Could this be added as a function? If this can be computed efficiently, the programmer can calculate the correlation matrix using computed or a priori means and variances, as I described in Give stats functions optional mean arguments?

BLAS does have dgemm to multiply matrices, either of which may be transposed, but does it optimize the special but common case that the two matrices are the same?

@ivan-pi
Copy link
Member

ivan-pi commented Apr 5, 2021

I just tested this with the Linnea tool, which recommends two algorithms:

  • Algorithm 1: use the BLAS level 3 routine dsyrk to calculate one half of the resulting symmetric matrix, then copy the other half
  • Algorithm 2: use the BLAS level 3 routine dgemm

Unfortunately, the tool only supports Julia output.

@awvwgk awvwgk added the topic: mathematics linear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ... label Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: mathematics linear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ...
Projects
None yet
Development

No branches or pull requests

3 participants