| [658] | 1 | /***************************************************************************
 | 
|---|
 | 2 |  * blitz/shapecheck.h    Functions for checking conformability of arrays
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  * $Id: shapecheck.h,v 1.1.1.1 1999-11-26 16:37:04 ansari Exp $
 | 
|---|
 | 5 |  *
 | 
|---|
 | 6 |  * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
 | 
|---|
 | 7 |  *
 | 
|---|
 | 8 |  * This program is free software; you can redistribute it and/or
 | 
|---|
 | 9 |  * modify it under the terms of the GNU General Public License
 | 
|---|
 | 10 |  * as published by the Free Software Foundation; either version 2
 | 
|---|
 | 11 |  * of the License, or (at your option) any later version.
 | 
|---|
 | 12 |  *
 | 
|---|
 | 13 |  * This program is distributed in the hope that it will be useful,
 | 
|---|
 | 14 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 16 |  * GNU General Public License for more details.
 | 
|---|
 | 17 |  *
 | 
|---|
 | 18 |  * Suggestions:          blitz-suggest@cybervision.com
 | 
|---|
 | 19 |  * Bugs:                 blitz-bugs@cybervision.com
 | 
|---|
 | 20 |  *
 | 
|---|
 | 21 |  * For more information, please see the Blitz++ Home Page:
 | 
|---|
 | 22 |  *    http://seurat.uwaterloo.ca/blitz/
 | 
|---|
 | 23 |  *
 | 
|---|
 | 24 |  ***************************************************************************
 | 
|---|
 | 25 |  * $Log: not supported by cvs2svn $
 | 
|---|
 | 26 |  * Revision 1.1.1.1  1999/04/09  17:59:02  ansari
 | 
|---|
 | 27 |  * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
 | 
|---|
 | 28 |  *
 | 
|---|
 | 29 |  * Revision 1.1  1998/03/14 00:04:47  tveldhui
 | 
|---|
 | 30 |  * 0.2-alpha-05
 | 
|---|
 | 31 |  *
 | 
|---|
 | 32 |  */
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | #ifndef BZ_SHAPECHECK_H
 | 
|---|
 | 35 | #define BZ_SHAPECHECK_H
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | BZ_NAMESPACE(blitz)
 | 
|---|
 | 38 | 
 | 
|---|
 | 39 | /*
 | 
|---|
 | 40 |  * The function areShapesConformable(A,B) checks that the shapes 
 | 
|---|
 | 41 |  * A and B are conformable (i.e. the same size/geometry).  Typically 
 | 
|---|
 | 42 |  * the A and B parameters are of type TinyVector<int,N_rank> and represent 
 | 
|---|
 | 43 |  * the extent of the arrays.  It's possible that in the future jagged-edged
 | 
|---|
 | 44 |  * arrays will be supported, in which case shapes may be lists
 | 
|---|
 | 45 |  * of subdomains.
 | 
|---|
 | 46 |  */
 | 
|---|
 | 47 | 
 | 
|---|
 | 48 | template<class T_shape1, class T_shape2>
 | 
|---|
 | 49 | inline _bz_bool areShapesConformable(const T_shape1&, const T_shape2&)
 | 
|---|
 | 50 | {
 | 
|---|
 | 51 |     // If the shape objects are different types, this means
 | 
|---|
 | 52 |     // that the arrays are different ranks, or one is jagged
 | 
|---|
 | 53 |     // edged, etc.  In this case the two arrays are not
 | 
|---|
 | 54 |     // conformable.
 | 
|---|
 | 55 |     return _bz_false;
 | 
|---|
 | 56 | }
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | template<class T_shape>
 | 
|---|
 | 59 | inline _bz_bool areShapesConformable(const T_shape& a, const T_shape& b)
 | 
|---|
 | 60 | {
 | 
|---|
 | 61 |     // The shape objects are the same type, so compare them.
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 |     // NEEDS_WORK-- once the "all" reduction is implemented, should
 | 
|---|
 | 64 |     // use it.
 | 
|---|
 | 65 |     // return all(a == b);
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 |     for (int i=0; i < a.length(); ++i)
 | 
|---|
 | 68 |     {
 | 
|---|
 | 69 |         if (a[i] != b[i])
 | 
|---|
 | 70 |         {
 | 
|---|
 | 71 |             BZ_DEBUG_MESSAGE("Incompatible shapes detected: " << endl 
 | 
|---|
 | 72 |                  << a << endl << b << endl);
 | 
|---|
 | 73 |             return _bz_false;
 | 
|---|
 | 74 |         }
 | 
|---|
 | 75 |     }
 | 
|---|
 | 76 | 
 | 
|---|
 | 77 |     return _bz_true;
 | 
|---|
 | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | BZ_NAMESPACE_END
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 | #endif
 | 
|---|