From d16c42d9f5a40b94406a859fa510bba96480d5e8 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Tue, 11 Apr 2023 18:45:45 -0400 Subject: Only store u[kx,ky] with kx>=0 --- src/io.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/io.c') diff --git a/src/io.c b/src/io.c index 5cdfc54..049f310 100644 --- a/src/io.c +++ b/src/io.c @@ -12,9 +12,9 @@ int write_u(_Complex double* u, int K1, int K2, FILE* file){ return 0; } - for(kx=-K1;kx<=K1;kx++){ + for(kx=0;kx<=K1;kx++){ for (ky=-K2;ky<=K2;ky++){ - fprintf(file,"%d %d % .15e % .15e\n",kx,ky,__real__ u[klookup(kx,ky,2*K1+1,2*K2+1)],__imag__ u[klookup(kx,ky,2*K1+1,2*K2+1)]); + fprintf(file,"%d %d % .15e % .15e\n",kx,ky,__real__ u[klookup_sym(kx,ky,K2)],__imag__ u[klookup_sym(kx,ky,K2)]); } } @@ -63,15 +63,18 @@ int read_u(_Complex double* u, int K1, int K2, FILE* file){ // errors if(ret!=4){ - fprintf(stderr, "warning: line %d does not match the input format: '%s'\n", counter, line); + fprintf(stderr, "warning: line %d does not match the input format: '%s', skipping\n", counter, line); } else{ if(kx>K1 || kx<-K1 || ky>K2 || ky<-K2){ - fprintf(stderr, "warning: reading line %d: kx or ky out of bounds: %d,%d\n", counter, kx, ky); + 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); } else{ // set u - u[klookup(kx, ky, 2*K1+1, 2*K2+1)]=r+i*I; + u[klookup_sym(kx, ky, K2)]=r+i*I; } } } -- cgit v1.2.3-54-g00ecf