text: /*BHEADER**********************************************************************
   * Copyright (c) 2006   The Regents of the University of California.
   * Produced at the Lawrence Livermore National Laboratory.
   * Written by the HYPRE team. UCRL-CODE-222953.
   * All rights reserved.
   *
   * This file is part of HYPRE (see http://www.llnl.gov/CASC/hypre/).
   * Please see the COPYRIGHT_and_LICENSE file for the copyright notice, 
   * disclaimer, contact information and the GNU Lesser General Public License.
   *
   * HYPRE is free software; you can redistribute it and/or modify it under the 
   * terms of the GNU General Public License (as published by the Free Software
   * Foundation) version 2.1 dated February 1999.
   *
   * HYPRE is distributed in the hope that it will be useful, but WITHOUT ANY 
   * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS 
   * FOR A PARTICULAR PURPOSE.  See the terms and conditions of the GNU General
   * Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public License
   * along with this program; if not, write to the Free Software Foundation,
   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   *
   * $Revision: 2.9 $
   ***********************************************************************EHEADER*/
  
  
  /******************************************************************************
   *
   * Header info for the Box structures
   *
   *****************************************************************************/
  
  #ifndef hypre_BOX_HEADER
  #define hypre_BOX_HEADER
  
  /*--------------------------------------------------------------------------
   * hypre_Index:
   *   This is used to define indices in index space, or dimension
   *   sizes of boxes.
   *
   *   The spatial dimensions x, y, and z may be specified by the
   *   integers 0, 1, and 2, respectively (see the hypre_IndexD macro below).
   *   This simplifies the code in the hypre_Box class by reducing code
   *   replication.
   *--------------------------------------------------------------------------*/
  
  typedef int  hypre_Index[3];
  typedef int *hypre_IndexRef;
  
  /*--------------------------------------------------------------------------
   * hypre_Box:
   *--------------------------------------------------------------------------*/
  
  typedef struct hypre_Box_struct
  {
     hypre_Index imin;           /* min bounding indices */
     hypre_Index imax;           /* max bounding indices */
  
  } hypre_Box;
  
  /*--------------------------------------------------------------------------
   * hypre_BoxArray:
   *   An array of boxes.
   *--------------------------------------------------------------------------*/
  
  typedef struct hypre_BoxArray_struct
  {
     hypre_Box  *boxes;         /* Array of boxes */
     int         size;          /* Size of box array */
     int         alloc_size;    /* Size of currently alloced space */
  
  } hypre_BoxArray;
  
  #define hypre_BoxArrayExcess 10
  
  /*--------------------------------------------------------------------------
   * hypre_BoxArrayArray:
   *   An array of box arrays.
   *--------------------------------------------------------------------------*/
  
  typedef struct hypre_BoxArrayArray_struct
  {
     hypre_BoxArray  **box_arrays;    /* Array of pointers to box arrays */
     int               size;          /* Size of box array array */
  
  } hypre_BoxArrayArray;
  
  
  /*--------------------------------------------------------------------------
   * Accessor macros: hypre_Index
   *--------------------------------------------------------------------------*/
  
  #define hypre_IndexD(index, d)  (index[d])
  
  #define hypre_IndexX(index)     hypre_IndexD(index, 0)
  #define hypre_IndexY(index)     hypre_IndexD(index, 1)
  #define hypre_IndexZ(index)     hypre_IndexD(index, 2)
  
  /*--------------------------------------------------------------------------
   * Member functions: hypre_Index
   *--------------------------------------------------------------------------*/
  
  #define hypre_SetIndex(index, ix, iy, iz) \
  ( hypre_IndexX(index) = ix,\
    hypre_IndexY(index) = iy,\
    hypre_IndexZ(index) = iz )
  
  #define hypre_ClearIndex(index)  hypre_SetIndex(index, 0, 0, 0)
  
  #define hypre_CopyIndex(index1, index2) \
  ( hypre_IndexX(index2) = hypre_IndexX(index1),\
    hypre_IndexY(index2) = hypre_IndexY(index1),\
    hypre_IndexZ(index2) = hypre_IndexZ(index1) )
  
  #define hypre_CopyToCleanIndex(in_index, ndim, out_index) \
  {\
     int d;\
     for (d = 0; d < ndim; d++)\
     {\
        hypre_IndexD(out_index, d) = hypre_IndexD(in_index, d);\
     }\
     for (d = ndim; d < 3; d++)\
     {\
        hypre_IndexD(out_index, d) = 0;\
     }\
  }
  
  /*--------------------------------------------------------------------------
   * Accessor macros: hypre_Box
   *--------------------------------------------------------------------------*/
  
  #define hypre_BoxIMin(box)     ((box) -> imin)
  #define hypre_BoxIMax(box)     ((box) -> imax)
  
  #define hypre_AddIndex(index1, index2, index3) \
  ( hypre_IndexX(index3) = hypre_IndexX(index2) + hypre_IndexX(index1),\
    hypre_IndexY(index3) = hypre_IndexY(index2) + hypre_IndexY(index1),\
    hypre_IndexZ(index3) = hypre_IndexZ(index2) + hypre_IndexZ(index1) )
  
  #define hypre_SubtractIndex(index1, index2, index3) \
  ( hypre_IndexX(index3) = hypre_IndexX(index1) - hypre_IndexX(index2),\
    hypre_IndexY(index3) = hypre_IndexY(index1) - hypre_IndexY(index2),\
    hypre_IndexZ(index3) = hypre_IndexZ(index1) - hypre_IndexZ(index2) )
  
  #define hypre_BoxIMinD(box, d) (hypre_IndexD(hypre_BoxIMin(box), d))
  #define hypre_BoxIMaxD(box, d) (hypre_IndexD(hypre_BoxIMax(box), d))
  #define hypre_BoxSizeD(box, d) \
  hypre_max(0, (hypre_BoxIMaxD(box, d) - hypre_BoxIMinD(box, d) + 1))
  
  #define hypre_BoxIMinX(box)    hypre_BoxIMinD(box, 0)
  #define hypre_BoxIMinY(box)    hypre_BoxIMinD(box, 1)
  #define hypre_BoxIMinZ(box)    hypre_BoxIMinD(box, 2)
  
  #define hypre_BoxIMaxX(box)    hypre_BoxIMaxD(box, 0)
  #define hypre_BoxIMaxY(box)    hypre_BoxIMaxD(box, 1)
  #define hypre_BoxIMaxZ(box)    hypre_BoxIMaxD(box, 2)
  
  #define hypre_BoxSizeX(box)    hypre_BoxSizeD(box, 0)
  #define hypre_BoxSizeY(box)    hypre_BoxSizeD(box, 1)
  #define hypre_BoxSizeZ(box)    hypre_BoxSizeD(box, 2)
  
  #define hypre_BoxEqualP( box1, box2 ) (\
   hypre_BoxIMinX(box1)==hypre_BoxIMinX(box2) &&\
   hypre_BoxIMaxX(box1)==hypre_BoxIMaxX(box2) &&\
   hypre_BoxIMinY(box1)==hypre_BoxIMinY(box2) &&\
   hypre_BoxIMaxY(box1)==hypre_BoxIMaxY(box2) &&\
   hypre_BoxIMinZ(box1)==hypre_BoxIMinZ(box2) &&\
   hypre_BoxIMaxZ(box1)==hypre_BoxIMaxZ(box2) )
  
  #define hypre_IndexInBoxP( index, box ) (\
   hypre_IndexX(index)>=hypre_BoxIMinX(box) &&\
   hypre_IndexX(index)<=hypre_BoxIMaxX(box) &&\
   hypre_IndexY(index)>=hypre_BoxIMinY(box) &&\
   hypre_IndexY(index)<=hypre_BoxIMaxY(box) &&\
   hypre_IndexZ(index)>=hypre_BoxIMinZ(box) &&\
   hypre_IndexZ(index)<=hypre_BoxIMaxZ(box) )
  
  
  #define hypre_IndexDInBoxP( index, d, box ) (\
   hypre_IndexD(index, d)>=hypre_BoxIMinD(box, d) &&\
   hypre_IndexD(index, d)<=hypre_BoxIMaxD(box, d) )
  
  #define hypre_CopyBox(box1, box2) \
  ( hypre_CopyIndex(hypre_BoxIMin(box1), hypre_BoxIMin(box2)),\
    hypre_CopyIndex(hypre_BoxIMax(box1), hypre_BoxIMax(box2)) )
  
  #define hypre_BoxVolume(box) \
  (hypre_BoxSizeX(box) * hypre_BoxSizeY(box) * hypre_BoxSizeZ(box))
  
  #define hypre_BoxShiftPos(box, shift) \
  {\
     hypre_BoxIMinX(box) += hypre_IndexX(shift);\
     hypre_BoxIMinY(box) += hypre_IndexY(shift);\
     hypre_BoxIMinZ(box) += hypre_IndexZ(shift);\
     hypre_BoxIMaxX(box) += hypre_IndexX(shift);\
     hypre_BoxIMaxY(box) += hypre_IndexY(shift);\
     hypre_BoxIMaxZ(box) += hypre_IndexZ(shift);\
  }
  
  #define hypre_BoxShiftNeg(box, shift) \
  {\
     hypre_BoxIMinX(box) -= hypre_IndexX(shift);\
     hypre_BoxIMinY(box) -= hypre_IndexY(shift);\
     hypre_BoxIMinZ(box) -= hypre_IndexZ(shift);\
     hypre_BoxIMaxX(box) -= hypre_IndexX(shift);\
     hypre_BoxIMaxY(box) -= hypre_IndexY(shift);\
     hypre_BoxIMaxZ(box) -= hypre_IndexZ(shift);\
  }
  
  #define hypre_BoxIndexRank(box, index) \
  ((hypre_IndexX(index) - hypre_BoxIMinX(box)) + \
   ((hypre_IndexY(index) - hypre_BoxIMinY(box)) + \
     ((hypre_IndexZ(index) - hypre_BoxIMinZ(box)) * \
      hypre_BoxSizeY(box))) * \
    hypre_BoxSizeX(box))
  
  /* The first hypre_CCBoxIndexRank is better style because it keeps
     its similarity to the variable coefficient hypre_BoxIndexRank.
     The second one sometimes avoids compiler warnings...*/
  #define hypre_CCBoxIndexRank(box, index) 0
  #define hypre_CCBoxIndexRank_noargs() 0
  
  #define hypre_BoxOffsetDistance(box, index) \
  (hypre_IndexX(index) + \
   (hypre_IndexY(index) + \
    (hypre_IndexZ(index) * \
     hypre_BoxSizeY(box))) * \
   hypre_BoxSizeX(box))
  
  #define hypre_CCBoxOffsetDistance(box, index) 0
    
  /*--------------------------------------------------------------------------
   * Accessor macros: hypre_BoxArray
   *--------------------------------------------------------------------------*/
  
  #define hypre_BoxArrayBoxes(box_array)     ((box_array) -> boxes)
  #define hypre_BoxArrayBox(box_array, i)    &((box_array) -> boxes[(i)])
  #define hypre_BoxArraySize(box_array)      ((box_array) -> size)
  #define hypre_BoxArrayAllocSize(box_array) ((box_array) -> alloc_size)
  
  /*--------------------------------------------------------------------------
   * Accessor macros: hypre_BoxArrayArray
   *--------------------------------------------------------------------------*/
  
  #define hypre_BoxArrayArrayBoxArrays(box_array_array) \
  ((box_array_array) -> box_arrays)
  #define hypre_BoxArrayArrayBoxArray(box_array_array, i) \
  ((box_array_array) -> box_arrays[(i)])
  #define hypre_BoxArrayArraySize(box_array_array) \
  ((box_array_array) -> size)
  
  /*--------------------------------------------------------------------------
   * Looping macros:
   *--------------------------------------------------------------------------*/
  
  #define hypre_ForBoxI(i, box_array) \
  for (i = 0; i < hypre_BoxArraySize(box_array); i++)
  
  #define hypre_ForBoxArrayI(i, box_array_array) \
  for (i = 0; i < hypre_BoxArrayArraySize(box_array_array); i++)
  
  /*--------------------------------------------------------------------------
   * BoxLoop macros:
   *
   * NOTE: PThreads version of BoxLoop looping macros are in `box_pthreads.h'.
   *
   *--------------------------------------------------------------------------*/
  
  #ifndef HYPRE_USE_PTHREADS
  
  #define hypre_BoxLoopDeclareS(dbox, stride, sx, sy, sz) \
  int  sx = (hypre_IndexX(stride));\
  int  sy = (hypre_IndexY(stride)*hypre_BoxSizeX(dbox));\
  int  sz = (hypre_IndexZ(stride)*\
             hypre_BoxSizeX(dbox)*hypre_BoxSizeY(dbox))
  
  #define hypre_BoxLoopDeclareN(loop_size) \
  int  hypre__nx = hypre_IndexX(loop_size);\
  int  hypre__ny = hypre_IndexY(loop_size);\
  int  hypre__nz = hypre_IndexZ(loop_size);\
  int  hypre__mx = hypre__nx;\
  int  hypre__my = hypre__ny;\
  int  hypre__mz = hypre__nz;\
  int  hypre__dir, hypre__max;\
  int  hypre__div, hypre__mod;\
  int  hypre__block, hypre__num_blocks;\
  hypre__dir = 0;\
  hypre__max = hypre__nx;\
  if (hypre__ny > hypre__max)\
  {\
     hypre__dir = 1;\
     hypre__max = hypre__ny;\
  }\
  if (hypre__nz > hypre__max)\
  {\
     hypre__dir = 2;\
     hypre__max = hypre__nz;\
  }\
  hypre__num_blocks = hypre_NumThreads();\
  if (hypre__max < hypre__num_blocks)\
  {\
     hypre__num_blocks = hypre__max;\
  }\
  if (hypre__num_blocks > 0)\
  {\
     hypre__div = hypre__max / hypre__num_blocks;\
     hypre__mod = hypre__max % hypre__num_blocks;\
  }
  
  #define hypre_BoxLoopSet(i, j, k) \
  i = 0;\
  j = 0;\
  k = 0;\
  hypre__nx = hypre__mx;\
  hypre__ny = hypre__my;\
  hypre__nz = hypre__mz;\
  if (hypre__num_blocks > 1)\
  {\
     if (hypre__dir == 0)\
     {\
        i = hypre__block * hypre__div + hypre_min(hypre__mod, hypre__block);\
        hypre__nx = hypre__div + ((hypre__mod > hypre__block) ? 1 : 0);\
     }\
     else if (hypre__dir == 1)\
     {\
        j = hypre__block * hypre__div + hypre_min(hypre__mod, hypre__block);\
        hypre__ny = hypre__div + ((hypre__mod > hypre__block) ? 1 : 0);\
     }\
     else if (hypre__dir == 2)\
     {\
        k = hypre__block * hypre__div + hypre_min(hypre__mod, hypre__block);\
        hypre__nz = hypre__div + ((hypre__mod > hypre__block) ? 1 : 0);\
     }\
  }
  
  #define hypre_BoxLoopGetIndex( index, base, i, j, k )\
   hypre_SetIndex( index, i+hypre_IndexX(base),\
    j+hypre_IndexY(base), k+hypre_IndexZ(base) )
  
  /*-----------------------------------*/
  
  #define hypre_BoxLoop0Begin(loop_size)\
  {\
     hypre_BoxLoopDeclareN(loop_size);
  
  #define hypre_BoxLoop0For(i, j, k)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {\
           for (i = 0; i < hypre__nx; i++)\
           {
  
  #define hypre_BoxLoop0End()\
           }\
        }\
     }\
     }\
  }
    
  /*-----------------------------------*/
  
  #define hypre_BoxLoop1Begin(loop_size,\
  			    dbox1, start1, stride1, i1)\
  {\
     int  hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
     hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
     hypre_BoxLoopDeclareN(loop_size);
  
  #define hypre_BoxLoop1For(i, j, k, i1)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {\
           for (i = 0; i < hypre__nx; i++)\
           {
  
  #define hypre_BoxLoop1End(i1)\
              i1 += hypre__sx1;\
           }\
           i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
        }\
        i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
     }\
     }\
  }
    
  /*-----------------------------------*/
  
  #define hypre_BoxLoop2Begin(loop_size,\
  			    dbox1, start1, stride1, i1,\
  			    dbox2, start2, stride2, i2)\
  {\
     int  hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
     int  hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
     hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
     hypre_BoxLoopDeclareS(dbox2, stride2, hypre__sx2, hypre__sy2, hypre__sz2);\
     hypre_BoxLoopDeclareN(loop_size);
  
  #define hypre_BoxLoop2For(i, j, k, i1, i2)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
     i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {\
           for (i = 0; i < hypre__nx; i++)\
           {
  
  #define hypre_BoxLoop2End(i1, i2)\
              i1 += hypre__sx1;\
              i2 += hypre__sx2;\
           }\
           i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
           i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
        }\
        i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
        i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
     }\
     }\
  }
  
  /* incomplete BoxLoop2 macros leave out the inner loop so it can be hand-coded */
  #define hypre_BoxLoop2For_INC(i, j, k, i1, i2)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
     i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {
  
  #define hypre_BoxLoop2End_INC(i1, i2)\
           i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
           i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
        }\
        i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
        i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
     }\
     }\
  }
  
  /* BoxLoop2 macros, but only for when all strides are equal.  To improve
   runtime, only one index is computed in the innermost loop, the internal
   index i.
   Since only the internal index, i, is updated in the innermost loop, you
   can't reference i1, i2 inside the innermost loop. To get the effect of i1, i2
   you have to use a macro (see below) to do pointer aliasing.  It works because
   you know that i has the same stride as i1, i2.
   This macro set invokes the user-defined macro hypre_UserOutsideInnerLoop inside
   the outer loops, just before the innermost loop.  The user can define this macro
   for pointer aliasing.
   It's safer to redefine hypre_UserOutsideInnerLoop to do nothing afterwards.
   The Begin_OneStride macro isn't really  needed, the Begin macro does the same
   thing, but without ensuring that the strides are the same.
   */
  
  #define hypre_UserOutsideInnerLoop
  
  #define hypre_BoxLoop2Begin_OneStride(loop_size, stride1,\
  			    dbox1, start1, i1,\
  			    dbox2, start2, i2)\
  {\
     int  hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
     int  hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
     hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
     hypre_BoxLoopDeclareS(dbox2, stride1, hypre__sx2, hypre__sy2, hypre__sz2);\
     hypre_BoxLoopDeclareN(loop_size);
  
  #define hypre_BoxLoop2For_OneStride(i, j, k, i1, i2)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
     i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {\
           hypre_UserOutsideInnerLoop;\
           for ( i=0; i<hypre__nx*hypre__sx1; i+=hypre__sx1 )\
           {
  
  #define hypre_BoxLoop2End_OneStride(i1, i2)\
           }\
           i1 += hypre__sy1;\
           i2 += hypre__sy2;\
        }\
        i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
        i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
     }\
     }\
  }
  
  
  
  
  /*-----------------------------------*/
  
  #define hypre_BoxLoop3Begin(loop_size,\
  			    dbox1, start1, stride1, i1,\
  			    dbox2, start2, stride2, i2,\
                              dbox3, start3, stride3, i3)\
  {\
     int  hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
     int  hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
     int  hypre__i3start = hypre_BoxIndexRank(dbox3, start3);\
     hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
     hypre_BoxLoopDeclareS(dbox2, stride2, hypre__sx2, hypre__sy2, hypre__sz2);\
     hypre_BoxLoopDeclareS(dbox3, stride3, hypre__sx3, hypre__sy3, hypre__sz3);\
     hypre_BoxLoopDeclareN(loop_size);
  
  #define hypre_BoxLoop3For(i, j, k, i1, i2, i3)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
     i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
     i3 = hypre__i3start + i*hypre__sx3 + j*hypre__sy3 + k*hypre__sz3;\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {\
           for (i = 0; i < hypre__nx; i++)\
           {
  
  #define hypre_BoxLoop3End(i1, i2, i3)\
              i1 += hypre__sx1;\
              i2 += hypre__sx2;\
              i3 += hypre__sx3;\
           }\
           i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
           i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
           i3 += hypre__sy3 - hypre__nx*hypre__sx3;\
        }\
        i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
        i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
        i3 += hypre__sz3 - hypre__ny*hypre__sy3;\
     }\
     }\
  }
  
  /*-----------------------------------*/
  
  #define hypre_BoxLoop4Begin(loop_size,\
  			    dbox1, start1, stride1, i1,\
  			    dbox2, start2, stride2, i2,\
                              dbox3, start3, stride3, i3,\
                              dbox4, start4, stride4, i4)\
  {\
     int  hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
     int  hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
     int  hypre__i3start = hypre_BoxIndexRank(dbox3, start3);\
     int  hypre__i4start = hypre_BoxIndexRank(dbox4, start4);\
     hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
     hypre_BoxLoopDeclareS(dbox2, stride2, hypre__sx2, hypre__sy2, hypre__sz2);\
     hypre_BoxLoopDeclareS(dbox3, stride3, hypre__sx3, hypre__sy3, hypre__sz3);\
     hypre_BoxLoopDeclareS(dbox4, stride4, hypre__sx4, hypre__sy4, hypre__sz4);\
     hypre_BoxLoopDeclareN(loop_size);
  
  #define hypre_BoxLoop4For(i, j, k, i1, i2, i3, i4)\
     for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
     {\
     hypre_BoxLoopSet(i, j, k);\
     i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
     i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
     i3 = hypre__i3start + i*hypre__sx3 + j*hypre__sy3 + k*hypre__sz3;\
     i4 = hypre__i4start + i*hypre__sx4 + j*hypre__sy4 + k*hypre__sz4;\
     for (k = 0; k < hypre__nz; k++)\
     {\
        for (j = 0; j < hypre__ny; j++)\
        {\
           for (i = 0; i < hypre__nx; i++)\
           {
  
  #define hypre_BoxLoop4End(i1, i2, i3, i4)\
              i1 += hypre__sx1;\
              i2 += hypre__sx2;\
              i3 += hypre__sx3;\
              i4 += hypre__sx4;\
           }\
           i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
           i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
           i3 += hypre__sy3 - hypre__nx*hypre__sx3;\
           i4 += hypre__sy4 - hypre__nx*hypre__sx4;\
        }\
        i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
        i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
        i3 += hypre__sz3 - hypre__ny*hypre__sy3;\
        i4 += hypre__sz4 - hypre__ny*hypre__sy4;\
     }\
     }\
  }
  
  /*-----------------------------------*/
  
  #endif  /* ifndef HYPRE_USE_PTHREADS */
  
  #endif
  