mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Pulled latest update from the eigen main codebase
This commit is contained in:
@@ -9,3 +9,4 @@ install(FILES
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(CXX11)
|
||||
8
unsupported/Eigen/CXX11/CMakeLists.txt
Normal file
8
unsupported/Eigen/CXX11/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
set(Eigen_CXX11_HEADERS Core Tensor TensorSymmetry)
|
||||
|
||||
install(FILES
|
||||
${Eigen_CXX11_HEADERS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11 COMPONENT Devel
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
3
unsupported/Eigen/CXX11/src/CMakeLists.txt
Normal file
3
unsupported/Eigen/CXX11/src/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
add_subdirectory(Core)
|
||||
add_subdirectory(Tensor)
|
||||
add_subdirectory(TensorSymmetry)
|
||||
1
unsupported/Eigen/CXX11/src/Core/CMakeLists.txt
Normal file
1
unsupported/Eigen/CXX11/src/Core/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(util)
|
||||
6
unsupported/Eigen/CXX11/src/Core/util/CMakeLists.txt
Normal file
6
unsupported/Eigen/CXX11/src/Core/util/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB Eigen_CXX11_Core_util_SRCS "*.h")
|
||||
|
||||
INSTALL(FILES
|
||||
${Eigen_CXX11_Core_util_SRCS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11/src/Core/util COMPONENT Devel
|
||||
)
|
||||
6
unsupported/Eigen/CXX11/src/Tensor/CMakeLists.txt
Normal file
6
unsupported/Eigen/CXX11/src/Tensor/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB Eigen_CXX11_Tensor_SRCS "*.h")
|
||||
|
||||
INSTALL(FILES
|
||||
${Eigen_CXX11_Tensor_SRCS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11/src/Tensor COMPONENT Devel
|
||||
)
|
||||
@@ -526,48 +526,101 @@ class TensorBase<Derived, WriteAccessors> : public TensorBase<Derived, ReadOnlyA
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorLayoutSwapOp<Derived>
|
||||
const TensorLayoutSwapOp<const Derived>
|
||||
swap_layout() const {
|
||||
return TensorLayoutSwapOp<const Derived>(derived());
|
||||
}
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorLayoutSwapOp<Derived>
|
||||
swap_layout() {
|
||||
return TensorLayoutSwapOp<Derived>(derived());
|
||||
}
|
||||
|
||||
template <typename Axis, typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorConcatenationOp<const Axis, const Derived, const OtherDerived>
|
||||
concatenate(const OtherDerived& other, const Axis& axis) const {
|
||||
return TensorConcatenationOp<const Axis, const Derived, const OtherDerived>(derived(), other, axis);
|
||||
}
|
||||
template <typename Axis, typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorConcatenationOp<const Axis, Derived, OtherDerived>
|
||||
concatenate(const OtherDerived& other, const Axis& axis) const {
|
||||
return TensorConcatenationOp<const Axis, Derived, OtherDerived>(derived(), other.derived(), axis);
|
||||
concatenate(const OtherDerived& other, const Axis& axis) {
|
||||
return TensorConcatenationOp<const Axis, Derived, OtherDerived>(derived(), other, axis);
|
||||
}
|
||||
|
||||
template <typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorReshapingOp<const NewDimensions, const Derived>
|
||||
reshape(const NewDimensions& newDimensions) const {
|
||||
return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
|
||||
}
|
||||
template <typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorReshapingOp<const NewDimensions, Derived>
|
||||
reshape(const NewDimensions& newDimensions) const {
|
||||
reshape(const NewDimensions& newDimensions) {
|
||||
return TensorReshapingOp<const NewDimensions, Derived>(derived(), newDimensions);
|
||||
}
|
||||
|
||||
template <typename StartIndices, typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
|
||||
slice(const StartIndices& startIndices, const Sizes& sizes) const {
|
||||
return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
|
||||
}
|
||||
template <typename StartIndices, typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorSlicingOp<const StartIndices, const Sizes, Derived>
|
||||
slice(const StartIndices& startIndices, const Sizes& sizes) const {
|
||||
slice(const StartIndices& startIndices, const Sizes& sizes) {
|
||||
return TensorSlicingOp<const StartIndices, const Sizes, Derived>(derived(), startIndices, sizes);
|
||||
}
|
||||
|
||||
template <DenseIndex DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorChippingOp<DimId, Derived>
|
||||
const TensorChippingOp<DimId, const Derived>
|
||||
chip(const Index offset) const {
|
||||
return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
|
||||
}
|
||||
template <Index DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorChippingOp<DimId, Derived>
|
||||
chip(const Index offset) {
|
||||
return TensorChippingOp<DimId, Derived>(derived(), offset, DimId);
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorChippingOp<Dynamic, const Derived>
|
||||
chip(const Index offset, const Index dim) const {
|
||||
return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
|
||||
}
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorChippingOp<Dynamic, Derived>
|
||||
chip(const Index offset, const Index dim) const {
|
||||
chip(const Index offset, const Index dim) {
|
||||
return TensorChippingOp<Dynamic, Derived>(derived(), offset, dim);
|
||||
}
|
||||
|
||||
template <typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorReverseOp<const ReverseDimensions, const Derived>
|
||||
reverse(const ReverseDimensions& rev) const {
|
||||
return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
|
||||
}
|
||||
template <typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorReverseOp<const ReverseDimensions, Derived>
|
||||
reverse(const ReverseDimensions& rev) const {
|
||||
reverse(const ReverseDimensions& rev) {
|
||||
return TensorReverseOp<const ReverseDimensions, Derived>(derived(), rev);
|
||||
}
|
||||
|
||||
template <typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorShufflingOp<const Shuffle, const Derived>
|
||||
shuffle(const Shuffle& shuffle) const {
|
||||
return TensorShufflingOp<const Shuffle, const Derived>(derived(), shuffle);
|
||||
}
|
||||
template <typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorShufflingOp<const Shuffle, Derived>
|
||||
shuffle(const Shuffle& shuffle) const {
|
||||
shuffle(const Shuffle& shuffle) {
|
||||
return TensorShufflingOp<const Shuffle, Derived>(derived(), shuffle);
|
||||
}
|
||||
|
||||
template <typename Strides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
const TensorStridingOp<const Strides, const Derived>
|
||||
stride(const Strides& strides) const {
|
||||
return TensorStridingOp<const Strides, const Derived>(derived(), strides);
|
||||
}
|
||||
template <typename Strides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
TensorStridingOp<const Strides, Derived>
|
||||
stride(const Strides& strides) const {
|
||||
stride(const Strides& strides) {
|
||||
return TensorStridingOp<const Strides, Derived>(derived(), strides);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ namespace Eigen {
|
||||
* Example:
|
||||
* C.device(EIGEN_GPU) = A + B;
|
||||
*
|
||||
* Todo: thread pools.
|
||||
* Todo: operator +=, -=, *= and so on.
|
||||
* Todo: operator *= and /=.
|
||||
*/
|
||||
|
||||
template <typename ExpressionType, typename DeviceType> class TensorDevice {
|
||||
@@ -50,6 +49,18 @@ template <typename ExpressionType, typename DeviceType> class TensorDevice {
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
EIGEN_STRONG_INLINE TensorDevice& operator-=(const OtherDerived& other) {
|
||||
typedef typename OtherDerived::Scalar Scalar;
|
||||
typedef TensorCwiseBinaryOp<internal::scalar_difference_op<Scalar>, const ExpressionType, const OtherDerived> Difference;
|
||||
Difference difference(m_expression, other);
|
||||
typedef TensorAssignOp<ExpressionType, const Difference> Assign;
|
||||
Assign assign(m_expression, difference);
|
||||
static const bool Vectorize = TensorEvaluator<const Assign, DeviceType>::PacketAccess;
|
||||
internal::TensorExecutor<const Assign, DeviceType, Vectorize>::run(assign, m_device);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
const DeviceType& m_device;
|
||||
ExpressionType& m_expression;
|
||||
@@ -82,6 +93,18 @@ template <typename ExpressionType> class TensorDevice<ExpressionType, ThreadPool
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
EIGEN_STRONG_INLINE TensorDevice& operator-=(const OtherDerived& other) {
|
||||
typedef typename OtherDerived::Scalar Scalar;
|
||||
typedef TensorCwiseBinaryOp<internal::scalar_difference_op<Scalar>, const ExpressionType, const OtherDerived> Difference;
|
||||
Difference difference(m_expression, other);
|
||||
typedef TensorAssignOp<ExpressionType, const Difference> Assign;
|
||||
Assign assign(m_expression, difference);
|
||||
static const bool Vectorize = TensorEvaluator<const Assign, ThreadPoolDevice>::PacketAccess;
|
||||
internal::TensorExecutor<const Assign, ThreadPoolDevice, Vectorize>::run(assign, m_device);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
const ThreadPoolDevice& m_device;
|
||||
ExpressionType& m_expression;
|
||||
@@ -114,6 +137,18 @@ template <typename ExpressionType> class TensorDevice<ExpressionType, GpuDevice>
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
EIGEN_STRONG_INLINE TensorDevice& operator-=(const OtherDerived& other) {
|
||||
typedef typename OtherDerived::Scalar Scalar;
|
||||
typedef TensorCwiseBinaryOp<internal::scalar_difference_op<Scalar>, const ExpressionType, const OtherDerived> Difference;
|
||||
Difference difference(m_expression, other);
|
||||
typedef TensorAssignOp<ExpressionType, const Difference> Assign;
|
||||
Assign assign(m_expression, difference);
|
||||
static const bool Vectorize = TensorEvaluator<const Assign, GpuDevice>::PacketAccess;
|
||||
internal::TensorExecutor<const Assign, GpuDevice, Vectorize>::run(assign, m_device);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
const GpuDevice& m_device;
|
||||
ExpressionType m_expression;
|
||||
|
||||
@@ -77,7 +77,7 @@ template <typename T> struct MeanReducer
|
||||
}
|
||||
template <typename Packet>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T finalizeBoth(const T saccum, const Packet& vaccum) const {
|
||||
return (saccum + predux(vaccum)) / (scalarCount_ + packetCount_ * packet_traits<Packet>::size);
|
||||
return (saccum + predux(vaccum)) / (scalarCount_ + packetCount_ * unpacket_traits<Packet>::size);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -30,14 +30,14 @@ std::ostream& operator << (std::ostream& os, const TensorBase<T, ReadOnlyAccesso
|
||||
typedef typename internal::remove_const<typename T::Scalar>::type Scalar;
|
||||
typedef typename T::Index Index;
|
||||
typedef typename TensorEvaluator<const TensorForcedEvalOp<const T>, DefaultDevice>::Dimensions Dimensions;
|
||||
const Index total_size = internal::array_prod(tensor.dimensions());
|
||||
const Index total_size = tensor.dimensions().TotalSize();
|
||||
|
||||
// Print the tensor as a 1d vector or a 2d matrix.
|
||||
if (internal::array_size<Dimensions>::value == 1) {
|
||||
Map<const Array<Scalar, Dynamic, 1> > array(const_cast<Scalar*>(tensor.data()), total_size);
|
||||
os << array;
|
||||
} else {
|
||||
const Index first_dim = tensor.dimensions()[0];
|
||||
const Index first_dim = Eigen::internal::array_get<0>(tensor.dimensions());
|
||||
static const int layout = TensorEvaluator<const TensorForcedEvalOp<const T>, DefaultDevice>::Layout;
|
||||
Map<const Array<Scalar, Dynamic, Dynamic, layout> > matrix(const_cast<Scalar*>(tensor.data()), first_dim, total_size/first_dim);
|
||||
os << matrix;
|
||||
|
||||
@@ -65,7 +65,7 @@ struct traits<Tensor<Scalar_, NumIndices_, Options_> >
|
||||
static const int Layout = Options_ & RowMajor ? RowMajor : ColMajor;
|
||||
enum {
|
||||
Options = Options_,
|
||||
Flags = compute_tensor_flags<Scalar_, Options_>::ret | LvalueBit,
|
||||
Flags = compute_tensor_flags<Scalar_, Options_>::ret | (is_const<Scalar_>::value ? 0 : LvalueBit),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ struct traits<TensorFixedSize<Scalar_, Dimensions, Options_> >
|
||||
static const int Layout = Options_ & RowMajor ? RowMajor : ColMajor;
|
||||
enum {
|
||||
Options = Options_,
|
||||
Flags = compute_tensor_flags<Scalar_, Options_>::ret | LvalueBit,
|
||||
Flags = compute_tensor_flags<Scalar_, Options_>::ret | (is_const<Scalar_>::value ? 0: LvalueBit),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -97,7 +97,7 @@ struct traits<TensorMap<PlainObjectType, Options_> >
|
||||
static const int Layout = BaseTraits::Layout;
|
||||
enum {
|
||||
Options = Options_,
|
||||
Flags = ((BaseTraits::Flags | LvalueBit) & ~AlignedBit) | (Options&Aligned ? AlignedBit : 0),
|
||||
Flags = (BaseTraits::Flags & ~AlignedBit) | (Options&Aligned ? AlignedBit : 0),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ struct traits<TensorRef<PlainObjectType> >
|
||||
static const int Layout = BaseTraits::Layout;
|
||||
enum {
|
||||
Options = BaseTraits::Options,
|
||||
Flags = ((BaseTraits::Flags | LvalueBit) & ~AlignedBit) | (Options&Aligned ? AlignedBit : 0),
|
||||
Flags = (BaseTraits::Flags & ~AlignedBit) | (Options&Aligned ? AlignedBit : 0),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
FILE(GLOB Eigen_CXX11_TensorSymmetry_SRCS "*.h")
|
||||
|
||||
INSTALL(FILES
|
||||
${Eigen_CXX11_TensorSymmetry_SRCS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11/src/TensorSymmetry COMPONENT Devel
|
||||
)
|
||||
|
||||
add_subdirectory(util)
|
||||
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB Eigen_CXX11_TensorSymmetry_util_SRCS "*.h")
|
||||
|
||||
INSTALL(FILES
|
||||
${Eigen_CXX11_TensorSymmetry_util_SRCS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11/src/TensorSymmetry/util COMPONENT Devel
|
||||
)
|
||||
@@ -141,20 +141,32 @@ int main()
|
||||
public:
|
||||
typedef mpfr::mpreal ResScalar;
|
||||
enum {
|
||||
Vectorizable = false,
|
||||
LhsPacketSize = 1,
|
||||
RhsPacketSize = 1,
|
||||
ResPacketSize = 1,
|
||||
NumberOfRegisters = 1,
|
||||
nr = 1,
|
||||
mr = 1,
|
||||
LhsProgress = 1,
|
||||
RhsProgress = 1
|
||||
};
|
||||
typedef ResScalar LhsPacket;
|
||||
typedef ResScalar RhsPacket;
|
||||
typedef ResScalar ResPacket;
|
||||
|
||||
};
|
||||
|
||||
template<typename Index, bool ConjugateLhs, bool ConjugateRhs>
|
||||
struct gebp_kernel<mpfr::mpreal,mpfr::mpreal,Index,1,1,ConjugateLhs,ConjugateRhs>
|
||||
|
||||
|
||||
template<typename Index, typename DataMapper, bool ConjugateLhs, bool ConjugateRhs>
|
||||
struct gebp_kernel<mpfr::mpreal,mpfr::mpreal,Index,DataMapper,1,1,ConjugateLhs,ConjugateRhs>
|
||||
{
|
||||
typedef mpfr::mpreal mpreal;
|
||||
|
||||
EIGEN_DONT_INLINE
|
||||
void operator()(mpreal* res, Index resStride, const mpreal* blockA, const mpreal* blockB, Index rows, Index depth, Index cols, mpreal alpha,
|
||||
void operator()(const DataMapper& res, const mpreal* blockA, const mpreal* blockB,
|
||||
Index rows, Index depth, Index cols, const mpreal& alpha,
|
||||
Index strideA=-1, Index strideB=-1, Index offsetA=0, Index offsetB=0)
|
||||
{
|
||||
if(rows==0 || cols==0 || depth==0)
|
||||
@@ -170,8 +182,6 @@ int main()
|
||||
{
|
||||
for(Index j=0; j<cols; ++j)
|
||||
{
|
||||
mpreal *C1 = res + j*resStride;
|
||||
|
||||
const mpreal *A = blockA + i*strideA + offsetA;
|
||||
const mpreal *B = blockB + j*strideB + offsetB;
|
||||
|
||||
@@ -183,7 +193,7 @@ int main()
|
||||
}
|
||||
|
||||
mpfr_mul(acc1.mpfr_ptr(), acc1.mpfr_srcptr(), alpha.mpfr_srcptr(), mpreal::get_default_rnd());
|
||||
mpfr_add(C1[i].mpfr_ptr(), C1[i].mpfr_srcptr(), acc1.mpfr_srcptr(), mpreal::get_default_rnd());
|
||||
mpfr_add(res(i,j).mpfr_ptr(), res(i,j).mpfr_srcptr(), acc1.mpfr_srcptr(), mpreal::get_default_rnd());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Eigen {
|
||||
namespace internal
|
||||
{
|
||||
template <typename Scalar>
|
||||
inline bool GetMarketLine (std::stringstream& line, int& M, int& N, int& i, int& j, Scalar& value)
|
||||
inline bool GetMarketLine (std::stringstream& line, Index& M, Index& N, Index& i, Index& j, Scalar& value)
|
||||
{
|
||||
line >> i >> j >> value;
|
||||
i--;
|
||||
@@ -31,7 +31,7 @@ namespace internal
|
||||
return false;
|
||||
}
|
||||
template <typename Scalar>
|
||||
inline bool GetMarketLine (std::stringstream& line, int& M, int& N, int& i, int& j, std::complex<Scalar>& value)
|
||||
inline bool GetMarketLine (std::stringstream& line, Index& M, Index& N, Index& i, Index& j, std::complex<Scalar>& value)
|
||||
{
|
||||
Scalar valR, valI;
|
||||
line >> i >> j >> valR >> valI;
|
||||
|
||||
Reference in New Issue
Block a user