Commit bb877f91 authored by David Moxey's avatar David Moxey

First pass that removes expression templates

parent bca80364
......@@ -177,10 +177,6 @@ IF (${CMAKE_COMPILER_IS_GNUCXX})
MARK_AS_ADVANCED(NEKTAR_ENABLE_PROFILE)
ENDIF (${CMAKE_COMPILER_IS_GNUCXX})
OPTION(NEKTAR_USE_EXPRESSION_TEMPLATES
"Use Expression templates." OFF)
MARK_AS_ADVANCED(NEKTAR_USE_EXPRESSION_TEMPLATES)
# BLAS Support
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SYSTEM_BLAS_LAPACK
"Use the system provided blas and lapack libraries" ON
......@@ -282,10 +278,6 @@ IF( NEKTAR_USE_TINYXML_STL )
ADD_DEFINITIONS( -DTIXML_USE_STL)
ENDIF( NEKTAR_USE_TINYXML_STL )
IF( NEKTAR_USE_EXPRESSION_TEMPLATES )
ADD_DEFINITIONS(-DNEKTAR_USE_EXPRESSION_TEMPLATES -DNEKTAR_USING_CMAKE)
ENDIF( NEKTAR_USE_EXPRESSION_TEMPLATES )
IF( NEKTAR_USE_MEMORY_POOLS )
ADD_DEFINITIONS(-DNEKTAR_MEMORY_POOL_ENABLED)
ELSE( NEKTAR_USE_MEMORY_POOLS )
......
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_ASSOCIATIVE_TRAITS_HPP
#define EXPRESSION_TEMPLATES_ASSOCIATIVE_TRAITS_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/Operators.hpp>
#include <boost/type_traits.hpp>
namespace expt
{
/// \brief Traits class indicating whether an operator is associative.
///
/// Given an expression T1 Op1 (T2 Op2 X), where T1 and T2 are data types
/// in an expression, Op1 and Op2 are the operators in the expression, and
/// X is an arbitrary expression, AssociativeTraits initicates whether
/// the expression can be rewritten using the associative property. If
/// it can, then the expression T1 Op1 (T2 Op2 X) can be rewritten as
/// (T1 Op1 T2) Op2 X.
///
/// This trait defaults to false. The class should be specialized for
/// all combinations of operators and data types that are associative.
template<typename T1, typename Op1, typename T2, typename Op2>
struct AssociativeTraits : public boost::false_type {};
/// \brief Specialization indicating multiplication is usually associative.
template<typename T>
struct AssociativeTraits<T, MultiplyOp, T, MultiplyOp> : public boost::true_type {};
/// \brief Specialization indicating addition is usually associative.
template<typename T>
struct AssociativeTraits<T, AddOp, T, AddOp> : public boost::true_type {};
}
#endif // NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_ASSOCIATIVE_TRAITS_HPP
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_ASSOCIATIVE_TRANSFORM_HPP
#define EXPRESSION_TEMPLATES_ASSOCIATIVE_TRANSFORM_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/Operators.hpp>
#include <ExpressionTemplates/AssociativeTraits.hpp>
#include <ExpressionTemplates/Node.hpp>
#include <boost/utility/enable_if.hpp>
namespace expt
{
/// \brief Transforms the given tree using an associative transform if appropriate.
///
/// Given a tree of the form A Op (B Op C), if Op is associative, this metafunction
/// transforms it to (A Op B) Op C.
template<typename NodeType, typename enabled = void>
struct AssociativeTransform
{
typedef NodeType TransformedNodeType;
};
template<typename LhsNodeType, typename OpType, typename R1, typename ROp, typename R2>
struct AssociativeTransform<Node<LhsNodeType, OpType, Node<R1, ROp, R2> >,
typename boost::enable_if
<
AssociativeTraits
<
typename LhsNodeType::ResultType,
OpType,
typename R1::ResultType,
ROp
>
>::type>
{
typedef Node<Node<LhsNodeType, OpType, R1>, ROp, R2> TransformedNodeType;
};
/// \brief Transforms the given tree using an associative transform if appropriate.
///
/// Given a tree of the form (A Op B) Op C, if Op is associative, this metafunction
/// transforms it to A Op (B Op C).
template<typename NodeType, typename enabled = void>
struct InverseAssociativeTransform
{
typedef NodeType TransformedNodeType;
};
template<typename L1, typename LOp, typename L2, typename OpType, typename RhsNodeType>
struct InverseAssociativeTransform<Node<Node<L1, LOp, L2>, OpType, RhsNodeType >,
typename boost::enable_if
<
AssociativeTraits
<
typename L1::ResultType,
LOp,
typename L2::ResultType,
OpType
>
>::type>
{
typedef Node<L1, LOp, Node<L2, OpType, RhsNodeType> > TransformedNodeType;
};
}
#endif //NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_ASSOCIATIVE_TRANSFORM_HPP
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_BACKWARD_ASSOCIATIVE_TRANSFORM_HPP
#define EXPRESSION_TEMPLATES_BACKWARD_ASSOCIATIVE_TRANSFORM_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
namespace expt
{
/// \brief Reverses a forward transform.
///
/// Given a tree of type A + (-B), where +/- are arbitrary inverse operators,
/// and A and B are arbitrary expressions, this transform produces A - B.
/// This transform does nothing if these conditions are not met.
template<typename NodeType, typename IndicesType, unsigned int StartIndex, typename enbled = void>
struct BackwardInverseTransform;
////////////////////////
// Constant
////////////////////////
template<typename DataType, typename IndicesType, unsigned int StartIndex>
struct BackwardInverseTransform<Node<DataType, void, void>, IndicesType, StartIndex >
{
typedef Node<DataType, void, void> TransformedNodeType;
typedef IndicesType TransformedIndicesType;
};
/////////////////////////////////////////////////////////
// Unary Node
/////////////////////////////////////////////////////////
template<typename ChildNodeType, typename UnaryOperatorType, typename IndicesType, unsigned int StartIndex>
struct BackwardInverseTransform<Node<ChildNodeType, UnaryOperatorType, void>, IndicesType, StartIndex >
{
typedef typename BackwardInverseTransform<ChildNodeType, IndicesType, StartIndex>::TransformedNodeType TransformedChildType;
typedef typename BackwardInverseTransform<ChildNodeType, IndicesType, StartIndex>::TransformedIndicesType TransformedIndicesType;
typedef Node<TransformedChildType, UnaryOperatorType, void> TransformedNodeType;
};
/////////////////////////////////////////////////////////
// Binary Node
/////////////////////////////////////////////////////////
namespace impl
{
template<typename LhsType, typename OpType, typename RhsType, typename IndicesType, unsigned int StartIndex, typename enabled = void>
struct BinaryBackwardInverseTransform
{
static const unsigned int RhsIndex = StartIndex + RhsType::TotalCount;
typedef typename BackwardInverseTransform<LhsType, IndicesType, StartIndex>::TransformedNodeType TransformedLhsType;
typedef typename BackwardInverseTransform<LhsType, IndicesType, StartIndex>::TransformedIndicesType Indices0;
typedef typename BackwardInverseTransform<RhsType, Indices0, RhsIndex>::TransformedNodeType TransformedRhsType;
typedef typename BackwardInverseTransform<RhsType, Indices0, RhsIndex>::TransformedIndicesType TransformedIndicesType;
typedef Node<TransformedLhsType, OpType, TransformedRhsType> TransformedNodeType;
};
template<typename LhsType, typename OpType, typename RhsType, typename enabled = void>
struct IsFixupNode : public boost::false_type {};
template<typename L, typename LOp, typename OpType, typename RhsType>
struct IsFixupNode<Node<L, LOp, void>, OpType, RhsType,
typename boost::enable_if
<
boost::mpl::and_
<
boost::is_same<LOp, typename InverseOperatorTypeTraits<OpType>::UnaryInversionType>,
CommutativeTraits<typename Node<L, LOp, void>::ResultType, OpType, typename RhsType::ResultType>,
IsConstantNode<L>
>
>::type> : public boost::true_type {};
template<typename LhsType, typename OpType, typename R1, typename ROp, typename IndicesType, unsigned int StartIndex>
struct BinaryBackwardInverseTransform<LhsType, OpType, Node<R1, ROp, void>, IndicesType, StartIndex,
typename boost::enable_if
<
boost::mpl::and_
<
boost::is_same<ROp, typename InverseOperatorTypeTraits<OpType>::UnaryInversionType>,
IsUnaryNode<Node<R1, ROp, void> >,
boost::mpl::not_<IsFixupNode<LhsType, OpType, Node<R1, ROp, void> > >
>
>::type>
{
static const unsigned int RhsIndex = StartIndex + R1::TotalCount;
typedef typename InverseOperatorTypeTraits<OpType>::InverseOpType InvertedOpType;
typedef typename BackwardInverseTransform<LhsType, IndicesType, StartIndex>::TransformedNodeType TransformedLhsType;
typedef typename BackwardInverseTransform<LhsType, IndicesType, StartIndex>::TransformedIndicesType Indices0;
typedef typename BackwardInverseTransform<R1, Indices0, RhsIndex>::TransformedNodeType TransformedRhsType;
typedef typename BackwardInverseTransform<R1, Indices0, RhsIndex>::TransformedIndicesType TransformedIndicesType;
typedef Node<TransformedLhsType, InvertedOpType, TransformedRhsType> TransformedNodeType;
};
// This case corresponds to something like
// (-A) + BC. The forward inverse transform creates negative nodes to maximize the
// size of clusters, but can create this situation where the negated node is moved to
// the far left side, even though optimally the tree should be BC-A.
// This fixes that up.
template<typename L, typename LOp, typename OpType, typename RhsType, typename IndicesType, unsigned int StartIndex>
struct BinaryBackwardInverseTransform<Node<L, LOp, void>, OpType, RhsType, IndicesType, StartIndex,
typename boost::enable_if
<
IsFixupNode<Node<L, LOp, void>, OpType, RhsType>
>::type>
{
static const unsigned int RhsIndex = StartIndex + RhsType::TotalCount;
typedef typename InverseOperatorTypeTraits<OpType>::InverseOpType InvertedOpType;
typedef Node<L, LOp, void> LhsType;
typedef typename BackwardInverseTransform<RhsType, IndicesType, RhsIndex>::TransformedNodeType TransformedRhsType;
typedef typename BackwardInverseTransform<RhsType, IndicesType, RhsIndex>::TransformedIndicesType Indices0;
typedef Node<LhsType, OpType, TransformedRhsType> NodeType0;
typedef typename CommutativeTransform<NodeType0, Indices0, StartIndex>::TransformedIndicesType TransformedIndicesType;
typedef Node<TransformedRhsType, InvertedOpType, L> TransformedNodeType;
};
}
template<typename LhsType, typename OpType, typename RhsType, typename IndicesType, unsigned int StartIndex>
struct BackwardInverseTransform<Node<LhsType, OpType, RhsType>, IndicesType, StartIndex >
{
typedef typename impl::BinaryBackwardInverseTransform<LhsType, OpType, RhsType, IndicesType, StartIndex >::TransformedNodeType TransformedNodeType;
typedef typename impl::BinaryBackwardInverseTransform<LhsType, OpType, RhsType,IndicesType, StartIndex>::TransformedIndicesType TransformedIndicesType;
};
}
#endif //NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_BACKWARD_ASSOCIATIVE_TRANSFORM_HPP
\ No newline at end of file
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_COMMUTATIVE_TRAITS_HPP
#define EXPRESSION_TEMPLATES_COMMUTATIVE_TRAITS_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/Operators.hpp>
#include <boost/type_traits.hpp>
namespace expt
{
/// \brief Traits class indicating whether an operator is commutative.
///
/// Given an expression T1 Op T2, where T1 and T2 are data types
/// in an expression, and Op is the operator, CommutativeTraits initicates whether
/// the expression can be rewritten using the commutative property. If
/// it can, then the expression T1 Op T2 and be rewritten as T2 Op T1.
///
/// This trait defaults to false. The class should be specialized for
/// all combinations of operators and data types that are commutative.
template<typename L, typename Op, typename R, typename enabled = void>
struct CommutativeTraits : public boost::false_type {};
/// \brief Specialization indicating that addition is usually commutative.
template<typename R, typename T>
struct CommutativeTraits<R, AddOp, T> : public boost::true_type {};
/// \brief Specialization indicating that multiplication is usually commutative.
template<typename R, typename T>
struct CommutativeTraits<R, MultiplyOp, T> : public boost::true_type {};
}
#endif //NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_COMMUTATIVE_TRAITS_HPP
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_COMMUTATIVE_TRANSFORM_HPP
#define EXPRESSION_TEMPLATES_COMMUTATIVE_TRANSFORM_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/Node.hpp>
#include <ExpressionTemplates/CommutativeTraits.hpp>
#include <boost/utility/enable_if.hpp>
namespace expt
{
/// \brief Utility metafunction to swap indices.
///
/// For a given sequence, this metafunction swaps the segment [start, partition) with
/// [partition, end).
///
/// For example, with the sequence 0, 1, 2, 3, 4, 5, start = 2, partition =4, end = 6, the
/// result of this metafunction is the sequence 0, 1, 4, 5, 2, 3.
template<typename InputSequence, unsigned int start, unsigned int partition, unsigned int end>
struct Swap
{
typedef typename boost::mpl::begin<InputSequence>::type Begin;
typedef Begin PrefixStart;
typedef typename boost::mpl::advance_c< Begin, start >::type PrefixEnd;
typedef PrefixEnd FirstPartitionStart;
typedef typename boost::mpl::advance_c< Begin, partition>::type FirstPartitionEnd;
typedef FirstPartitionEnd SecondPartitionStart;
typedef typename boost::mpl::advance_c<Begin, end>::type SecondPartitionEnd;
typedef SecondPartitionEnd SuffixStart;
typedef typename boost::mpl::end<InputSequence>::type SuffixEnd;
typedef typename boost::mpl::iterator_range<PrefixStart, PrefixEnd>::type Prefix;
typedef typename boost::mpl::iterator_range<FirstPartitionStart, FirstPartitionEnd>::type FirstPartition;
typedef typename boost::mpl::iterator_range<SecondPartitionStart, SecondPartitionEnd>::type SecondPartition;
typedef typename boost::mpl::iterator_range<SuffixStart, SuffixEnd>::type Suffix;
typedef typename boost::mpl::joint_view<Prefix, SecondPartition>::type View1;
typedef typename boost::mpl::joint_view<FirstPartition, Suffix>::type View2;
typedef typename boost::mpl::joint_view<View1, View2>::type type;
};
/// \brief Performs a commutative transform on a node if the operator is commutative.
template<typename NodeType, typename IndicesType, unsigned int IndexStart, typename enabled=void>
struct CommutativeTransform
{
typedef NodeType TransformedNodeType;
typedef IndicesType TransformedIndicesType;
};
template<typename Left, typename Op, typename Right, typename IndicesType, unsigned int IndexStart>
struct CommutativeTransform<Node<Left, Op, Right>, IndicesType, IndexStart,
typename boost::enable_if<CommutativeTraits<typename Left::ResultType, Op, typename Right::ResultType> >::type>
{
typedef Node<Left, Op, Right> BaseNode;
typedef Node<Right, Op, Left> TransformedNodeType;
static const unsigned int partition = IndexStart + Left::TotalCount;
static const unsigned int end = IndexStart + Left::TotalCount + Right::TotalCount;
typedef typename Swap<IndicesType, IndexStart, partition, end>::type TransformedIndicesType;
};
}
#endif //NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_COMMUTATIVE_TRANSFORM_HPP
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_CREATE_FROM_TREE_HPP
#define EXPRESSION_TEMPLATES_CREATE_FROM_TREE_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
namespace expt
{
/// \brief Creates an accumulator to be used to evaluate the given tree.
///
/// During expression evaluation, there are times when the creation of a
/// temporary is unavoidable. In these cases, we need to create an object
/// of the appropriate data type to be used during evaluation.
///
/// In some cases, the accumulator needs information from the tree. An example
/// is a tree using matrices, in which case the accumulator needs to know the
/// expected size of the result to size memory appropriately. When this occurs,
/// the user is responsible for creating a specialized version of CreateFromTree
/// to create the accumulator appropriately.
template<typename DataType, typename NodeType, typename Indices, unsigned int StartIndex>
struct CreateFromTree
{
template<typename ArgVectorType>
static DataType Apply(const ArgVectorType& tree)
{
return DataType();
}
};
}
#endif //NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_CREATE_FROM_TREE_HPP
\ No newline at end of file
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_HPP
#define EXPRESSION_TEMPLATES_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/AssociativeTraits.hpp>
#include <ExpressionTemplates/AssociativeTransform.hpp>
#include <ExpressionTemplates/CommutativeTraits.hpp>
#include <ExpressionTemplates/CommutativeTransform.hpp>
#include <ExpressionTemplates/ExpressionEvaluator.hpp>
#include <ExpressionTemplates/Node.hpp>
#include <ExpressionTemplates/Operators.hpp>
#include <ExpressionTemplates/RemoveAllUnecessaryTemporaries.hpp>
#include <ExpressionTemplates/InvertNode.hpp>
#include <ExpressionTemplates/ForwardInverseTransform.hpp>
#include <ExpressionTemplates/BackwardInverseTransform.hpp>
#include <ExpressionTemplates/PushDownUnaryNodes.hpp>
#include <ExpressionTemplates/CreateFromTree.hpp>
#endif
#endif
\ No newline at end of file
///////////////////////////////////////////////////////////////////////////////
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_FORWARD_ASSOCIATIVE_TRANSFORM_HPP
#define EXPRESSION_TEMPLATES_FORWARD_ASSOCIATIVE_TRANSFORM_HPP