| [221] | 1 | /***************************************************************************
 | 
|---|
 | 2 |  * blitz/vecexprwrap.h   Vector expression templates wrapper class
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  * $Id: vecexprwrap.h,v 1.1.1.1 1999-04-09 17:59:01 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.2  1998/03/14 00:04:47  tveldhui
 | 
|---|
 | 27 |  * 0.2-alpha-05
 | 
|---|
 | 28 |  *
 | 
|---|
 | 29 |  * Revision 1.1  1997/07/16 14:51:20  tveldhui
 | 
|---|
 | 30 |  * Update: Alpha release 0.2 (Arrays)
 | 
|---|
 | 31 |  *
 | 
|---|
 | 32 |  */
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | #ifndef BZ_VECEXPRWRAP_H
 | 
|---|
 | 35 | #define BZ_VECEXPRWRAP_H
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | #ifndef BZ_BLITZ_H
 | 
|---|
 | 38 |  #include <blitz/blitz.h>
 | 
|---|
 | 39 | #endif
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 | BZ_NAMESPACE(blitz)
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 | template<class P_expr>
 | 
|---|
 | 44 | class _bz_VecExpr {
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 | public:
 | 
|---|
 | 47 |     typedef P_expr T_expr;
 | 
|---|
 | 48 |     typedef _bz_typename T_expr::T_numtype T_numtype;
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | #ifdef BZ_PASS_EXPR_BY_VALUE
 | 
|---|
 | 51 |     _bz_VecExpr(T_expr a)
 | 
|---|
 | 52 |         : iter_(a)
 | 
|---|
 | 53 |     { }
 | 
|---|
 | 54 | #else
 | 
|---|
 | 55 |     _bz_VecExpr(const T_expr& a)
 | 
|---|
 | 56 |         : iter_(a)
 | 
|---|
 | 57 |     { }
 | 
|---|
 | 58 | #endif
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | #ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
 | 
|---|
 | 61 |     _bz_VecExpr(const _bz_VecExpr<T_expr>& a)
 | 
|---|
 | 62 |         : iter_(a.iter_)
 | 
|---|
 | 63 |     { }
 | 
|---|
 | 64 | #endif
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 |     T_numtype operator[](int i) const
 | 
|---|
 | 67 |     { return iter_[i]; }
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 |     T_numtype operator()(int i) const
 | 
|---|
 | 70 |     { return iter_(i); }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 |     int length(int recommendedLength) const
 | 
|---|
 | 73 |     { return iter_.length(recommendedLength); }
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 |     enum { _bz_staticLengthCount = BZ_ENUM_CAST(P_expr::_bz_staticLengthCount),
 | 
|---|
 | 76 |            _bz_dynamicLengthCount = BZ_ENUM_CAST(P_expr::_bz_dynamicLengthCount),
 | 
|---|
 | 77 |            _bz_staticLength = BZ_ENUM_CAST(P_expr::_bz_staticLength) };
 | 
|---|
 | 78 | 
 | 
|---|
 | 79 |     int _bz_suggestLength() const
 | 
|---|
 | 80 |     { return iter_._bz_suggestLength(); }
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 |     _bz_bool _bz_hasFastAccess() const
 | 
|---|
 | 83 |     { return iter_._bz_hasFastAccess(); }
 | 
|---|
 | 84 | 
 | 
|---|
 | 85 |     T_numtype _bz_fastAccess(int i) const
 | 
|---|
 | 86 |     { return iter_._bz_fastAccess(i); }
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | private:
 | 
|---|
 | 89 |     _bz_VecExpr();
 | 
|---|
 | 90 | 
 | 
|---|
 | 91 |     T_expr iter_;
 | 
|---|
 | 92 | };
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 | BZ_NAMESPACE_END
 | 
|---|
 | 95 | 
 | 
|---|
 | 96 | #endif // BZ_VECEXPRWRAP_H
 | 
|---|