fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int i,j,n,c;
  6. int col;
  7. int *row_ind, *col_ind, *row_ptr;
  8. double *val;
  9.  
  10. int main (void){
  11. FILE *fin;
  12.  
  13. col = 51;
  14. n = 75;
  15.  
  16. //double *val;
  17. val = (double*)malloc(sizeof(double)*(n));
  18.  
  19. //static int *row_ind, *col_ind, *row_ptr;
  20. row_ind = (int *)malloc( sizeof( int ) * n);
  21. col_ind = (int *)malloc( sizeof( int ) * n);
  22. row_ptr = (int *)malloc( sizeof( int ) * n);
  23.  
  24.  
  25. fin = fopen("test_mm.mtx" ,"r");
  26.  
  27. for( i = 1 ; i <= n ; i++)
  28. {
  29. fscanf(fin, "%d %d %lg\n", &row_ind[i-1], &col_ind[i-1], &val[i-1]);
  30. }
  31.  
  32.  
  33. //row_ptr取り込み
  34.  
  35.  
  36. for(i=0;i<n;i++){
  37. printf("\nval =");
  38. printf(" %lf\n", val[i]);
  39. printf("\nrow_ind =");
  40. printf(" %d", row_ind[i]);
  41. printf("\ncol_ind =");
  42. printf(" %d\n", col_ind[i]);
  43. }
  44.  
  45. for(i=0;i<=col;i++){
  46. printf("\nrow_ptr[%d] =%d",row_ptr[i],i);
  47. }
  48. printf("\n");
  49. return 0;
  50. }
  51.  
  52.  
  53. /*
  54. test_mm.mtx
  55. 行 列 非零要素
  56. 1 1 1064685280.47
  57. 5 1 10097137.073
  58. 7 1 449885280.472
  59. 2 2 427728386.378
  60. 4 2 -4238867.37393
  61. 8 2 208101719.712
  62. 3 3 1.044e6
  63. 9 3 -1.044e6
  64. 4 4 642010.94971
  65. 5 4 -7.5453722119e-9
  66. 6 4 -139397.060211
  67. 7 4 4635264.30435
  68. 8 4 -4238867.37393
  69. 9 4 2914870.77518
  70. 10 4 -87659.3847246
  71. 12 4 139397.060211
  72. 13 4 4635264.30435
  73. 15 4 2914870.77518
  74. 46 4 -497833.333333
  75. 47 4 7.5453722119e-9
  76. 48 4 3.77272463354e-9
  77. 49 4 7.00812794124e-26
  78. 50 4 -4.98230079945e-11
  79. 51 4 1.08892637781e-10
  80. 5 5 4626538.74061
  81. 6 5 -846.8959922
  82. 7 5 10097137.073
  83. 8 5 101627.519064
  84. 9 5 57997.4828172
  85. 11 5 -4491426.93395
  86. 46 5 7.5453722119e-9
  87. 47 5 -483.31235681
  88. 48 5 846.8959922
  89. 49 5 1.98006486354e-9
  90. 50 5 101627.519064
  91. 51 5 57997.4828172
  92. 6 6 8031000.16844
  93. 7 6 -9839944.65487
  94. 8 6 -209828.755322
  95. 9 6 -4736891.82342
  96. 10 6 139397.060211
  97. 12 6 -295918.262146
  98. 13 6 -9839944.65487
  99. 15 6 -4635264.30435
  100. 46 6 3.77272463354e-9
  101. 47 6 846.8959922
  102. 48 6 -1748.57296102
  103. 49 6 -3.95088310528e-9
  104. 50 6 -209828.755323
  105. 51 6 -101627.519064
  106. 7 7 1572032934.94
  107. 8 7 -3.58058582794e-6
  108. 9 7 241034053.726
  109. 10 7 -4635264.30435
  110. 11 7 -4.08492899983e-6
  111. 12 7 9839944.65487
  112. 13 7 147056055.205
  113. 15 7 67231775.3905
  114. 46 7 -7.00812793411e-26
  115. 47 7 -1.98006486354e-9
  116. 48 7 3.95088310528e-9
  117. 49 7 -3335
  118. 50 7 3.13049447079e-7
  119. 51 7 1.56890899053e-7
  120. 8 8 461552214.933
  121. 9 8 16341500.8471
  122. 10 8 7.97257459677e-8
  123. 12 8 -1.26780887705e-7
  124. 13 8 -4.21574832612e-6
  125. 14 8 -89130.8412912
  126. 15 8 -2.65105952638e-6
  127. 46 8 4.98230080059e-11
  128. 47 8 -101627.519064
  129. 48 8 209828.755322
  130. 49 8 3.13049447079e-7
  131. 50 8 16624203.5638
  132.  
  133. */
  134.  
Runtime error #stdin #stdout 0.01s 1804KB
stdin
Standard input is empty
stdout
Standard output is empty