/usr/include/blitz/array/asexpr.h is in libblitz0-dev 1:0.10-3.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | // -*- C++ -*-
/***************************************************************************
* blitz/array/asexpr.h Declaration of the asExpr helper functions
*
* $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
***************************************************************************/
#ifndef BZ_ASEXPR_H
#define BZ_ASEXPR_H
#include <blitz/et-forward.h>
#include <blitz/numtrait.h>
BZ_NAMESPACE(blitz)
// The traits class asExpr converts arbitrary things to
// expression templatable operands.
// Default to scalar.
template <typename T>
struct asExpr {
typedef _bz_ArrayExpr<_bz_ArrayExprConstant<T> > T_expr;
static T_expr getExpr(const T& x);
};
// Already an expression template term
template <typename T>
struct asExpr<_bz_ArrayExpr<T> > {
typedef _bz_ArrayExpr<T> T_expr;
static const T_expr& getExpr(const T_expr& x);
};
// Specialization of asExpr for array operands
// why doesn't it wrap iterators in an ArrayExpr?
template <typename T,int N>
struct asExpr<Array<T,N> > {
//typedef FastArrayIterator<T,N> T_expr;
typedef _bz_ArrayExpr<FastArrayIterator<T,N> > T_expr;
static T_expr getExpr(const Array<T,N>& x);
};
// Specialization of asExpr for tinyvector operands
template <typename T,int N>
struct asExpr<TinyVector<T,N> > {
typedef _bz_ArrayExpr<FastTV2Iterator<T,N> > T_expr;
static T_expr getExpr(const TinyVector<T,N>& x);
};
// Specialization of asExpr for tinymatrix operands
template <typename T,int Nr, int Nc>
struct asExpr<TinyMatrix<T,Nr, Nc> > {
typedef _bz_ArrayExpr<FastTM2Iterator<T,Nr, Nc> > T_expr;
static T_expr getExpr(const TinyMatrix<T,Nr,Nc>& x);
};
// Index placeholder
template <int N>
struct asExpr<IndexPlaceholder<N> > {
// typedef _bz_ArrayExpr<IndexPlaceholder<N> > T_expr;
typedef _bz_ArrayExpr<IndexPlaceholder<N> > T_expr;
static T_expr getExpr(const T_expr& x);
};
// the levi-civita symbol
template <>
struct asExpr<LeviCivita> {
typedef _bz_ArrayExpr<LeviCivita> T_expr;
static T_expr getExpr(T_expr x);
};
// Range
template <>
struct asExpr<Range> {
typedef _bz_ArrayExpr<Range> T_expr;
static T_expr getExpr(T_expr x);
};
// traits class that transforms ETBase subclasses into the
// ET<>-wrapped superclass and corresponding expression, but unlike
// the asExpr class it leaves POD types alone. This is necessary so
// operators on multicomponent arrays can resolve properly.
template<typename T>
struct asET {
typedef T T_wrapped;
typedef T T_expr;
};
template<typename T>
struct asET<ETBase<T> > {
typedef ETBase<typename asExpr<T>::T_expr> T_wrapped;
typedef typename asExpr<T>::T_expr T_expr;
};
template<typename T, int N>
struct asET<Array<T,N> > {
typedef ETBase<typename asExpr<Array<T,N> >::T_expr> T_wrapped;
typedef typename asExpr<Array<T,N> >::T_expr T_expr;
};
template<typename T, int N>
struct asET<TinyVector<T,N> > {
typedef ETBase<typename asExpr<TinyVector<T,N> >::T_expr> T_wrapped;
typedef typename asExpr<TinyVector<T,N> >::T_expr T_expr;
};
template<typename T, int Nr, int Nc>
struct asET<TinyMatrix<T,Nr,Nc> > {
typedef ETBase<typename asExpr<TinyMatrix<T,Nr,Nc> >::T_expr> T_wrapped;
typedef typename asExpr<TinyMatrix<T,Nr,Nc> >::T_expr T_expr;
};
// traits class that unwraps an ETBase type, otherwise leaves it untouched.
template<typename T>
struct unwrapET {
typedef T T_unwrapped;
};
template<typename T>
struct unwrapET<ETBase<T> > {
typedef T T_unwrapped;
};
// traits classes that are used to switch between an ET type or an
// unknown type. If the supplied type T is an ET type, T_selected will
// be T_ifET, otherwise T.
template<typename T, typename T_ifnotET, typename T_ifET>
struct selectET {
typedef T_ifnotET T_selected;
};
template<typename T, typename T_ifnotET, typename T_ifET>
struct selectET<ETBase<T>, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
// for binary exprs, it is more complicated. if T1 or T2 are an ET,
// T_ifET is selected, otherwise T_ifnotET.
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2 {
typedef T_ifnotET T_selected;
};
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2<ETBase<T1>, T2, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2<T1, ETBase<T2>, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2<ETBase<T1>, ETBase<T2>, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
// traits class that resolves to the ultimate numeric datatype used
// for operations on the container. This is necessary because for
// multicomponent containers we need to determine what the ultimate
// POD data type is.
template<typename T>
struct opType {
typedef T T_optype;
};
template<typename T>
struct opType<ETBase<T> > {
typedef typename opType<T>::T_optype T_optype;
};
template<typename T, int N>
struct opType<Array<T,N> > {
typedef typename opType<T>::T_optype T_optype;
};
template<typename T, int N>
struct opType<TinyVector<T,N> > {
typedef typename opType<T>::T_optype T_optype;
};
template<typename T, int Nr, int Nc>
struct opType<TinyMatrix<T,Nr,Nc> > {
typedef typename opType<T>::T_optype T_optype;
};
#ifdef BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS
// traits classes that provide the return type of operations
template <template <typename T1> class OP, typename O1>
struct BzUnaryExprResult {
typedef _bz_ArrayExpr<
_bz_ArrayExprUnaryOp<
typename asExpr<O1>::T_expr,
OP<
typename asExpr<O1>::T_expr::T_optype
>
> > T_result;
};
template <template <typename T1, typename T2> class OP,
typename O1, typename O2>
struct BzBinaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
typename asExpr<O1>::T_expr,
typename asExpr<O2>::T_expr,
OP<
typename asExpr<O1>::T_expr::T_optype,
typename asExpr<O2>::T_expr::T_optype
> > > T_result;
};
template <template <typename T1, typename T2, typename T3> class OP,
typename O1, typename O2, typename O3>
struct BzTernaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprTernaryOp<
typename asExpr<O1>::T_expr,
typename asExpr<O2>::T_expr,
typename asExpr<O3>::T_expr,
OP<
typename asExpr<O1>::T_expr::T_optype,
typename asExpr<O2>::T_expr::T_optype,
typename asExpr<O3>::T_expr::T_optype
> > > T_result;
};
template <template <typename T1, typename T2, typename T3, typename T4> class OP,
typename O1, typename O2, typename O3, typename O4>
struct BzQuaternaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprQuaternaryOp<
typename asExpr<O1>::T_expr,
typename asExpr<O2>::T_expr,
typename asExpr<O3>::T_expr,
typename asExpr<O4>::T_expr,
OP<
typename asExpr<O1>::T_expr::T_optype,
typename asExpr<O2>::T_expr::T_optype,
typename asExpr<O3>::T_expr::T_optype,
typename asExpr<O4>::T_expr::T_optype
> > > T_result;
};
template <template <typename T1, typename T2> class RED, int N, typename O1,
typename P_result = BZ_SUMTYPE(typename asExpr<O1>::T_expr::T_optype)>
struct BzReductionResult {
typedef _bz_ArrayExpr<
_bz_ArrayExprReduce<
typename asExpr<O1>::T_expr,
N,
RED<typename asExpr<O1>::T_expr::T_optype, P_result>
> > T_result;
};
template<typename O1, int N0, int N1=0, int N2=0, int N3=0, int N4=0,
int N5=0, int N6=0, int N7=0, int N8=0, int N9=0, int N10=0>
struct BzIndexmapResult {
typedef _bz_ArrayExpr<
ArrayIndexMapping<
typename asExpr<O1>::T_expr,
N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10
>
> T_result;
};
template<template <typename T> class STENCIL, typename O1>
struct BzStencilResult {
typedef _bz_ArrayExpr<
STENCIL<
typename asExpr<O1>::T_expr::T_range_result
>
> T_result;
};
template<template <typename T1, typename T2, typename T3> class STENCIL,
typename O1, typename O2, typename P_result>
struct BzBinaryStencilResult {
typedef _bz_ArrayExpr<
STENCIL<
typename asExpr<O1>::T_expr::T_range_result,
typename asExpr<O2>::T_expr::T_range_result,
P_result
> > T_result;
};
#endif /* BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS */
BZ_NAMESPACE_END
#endif
|