6
$\begingroup$

My matrix sizes have grown beyond what can fit on the RAM but I have a function which defines each element cheaply.

Is it possible use BLAS (in Fortran or even in MATLAB) in such cases?

If I had a matrix in memory, I could use dgemv or dgemm or whatever and pass my matrix as one of the arguments. Now, I have no matrix. How do I tackle that?

I could write my own codes, but no matter what I do, I doubt my programming will be as thorough as the guys up at Intel MKL. There is simply too much to keep track of in such kind of programming.

EDIT: My matrix is dense. Almost full dense. I have a function in terms of indices $(i,j)$ and a $10^{6} \times 1$ vector. Like : $$f(i,j) = \frac{|a(i) + a(j)|}{(i-j)^2} $$

Also, I'm not saying I must use BLAS. I can use anything similar as long as it gets my job done. But as far as I know, there isn't any other library.

$\endgroup$
  • $\begingroup$ BLAS is designed for dense matrices with explicit entries; I do remember that there are a number of sparse libraries that allow for a rule-based specification of entries, but I don't have my notes with me at the moment... $\endgroup$ – J. M. Feb 3 '12 at 6:33
  • 2
    $\begingroup$ What do you want to do with this matrix? If you just want to multiply with a vector or another matrix, you should write that cod e yourself. If you want to factor the matrix, you will have to find the memory. If you want to solve systems or eigenvalue problems, you could use PETSc with MatShell. Depending on the problem, you might need a preconditioner. $\endgroup$ – Jed Brown Feb 3 '12 at 13:59
  • $\begingroup$ I want DGEMV. I think, I'll write my own code then. $\endgroup$ – Inquest Feb 3 '12 at 14:04
  • $\begingroup$ What will be the next step? Will you be able to hold the resulting vector in RAM as explicit entries? If not, I can see two options for what the result might look like: either as a function that can compute entries of the resulting product on demand (a lazy approach) or a function that writes results to disk. If the algorithm using your result reuses the same entries frequently, you could even construct a cache for entries requested frequently in the past. $\endgroup$ – Erik P. Feb 3 '12 at 18:10
  • 1
    $\begingroup$ @JedBrown, do you mind restating your comment as answer? I don't want it to be missed by the community. $\endgroup$ – Aron Ahmadia Feb 4 '12 at 19:33
4
$\begingroup$

What do you want to do with this matrix? If you just want to multiply with a vector or another matrix, you should write that code yourself. If you want to factor the matrix, you will have to find the memory to store it. If you want to solve systems or eigenvalue problems, you could use PETSc with MatShell. Depending on the problem, you might need a preconditioner (which you might also be able to implement without assembling, if you like).

$\endgroup$
4
$\begingroup$

In a word: No. The reason MKL and other optimized libraries are so good is they are optimized to balance calculation versus memory use (i.e. your matrix is fully stored in RAM explicitly). If your matrix is indeed so large my only real suggestion would be to block it out yourself so that each individual block fits, and use BLAS on the blocks sequentially (accumulating results as necessary in a block matrix-multiply).

Of course you could write your own routines like you mention. It might be faster programming wise.

$\endgroup$
0
$\begingroup$

Then consider trying to factor your matrix.

A famous example is the DFT (Discrete Fourier Transform) matrices which are dense, but if you factor them you can get a matrix representation for the FFT (Fast Fourier Transform) where each factor ideally has only 2 nonzero elements each row and there are only $\log(N)$ such matrices where $N$ is the data size.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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