Skip to content
Snippets Groups Projects
Verified Commit e2ab314e authored by Justin Carpentier's avatar Justin Carpentier
Browse files

test: fix

parent 90cf65ca
No related branches found
No related tags found
No related merge requests found
Pipeline #18403 passed with warnings
...@@ -42,8 +42,13 @@ Eigen::Ref<MatType> editBlock(Eigen::Ref<MatType> mat, Eigen::DenseIndex i, ...@@ -42,8 +42,13 @@ Eigen::Ref<MatType> editBlock(Eigen::Ref<MatType> mat, Eigen::DenseIndex i,
Eigen::DenseIndex j, Eigen::DenseIndex n, Eigen::DenseIndex j, Eigen::DenseIndex n,
Eigen::DenseIndex m) { Eigen::DenseIndex m) {
typename Eigen::Ref<MatType>::BlockXpr B = mat.block(i, j, n, m); typename Eigen::Ref<MatType>::BlockXpr B = mat.block(i, j, n, m);
Eigen::Map<VectorXd> view(B.data(), B.size()); int k = 0;
view.setLinSpaced(0., (double)view.size() - 1.); for (int i = 0; i < B.rows(); ++i) {
for (int j = 0; j < B.cols(); ++j) {
B(i, j) = k++;
}
}
std::cout << "B:\n" << B << std::endl;
return mat; return mat;
} }
......
...@@ -22,7 +22,6 @@ def test(mat): ...@@ -22,7 +22,6 @@ def test(mat):
assert np.all(ref == mat) assert np.all(ref == mat)
const_ref = asConstRef(mat) const_ref = asConstRef(mat)
# import pdb; pdb.set_trace()
assert np.all(const_ref == mat) assert np.all(const_ref == mat)
mat.fill(0.0) mat.fill(0.0)
...@@ -37,11 +36,12 @@ def test(mat): ...@@ -37,11 +36,12 @@ def test(mat):
mat.fill(0.0) mat.fill(0.0)
mat_as_C_order = np.array(mat, order="F") mat_as_C_order = np.array(mat, order="F")
mat_copy = mat_as_C_order.copy()
getBlock(mat_as_C_order, 0, 0, 3, 2)[:, :] = 1.0 getBlock(mat_as_C_order, 0, 0, 3, 2)[:, :] = 1.0
assert np.all(mat_as_C_order[:3, :2] == np.ones((3, 2))) assert np.all(mat_as_C_order[:3, :2] == np.ones((3, 2)))
mat_as_C_order[:3, :2] = 0.0
mat_copy = mat_as_C_order.copy()
editBlock(mat_as_C_order, 0, 0, 3, 2) editBlock(mat_as_C_order, 0, 0, 3, 2)
mat_copy[:3, :2] = np.arange(6).reshape(3, 2) mat_copy[:3, :2] = np.arange(6).reshape(3, 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment