MCPcopy Create free account
hub / github.com/pybind/pybind11 / FortranMatrix

Class FortranMatrix

tests/test_buffers.cpp:171–186  ·  view source on GitHub ↗

A matrix that uses Fortran storage order.

Source from the content-addressed store, hash-verified

169
170 // A matrix that uses Fortran storage order.
171 class FortranMatrix : public Matrix {
172 public:
173 FortranMatrix(py::ssize_t rows, py::ssize_t cols) : Matrix(cols, rows) {
174 print_created(this,
175 std::to_string(rows) + "x" + std::to_string(cols) + " Fortran matrix");
176 }
177
178 float operator()(py::ssize_t i, py::ssize_t j) const { return Matrix::operator()(j, i); }
179
180 float &operator()(py::ssize_t i, py::ssize_t j) { return Matrix::operator()(j, i); }
181
182 using Matrix::data;
183
184 py::ssize_t rows() const { return Matrix::cols(); }
185 py::ssize_t cols() const { return Matrix::rows(); }
186 };
187 py::class_<FortranMatrix, Matrix>(m, "FortranMatrix", py::buffer_protocol())
188 .def(py::init<py::ssize_t, py::ssize_t>())
189

Callers

nothing calls this directly

Calls 1

operator()Function · 0.50

Tested by

no test coverage detected