28 #include <itpp/itbase.h>
37 char cstr[file_name.size()+1];
38 strcpy(cstr,file_name.c_str());
43 char cstr[file_name.size()+1];
44 strcpy(cstr,file_name.c_str());
58 if ((f = fopen(file_name,
"r")) == NULL) {
59 std::cout<<
"file open fail:"<<file_name<<std::endl;
63 printf(
"Could not process Matrix Market banner.\n");
73 printf(
"Sorry, this application does not support ");
85 I = (
int *) malloc(nz *
sizeof(
int));
86 J = (
int *) malloc(nz *
sizeof(
int));
87 val = (
double *) malloc(nz *
sizeof(
double));
96 if ( fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i]) !=3 ){
97 fprintf( stderr,
"Expected at least three numbers as input\n");
104 if (f !=stdin) fclose(f);
118 for (
int i=0;i<nz;i++){
119 G.set(I[i],J[i],val[i]);
136 if ((f = fopen(file_name,
"r")) == NULL) {
137 std::cout<<
"file open fail:"<<file_name<<std::endl;
141 printf(
"Could not process Matrix Market banner.\n");
149 if (f !=stdin) fclose(f);
157 printf(
"Sorry, this application does not support ");
169 I = (
int *) malloc(nz *
sizeof(
int));
170 J = (
int *) malloc(nz *
sizeof(
int));
171 val = (
double *) malloc(nz *
sizeof(
double));
180 if ( fscanf(f,
"%d %d %lg\n", &I[i], &J[i], &val[i]) !=3){
181 fprintf( stderr,
"Expected at least three numbers as input\n");
188 if (f !=stdin) fclose(f);
203 for (
int i=0;i<nz;i++){
204 G.set(I[i],J[i],val[i]);
220 if ((f = fopen(file_name,
"r")) == NULL) {
221 std::cout<<
"file open fail:"<<file_name<<std::endl;
225 printf(
"Could not process Matrix Market banner.\n");
236 printf(
"Sorry, this application does not support ");
251 val = (
double *) malloc(nz *
sizeof(
double));
263 if ( fscanf(f,
" %lg\n", &val[i]) !=1){
264 fprintf( stderr,
"Expected at least one numbers as input\n");
281 if (f !=stdin) fclose(f);
290 for (
int i=0;i<M;i++){
291 for (
int j=0;j<N;j++){
294 G.set(i,j,val[j*M+i]);