| 1 | /*************************************************************************** | 
|---|
| 2 | * blitz/shapecheck.h    Functions for checking conformability of arrays | 
|---|
| 3 | * | 
|---|
| 4 | * $Id: shapecheck.h,v 1.1.1.1 1999-04-09 17:59:02 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  1998/03/14 00:04:47  tveldhui | 
|---|
| 27 | * 0.2-alpha-05 | 
|---|
| 28 | * | 
|---|
| 29 | */ | 
|---|
| 30 |  | 
|---|
| 31 | #ifndef BZ_SHAPECHECK_H | 
|---|
| 32 | #define BZ_SHAPECHECK_H | 
|---|
| 33 |  | 
|---|
| 34 | BZ_NAMESPACE(blitz) | 
|---|
| 35 |  | 
|---|
| 36 | /* | 
|---|
| 37 | * The function areShapesConformable(A,B) checks that the shapes | 
|---|
| 38 | * A and B are conformable (i.e. the same size/geometry).  Typically | 
|---|
| 39 | * the A and B parameters are of type TinyVector<int,N_rank> and represent | 
|---|
| 40 | * the extent of the arrays.  It's possible that in the future jagged-edged | 
|---|
| 41 | * arrays will be supported, in which case shapes may be lists | 
|---|
| 42 | * of subdomains. | 
|---|
| 43 | */ | 
|---|
| 44 |  | 
|---|
| 45 | template<class T_shape1, class T_shape2> | 
|---|
| 46 | inline _bz_bool areShapesConformable(const T_shape1&, const T_shape2&) | 
|---|
| 47 | { | 
|---|
| 48 | // If the shape objects are different types, this means | 
|---|
| 49 | // that the arrays are different ranks, or one is jagged | 
|---|
| 50 | // edged, etc.  In this case the two arrays are not | 
|---|
| 51 | // conformable. | 
|---|
| 52 | return _bz_false; | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | template<class T_shape> | 
|---|
| 56 | inline _bz_bool areShapesConformable(const T_shape& a, const T_shape& b) | 
|---|
| 57 | { | 
|---|
| 58 | // The shape objects are the same type, so compare them. | 
|---|
| 59 |  | 
|---|
| 60 | // NEEDS_WORK-- once the "all" reduction is implemented, should | 
|---|
| 61 | // use it. | 
|---|
| 62 | // return all(a == b); | 
|---|
| 63 |  | 
|---|
| 64 | for (int i=0; i < a.length(); ++i) | 
|---|
| 65 | { | 
|---|
| 66 | if (a[i] != b[i]) | 
|---|
| 67 | { | 
|---|
| 68 | BZ_DEBUG_MESSAGE("Incompatible shapes detected: " << endl | 
|---|
| 69 | << a << endl << b << endl); | 
|---|
| 70 | return _bz_false; | 
|---|
| 71 | } | 
|---|
| 72 | } | 
|---|
| 73 |  | 
|---|
| 74 | return _bz_true; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | BZ_NAMESPACE_END | 
|---|
| 78 |  | 
|---|
| 79 | #endif | 
|---|