MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / la

Function la

python/dolfinx/wrappers/la.cpp:45–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43namespace dolfinx_wrappers
44{
45void la(nb::module_& m)
46{
47 nb::enum_<PyInsertMode>(m, "InsertMode")
48 .value("add", PyInsertMode::add)
49 .value("insert", PyInsertMode::insert);
50
51 nb::enum_<dolfinx::la::BlockMode>(m, "BlockMode")
52 .value("compact", dolfinx::la::BlockMode::compact)
53 .value("expanded", dolfinx::la::BlockMode::expanded);
54
55 nb::enum_<dolfinx::la::Norm>(m, "Norm")
56 .value("l1", dolfinx::la::Norm::l1, "l1 norm")
57 .value("l2", dolfinx::la::Norm::l2, "l2 norm")
58 .value("linf", dolfinx::la::Norm::linf, "linf norm")
59 .value("frobenius", dolfinx::la::Norm::frobenius, "Frobenius norm");
60
61 // dolfinx::la::SparsityPattern
62 nb::class_<dolfinx::la::SparsityPattern>(m, "SparsityPattern")
63 .def(
64 "__init__",
65 [](dolfinx::la::SparsityPattern* sp, MPICommWrapper comm,
66 std::array<std::shared_ptr<const dolfinx::common::IndexMap>, 2>
67 maps,
68 std::array<int, 2> bs)
69 { new (sp) dolfinx::la::SparsityPattern(comm.get(), maps, bs); },
70 nb::arg("comm"), nb::arg("maps"), nb::arg("bs"))
71 .def(
72 "__init__",
73 [](dolfinx::la::SparsityPattern* sp, MPICommWrapper comm,
74 const std::vector<
75 std::vector<const dolfinx::la::SparsityPattern*>>& patterns,
76 const std::array<
77 std::vector<std::pair<
78 std::reference_wrapper<const dolfinx::common::IndexMap>,
79 int>>,
80 2>& maps,
81 std::array<std::vector<int>, 2> bs)
82 {
83 new (sp)
84 dolfinx::la::SparsityPattern(comm.get(), patterns, maps, bs);
85 },
86 nb::arg("comm"), nb::arg("patterns"), nb::arg("maps"), nb::arg("bs"))
87 .def("index_map", &dolfinx::la::SparsityPattern::index_map,
88 nb::arg("dim"))
89 .def("finalize", &dolfinx::la::SparsityPattern::finalize)
90 .def_prop_ro("num_nonzeros", &dolfinx::la::SparsityPattern::num_nonzeros)
91 .def(
92 "insert",
93 [](dolfinx::la::SparsityPattern& self,
94 nb::ndarray<const std::int32_t, nb::ndim<1>, nb::c_contig> rows,
95 nb::ndarray<const std::int32_t, nb::ndim<1>, nb::c_contig> cols)
96 {
97 self.insert(std::span(rows.data(), rows.size()),
98 std::span(cols.data(), cols.size()));
99 },
100 nb::arg("rows"), nb::arg("cols"))
101 .def("insert",
102 nb::overload_cast<int32_t, int32_t>(

Callers 1

NB_MODULEFunction · 0.85

Calls 7

insertMethod · 0.80
dataMethod · 0.80
insert_diagonalMethod · 0.80
valueMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
graphMethod · 0.45

Tested by

no test coverage detected