#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int i,j,n,c;
int col;
int *row_ind, *col_ind, *row_ptr;
double *val;
int main (void){
FILE *fin;
col = 51;
n = 75;
//double *val;
val
= (double*)malloc(sizeof(double)*(n
));
//static int *row_ind, *col_ind, *row_ptr;
row_ind
= (int *)malloc( sizeof( int ) * n
); col_ind
= (int *)malloc( sizeof( int ) * n
); row_ptr
= (int *)malloc( sizeof( int ) * n
);
fin
= fopen("test_mm.mtx" ,"r");
for( i = 1 ; i <= n ; i++)
{
fscanf(fin
, "%d %d %lg\n", &row_ind
[i
-1], &col_ind
[i
-1], &val
[i
-1]); }
//row_ptr取り込み
for(i=0;i<n;i++){
}
for(i=0;i<=col;i++){
printf("\nrow_ptr[%d] =%d",row_ptr
[i
],i
); }
return 0;
}
/*
test_mm.mtx
行 列 非零要素
1 1 1064685280.47
5 1 10097137.073
7 1 449885280.472
2 2 427728386.378
4 2 -4238867.37393
8 2 208101719.712
3 3 1.044e6
9 3 -1.044e6
4 4 642010.94971
5 4 -7.5453722119e-9
6 4 -139397.060211
7 4 4635264.30435
8 4 -4238867.37393
9 4 2914870.77518
10 4 -87659.3847246
12 4 139397.060211
13 4 4635264.30435
15 4 2914870.77518
46 4 -497833.333333
47 4 7.5453722119e-9
48 4 3.77272463354e-9
49 4 7.00812794124e-26
50 4 -4.98230079945e-11
51 4 1.08892637781e-10
5 5 4626538.74061
6 5 -846.8959922
7 5 10097137.073
8 5 101627.519064
9 5 57997.4828172
11 5 -4491426.93395
46 5 7.5453722119e-9
47 5 -483.31235681
48 5 846.8959922
49 5 1.98006486354e-9
50 5 101627.519064
51 5 57997.4828172
6 6 8031000.16844
7 6 -9839944.65487
8 6 -209828.755322
9 6 -4736891.82342
10 6 139397.060211
12 6 -295918.262146
13 6 -9839944.65487
15 6 -4635264.30435
46 6 3.77272463354e-9
47 6 846.8959922
48 6 -1748.57296102
49 6 -3.95088310528e-9
50 6 -209828.755323
51 6 -101627.519064
7 7 1572032934.94
8 7 -3.58058582794e-6
9 7 241034053.726
10 7 -4635264.30435
11 7 -4.08492899983e-6
12 7 9839944.65487
13 7 147056055.205
15 7 67231775.3905
46 7 -7.00812793411e-26
47 7 -1.98006486354e-9
48 7 3.95088310528e-9
49 7 -3335
50 7 3.13049447079e-7
51 7 1.56890899053e-7
8 8 461552214.933
9 8 16341500.8471
10 8 7.97257459677e-8
12 8 -1.26780887705e-7
13 8 -4.21574832612e-6
14 8 -89130.8412912
15 8 -2.65105952638e-6
46 8 4.98230080059e-11
47 8 -101627.519064
48 8 209828.755322
49 8 3.13049447079e-7
50 8 16624203.5638
*/
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KCmludCBpLGosbixjOwppbnQgY29sOwppbnQgKnJvd19pbmQsICpjb2xfaW5kLCAqcm93X3B0cjsKZG91YmxlICp2YWw7CgppbnQgbWFpbiAodm9pZCl7CkZJTEUgKmZpbjsKICAgIAoJY29sID0gNTE7CgluID0gNzU7CgoJLy9kb3VibGUgKnZhbDsKCXZhbCA9IChkb3VibGUqKW1hbGxvYyhzaXplb2YoZG91YmxlKSoobikpOwoKCS8vc3RhdGljIGludCAqcm93X2luZCwgKmNvbF9pbmQsICpyb3dfcHRyOwoJcm93X2luZCA9IChpbnQgKiltYWxsb2MoIHNpemVvZiggaW50ICkgKiBuKTsKCWNvbF9pbmQgPSAoaW50ICopbWFsbG9jKCBzaXplb2YoIGludCApICogbik7Cglyb3dfcHRyID0gKGludCAqKW1hbGxvYyggc2l6ZW9mKCBpbnQgKSAqIG4pOwoKCglmaW4gPSBmb3BlbigidGVzdF9tbS5tdHgiICwiciIpOwoKICAgIGZvciggaSA9IDEgOyBpIDw9IG4gOyBpKyspCiAgICB7CgkJZnNjYW5mKGZpbiwgIiVkICVkICVsZ1xuIiwgJnJvd19pbmRbaS0xXSwgJmNvbF9pbmRbaS0xXSwgJnZhbFtpLTFdKTsJCQkKCX0KCg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