1 #include "matrix2file.h"
5 void dumpMatrix(
const char *infilename,
double *matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
10 memset(filename, 0 , 1000);
11 strncpy(fmt,infilename,999);
12 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
13 sprintf(filename,fmt, w, x, y, z, symmetric);
14 FILE *loutfile = fopen(filename,
"w");
15 #ifdef PAIRCALC_TEST_DUMP
16 fprintf(loutfile,
"%d\n",ydim);
18 for(
int i=0;i<xdim;i++)
19 for(
int j=0;j<ydim;j++)
20 fprintf(loutfile,
"%d %d %.12g\n",x+i,y+j,matrix[i*ydim+j]);
26 void dumpMatrix(
const char *infilename,
complex *matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
30 memset(fmt, 0 , 1000);
31 memset(filename, 0 , 1000);
32 strncpy(fmt,infilename,999);
33 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
34 sprintf(filename,fmt, w, x, y, z, symmetric);
35 FILE *loutfile = fopen(filename,
"w");
36 #ifdef PAIRCALC_TEST_DUMP
37 fprintf(loutfile,
"%d\n",ydim);
39 for(
int i=0;i<xdim;i++)
40 for(
int j=0;j<ydim;j++)
41 fprintf(loutfile,
"%d %d %.12g %.12g\n",x+i,y+j,matrix[i*ydim+j].re, matrix[i*ydim+j].im);
47 void loadMatrix(
const char *infilename,
double *matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
51 memset(fmt, 0 , 1000);
52 memset(filename, 0 , 1000);
53 strncpy(fmt,infilename,999);
54 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
55 sprintf(filename,fmt, w, x, y, z, symmetric);
56 FILE *loutfile = fopen(filename,
"r");
60 for(
int i=0;i<xdim;i++)
61 for(
int j=0;j<ydim;j++)
62 assert(fscanf(loutfile,
"%d %d %lf\n",&junk1,&junk2,&(matrix[i*ydim+j])));
73 void loadMatrix(
const char *infilename,
complex *matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
77 memset(fmt, 0 , 1000);
78 memset(filename, 0 , 1000);
79 strncpy(fmt,infilename,999);
80 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
81 sprintf(filename,fmt, w, x, y, z, symmetric);
82 FILE *loutfile = fopen(filename,
"r");
86 for(
int i=0;i<xdim;i++)
87 for(
int j=0;j<ydim;j++)
88 assert(fscanf(loutfile,
"%d %d %lf %lf\n",&junk1,&junk2,&(matrix[i*ydim+j].re),&(matrix[i*ydim+j].im)));
98 void dumpMatrix2DDouble(
const char *infilename,
double **matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
102 memset(fmt, 0 , 1000);
103 memset(filename, 0 , 1000);
104 strncpy(fmt,infilename,999);
105 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
106 sprintf(filename,fmt, w, x, y, z, symmetric);
107 FILE *loutfile = fopen(filename,
"w");
108 for(
int i=0;i<xdim;i++)
109 for(
int j=1;j<=ydim;j++)
110 fprintf(loutfile,
"%d %d %.12g\n",i,j,matrix[i][j]);
113 void loadMatrix2DDouble(
const char *infilename,
double **matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
117 memset(fmt, 0 , 1000);
118 memset(filename, 0 , 1000);
119 strncpy(fmt,infilename,999);
120 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
121 sprintf(filename,fmt, w, x, y, z, symmetric);
122 FILE *loutfile = fopen(filename,
"r");
126 for(
int i=0;i<xdim;i++)
127 for(
int j=1;j<=ydim;j++)
128 assert(fscanf(loutfile,
"%d %d %lf\n",&junk1,&junk2,&(matrix[i][j])));
139 void dumpMatrix2DInt(
const char *infilename,
int **matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
143 memset(fmt, 0 , 1000);
144 memset(filename, 0 , 1000);
145 strncpy(fmt,infilename,999);
146 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
147 sprintf(filename,fmt, w, x, y, z, symmetric);
148 FILE *loutfile = fopen(filename,
"w");
149 for(
int i=0;i<xdim;i++)
150 for(
int j=1;j<=ydim;j++)
151 fprintf(loutfile,
"%d %d %d\n",i,j,matrix[i][j]);
154 void loadMatrix2DInt(
const char *infilename,
int **matrix,
int xdim,
int ydim,
int w,
int x,
int y,
int z,
bool symmetric)
158 memset(fmt, 0 , 1000);
159 memset(filename, 0 , 1000);
160 strncpy(fmt,infilename,999);
161 strncat(fmt,
"_%d_%d_%d_%d_%d.out",999);
162 sprintf(filename,fmt, w, x, y, z, symmetric);
163 FILE *loutfile = fopen(filename,
"r");
167 for(
int i=0;i<xdim;i++)
168 for(
int j=1;j<=ydim;j++)
169 assert(fscanf(loutfile,
"%d %d %d\n",&junk1,&junk2,&(matrix[i][j])));