Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmake/modules/FindEigen3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ if(NOT Eigen3_FIND_VERSION)
endif(NOT Eigen3_FIND_VERSION)

macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
# Try the Eigen 5.x location first
if(EXISTS "${EIGEN3_INCLUDE_DIR}/Eigen/Version")
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/Version" _eigen3_version_header)
# Fall back to Eigen 3.x location
elseif(EXISTS "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h")
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
else()
# Could not locate any known Eigen version header; mark version as not OK and return.
set(EIGEN3_VERSION_OK FALSE)
message(STATUS "Could not find Eigen version header under ${EIGEN3_INCLUDE_DIR}")
return()
endif()

string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
Expand Down
2 changes: 0 additions & 2 deletions src/TiledArray/tensor/tensor_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class TensorInterface {
/// \param data The data pointer for this tensor
TensorInterface(const range_type& range, pointer data)
: range_(range), data_(data) {
TA_ASSERT(data);
}

/// Construct a new view of \c tensor
Expand All @@ -188,7 +187,6 @@ class TensorInterface {
/// \param data The data pointer for this tensor
TensorInterface(range_type&& range, pointer data)
: range_(std::move(range)), data_(data) {
TA_ASSERT(data);
}

template <typename T1, typename std::enable_if<detail::is_nested_tensor<
Expand Down
39 changes: 21 additions & 18 deletions tests/sparse_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,31 @@ class EigenSparseTile {

/// makes an uninitialized matrix
explicit EigenSparseTile(const range_type& r)
: impl_(std::make_shared<impl_type>(
std::make_tuple(matrix_type(r.extent()[0], r.extent()[1]), r))) {
TA_ASSERT(r.extent()[0] > 0);
TA_ASSERT(r.extent()[1] > 0);
}
: impl_([&]() {
TA_ASSERT(r.extent()[0] > 0);
TA_ASSERT(r.extent()[1] > 0);
return std::make_shared<impl_type>(
std::make_tuple(matrix_type(r.extent()[0], r.extent()[1]), r));
}()) {}

/// ctor using sparse matrix
EigenSparseTile(matrix_type&& mat, const range_type& range)
: impl_(std::make_shared<impl_type>(
std::make_tuple(std::move(mat), range))) {
using extent_type = typename range_type::extent_type::value_type;
TA_ASSERT(static_cast<extent_type>(mat.rows()) == range.extent()[0]);
TA_ASSERT(static_cast<extent_type>(mat.cols()) == range.extent()[1]);
}
: impl_([&]() {
using extent_type = typename range_type::extent_type::value_type;
TA_ASSERT(static_cast<extent_type>(mat.rows()) == range.extent()[0]);
TA_ASSERT(static_cast<extent_type>(mat.cols()) == range.extent()[1]);
return std::make_shared<impl_type>(
std::make_tuple(std::move(mat), range));
}()) {}

/// ctor using sparse matrix
EigenSparseTile(const matrix_type& mat, const range_type& range)
: impl_(std::make_shared<impl_type>(std::make_tuple(mat, range))) {
using extent_type = typename range_type::extent_type::value_type;
TA_ASSERT(static_cast<extent_type>(mat.rows()) == range.extent()[0]);
TA_ASSERT(static_cast<extent_type>(mat.cols()) == range.extent()[1]);
}
: impl_([&]() {
using extent_type = typename range_type::extent_type::value_type;
TA_ASSERT(static_cast<extent_type>(mat.rows()) == range.extent()[0]);
TA_ASSERT(static_cast<extent_type>(mat.cols()) == range.extent()[1]);
return std::make_shared<impl_type>(std::make_tuple(mat, range));
}()) {}

// Deep copy
EigenSparseTile clone() const {
Expand Down Expand Up @@ -683,15 +686,15 @@ struct ArchiveLoadImpl<Archive, Eigen::Triplet<T>> {
static inline void load(const Archive& ar, Eigen::Triplet<T>& obj) {
int row, col;
T value;
ar & row & col & value;
ar& row& col& value;
obj = Eigen::Triplet<T>(row, col, value);
}
};

template <class Archive, typename T>
struct ArchiveStoreImpl<Archive, Eigen::Triplet<T>> {
static inline void store(const Archive& ar, const Eigen::Triplet<T>& obj) {
ar & obj.row() & obj.col() & obj.value();
ar& obj.row() & obj.col() & obj.value();
}
};
} // namespace archive
Expand Down
Loading