Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating 4D arrays #33

Merged
merged 3 commits into from Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion blaze_tensor/math/Array.h
Expand Up @@ -140,7 +140,7 @@ inline std::ostream& operator<<( std::ostream& os, const Array<MT>& m )

ArrayForEachGrouped(
tmp.dimensions(),
[&]( std::array< size_t, MT::num_dimensions() > const& dims ) {
[&]( std::array< size_t, MT::num_dimensions > const& dims ) {
os << std::setw( 12 ) << tmp( dims ) << " ";
},
[&]( size_t ) { os << "("; },
Expand Down
5 changes: 3 additions & 2 deletions blaze_tensor/math/dense/CustomArray.h
Expand Up @@ -46,9 +46,9 @@
#include <blaze/math/dense/CustomMatrix.h>
#include <blaze/util/EnableIf.h>

#include <blaze_tensor/math/Array.h>
#include <blaze_tensor/math/Forward.h>
#include <blaze_tensor/math/InitializerList.h>
#include <blaze_tensor/math/Array.h>
#include <blaze_tensor/math/expressions/DenseArray.h>
#include <blaze_tensor/math/SMP.h>
#include <blaze_tensor/math/typetraits/IsDenseArray.h>
Expand Down Expand Up @@ -414,6 +414,8 @@ class CustomArray
static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
//**********************************************************************************************

static constexpr size_t num_dimensions = N; // Dimensionality of the array

//**Constructors********************************************************************************
/*!\name Constructors */
//@{
Expand Down Expand Up @@ -530,7 +532,6 @@ class CustomArray
//**Utility functions***************************************************************************
/*!\name Utility functions */
//@{
inline static constexpr size_t num_dimensions() noexcept { return N; }
inline constexpr std::array< size_t, N > const& dimensions() const noexcept;
inline size_t quats() const noexcept;
inline size_t pages() const noexcept;
Expand Down
1 change: 0 additions & 1 deletion blaze_tensor/math/dense/CustomTensor.h
Expand Up @@ -3010,7 +3010,6 @@ inline void swap( CustomTensor<Type,AF,PF,RT>& a, CustomTensor<Type,AF,PF,RT>& b




//=================================================================================================
//
// HASCONSTDATAACCESS SPECIALIZATIONS
Expand Down
10 changes: 5 additions & 5 deletions blaze_tensor/math/dense/DenseArray.h
Expand Up @@ -136,7 +136,7 @@ inline auto operator==( const DenseArray<T1>& arr, T2 scalar )
using CT1 = CompositeType_t<T1>;

constexpr size_t N =
RemoveCV_t< RemoveReference_t< decltype( ~arr ) > >::num_dimensions();
RemoveCV_t< RemoveReference_t< decltype( ~arr ) > >::num_dimensions;

// Evaluation of the dense array operand
CT1 A( ~arr );
Expand Down Expand Up @@ -237,7 +237,7 @@ inline auto operator*=( DenseArray<TT>& arr, ST scalar )
{
if( IsRestricted_v<TT> ) {
constexpr size_t N =
RemoveCV_t< RemoveReference_t< decltype( ~arr ) > >::num_dimensions();
RemoveCV_t< RemoveReference_t< decltype( ~arr ) > >::num_dimensions;

std::array< size_t, N > dims{};
if( !tryMult( ~arr, dims, (~arr).dimensions(), scalar ) ) {
Expand Down Expand Up @@ -305,7 +305,7 @@ inline auto operator/=( DenseArray<TT>& arr, ST scalar )

if( IsRestricted_v<TT> ) {
constexpr size_t N =
RemoveCV_t< RemoveReference_t< decltype( ~arr ) > >::num_dimensions();
RemoveCV_t< RemoveReference_t< decltype( ~arr ) > >::num_dimensions;

std::array< size_t, N > dims{};
if( !tryDiv( ~arr, dims, (~arr).dimensions(), scalar ) ) {
Expand Down Expand Up @@ -428,7 +428,7 @@ bool isnan( const DenseArray<TT>& dm )
using CT = CompositeType_t<TT>;

constexpr size_t N =
RemoveCV_t< RemoveReference_t< decltype( ~dm ) > >::num_dimensions();
RemoveCV_t< RemoveReference_t< decltype( ~dm ) > >::num_dimensions;

CT A( ~dm ); // Evaluation of the dense array operand

Expand Down Expand Up @@ -482,7 +482,7 @@ bool isUniform_backend( const DenseArray<MT>& dm )
#endif

constexpr size_t N =
RemoveCV_t< RemoveReference_t< decltype( ~dm ) > >::num_dimensions();
RemoveCV_t< RemoveReference_t< decltype( ~dm ) > >::num_dimensions;

std::array< size_t, N > dims{};
const auto& cmp( (~dm)( dims ) );
Expand Down
8 changes: 5 additions & 3 deletions blaze_tensor/math/dense/DynamicArray.h
Expand Up @@ -60,15 +60,14 @@
#include <blaze/util/StaticAssert.h>

#include <blaze_tensor/math/Array.h>
#include <blaze_tensor/math/CustomArray.h>
//#include <blaze_tensor/math/CustomArray.h>
#include <blaze_tensor/math/Forward.h>
#include <blaze_tensor/math/InitFromValue.h>
#include <blaze_tensor/math/InitializerList.h>
#include <blaze_tensor/math/SMP.h>
#include <blaze_tensor/math/dense/DynamicTensor.h>
#include <blaze_tensor/math/dense/Transposition.h>
#include <blaze_tensor/math/expressions/DenseArray.h>
//#include <blaze_tensor/math/traits/ArraySliceTrait.h>
#include <blaze_tensor/math/traits/QuatSliceTrait.h>
#include <blaze_tensor/math/typetraits/IsNdArray.h>
#include <blaze_tensor/math/typetraits/IsDenseArray.h>
Expand Down Expand Up @@ -194,6 +193,10 @@ class DynamicArray
(shared memory parallel) assignments (both on the left-hand and right-hand side of the
assignment). */
static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;

//**********************************************************************************************

static constexpr size_t num_dimensions = N; // Dimensionality of the array
//**********************************************************************************************

//**Constructors********************************************************************************
Expand Down Expand Up @@ -312,7 +315,6 @@ class DynamicArray
//**Utility functions***************************************************************************
/*!\name Utility functions */
//@{
inline static constexpr size_t num_dimensions() noexcept { return N; }
inline constexpr std::array< size_t, N > const& dimensions() const noexcept;
inline size_t quats() const noexcept;
inline size_t pages() const noexcept;
Expand Down
35 changes: 18 additions & 17 deletions blaze_tensor/math/dense/DynamicTensor.h
Expand Up @@ -47,6 +47,7 @@
#include <blaze_tensor/math/InitializerList.h>
#include <blaze_tensor/math/SMP.h>
#include <blaze_tensor/math/Tensor.h>
//#include <blaze_tensor/math/dense/DynamicArray.h>
#include <blaze_tensor/math/dense/DynamicMatrix.h>
#include <blaze_tensor/math/dense/HybridMatrix.h>
#include <blaze_tensor/math/dense/Transposition.h>
Expand Down Expand Up @@ -3511,25 +3512,25 @@ struct PageSliceTraitEval2<

//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
//template <typename MT, size_t M>
//struct QuatSliceTraitEval2<
// MT, M,
// EnableIf_t< IsDenseArray_v<MT> &&
// ( Size_v< MT,1UL > == DefaultSize_v ||
// Size_v< MT,2UL > == DefaultSize_v ||
// Size_v< MT,3UL > == DefaultSize_v ) &&
// ( MaxSize_v< MT,1UL > == DefaultMaxSize_v ||
// MaxSize_v< MT,2UL > == DefaultMaxSize_v ||
// MaxSize_v< MT,3UL > == DefaultMaxSize_v ) > >
//{
// using Type = DynamicTensor< RemoveConst_t< ElementType_t<MT> > >;
//};

template< typename ET, size_t I >
struct QuatSliceTraitEval2< DynamicArray<4, ET>, I >
template <typename MT, size_t I>
struct QuatSliceTraitEval2<
MT, I,
EnableIf_t< IsDenseArray_v<MT> && MT::num_dimensions == 4 &&
( Size_v< MT,1UL > == DefaultSize_v ||
Size_v< MT,2UL > == DefaultSize_v ||
Size_v< MT,3UL > == DefaultSize_v ) &&
( MaxSize_v< MT,1UL > == DefaultMaxSize_v ||
MaxSize_v< MT,2UL > == DefaultMaxSize_v ||
MaxSize_v< MT,3UL > == DefaultMaxSize_v ) > >
{
using Type = DynamicTensor< ET >;
using Type = DynamicTensor< RemoveConst_t< ElementType_t<MT> > >;
};

//template< typename ET, size_t I >
//struct QuatSliceTraitEval2< DynamicArray<4, ET>, I >
//{
// using Type = DynamicTensor< ET >;
//};
/*! \endcond */
//*************************************************************************************************

Expand Down
2 changes: 1 addition & 1 deletion blaze_tensor/math/expressions/DArrDArrEqualExpr.h
Expand Up @@ -118,7 +118,7 @@ inline bool //DisableIf_t< DArrDArrEqualExprHelper<MT1,MT2>::value, bool >
return false;
}

constexpr size_t N = MT1::num_dimensions();
constexpr size_t N = MT1::num_dimensions;

// Evaluation of the two dense array operands
CT1 A( ~lhs );
Expand Down
8 changes: 4 additions & 4 deletions blaze_tensor/math/expressions/DArrDArrMapExpr.h
Expand Up @@ -513,10 +513,10 @@ class DArrDArrMapExpr
//
// \return The number of rows of the array.
*/
inline static constexpr size_t num_dimensions() noexcept {
return RemoveCV_t<RemoveReference_t<LeftOperand>>::num_dimensions();
}
//**********************************************************************************************
static constexpr size_t num_dimensions =
RemoveCV_t<RemoveReference_t<LeftOperand>>::num_dimensions;

//**********************************************************************************************

//**Dimensions function****************************************************************************
/*!\brief Returns the current dimensions of the array.
Expand Down
6 changes: 3 additions & 3 deletions blaze_tensor/math/expressions/DArrMapExpr.h
Expand Up @@ -482,9 +482,9 @@ class DArrMapExpr
//
// \return The number of rows of the array.
*/
inline static constexpr size_t num_dimensions() noexcept {
return RemoveCV_t<RemoveReference_t<Operand>>::num_dimensions();
}
static constexpr size_t num_dimensions =
RemoveCV_t< RemoveReference_t< Operand > >::num_dimensions;

//**********************************************************************************************

//**Dimensions function****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion blaze_tensor/math/expressions/DArrNormExpr.h
Expand Up @@ -177,7 +177,7 @@ decltype(auto) norm_backend( const DenseArray<MT>& dm, Abs abs, Power power, Roo
BLAZE_INTERNAL_ASSERT( tmp.dimensions() == (~dm).dimensions(), "Invalid number of elements" );

using AT = RemoveCV_t<RemoveReference_t< decltype( ~dm ) > >;
constexpr size_t N = AT::num_dimensions();
constexpr size_t N = AT::num_dimensions;

std::array< size_t, N > dims{};
ET norm( power( abs( tmp( dims ) ) ) );
Expand Down
8 changes: 4 additions & 4 deletions blaze_tensor/math/expressions/DArrReduceExpr.h
Expand Up @@ -489,9 +489,9 @@ class ReducedArray
//
// \return The size of the array.
*/
inline static constexpr size_t num_dimensions() noexcept {
return RemoveCV_t<RemoveReference_t<Operand>>::num_dimensions();
}
static constexpr size_t num_dimensions =
RemoveCV_t< RemoveReference_t< Operand > >::num_dimensions;

//**********************************************************************************************

//**Dimensions function****************************************************************************
Expand Down Expand Up @@ -945,7 +945,7 @@ inline ElementType_t<MT> darrayreduce( const DenseArray<MT>& dm, OP op )
using ET = ElementType_t<MT>;

constexpr size_t N =
RemoveCV_t< RemoveReference_t< decltype( ~dm ) > >::num_dimensions();
RemoveCV_t< RemoveReference_t< decltype( ~dm ) > >::num_dimensions;

std::array< size_t, N > dims{};

Expand Down
6 changes: 3 additions & 3 deletions blaze_tensor/math/expressions/DArrScalarDivExpr.h
Expand Up @@ -480,9 +480,9 @@ class DArrScalarDivExpr
//
// \return The number of rows of the array.
*/
inline static constexpr size_t num_dimensions() noexcept {
return RemoveCV_t<RemoveReference_t<LeftOperand>>::num_dimensions();
}
static constexpr size_t num_dimensions =
RemoveCV_t< RemoveReference_t< LeftOperand > >::num_dimensions;

//**********************************************************************************************

//**Dimensions function****************************************************************************
Expand Down
6 changes: 3 additions & 3 deletions blaze_tensor/math/expressions/DArrScalarMultExpr.h
Expand Up @@ -480,9 +480,9 @@ class DArrScalarMultExpr
//
// \return The number of rows of the array.
*/
inline static constexpr size_t num_dimensions() noexcept {
return RemoveCV_t<RemoveReference_t<LeftOperand>>::num_dimensions();
}
static constexpr size_t num_dimensions =
RemoveCV_t< RemoveReference_t< LeftOperand > >::num_dimensions;

//**********************************************************************************************

//**Dimensions function****************************************************************************
Expand Down
10 changes: 5 additions & 5 deletions blaze_tensor/math/views/QuatSlice.h
Expand Up @@ -1223,7 +1223,7 @@ inline bool tryAssign( const QuatSlice<AT,CRAs...>& lhs,
BLAZE_INTERNAL_ASSERT( j <= lhs.columns(), "Invalid column access index" );
BLAZE_INTERNAL_ASSERT( j + (~rhs).columns() <= lhs.columns(), "Invalid columns range size" );

return tryAssign( lhs.operand(), ~rhs, lhs.quat(), k, i, j );
return true;
}
/*! \endcond */
//*************************************************************************************************
Expand Down Expand Up @@ -1257,7 +1257,7 @@ inline bool tryAddAssign( const QuatSlice<AT,CRAs...>& lhs,
BLAZE_INTERNAL_ASSERT( j <= lhs.columns(), "Invalid column access index" );
BLAZE_INTERNAL_ASSERT( j + (~rhs).columns() <= lhs.columns(), "Invalid columns range size" );

return tryAddAssign( lhs.operand(), ~rhs, lhs.quat(), k, i, j );
return true;
}
/*! \endcond */
//*************************************************************************************************
Expand Down Expand Up @@ -1291,7 +1291,7 @@ inline bool trySubAssign( const QuatSlice<AT,CRAs...>& lhs,
BLAZE_INTERNAL_ASSERT( j <= lhs.columns(), "Invalid column access index" );
BLAZE_INTERNAL_ASSERT( j + (~rhs).columns() <= lhs.columns(), "Invalid columns range size" );

return trySubAssign( lhs.operand(), ~rhs, lhs.quat(), k, i, j );
return true;
}
/*! \endcond */
//*************************************************************************************************
Expand Down Expand Up @@ -1325,7 +1325,7 @@ inline bool tryMultAssign( const QuatSlice<AT,CRAs...>& lhs,
BLAZE_INTERNAL_ASSERT( j <= lhs.columns(), "Invalid column access index" );
BLAZE_INTERNAL_ASSERT( j + (~rhs).columns() <= lhs.columns(), "Invalid columns range size" );

return tryMultAssign( lhs.operand(), ~rhs, lhs.quat(), k, i, j );
return true;
}
/*! \endcond */
//*************************************************************************************************
Expand Down Expand Up @@ -1359,7 +1359,7 @@ inline bool tryDivAssign( const QuatSlice<AT,CRAs...>& lhs,
BLAZE_INTERNAL_ASSERT( j <= lhs.columns(), "Invalid column access index" );
BLAZE_INTERNAL_ASSERT( j + (~rhs).columns() <= lhs.columns(), "Invalid columns range size" );

return tryDivAssign( lhs.operand(), ~rhs, lhs.quat(), k, i, j );
return true;
}
/*! \endcond */
//*************************************************************************************************
Expand Down