source: XIOS/dev/dev_olga/src/extern/blitz/include/blitz/array/misc.cc @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 4.4 KB
Line 
1/***************************************************************************
2 * blitz/array/misc.cc  Miscellaneous operators for arrays
3 *
4 * $Id$
5 *
6 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
7 *
8 * This file is a part of Blitz.
9 *
10 * Blitz is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation, either version 3
13 * of the License, or (at your option) any later version.
14 *
15 * Blitz is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
22 *
23 * Suggestions:          blitz-devel@lists.sourceforge.net
24 * Bugs:                 blitz-support@lists.sourceforge.net   
25 *
26 * For more information, please see the Blitz++ Home Page:
27 *    https://sourceforge.net/projects/blitz/
28 *
29 ****************************************************************************/
30#ifndef BZ_ARRAYMISC_CC
31#define BZ_ARRAYMISC_CC
32
33#ifndef BZ_ARRAY_H
34 #error <blitz/array/misc.cc> must be included via <blitz/array.h>
35#endif
36
37BZ_NAMESPACE(blitz)
38
39#define BZ_ARRAY_DECLARE_UOP(fn, fnobj)                                \
40template<typename T_numtype, int N_rank>                                  \
41inline                                                                 \
42_bz_ArrayExpr<_bz_ArrayExprUnaryOp<FastArrayIterator<T_numtype,N_rank>, \
43    fnobj<T_numtype> > >                                               \
44fn(const Array<T_numtype,N_rank>& array)                               \
45{                                                                      \
46    return _bz_ArrayExprUnaryOp<FastArrayIterator<T_numtype,N_rank>,   \
47        fnobj<T_numtype> >(array.beginFast());                         \
48}                                                                      \
49                                                                       \
50template<typename T_expr>                                                 \
51inline                                                                 \
52_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,              \
53    fnobj<_bz_typename T_expr::T_numtype> > >                          \
54fn(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr)                              \
55{                                                                      \
56    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,                 \
57        fnobj<_bz_typename T_expr::T_numtype> >(expr);                 \
58}                                                                     
59                                                                       
60BZ_ARRAY_DECLARE_UOP(operator!, LogicalNot)
61BZ_ARRAY_DECLARE_UOP(operator~, BitwiseNot)
62BZ_ARRAY_DECLARE_UOP(operator-, Negate)
63
64/*
65 * cast() functions, for explicit type casting
66 */
67
68template<typename T_numtype, int N_rank, typename T_cast>
69inline                                                                 
70_bz_ArrayExpr<_bz_ArrayExprUnaryOp<FastArrayIterator<T_numtype,N_rank>,   
71    Cast<T_numtype, T_cast> > >
72cast(const Array<T_numtype,N_rank>& array, T_cast)
73{                                                                     
74    return _bz_ArrayExprUnaryOp<FastArrayIterator<T_numtype,N_rank>,     
75        Cast<T_numtype,T_cast> >(array.beginFast());                           
76}                                                                     
77                                                                       
78template<typename T_expr, typename T_cast>
79inline                                                                 
80_bz_ArrayExpr<_bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,             
81    Cast<_bz_typename T_expr::T_numtype,T_cast> > >                         
82cast(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr, T_cast)
83{                                                                     
84    return _bz_ArrayExprUnaryOp<_bz_ArrayExpr<T_expr>,                 
85        Cast<_bz_typename T_expr::T_numtype,T_cast> >(expr);                 
86}                                                                     
87                                                                       
88BZ_NAMESPACE_END
89
90#endif // BZ_ARRAYMISC_CC
91
Note: See TracBrowser for help on using the repository browser.