From d8380602656b54649c46bac93876b814b4d8eba7 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Tue, 25 Apr 2023 17:51:14 -0400 Subject: Remove terms with kx=0 and ky<=0 --- src/io.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/io.c') 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; } -- cgit v1.2.3-54-g00ecf