Ian Jauslin
summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/io.c b/src/io.c
index e8afbb1..c01f0c9 100644
--- a/src/io.c
+++ b/src/io.c
@@ -14,7 +14,7 @@ int write_vec(_Complex double* vec, int K1, int K2, FILE* file){
}
for(kx=0;kx<=K1;kx++){
- for (ky=-K2;ky<=K2;ky++){
+ for(ky=(kx>0 ? -K2 : 1);ky<=K2;ky++){
fprintf(file,"% 3d % 3d % .15e % .15e\n",kx,ky,__real__ vec[klookup_sym(kx,ky,K2)],__imag__ vec[klookup_sym(kx,ky,K2)]);
}
}
@@ -29,7 +29,7 @@ int write_vec_bin(_Complex double* vec, int K1, int K2, FILE* file){
return 0;
}
- fwrite(vec, sizeof(_Complex double), (K1+1)*(2*K2+1), file);
+ fwrite(vec, sizeof(_Complex double), K1*(2*K2+1)+K2, file);
return 0;
}
@@ -83,7 +83,10 @@ int read_vec(_Complex double* out, int K1, int K2, FILE* file){
fprintf(stderr, "warning: reading line %d: kx or ky out of bounds: %d,%d, skipping\n", counter, kx, ky);
}
else if (kx<0){
- fprintf(stderr, "warning: reading line %d: kx should be >=0, skipping\n", counter);
+ fprintf(stderr, "warning: reading line %d: kx should be >=0, got %d, skipping\n", counter, kx);
+ }
+ else if (kx==0 && ky<=0){
+ fprintf(stderr, "warning: reading line %d: if kx==0 then ky should be >0, got kx=%d ky=%d, skipping\n", counter, kx, ky);
}
else{
// set output
@@ -164,7 +167,7 @@ int read_vec_bin(_Complex double* out, int K1, int K2, FILE* file){
}
}
- fread(out, sizeof(_Complex double), (K1+1)*(2*K2+1), file);
+ fread(out, sizeof(_Complex double), K1*(2*K2+1)+K2, file);
return 0;
}