Skip to content

Commit b2eff82

Browse files
Merge branch 'master' into pr_basemodelpydantic
2 parents aee9423 + a74b758 commit b2eff82

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

bindings/Sofa/src/SofaPython3/Sofa/Types/Binding_CompressedRowSparseMatrix.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ void bindCompressedRowSparseMatrixConstraint(pybind11::module& m)
5353

5454
crsmc.def_property_readonly("value", [](sofa::Data<MatrixDeriv>& self)
5555
{
56-
sofa::helper::ReadAccessor accessor(self);
56+
sofa::helper::WriteAccessor accessor(self);
57+
accessor.wref().compress();
5758
return toEigen(accessor.ref());
5859
});
5960

61+
crsmc.def("add", [](sofa::Data<MatrixDeriv>& self, sofa::Index row, sofa::Index col, const typename MatrixDeriv::Block value)
62+
{
63+
sofa::helper::WriteAccessor accessor(self);
64+
auto line = accessor->writeLine(row);
65+
line.addCol(col, value);
66+
});
67+
6068
PythonFactory::registerType(MatrixDeriv::Name(), [](sofa::core::BaseData* data) -> py::object {
6169
auto matrix = reinterpret_cast<sofa::Data<MatrixDeriv>*>(data);
6270
return py::cast(matrix);

0 commit comments

Comments
 (0)