M
Matt Jackson
I'm trying to write a program to map the contents of compressed row
storage back to the original indices. What I envision is some program
that given F(i,j) will return the correct column entry for a give row i..
Consider this example:
int c[]={0,10,31,512,12521};
I would like to somehow point to this data by defining a double pointer:
int **b;
b=new int*[num_of_rows];
Then let each b represent a row...
finally have the various entries point to the real array data:
b[0][0]=c[0];
b[0][10]=c[1];
b[0][31]=c[2];
b[0][512]=c[3];
b[0][12521]=c[4];
thus storing only the values I need, rather than wasting enormous amount
of space by creating a 2d int array filled 95%+ with zeros.
Is this even possible? I've tried the following unsuccessfully, which
ironically compiles fine with the g++ but segfaults immediately...
#include <iostream>
using namespace std;
int main(){
int **A;
int *b;
b=new int[4];
b[0]=0;
b[1]=2;
b[2]=6;
b[3]=25;
int g=2;
A=new int* [25];//assume there are 25 rows...
A[0][0]=b[0];
A[0][2]=b[1];
A[0][6]=b[2];
A[0][25]=b[3];
int d=A[0][3]*2;
cout<<d;
}
Thanks for your help!
Matt
storage back to the original indices. What I envision is some program
that given F(i,j) will return the correct column entry for a give row i..
Consider this example:
int c[]={0,10,31,512,12521};
I would like to somehow point to this data by defining a double pointer:
int **b;
b=new int*[num_of_rows];
Then let each b represent a row...
finally have the various entries point to the real array data:
b[0][0]=c[0];
b[0][10]=c[1];
b[0][31]=c[2];
b[0][512]=c[3];
b[0][12521]=c[4];
thus storing only the values I need, rather than wasting enormous amount
of space by creating a 2d int array filled 95%+ with zeros.
Is this even possible? I've tried the following unsuccessfully, which
ironically compiles fine with the g++ but segfaults immediately...
#include <iostream>
using namespace std;
int main(){
int **A;
int *b;
b=new int[4];
b[0]=0;
b[1]=2;
b[2]=6;
b[3]=25;
int g=2;
A=new int* [25];//assume there are 25 rows...
A[0][0]=b[0];
A[0][2]=b[1];
A[0][6]=b[2];
A[0][25]=b[3];
int d=A[0][3]*2;
cout<<d;
}
Thanks for your help!
Matt