Loading src/Python/pytnl/tnl_tuple_conversion.h +5 −5 Original line number Diff line number Diff line Loading @@ -13,14 +13,14 @@ namespace pybind11 { namespace detail { struct _tnl_tuple_caster { using Value = typename std::remove_reference< decltype(ArrayType()[0]) >::type; using StdArray = std::array< Value, ArrayType::size >; using StdArray = std::array< Value, ArrayType::getSize() >; using StdArrayCaster = type_caster< StdArray >; // StdArrayCaster _caster; using value_conv = make_caster<Value>; public: // PYBIND11_TYPE_CASTER(ArrayType, StdArrayCaster::name); PYBIND11_TYPE_CASTER(ArrayType, _("Tuple[") + value_conv::name + _<false>(_(""), _("[") + _<ArrayType::size>() + _("]")) + _("]")); PYBIND11_TYPE_CASTER(ArrayType, _("Tuple[") + value_conv::name + _<false>(_(""), _("[") + _<ArrayType::getSize()>() + _("]")) + _("]")); /** * Conversion part 1 (Python -> C++): convert a PyObject into an ArrayType Loading @@ -33,14 +33,14 @@ namespace pybind11 { namespace detail { // if( ! _caster.load(src, implicit) ) // return false; // const StdArray& arr = (StdArray&) _caster; // for( int i = 0; i < ArrayType::size; i++ ) // for( int i = 0; i < ArrayType::getSize(); i++ ) // value[ i ] = arr[ i ]; // return true; if (!isinstance<tuple>(src)) return false; auto t = reinterpret_borrow<tuple>(src); if (t.size() != ArrayType::size) if (t.size() != ArrayType::getSize()) return false; size_t ctr = 0; for (auto it : t) { Loading @@ -62,7 +62,7 @@ namespace pybind11 { namespace detail { static handle cast(const ArrayType& src, return_value_policy policy, handle parent) { StdArray arr; for( int i = 0; i < ArrayType::size; i++ ) for( int i = 0; i < ArrayType::getSize(); i++ ) arr[ i ] = src[ i ]; return StdArrayCaster::cast( arr, policy, parent ); } Loading src/TNL/Containers/StaticArray.hpp +17 −17 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ namespace TNL { namespace Containers { namespace Detail { namespace detail { //// // Lambdas used together with StaticFor for static loop unrolling in the Loading Loading @@ -90,7 +90,7 @@ struct StaticArraySort< 0, 0, Value > static void exec( Value* data ) {} }; } //namespace Detail } // namespace detail template< int Size, typename Value > Loading @@ -112,21 +112,21 @@ template< int Size, typename Value > __cuda_callable__ StaticArray< Size, Value >::StaticArray( const Value v[ Size ] ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value >, data, v ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value >, data, v ); } template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >::StaticArray( const Value& v ) { StaticFor< 0, Size >::exec( Detail::assignValueLambda< Value >, data, v ); StaticFor< 0, Size >::exec( detail::assignValueLambda< Value >, data, v ); } template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >::StaticArray( const StaticArray< Size, Value >& v ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value >, data, v.getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value >, data, v.getData() ); } template< int Size, typename Value > Loading Loading @@ -247,7 +247,7 @@ template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >& StaticArray< Size, Value >::operator=( const StaticArray< Size, Value >& array ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value >, data, array.getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value >, data, array.getData() ); return *this; } Loading @@ -256,7 +256,7 @@ template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >& StaticArray< Size, Value >::operator=( const Array& array ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value, typename Array::ValueType >, data, array.getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value, typename Array::ValueType >, data, array.getData() ); return *this; } Loading @@ -265,7 +265,7 @@ template< int Size, typename Value > __cuda_callable__ inline bool StaticArray< Size, Value >::operator==( const Array& array ) const { return Detail::StaticArrayComparator< Size, Value, typename Array::ValueType, 0 >::EQ( *this, array ); return detail::StaticArrayComparator< Size, Value, typename Array::ValueType, 0 >::EQ( *this, array ); } template< int Size, typename Value > Loading @@ -283,7 +283,7 @@ StaticArray< Size, Value >:: operator StaticArray< Size, OtherValue >() const { StaticArray< Size, OtherValue > aux; StaticFor< 0, Size >::exec( Detail::assignArrayLambda< OtherValue, Value >, aux.getData(), data ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< OtherValue, Value >, aux.getData(), data ); return aux; } Loading @@ -291,7 +291,7 @@ template< int Size, typename Value > __cuda_callable__ inline void StaticArray< Size, Value >::setValue( const ValueType& val ) { StaticFor< 0, Size >::exec( Detail::assignValueLambda< Value >, data, val ); StaticFor< 0, Size >::exec( detail::assignValueLambda< Value >, data, val ); } template< int Size, typename Value > Loading @@ -311,7 +311,7 @@ bool StaticArray< Size, Value >::load( File& file) template< int Size, typename Value > void StaticArray< Size, Value >::sort() { Detail::StaticArraySort< Size - 1, 0, Value >::exec( data ); detail::StaticArraySort< Size - 1, 0, Value >::exec( data ); } template< int Size, typename Value > Loading src/TNL/Containers/StaticVector.h +1 −4 Original line number Diff line number Diff line Loading @@ -29,9 +29,6 @@ class StaticVector : public StaticArray< Size, Real > public: using RealType = Real; using IndexType = int; using ThisType = StaticVector< Size, Real >; constexpr static int size = Size; using StaticArray< Size, Real >::getSize; //using StaticArray< Size, Real >::operator ==; Loading src/TNL/Containers/StaticVector.hpp +7 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ namespace TNL { namespace Containers { namespace Detail { namespace detail { //// // Lambdas used together with StaticFor for static loop unrolling in the Loading @@ -31,7 +31,7 @@ auto subtractVectorLambda = [] __cuda_callable__ ( int i, LeftReal* data, const template< typename LeftReal, typename RightReal = LeftReal > auto scalarMultiplicationLambda = [] __cuda_callable__ ( int i, LeftReal* data, const RightReal v ) { data[ i ] *= v; }; } //namespace Detail } // namespace detail template< int Size, typename Real > __cuda_callable__ Loading Loading @@ -138,7 +138,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator += ( const StaticVector& v ) { StaticFor< 0, Size >::exec( Detail::addVectorLambda< Real >, this->getData(), v.getData() ); StaticFor< 0, Size >::exec( detail::addVectorLambda< Real >, this->getData(), v.getData() ); return *this; } Loading @@ -146,7 +146,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator -= ( const StaticVector& v ) { StaticFor< 0, Size >::exec( Detail::subtractVectorLambda< Real >, this->getData(), v.getData() ); StaticFor< 0, Size >::exec( detail::subtractVectorLambda< Real >, this->getData(), v.getData() ); return *this; } Loading @@ -154,7 +154,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator *= ( const Real& c ) { StaticFor< 0, Size >::exec( Detail::scalarMultiplicationLambda< Real >, this->getData(), c ); StaticFor< 0, Size >::exec( detail::scalarMultiplicationLambda< Real >, this->getData(), c ); return *this; } Loading @@ -162,7 +162,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator /= ( const Real& c ) { StaticFor< 0, Size >::exec( Detail::scalarMultiplicationLambda< Real >, this->getData(), 1.0 / c ); StaticFor< 0, Size >::exec( detail::scalarMultiplicationLambda< Real >, this->getData(), 1.0 / c ); return *this; } Loading @@ -173,7 +173,7 @@ StaticVector< Size, Real >:: operator StaticVector< Size, OtherReal >() const { StaticVector< Size, OtherReal > aux; StaticFor< 0, Size >::exec( Detail::assignArrayLambda< OtherReal, Real >, aux.getData(), this->getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< OtherReal, Real >, aux.getData(), this->getData() ); return aux; } Loading src/TNL/Meshes/DistributedMeshes/Directions.h +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ public: static int getDirection(Containers::StaticVector<numerofDriection,int> directions) //takes +/- nuber of ax (i.e. (-2,+3)) { int result=0; for(int i=0;i<directions.size;i++) for(int i=0;i<directions.getSize();i++) result+=add(directions[i]); return result-1; } Loading Loading
src/Python/pytnl/tnl_tuple_conversion.h +5 −5 Original line number Diff line number Diff line Loading @@ -13,14 +13,14 @@ namespace pybind11 { namespace detail { struct _tnl_tuple_caster { using Value = typename std::remove_reference< decltype(ArrayType()[0]) >::type; using StdArray = std::array< Value, ArrayType::size >; using StdArray = std::array< Value, ArrayType::getSize() >; using StdArrayCaster = type_caster< StdArray >; // StdArrayCaster _caster; using value_conv = make_caster<Value>; public: // PYBIND11_TYPE_CASTER(ArrayType, StdArrayCaster::name); PYBIND11_TYPE_CASTER(ArrayType, _("Tuple[") + value_conv::name + _<false>(_(""), _("[") + _<ArrayType::size>() + _("]")) + _("]")); PYBIND11_TYPE_CASTER(ArrayType, _("Tuple[") + value_conv::name + _<false>(_(""), _("[") + _<ArrayType::getSize()>() + _("]")) + _("]")); /** * Conversion part 1 (Python -> C++): convert a PyObject into an ArrayType Loading @@ -33,14 +33,14 @@ namespace pybind11 { namespace detail { // if( ! _caster.load(src, implicit) ) // return false; // const StdArray& arr = (StdArray&) _caster; // for( int i = 0; i < ArrayType::size; i++ ) // for( int i = 0; i < ArrayType::getSize(); i++ ) // value[ i ] = arr[ i ]; // return true; if (!isinstance<tuple>(src)) return false; auto t = reinterpret_borrow<tuple>(src); if (t.size() != ArrayType::size) if (t.size() != ArrayType::getSize()) return false; size_t ctr = 0; for (auto it : t) { Loading @@ -62,7 +62,7 @@ namespace pybind11 { namespace detail { static handle cast(const ArrayType& src, return_value_policy policy, handle parent) { StdArray arr; for( int i = 0; i < ArrayType::size; i++ ) for( int i = 0; i < ArrayType::getSize(); i++ ) arr[ i ] = src[ i ]; return StdArrayCaster::cast( arr, policy, parent ); } Loading
src/TNL/Containers/StaticArray.hpp +17 −17 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ namespace TNL { namespace Containers { namespace Detail { namespace detail { //// // Lambdas used together with StaticFor for static loop unrolling in the Loading Loading @@ -90,7 +90,7 @@ struct StaticArraySort< 0, 0, Value > static void exec( Value* data ) {} }; } //namespace Detail } // namespace detail template< int Size, typename Value > Loading @@ -112,21 +112,21 @@ template< int Size, typename Value > __cuda_callable__ StaticArray< Size, Value >::StaticArray( const Value v[ Size ] ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value >, data, v ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value >, data, v ); } template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >::StaticArray( const Value& v ) { StaticFor< 0, Size >::exec( Detail::assignValueLambda< Value >, data, v ); StaticFor< 0, Size >::exec( detail::assignValueLambda< Value >, data, v ); } template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >::StaticArray( const StaticArray< Size, Value >& v ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value >, data, v.getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value >, data, v.getData() ); } template< int Size, typename Value > Loading Loading @@ -247,7 +247,7 @@ template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >& StaticArray< Size, Value >::operator=( const StaticArray< Size, Value >& array ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value >, data, array.getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value >, data, array.getData() ); return *this; } Loading @@ -256,7 +256,7 @@ template< int Size, typename Value > __cuda_callable__ inline StaticArray< Size, Value >& StaticArray< Size, Value >::operator=( const Array& array ) { StaticFor< 0, Size >::exec( Detail::assignArrayLambda< Value, typename Array::ValueType >, data, array.getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< Value, typename Array::ValueType >, data, array.getData() ); return *this; } Loading @@ -265,7 +265,7 @@ template< int Size, typename Value > __cuda_callable__ inline bool StaticArray< Size, Value >::operator==( const Array& array ) const { return Detail::StaticArrayComparator< Size, Value, typename Array::ValueType, 0 >::EQ( *this, array ); return detail::StaticArrayComparator< Size, Value, typename Array::ValueType, 0 >::EQ( *this, array ); } template< int Size, typename Value > Loading @@ -283,7 +283,7 @@ StaticArray< Size, Value >:: operator StaticArray< Size, OtherValue >() const { StaticArray< Size, OtherValue > aux; StaticFor< 0, Size >::exec( Detail::assignArrayLambda< OtherValue, Value >, aux.getData(), data ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< OtherValue, Value >, aux.getData(), data ); return aux; } Loading @@ -291,7 +291,7 @@ template< int Size, typename Value > __cuda_callable__ inline void StaticArray< Size, Value >::setValue( const ValueType& val ) { StaticFor< 0, Size >::exec( Detail::assignValueLambda< Value >, data, val ); StaticFor< 0, Size >::exec( detail::assignValueLambda< Value >, data, val ); } template< int Size, typename Value > Loading @@ -311,7 +311,7 @@ bool StaticArray< Size, Value >::load( File& file) template< int Size, typename Value > void StaticArray< Size, Value >::sort() { Detail::StaticArraySort< Size - 1, 0, Value >::exec( data ); detail::StaticArraySort< Size - 1, 0, Value >::exec( data ); } template< int Size, typename Value > Loading
src/TNL/Containers/StaticVector.h +1 −4 Original line number Diff line number Diff line Loading @@ -29,9 +29,6 @@ class StaticVector : public StaticArray< Size, Real > public: using RealType = Real; using IndexType = int; using ThisType = StaticVector< Size, Real >; constexpr static int size = Size; using StaticArray< Size, Real >::getSize; //using StaticArray< Size, Real >::operator ==; Loading
src/TNL/Containers/StaticVector.hpp +7 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ namespace TNL { namespace Containers { namespace Detail { namespace detail { //// // Lambdas used together with StaticFor for static loop unrolling in the Loading @@ -31,7 +31,7 @@ auto subtractVectorLambda = [] __cuda_callable__ ( int i, LeftReal* data, const template< typename LeftReal, typename RightReal = LeftReal > auto scalarMultiplicationLambda = [] __cuda_callable__ ( int i, LeftReal* data, const RightReal v ) { data[ i ] *= v; }; } //namespace Detail } // namespace detail template< int Size, typename Real > __cuda_callable__ Loading Loading @@ -138,7 +138,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator += ( const StaticVector& v ) { StaticFor< 0, Size >::exec( Detail::addVectorLambda< Real >, this->getData(), v.getData() ); StaticFor< 0, Size >::exec( detail::addVectorLambda< Real >, this->getData(), v.getData() ); return *this; } Loading @@ -146,7 +146,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator -= ( const StaticVector& v ) { StaticFor< 0, Size >::exec( Detail::subtractVectorLambda< Real >, this->getData(), v.getData() ); StaticFor< 0, Size >::exec( detail::subtractVectorLambda< Real >, this->getData(), v.getData() ); return *this; } Loading @@ -154,7 +154,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator *= ( const Real& c ) { StaticFor< 0, Size >::exec( Detail::scalarMultiplicationLambda< Real >, this->getData(), c ); StaticFor< 0, Size >::exec( detail::scalarMultiplicationLambda< Real >, this->getData(), c ); return *this; } Loading @@ -162,7 +162,7 @@ template< int Size, typename Real > __cuda_callable__ StaticVector< Size, Real >& StaticVector< Size, Real >::operator /= ( const Real& c ) { StaticFor< 0, Size >::exec( Detail::scalarMultiplicationLambda< Real >, this->getData(), 1.0 / c ); StaticFor< 0, Size >::exec( detail::scalarMultiplicationLambda< Real >, this->getData(), 1.0 / c ); return *this; } Loading @@ -173,7 +173,7 @@ StaticVector< Size, Real >:: operator StaticVector< Size, OtherReal >() const { StaticVector< Size, OtherReal > aux; StaticFor< 0, Size >::exec( Detail::assignArrayLambda< OtherReal, Real >, aux.getData(), this->getData() ); StaticFor< 0, Size >::exec( detail::assignArrayLambda< OtherReal, Real >, aux.getData(), this->getData() ); return aux; } Loading
src/TNL/Meshes/DistributedMeshes/Directions.h +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ public: static int getDirection(Containers::StaticVector<numerofDriection,int> directions) //takes +/- nuber of ax (i.e. (-2,+3)) { int result=0; for(int i=0;i<directions.size;i++) for(int i=0;i<directions.getSize();i++) result+=add(directions[i]); return result-1; } Loading