source: XMLIO_V2/external/include/blitz/array/misc.cc @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

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