blitz
Version 1.0.2
Toggle main menu visibility
Loading...
Searching...
No Matches
shapecheck.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
/***************************************************************************
3
* blitz/shapecheck.h Functions for checking conformability of arrays
4
*
5
* $Id$
6
*
7
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
8
*
9
* This file is a part of Blitz.
10
*
11
* Blitz is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License
13
* as published by the Free Software Foundation, either version 3
14
* of the License, or (at your option) any later version.
15
*
16
* Blitz is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
20
*
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
23
*
24
* Suggestions: blitz-devel@lists.sourceforge.net
25
* Bugs: blitz-support@lists.sourceforge.net
26
*
27
* For more information, please see the Blitz++ Home Page:
28
* https://sourceforge.net/projects/blitz/
29
*
30
***************************************************************************/
31
32
#ifndef BZ_SHAPECHECK_H
33
#define BZ_SHAPECHECK_H
34
35
#include <iostream>
36
#include <
blitz/blitz.h
>
37
38
namespace
blitz
{
39
40
/*
41
* The function areShapesConformable(A,B) checks that the shapes
42
* A and B are conformable (i.e. the same size/geometry). Typically
43
* the A and B parameters are of type TinyVector<int,N_rank> and represent
44
* the extent of the arrays. It's possible that in the future jagged-edged
45
* arrays will be supported, in which case shapes may be lists
46
* of subdomains.
47
*/
48
49
template
<
typename
T_shape1,
typename
T_shape2>
50
inline
bool
areShapesConformable
(
const
T_shape1&,
const
T_shape2&)
51
{
52
// If the shape objects are different types, this means
53
// that the arrays are different ranks, or one is jagged
54
// edged, etc. In this case the two arrays are not
55
// conformable.
56
return
false
;
57
}
58
59
template
<
typename
T_shape>
60
inline
bool
areShapesConformable
(
const
T_shape&
a
,
const
T_shape&
b
)
61
{
62
// The shape objects are the same type, so compare them.
63
64
// NEEDS_WORK-- once the "all" reduction is implemented, should
65
// use it.
66
// return all(a == b);
67
68
for
(
int
i=0; i <
a
.length(); ++i)
69
{
70
if
(
a
[i] !=
b
[i])
71
{
72
BZ_DEBUG_MESSAGE(
"Incompatible shapes detected: "
<< std::endl
73
<<
a
<< std::endl <<
b
<< std::endl);
74
return
false
;
75
}
76
}
77
78
return
true
;
79
}
80
81
}
82
83
#endif
blitz.h
blitz
Definition
array-impl.h:66
blitz::b
N_length const TinyVector< T_numtype2, N_length > & b
Definition
tvecglobs.h:49
blitz::areShapesConformable
bool areShapesConformable(const T_shape1 &, const T_shape2 &)
Definition
shapecheck.h:50
blitz::a
N_length & a
Definition
tvecglobs.h:47
blitz
shapecheck.h
Generated by
1.17.0