Skip to content

Commit

Permalink
Merge branch 'codac2_dev' of https://github.com/damien-masse/codac in…
Browse files Browse the repository at this point in the history
…to codac2_dev
  • Loading branch information
damien-masse committed Nov 5, 2024
2 parents 28cf2eb + 1b40e95 commit 05b2175
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions python/src/core/matrices/codac2_py_VectorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ void export_VectorBase(py::module& m, py::class_<S>& pyclass)

.def("__iter__", [](const S &x)
{
auto x_ = x._e.reshaped();
return py::make_iterator(x_.begin(), x_.end());
return py::make_iterator(x._e.begin(), x._e.end());
},
py::keep_alive<0, 1>() /* keep object alive while iterator exists */)
;
Expand Down
4 changes: 2 additions & 2 deletions src/core/matrices/codac2_MatrixBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ namespace codac2

iterator begin()
{
return const_cast<iterator>(const_cast<const MatrixBase<S,T,Rows,Cols>*>(this)->begin());
return _e.begin();
}

const_iterator begin() const
Expand All @@ -313,7 +313,7 @@ namespace codac2

iterator end()
{
return const_cast<iterator>(const_cast<const MatrixBase<S,T,Rows,Cols>*>(this)->end());
return _e.end();
}

EigenType _e;
Expand Down
6 changes: 5 additions & 1 deletion tests/core/matrices/codac2_tests_Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ using namespace codac2;

TEST_CASE("Vector")
{

size_t i = 0;
Vector a(3), b {{-1},{2},{-3}};
for(const auto& bi : b)
a[i++] = bi;
CHECK(a == b);
}

0 comments on commit 05b2175

Please sign in to comment.