| 1 | #ifndef BZ_ARRAYZIP_H
 | 
|---|
| 2 | #define BZ_ARRAYZIP_H
 | 
|---|
| 3 | 
 | 
|---|
| 4 | #ifndef BZ_ARRAY_H
 | 
|---|
| 5 |  #error <blitz/array/zip.h> must be included via <blitz/array.h>
 | 
|---|
| 6 | #endif
 | 
|---|
| 7 | 
 | 
|---|
| 8 | BZ_NAMESPACE(blitz)
 | 
|---|
| 9 | 
 | 
|---|
| 10 | template<class P_component, class T1, class T2>
 | 
|---|
| 11 | struct Zip2 {
 | 
|---|
| 12 |     typedef P_component T_numtype;
 | 
|---|
| 13 | 
 | 
|---|
| 14 |     static inline T_numtype apply(T1 a, T2 b)
 | 
|---|
| 15 |     { return T_numtype(a,b); }
 | 
|---|
| 16 | 
 | 
|---|
| 17 |     template<class T_left, class T_right>
 | 
|---|
| 18 |     static inline void prettyPrint(string& str,
 | 
|---|
| 19 |         prettyPrintFormat& format, const T_left& t1,
 | 
|---|
| 20 |         const T_right& t2)
 | 
|---|
| 21 |     {
 | 
|---|
| 22 |         str += "zip(";
 | 
|---|
| 23 |         t1.prettyPrint(str, format);
 | 
|---|
| 24 |         str += ",";
 | 
|---|
| 25 |         t2.prettyPrint(str, format);
 | 
|---|
| 26 |         str += ")";
 | 
|---|
| 27 |     }
 | 
|---|
| 28 | };
 | 
|---|
| 29 | 
 | 
|---|
| 30 | template<class T_component, class T1, class T2>
 | 
|---|
| 31 | inline _bz_ArrayExpr<_bz_ArrayExprOp<_bz_typename asExpr<T1>::T_expr, 
 | 
|---|
| 32 |     _bz_typename asExpr<T2>::T_expr, Zip2<T_component, 
 | 
|---|
| 33 |     _bz_typename asExpr<T1>::T_expr::T_numtype,
 | 
|---|
| 34 |     _bz_typename asExpr<T2>::T_expr::T_numtype> > >
 | 
|---|
| 35 | zip(const T1& a, const T2& b, T_component)
 | 
|---|
| 36 | {
 | 
|---|
| 37 |     return _bz_ArrayExpr<_bz_ArrayExprOp<_bz_typename asExpr<T1>::T_expr,
 | 
|---|
| 38 |         _bz_typename asExpr<T2>::T_expr, Zip2<T_component, 
 | 
|---|
| 39 |         _bz_typename asExpr<T1>::T_expr::T_numtype,
 | 
|---|
| 40 |         _bz_typename asExpr<T2>::T_expr::T_numtype> > >(a,b);
 | 
|---|
| 41 | }
 | 
|---|
| 42 | 
 | 
|---|
| 43 | BZ_NAMESPACE_END
 | 
|---|
| 44 | 
 | 
|---|
| 45 | #endif // BZ_ARRAYZIP_H
 | 
|---|
| 46 | 
 | 
|---|