MCPcopy Create free account
hub / github.com/davisking/dlib / bind_matrix

Function bind_matrix

tools/python/src/matrix.cpp:194–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void bind_matrix(py::module& m)
195{
196 py::class_<mat_row>(m, "_row")
197 .def("__len__", &mat_row__len__)
198 .def("__repr__", &mat_row__repr__)
199 .def("__str__", &mat_row__str__)
200 .def("__setitem__", &mat_row__setitem__)
201 .def("__getitem__", &mat_row__getitem__);
202
203 py::class_<matrix<double>, std::shared_ptr<matrix<double>>>(m, "matrix",
204 "This object represents a dense 2D matrix of floating point numbers."
205 "Moreover, it binds directly to the C++ type dlib::matrix<double>.")
206 .def(py::init<>())
207 .def(py::init(&from_list))
208 .def(py::init(&from_object))
209 .def(py::init(&make_matrix_from_size))
210 .def("set_size", &matrix_set_size, py::arg("rows"), py::arg("cols"), "Set the size of the matrix to the given number of rows and columns.")
211 .def("__repr__", &matrix_double__repr__)
212 .def("__str__", &matrix_double__str__)
213 .def("nr", &matrix<double>::nr, "Return the number of rows in the matrix.")
214 .def("nc", &matrix<double>::nc, "Return the number of columns in the matrix.")
215 .def("serialize", &matrix_double_serialize, py::arg("file"), "Serialize the matrix to a file")
216 .def("deserialize", &matrix_double_deserialize, py::arg("file"), "Deserialize the matrix from a file")
217 .def("__len__", &matrix_double__len__)
218 .def("__getitem__", &matrix_double__getitem__, py::keep_alive<0,1>())
219 .def_property_readonly("shape", &get_matrix_size)
220 .def(py::pickle(&getstate<matrix<double>>, &setstate<matrix<double>>));
221}

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 3

initFunction · 0.85
pickleFunction · 0.85
argClass · 0.50

Tested by

no test coverage detected