| 1 | /* | 
|---|
| 2 | * $Id: vecany.cc,v 1.1.1.1 1999-11-26 16:37:05 ansari Exp $ | 
|---|
| 3 | * | 
|---|
| 4 | * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca> | 
|---|
| 5 | * All rights reserved.  Please see <blitz/blitz.h> for terms and | 
|---|
| 6 | * conditions of use. | 
|---|
| 7 | * | 
|---|
| 8 | * $Log: not supported by cvs2svn $ | 
|---|
| 9 | // Revision 1.1.1.1  1999/04/09  17:59:01  ansari | 
|---|
| 10 | // Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99 | 
|---|
| 11 | // | 
|---|
| 12 | * Revision 1.2  1998/03/14 00:04:47  tveldhui | 
|---|
| 13 | * 0.2-alpha-05 | 
|---|
| 14 | * | 
|---|
| 15 | * Revision 1.1  1997/07/16 14:51:20  tveldhui | 
|---|
| 16 | * Update: Alpha release 0.2 (Arrays) | 
|---|
| 17 | * | 
|---|
| 18 | * Revision 1.2  1997/01/24 14:42:00  tveldhui | 
|---|
| 19 | * Periodic RCS update | 
|---|
| 20 | * | 
|---|
| 21 | */ | 
|---|
| 22 |  | 
|---|
| 23 | #ifndef BZ_VECANY_CC | 
|---|
| 24 | #define BZ_VECANY_CC | 
|---|
| 25 |  | 
|---|
| 26 | #ifndef BZ_VECGLOBS_H | 
|---|
| 27 | #error <blitz/vecany.cc> must be included via <blitz/vecglobs.h> | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | BZ_NAMESPACE(blitz) | 
|---|
| 31 |  | 
|---|
| 32 | template<class P_expr> | 
|---|
| 33 | inline _bz_bool _bz_vec_any(P_expr vector) | 
|---|
| 34 | { | 
|---|
| 35 | int length = vector._bz_suggestLength(); | 
|---|
| 36 |  | 
|---|
| 37 | if (vector._bz_hasFastAccess()) | 
|---|
| 38 | { | 
|---|
| 39 | for (int i=0; i < length; ++i) | 
|---|
| 40 | if (vector._bz_fastAccess(i)) | 
|---|
| 41 | return _bz_true; | 
|---|
| 42 | } | 
|---|
| 43 | else { | 
|---|
| 44 | for (int i=0; i < length; ++i) | 
|---|
| 45 | if (vector[i]) | 
|---|
| 46 | return _bz_true; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | return _bz_false; | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | template<class P_numtype> | 
|---|
| 53 | inline _bz_bool any(const Vector<P_numtype>& x) | 
|---|
| 54 | { | 
|---|
| 55 | return _bz_vec_any(x._bz_asVecExpr()); | 
|---|
| 56 | } | 
|---|
| 57 |  | 
|---|
| 58 | template<class P_expr> | 
|---|
| 59 | inline _bz_bool any(_bz_VecExpr<P_expr> expr) | 
|---|
| 60 | { | 
|---|
| 61 | return _bz_vec_any(expr); | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 | template<class P_numtype> | 
|---|
| 65 | inline _bz_bool any(const VectorPick<P_numtype>& x) | 
|---|
| 66 | { | 
|---|
| 67 | return _bz_vec_any(x._bz_asVecExpr()); | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | template<class P_numtype, int N_dimensions> | 
|---|
| 71 | inline _bz_bool any(const TinyVector<P_numtype, N_dimensions>& x) | 
|---|
| 72 | { | 
|---|
| 73 | return _bz_vec_any(x._bz_asVecExpr()); | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | BZ_NAMESPACE_END | 
|---|
| 77 |  | 
|---|
| 78 | #endif // BZ_VECANY_CC | 
|---|
| 79 |  | 
|---|