blitz/shapecheck.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  * blitz/shapecheck.h    Functions for checking conformability of arrays
00003  *
00004  * $Id: shapecheck.h,v 1.5 2003/12/11 03:44:22 julianc Exp $
00005  *
00006  * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * Suggestions:          blitz-dev@oonumerics.org
00019  * Bugs:                 blitz-bugs@oonumerics.org
00020  *
00021  * For more information, please see the Blitz++ Home Page:
00022  *    http://oonumerics.org/blitz/
00023  *
00024  ***************************************************************************/
00025 
00026 #ifndef BZ_SHAPECHECK_H
00027 #define BZ_SHAPECHECK_H
00028 
00029 BZ_NAMESPACE(blitz)
00030 
00031 /*
00032  * The function areShapesConformable(A,B) checks that the shapes 
00033  * A and B are conformable (i.e. the same size/geometry).  Typically 
00034  * the A and B parameters are of type TinyVector<int,N_rank> and represent 
00035  * the extent of the arrays.  It's possible that in the future jagged-edged
00036  * arrays will be supported, in which case shapes may be lists
00037  * of subdomains.
00038  */
00039 
00040 template<typename T_shape1, typename T_shape2>
00041 inline bool areShapesConformable(const T_shape1&, const T_shape2&)
00042 {
00043     // If the shape objects are different types, this means
00044     // that the arrays are different ranks, or one is jagged
00045     // edged, etc.  In this case the two arrays are not
00046     // conformable.
00047     return false;
00048 }
00049 
00050 template<typename T_shape>
00051 inline bool areShapesConformable(const T_shape& a, const T_shape& b)
00052 {
00053     // The shape objects are the same type, so compare them.
00054 
00055     // NEEDS_WORK-- once the "all" reduction is implemented, should
00056     // use it.
00057     // return all(a == b);
00058 
00059     for (unsigned i=0; i < a.length(); ++i)
00060     {
00061         if (a[i] != b[i])
00062         {
00063             BZ_DEBUG_MESSAGE("Incompatible shapes detected: " << endl 
00064                  << a << endl << b << endl);
00065             return false;
00066         }
00067     }
00068 
00069     return true;
00070 }
00071 
00072 BZ_NAMESPACE_END
00073 
00074 #endif

Generated on Wed Oct 17 15:37:28 2007 for blitz by  doxygen 1.5.2