From 997fb4bb26ecfd7883f59d44064cda094faa41a7 Mon Sep 17 00:00:00 2001 From: rhaas Date: Tue, 25 May 2010 19:18:18 +0000 Subject: TwoPunctures: fix bug in d3tensor Had hard coded the lower bound to be zero and forgotten to initialize the first column of pointers git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinInitialData/TwoPunctures/trunk@108 b2a53a04-0f4f-0410-87ed-f9f25ced00cf --- src/TP_utilities.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/TP_utilities.c b/src/TP_utilities.c index 35a0c22..f883a78 100644 --- a/src/TP_utilities.c +++ b/src/TP_utilities.c @@ -124,16 +124,20 @@ d3tensor (long nrl, long nrh, long ncl, long nch, long ndl, long ndh) /* slice chunk into rows and columns */ long width = (nch-ncl+1); long depth = (ndh-ndl+1); + for(long j = ncl+1 ; j <= nch ; j++) { /* first row of columns */ + retval[nrl][j] = retval[nrl][j-1] + depth; + } + assert(retval[nrl][nch]-retval[nrl][ncl] == (nch-ncl)*depth); for(long i = nrl+1 ; i <= nrh ; i++) { retval[i] = retval[i-1] + width; - retval[i][0] = retval[i-1][0] + width*depth; + retval[i][ncl] = retval[i-1][ncl] + width*depth; /* first cell in column */ for(long j = ncl+1 ; j <= nch ; j++) { retval[i][j] = retval[i][j-1] + depth; } - assert(retval[i][nch]-retval[i][ncl] == (ndh-ndl)*depth); + assert(retval[i][nch]-retval[i][ncl] == (nch-ncl)*depth); } assert(retval[nrh]-retval[nrl] == (nrh-nrl)*width); - assert(retval[nrh][nch]-retval[nrl][ncl] == (nrh-nrl)*(nch-ncl)*depth); + assert(&retval[nrh][nch][ndh]-&retval[nrl][ncl][ndl] == (nrh-nrl+1)*(nch-ncl+1)*(ndh-ndl+1)-1); return retval; } -- cgit v1.2.3