 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
mediratta@gmail.com Guest
|
Posted: Fri May 11, 2007 9:12 am Post subject: large and sparse matrices |
|
|
Hi,
I want to allocate memory for a large matrix, whose size will be
around 2.5 million x 17000. Three fourth of its rows will have all
zeroes, but it is not known which will be those rows. If I try to
allocate memory for this huge array, then I get a segmentation fault
saying:
Program received signal SIGSEGV, Segmentation fault.
0xb7dd5226 in mallopt () from /lib/tls/i686/cmov/libc.so.6
I have not given any compiler options. I think that the error is
because I am allocating too big a size ?
Can anyone please, suggest me how to store/manage such a matrix in C/C+
+ ? Can mmap be useful ?
I am using linux on i386 with gcc (GCC) 4.1.2 20060928 (prerelease)
(Ubuntu 4.1.1-13ubuntu5)
thanks
anupam |
|
| Back to top |
|
 |
jacob navia Guest
|
Posted: Fri May 11, 2007 9:12 am Post subject: Re: large and sparse matrices |
|
|
mediratta (AT) gmail (DOT) com a écrit :
| Quote: | Hi,
I want to allocate memory for a large matrix, whose size will be
around 2.5 million x 17000. Three fourth of its rows will have all
zeroes, but it is not known which will be those rows. If I try to
allocate memory for this huge array, then I get a segmentation fault
saying:
Program received signal SIGSEGV, Segmentation fault.
0xb7dd5226 in mallopt () from /lib/tls/i686/cmov/libc.so.6
I have not given any compiler options. I think that the error is
because I am allocating too big a size ?
Can anyone please, suggest me how to store/manage such a matrix in C/C+
+ ? Can mmap be useful ?
I am using linux on i386 with gcc (GCC) 4.1.2 20060928 (prerelease)
(Ubuntu 4.1.1-13ubuntu5)
thanks
anupam
|
You want memory of 2 500 000 * 17 000 * sizeof(double). This is
340 000 000 000 bytes, around 316.6 GB.
Even if you do not use double but just a char for your data you need
more than 42 GB.
There are several alternatives. For instance,
typedef struct matRow {
int index; // 0 to 2 500 000
struct matRow *NextRow; // Pointer to next row
double data[17000];
} MATROW;
Then, you store just the rows with some data in it. When you
want to index the matrix, if the row is not in the list of rows
the dta is zero. Of course this is naive and very inefficient.
This is just the idea. To see more advanced sparse matrix software
google for "sparse matrix implementation" or similar. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|