ADD: added other eigen lib
This commit is contained in:
@@ -10,8 +10,11 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
using Eigen::placeholders::last;
|
||||
using Eigen::placeholders::all;
|
||||
|
||||
template<typename T1,typename T2>
|
||||
typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
|
||||
std::enable_if_t<internal::is_same<T1,T2>::value,bool>
|
||||
is_same_eq(const T1& a, const T2& b)
|
||||
{
|
||||
return (a.array() == b.array()).all();
|
||||
@@ -193,6 +196,24 @@ void reshape4x4(MatType m)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BlockType>
|
||||
void reshape_block(const BlockType& M) {
|
||||
auto dense = M.eval();
|
||||
Index rows = M.size() / 2;
|
||||
Index cols = M.size() / rows;
|
||||
VERIFY_IS_EQUAL(dense.reshaped(rows, cols), M.reshaped(rows, cols));
|
||||
|
||||
for (Index i=0; i<rows; ++i) {
|
||||
VERIFY_IS_EQUAL(dense.reshaped(rows, cols).row(i),
|
||||
M.reshaped(rows, cols).row(i));
|
||||
}
|
||||
|
||||
for (Index j = 0; j<cols; ++j) {
|
||||
VERIFY_IS_EQUAL(dense.reshaped(rows, cols).col(j),
|
||||
M.reshaped(rows, cols).col(j));
|
||||
}
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(reshape)
|
||||
{
|
||||
typedef Matrix<int,Dynamic,Dynamic,RowMajor> RowMatrixXi;
|
||||
@@ -213,4 +234,5 @@ EIGEN_DECLARE_TEST(reshape)
|
||||
|
||||
CALL_SUBTEST(reshape4x4(rmx));
|
||||
CALL_SUBTEST(reshape4x4(rm4));
|
||||
CALL_SUBTEST(reshape_block(rm4.col(1)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user