Loading src/TNL/Containers/Expressions/Comparison.h +7 −7 Original line number Diff line number Diff line Loading @@ -11,7 +11,9 @@ #pragma once #include <stdexcept> #include <TNL/Assert.h> #include <TNL/TypeTraits.h> #include <TNL/Containers/Algorithms/Reduction.h> #include <TNL/Containers/Algorithms/ArrayOperations.h> Loading @@ -31,10 +33,8 @@ struct Comparison template< typename T1, typename T2, bool BothAreVectors = IsVectorType< T1 >::value && IsVectorType< T2 >::value > struct VectorComparison { }; bool BothAreVectors = IsArrayType< T1 >::value && IsArrayType< T2 >::value > struct VectorComparison; template< typename T1, typename T2 > Loading src/TNL/Containers/Expressions/ExpressionVariableType.h +10 −125 Original line number Diff line number Diff line Loading @@ -10,133 +10,18 @@ #pragma once #include <type_traits> #include <TNL/Containers/Expressions/TypeTraits.h> #include <TNL/TypeTraits.h> #include <TNL/Devices/Host.h> namespace TNL { namespace Containers { template< int Size, typename Real > class StaticVector; template< typename Real, typename Device, typename Index > class VectorView; template< typename Real, typename Device, typename Index, typename Allocator > class Vector; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedVectorView; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedVector; template< int Size, typename Real > class StaticArray; template< typename Real, typename Device, typename Index > class ArrayView; template< typename Real, typename Device, typename Index, typename Allocator > class Array; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedArrayView; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedArray; namespace Expressions { enum ExpressionVariableType { ArithmeticVariable, VectorVariable, VectorExpressionVariable, OtherVariable }; template< typename T > struct IsVectorType { static constexpr bool value = false; }; template< int Size, typename Real > struct IsVectorType< StaticVector< Size, Real > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index > struct IsVectorType< VectorView< Real, Device, Index > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Allocator > struct IsVectorType< Vector< Real, Device, Index, Allocator > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Communicator > struct IsVectorType< DistributedVectorView< Real, Device, Index, Communicator > > { static constexpr bool value = true; }; template< int Size, typename Real > struct IsVectorType< StaticArray< Size, Real > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index > struct IsVectorType< ArrayView< Real, Device, Index > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Allocator > struct IsVectorType< Array< Real, Device, Index, Allocator > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Communicator > struct IsVectorType< DistributedArrayView< Real, Device, Index, Communicator > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Communicator > struct IsVectorType< DistributedArray< Real, Device, Index, Communicator > > { static constexpr bool value = true; }; enum ExpressionVariableType { ArithmeticVariable, VectorExpressionVariable, OtherVariable }; template< typename T, bool IsArithmetic = std::is_arithmetic< T >::value, bool IsVector = IsVectorType< T >::value || IsExpressionTemplate< T >::value > bool IsVector = HasSubscriptOperator< T >::value > struct ExpressionVariableTypeGetter { static constexpr ExpressionVariableType value = OtherVariable; Loading @@ -156,18 +41,18 @@ struct ExpressionVariableTypeGetter< T, false, true > //// // Non-static expression templates might be passed on GPU, for example. In this // case, we cannot store ET operands using references but we nee to make copies. // case, we cannot store ET operands using references but we need to make copies. template< typename T, typename Device > struct OperandType { using type = typename std::add_const< typename std::remove_reference< T >::type >::type; using type = std::add_const_t< std::remove_reference_t< T > >; }; template< typename T > struct OperandType< T, Devices::Host > { using type = typename std::add_const< typename std::add_lvalue_reference< T >::type >::type; using type = std::add_const_t< std::add_lvalue_reference_t< T > >; }; } // namespace Expressions Loading Loading
src/TNL/Containers/Expressions/Comparison.h +7 −7 Original line number Diff line number Diff line Loading @@ -11,7 +11,9 @@ #pragma once #include <stdexcept> #include <TNL/Assert.h> #include <TNL/TypeTraits.h> #include <TNL/Containers/Algorithms/Reduction.h> #include <TNL/Containers/Algorithms/ArrayOperations.h> Loading @@ -31,10 +33,8 @@ struct Comparison template< typename T1, typename T2, bool BothAreVectors = IsVectorType< T1 >::value && IsVectorType< T2 >::value > struct VectorComparison { }; bool BothAreVectors = IsArrayType< T1 >::value && IsArrayType< T2 >::value > struct VectorComparison; template< typename T1, typename T2 > Loading
src/TNL/Containers/Expressions/ExpressionVariableType.h +10 −125 Original line number Diff line number Diff line Loading @@ -10,133 +10,18 @@ #pragma once #include <type_traits> #include <TNL/Containers/Expressions/TypeTraits.h> #include <TNL/TypeTraits.h> #include <TNL/Devices/Host.h> namespace TNL { namespace Containers { template< int Size, typename Real > class StaticVector; template< typename Real, typename Device, typename Index > class VectorView; template< typename Real, typename Device, typename Index, typename Allocator > class Vector; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedVectorView; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedVector; template< int Size, typename Real > class StaticArray; template< typename Real, typename Device, typename Index > class ArrayView; template< typename Real, typename Device, typename Index, typename Allocator > class Array; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedArrayView; template< typename Real, typename Device, typename Index, typename Communicator > class DistributedArray; namespace Expressions { enum ExpressionVariableType { ArithmeticVariable, VectorVariable, VectorExpressionVariable, OtherVariable }; template< typename T > struct IsVectorType { static constexpr bool value = false; }; template< int Size, typename Real > struct IsVectorType< StaticVector< Size, Real > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index > struct IsVectorType< VectorView< Real, Device, Index > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Allocator > struct IsVectorType< Vector< Real, Device, Index, Allocator > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Communicator > struct IsVectorType< DistributedVectorView< Real, Device, Index, Communicator > > { static constexpr bool value = true; }; template< int Size, typename Real > struct IsVectorType< StaticArray< Size, Real > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index > struct IsVectorType< ArrayView< Real, Device, Index > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Allocator > struct IsVectorType< Array< Real, Device, Index, Allocator > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Communicator > struct IsVectorType< DistributedArrayView< Real, Device, Index, Communicator > > { static constexpr bool value = true; }; template< typename Real, typename Device, typename Index, typename Communicator > struct IsVectorType< DistributedArray< Real, Device, Index, Communicator > > { static constexpr bool value = true; }; enum ExpressionVariableType { ArithmeticVariable, VectorExpressionVariable, OtherVariable }; template< typename T, bool IsArithmetic = std::is_arithmetic< T >::value, bool IsVector = IsVectorType< T >::value || IsExpressionTemplate< T >::value > bool IsVector = HasSubscriptOperator< T >::value > struct ExpressionVariableTypeGetter { static constexpr ExpressionVariableType value = OtherVariable; Loading @@ -156,18 +41,18 @@ struct ExpressionVariableTypeGetter< T, false, true > //// // Non-static expression templates might be passed on GPU, for example. In this // case, we cannot store ET operands using references but we nee to make copies. // case, we cannot store ET operands using references but we need to make copies. template< typename T, typename Device > struct OperandType { using type = typename std::add_const< typename std::remove_reference< T >::type >::type; using type = std::add_const_t< std::remove_reference_t< T > >; }; template< typename T > struct OperandType< T, Devices::Host > { using type = typename std::add_const< typename std::add_lvalue_reference< T >::type >::type; using type = std::add_const_t< std::add_lvalue_reference_t< T > >; }; } // namespace Expressions Loading