source: XMLIO_V2/external/include/blitz/vecany.cc @ 73

Last change on this file since 73 was 73, checked in by ymipsl, 14 years ago
File size: 1.3 KB
Line 
1/*
2 * $Id: vecany.cc,v 1.3 2003/12/11 03:44:22 julianc Exp $
3 *
4 * Copyright (C) 1997 Todd Veldhuizen <tveldhui@oonumerics.org>
5 * All rights reserved.  Please see <blitz/blitz.h> for terms and
6 * conditions of use.
7 *
8 */
9
10#ifndef BZ_VECANY_CC
11#define BZ_VECANY_CC
12
13#ifndef BZ_VECGLOBS_H
14 #error <blitz/vecany.cc> must be included via <blitz/vecglobs.h>
15#endif
16
17BZ_NAMESPACE(blitz)
18
19template<typename P_expr>
20inline bool _bz_vec_any(P_expr vector)
21{
22    int length = vector._bz_suggestLength();
23
24    if (vector._bz_hasFastAccess())
25    {
26        for (int i=0; i < length; ++i)
27            if (vector._bz_fastAccess(i))
28                return true;
29    }
30    else {
31        for (int i=0; i < length; ++i)
32            if (vector[i])
33                return true;
34    }
35
36    return false;
37}
38
39template<typename P_numtype>
40inline bool any(const Vector<P_numtype>& x)
41{
42    return _bz_vec_any(x._bz_asVecExpr());
43}
44
45template<typename P_expr>
46inline bool any(_bz_VecExpr<P_expr> expr)
47{
48    return _bz_vec_any(expr);
49}
50
51template<typename P_numtype>
52inline bool any(const VectorPick<P_numtype>& x)
53{
54    return _bz_vec_any(x._bz_asVecExpr());
55}
56
57template<typename P_numtype, int N_dimensions>
58inline bool any(const TinyVector<P_numtype, N_dimensions>& x)
59{
60    return _bz_vec_any(x._bz_asVecExpr());
61}
62
63BZ_NAMESPACE_END
64
65#endif // BZ_VECANY_CC
66
Note: See TracBrowser for help on using the repository browser.