OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Assign.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 *
7 * Visit http://people.web.psi.ch/adelmann/ for more details
8 *
9 ***************************************************************************/
10
11#ifndef ASSIGN_H
12#define ASSIGN_H
13
14// include files
16#include <complex>
17
18// forward declarations
19template<class T, unsigned Dim> class BareField;
20template<class T, unsigned Dim> class LField;
21template<class T, unsigned Dim, unsigned Brackets> class IndexedBareField;
22
23// a debugging output message macro for assign functions. This is
24// only enabled if you specificall add -DDEBUG_ASSIGN somewhere.
25#ifdef DEBUG_ASSIGN
26#define ASSIGNMSG(x) x
27#else
28#define ASSIGNMSG(x)
29#endif
30
31
33//
34// Currently, some of the assignment algorithms depend
35// on knowing that there is just one Field on the rhs.
36// We detect these here by building a simple tag class ExprTag
37// that has a bool template argument. The arg is true
38// if the the assign should deal with general expressions,
39// and false if it can use the special purpose single field version.
40//
41// This wouldn't be needed if we had partial specialization,
42// but this will disambiguate expressions even without it.
43//
45
46template <bool IsExpr>
48{
49};
50
52
53// BareField = Expression
54template<class T, unsigned Dim, class RHS, class OP>
55void
56assign(const BareField<T,Dim>& a, RHS b, OP op, ExprTag<true>);
57
58// IndexedBareField = Expression
59template<class T1, unsigned Dim, class RHS, class OP>
60void
62 bool fillGC); // tjw added fillGC 12/16/1997 new BC hack
63
64// IndexedBareField = Expression
65template<class T1, unsigned Dim, class RHS, class OP>
66inline void
68 assign(a, b, op, et, true);
69}
70
71// Component = Expression
72template<class A, class RHS, class OP, class Tag, class TP>
73void
74assign(PETE_TUTree<OpParens<TP>,A> lhs, RHS rhs, OP op, Tag,
75 bool fillGC=true); // tjw added fillGC 12/16/1997 new BC hack
76
77// BareField = BareField, with communication.
78template<class T1, unsigned D1, class RHS, class Op>
79void
80assign(const BareField<T1,D1>& lhs, RHS rhs, Op op, ExprTag<false>);
81
82// IndexedBareField = IndexedBareField, different dimensions.
83template<class T1, unsigned D1, class RHS, class Op>
84void
86
88
89// Expression = constant;
90template<class T, unsigned D, class OP>
91inline void
93{
95}
96
97template<class T, unsigned D, class OP>
98inline void
100{
102}
103
105
106template<class T> struct IsExprTrait { enum { IsExpr = T::IsExpr } ; };
107template<> struct IsExprTrait<double> { enum { IsExpr = 1 }; };
108template<> struct IsExprTrait<std::complex<double>> { enum { IsExpr = 1 }; };
109template<> struct IsExprTrait<float> { enum { IsExpr = 1 }; };
110template<> struct IsExprTrait<short> { enum { IsExpr = 1 }; };
111template<> struct IsExprTrait<int> { enum { IsExpr = 1 }; };
112template<> struct IsExprTrait<long> { enum { IsExpr = 1 }; };
113template<> struct IsExprTrait<Index> { enum { IsExpr = 1 }; };
114
115#define ASSIGNMENT_OPERATORS(FUNC,OP) \
116 \
117template<class LHS, class RHS> \
118inline void \
119FUNC(const PETE_Expr<LHS>& lhs, const PETE_Expr<RHS>& rhs) \
120{ \
121 assign(lhs.PETE_unwrap(), rhs.PETE_unwrap().MakeExpression(), \
122 OP(),ExprTag< IsExprTrait<RHS>::IsExpr >()); \
123} \
124 \
125template<class T, unsigned D> \
126inline void \
127FUNC(const IndexedBareField<T,D,D>& lhs, const T& rhs) \
128{ \
129 assign(lhs,PETE_Scalar<T>(rhs), OP(),ExprTag<true>(),true); \
130} \
131 \
132template<class T, unsigned D> \
133inline void \
134FUNC(const BareField<T,D>& lhs, const T& rhs) \
135{ \
136 assign(lhs,PETE_Scalar<T>(rhs),OP(),ExprTag<true>()); \
137} \
138 \
139template<class A, class TP> \
140inline void \
141FUNC(const PETE_TUTree<OpParens<TP>,A>& lhs, const bool& rhs) \
142{ \
143 assign(lhs,PETE_Scalar<bool>(rhs),OP(),ExprTag<true>()); \
144} \
145template<class A, class TP> \
146inline void \
147FUNC(const PETE_TUTree<OpParens<TP>,A>& lhs, const char& rhs) \
148{ \
149 assign(lhs,PETE_Scalar<char>(rhs),OP(),ExprTag<true>()); \
150} \
151template<class A, class TP> \
152inline void \
153FUNC(const PETE_TUTree<OpParens<TP>,A>& lhs, const int& rhs) \
154{ \
155 assign(lhs,PETE_Scalar<int>(rhs),OP(),ExprTag<true>()); \
156} \
157template<class A,class TP> \
158inline void \
159FUNC(const PETE_TUTree<OpParens<TP>,A>& lhs, const float& rhs) \
160{ \
161 assign(lhs,PETE_Scalar<float>(rhs),OP(),ExprTag<true>()); \
162} \
163template<class A, class TP> \
164inline void \
165FUNC(const PETE_TUTree<OpParens<TP>,A>& lhs, const double& rhs) \
166{ \
167 assign(lhs,PETE_Scalar<double>(rhs),OP(),ExprTag<true>()); \
168} \
169template<class A, class TP> \
170inline void \
171FUNC(const PETE_TUTree<OpParens<TP>,A>& lhs, const std::complex<double>& rhs)\
172{ \
173 assign(lhs,PETE_Scalar<std::complex<double>>(rhs),OP(),ExprTag<true>()); \
174}
175
184
185
186// Determine whether to compress or uncompress the
187// left hand side given information about the expression.
188// This prototype is defined here because the SubField assignment
189// files need this functionality as well.
190template<class T, unsigned Dim, class A, class Op>
191bool TryCompressLHS(LField<T,Dim>&, A&, Op, const NDIndex<Dim>&);
192
193
194// Include the .cpp function definitions.
195#include "Field/Assign.hpp"
198
199#endif // ASSIGN_H
200
201/***************************************************************************
202 * $RCSfile: Assign.h,v $ $Author: adelmann $
203 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
204 * IPPL_VERSION_ID: $Id: Assign.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
205 ***************************************************************************/
const unsigned Dim
void mineq(const PETE_Expr< LHS > &lhs, const PETE_Expr< RHS > &rhs)
Definition: Assign.h:182
void assign(const BareField< T, Dim > &a, RHS b, OP op, ExprTag< true >)
void maxeq(const PETE_Expr< LHS > &lhs, const PETE_Expr< RHS > &rhs)
Definition: Assign.h:183
#define ASSIGNMENT_OPERATORS(FUNC, OP)
Definition: Assign.h:115
bool TryCompressLHS(LField< T, Dim > &, A &, Op, const NDIndex< Dim > &)
Definition: Assign.hpp:48
std::complex< double > a
MMatrix< m_complex > complex(MMatrix< double > real)
Definition: MMatrix.cpp:396
Definition: LField.h:58
Definition: Assign.h:48
Definition: Index.h:237