MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Memory problems using mathlink (Sparse Matrix)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24252] Memory problems using mathlink (Sparse Matrix)
  • From: Martin Zacho <zac at mip.sdu.dk>
  • Date: Tue, 4 Jul 2000 15:22:13 -0400 (EDT)
  • Organization: UNI-C
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I'm doing some rather big matrixcomputations in C and would like to
solve the problem using mathematica. The (sparse) matrix is about 4
millions doubles and I'm using the following form:
    {{...},{{i,j}->A[i][j],...},{...}}

The relevant MathLink part of the program is as follows:

....do some rather long and booring calculations...
MLPutFunction(stdlink, "List", 2);
MLPutFunction(stdlink, "List", M);
for (j=0; j<M; j++) {
    MLPutFunction(stdlink, "List", no[j]);
    for (k=0; k<M; k++) {
        MLPutFunction(stdlink, "Rule", 2);
        MLPutFunction(stdlink, "List", 2);
        MLPutInteger(stdlink, j+1);
        MLPutInteger(stdlink, k+1);
        MLPutReal(stdlink, BigMatrix[i][j]);
    }
}
MLPutRealList(stdlink, y, M);
....clean up memory...

I'm also transfeering a small list of length M (approx. 8000 doubles).
The matrix is a MxM matrix with numbers in approx 7% of the cells.

The data structures occupies approx. 90MB in C but when they are
transfered to mathematica, MathKernel uses a _lot_ of memory (>500MB).
This causes 'my' machine to crash for some odd reason even though it has
8GB of RAM and 6GB of swap. The machine is a SUN running Solaris. The
kernel is version 4.0 release 2.

My problem:
    How can I reduce memory req. ?
    Am I doing anything wrong ?

Sincerely,
Martin Zacho



  • Prev by Date: RE: Building a Table with initially unknown length?
  • Next by Date: Re: Detecting and handling error messages?
  • Previous by thread: Re: Using Block instead of Module?
  • Next by thread: Re: Memory problems using mathlink (Sparse Matrix)