Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13002 > unrolled thread

Large SparseArray in Mathematica 9 and the predictive interface

Started byjmmv73@gmail.com
First post2012-12-31 01:49 +0000
Last post2013-01-03 02:14 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Large SparseArray in Mathematica 9 and the predictive interface jmmv73@gmail.com - 2012-12-31 01:49 +0000
    Re: Large SparseArray in Mathematica 9 and the predictive interface David Reiss <dbreiss@gmail.com> - 2013-01-01 00:45 +0000
    Re: Large SparseArray in Mathematica 9 and the predictive interface jmmv73@gmail.com - 2013-01-03 02:14 +0000

#13002 — Large SparseArray in Mathematica 9 and the predictive interface

Fromjmmv73@gmail.com
Date2012-12-31 01:49 +0000
SubjectLarge SparseArray in Mathematica 9 and the predictive interface
Message-ID<kbqqv6$7vv$1@smc.vnet.net>
Hi there,

I was generating a banded sparse array with the following code
in the new Mathematica 9.0:

gmat[K_, l_, m_] :=
  Module[{bandU, bandL, bandD, res},
   
   bandU = Table[l, {K - 1}];
   bandL = Table[m, {K - 1}];
   bandD = Table[-l - m, {K}];
   bandD[[1]] = -l;
   bandD[[K]] = -m;
   
   res = DiagonalMatrix[SparseArray[bandU], 1]
     + DiagonalMatrix[SparseArray[bandD]]
     + DiagonalMatrix[SparseArray[bandL], -1];
   
   Return[res];
   ];


then I used the function with the following parameters (without semicolon):


gmat[100, 0.8, 1]


...and everything was ok! a 100x100 sparse matrix was created and the
"predictive interface bar" appeared.

Nevertheless, when I typed (without semicolon): 


gmat[10000, 0.8, 1]


...everything went not so good, a 10000x10000 sparse matrix was created 
(what was ok), but the kernel went nuts with the memory use, some gigabytes 
for a small sparsearray (You can try with greater parameters, but starting
with K=5000 things go weird)

I think the problem has to do with the "predictive interface" that tries to
generate the normal form of the matrix, so it uses a lot of memory (and even
produces a kernel crash).

Has anyone had the same problem with SparseArray? or have any
explanation to what actually happens? or it is just me?

Many thanks in advance for any help or advice with this issue.

Regards,

 Jose M. Martinez
 Ph.D. Student
 Department of Electronic Engineering
 Universidad Tecnica Federico Santa Maria
 Valparaiso, Chile

[toc] | [next] | [standalone]


#13007

FromDavid Reiss <dbreiss@gmail.com>
Date2013-01-01 00:45 +0000
Message-ID<kbtbje$cpv$1@smc.vnet.net>
In reply to#13002
of course you should report this as a bug to Wolfram Support....
--David

On Dec 30, 8:49 pm, jmm...@gmail.com wrote:
> Hi there,
>
> I was generating a banded sparse array with the following code
> in the new Mathematica 9.0:
>
> gmat[K_, l_, m_] :=
>   Module[{bandU, bandL, bandD, res},
>
>    bandU = Table[l, {K - 1}];
>    bandL = Table[m, {K - 1}];
>    bandD = Table[-l - m, {K}];
>    bandD[[1]] = -l;
>    bandD[[K]] = -m;
>
>    res = DiagonalMatrix[SparseArray[bandU], 1]
>      + DiagonalMatrix[SparseArray[bandD]]
>      + DiagonalMatrix[SparseArray[bandL], -1];
>
>    Return[res];
>    ];
>
> then I used the function with the following parameters (without semicolon:
>
> gmat[100, 0.8, 1]
>
> ...and everything was ok! a 100x100 sparse matrix was created and the
> "predictive interface bar" appeared.
>
> Nevertheless, when I typed (without semicolon):
>
> gmat[10000, 0.8, 1]
>
> ...everything went not so good, a 10000x10000 sparse matrix was created
> (what was ok), but the kernel went nuts with the memory use, some gigabytes
> for a small sparsearray (You can try with greater parameters, but starting
> with K=5000 things go weird)
>
> I think the problem has to do with the "predictive interface" that tries to
> generate the normal form of the matrix, so it uses a lot of memory (and even
> produces a kernel crash).
>
> Has anyone had the same problem with SparseArray? or have any
> explanation to what actually happens? or it is just me?
>
> Many thanks in advance for any help or advice with this issue.
>
> Regards,
>
>  Jose M. Martinez
>  Ph.D. Student
>  Department of Electronic Engineering
>  Universidad Tecnica Federico Santa Maria
>  Valparaiso, Chile

[toc] | [prev] | [next] | [standalone]


#13020

Fromjmmv73@gmail.com
Date2013-01-03 02:14 +0000
Message-ID<kc2phi$md3$1@smc.vnet.net>
In reply to#13002
Hi again,

You could even try the following (which is not a big sparse array):


DiagonalMatrix[SparseArray@Table[1.0, {100000}]]


...(without the semicolon and the "Suggestion bar" activated) and 
the kernel will crash.
But, if you deactivate the "Suggestion Bar" everything goes smoothly.

I use to monitor the processes and memory by using the Sysinternals suite, 
and in particular, the "process explorer" that comes with it.

My machine is a 4Gb Windows 7 Pro notebook with an Intel i5.

many thanks for the several answers given,
regards,

  Jose M. Martinez
  Ph.D. Student
  Department of Electronic Engineering
  Universidad Tecnica Federico Santa Maria
  Valparaiso, Chile

On Sunday, December 30, 2012 10:49:26 PM UTC-3, jmm...@gmail.com wrote:
> Hi there,
> 
> 
> I was generating a banded sparse array with the following code
> in the new Mathematica 9.0:
> 
> 
> gmat[K_, l_, m_] :=
>   Module[{bandU, bandL, bandD, res},
> 
>    bandU = Table[l, {K - 1}];
>    bandL = Table[m, {K - 1}];
>    bandD = Table[-l - m, {K}];
>    bandD[[1]] = -l;
>    bandD[[K]] = -m;
> 
>    res = DiagonalMatrix[SparseArray[bandU], 1]
>      + DiagonalMatrix[SparseArray[bandD]]
>      + DiagonalMatrix[SparseArray[bandL], -1];
 
>    Return[res];
>    ];
> 
> 
> then I used the function with the following parameters (without semicolon):
> 
> gmat[100, 0.8, 1]
> 
> ...and everything was ok! a 100x100 sparse matrix was created and the
> "predictive interface bar" appeared.
>
> Nevertheless, when I typed (without semicolon): 
> 
> gmat[10000, 0.8, 1]
> 
> ...everything went not so good, a 10000x10000 sparse matrix was created 
> (what was ok), but the kernel went nuts with the memory use, some gigabytes 
> for a small sparsearray (You can try with greater parameters, but starting> 
> with K=5000 things go weird)
> 
> I think the problem has to do with the "predictive interface" that tries to
> generate the normal form of the matrix, so it uses a lot of memory (and even
> produces a kernel crash).
> 
> Has anyone had the same problem with SparseArray? or have any
> explanation to what actually happens? or it is just me?
> 
> Many thanks in advance for any help or advice with this issue.
> 
> Regards,
> 
>  Jose M. Martinez
>  Ph.D. Student
>  Department of Electronic Engineering
>  Universidad Tecnica Federico Santa Maria
>  Valparaiso, Chile

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web