forum.alglib.net
http://forum.alglib.net/

Memory usage of rmatrixsolvels
http://forum.alglib.net/viewtopic.php?f=2&t=894
Page 1 of 1

Author:  maxter [ Wed Jul 24, 2013 7:17 pm ]
Post subject:  Memory usage of rmatrixsolvels

Hello Sergey,
I am trying to use rmatrixsolvels to solve a system of linear equation. I can get it to work fine, but sometimes I need to input matrixes with thousand of elements.
For exemple, a typical call would be (using C#):
rmatrixsolvels(a, 2, 9000, b, 0.0, out info, out rep, out x);
with "b" a vector of length 2 and "a" a matrix of dimension[2,9000];

Such call use a lot of memory (over 1.3 go). Is there any way to limit memory usage? Or is there another similar function I could use to do the same job?

thank you

Author:  Sergey.Bochkanov [ Mon Jul 29, 2013 1:29 pm ]
Post subject:  Re: Memory usage of rmatrixsolvels

Hello!

The reason behind such large memory consumption is that ALGLIB allocates 9000x9000 array for Rep.CX field, where nullspace(A) is stored.

Memory impact is insignificant when function is used in most traditional way (more rows than variables), so this field is always allocated. However, your use case is unusual because you have much more variables than rows. If you want, you may try to solve this issue as follows:
* comment out all rows in rmatrixsolvels() which initialize Rep.CX
* replace rmatrixsvd(a, nrows, ncols, 1, 2, 2, sv, u, vt) in rmatrixsolvels() by rmatrixsvd(a, nrows, ncols, 1, 1, 1, sv, u, vt)

I have not tested these modifications, but they should work. In case I forgot something, your program should crash with violation of array bounds, so you won't miss it :)

P.S. I added notice to implement compact version of SolveLS(), but it will be done in 3.9.0, because 3.8.0 is in the feature freeze mode (will be released within days from now).

Author:  maxter [ Mon Jul 29, 2013 1:41 pm ]
Post subject:  Re: Memory usage of rmatrixsolvels

Thank you very much for your support!

Author:  snowflake [ Thu Aug 15, 2013 10:41 am ]
Post subject:  Re: Memory usage of rmatrixsolvels

But the 9000x9000 matrix is always present, or am i wrong ?

if i use it traditional with 9000 points in 2 dimensions, the left singular matrix u should be 9000x9000 if calculated wholly and for 2 points in 9000 dimensions the right singular matrix v is of that size.

With uneeded and vtneeded = 1, the output matrices should be rectangular

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/