Commit 7fa3e91d authored by Leon Merten Lohse's avatar Leon Merten Lohse
Browse files

use move semantics

parent 0000f245
......@@ -20,7 +20,7 @@ namespace algebra {
*/
template <typename T>
array1d<T> tridiagonal(TriMatrix<T> &m, array1d<T> &r) {
array1d<T> tridiagonal(TriMatrix<T> &&m, array1d<T> &&r) {
int n = r.size();
auto a = m.row(0);
......@@ -105,7 +105,7 @@ namespace finite_differences {
// initialize writeable copy
array_1D u_new {u};
u_new.segment(1, n) = algebra::tridiagonal(m, r);
u_new.segment(1, n) = algebra::tridiagonal(std::move(m), std::move(r));
return u_new;
}
......@@ -153,7 +153,7 @@ namespace finite_differences {
// initialize writeable copy
array_1D u_new {u};
u_new.segment(0, n) = algebra::tridiagonal(m, r);
u_new.segment(0, n) = algebra::tridiagonal(std::move(m), std::move(r));
return u_new;
}
......@@ -209,7 +209,7 @@ namespace finite_differences {
r(0) += rxx * u(0, iy);
r(nx-1) += rxx * u(nx+1, iy);
uhalf.col(iy).segment(1, nx) = algebra::tridiagonal(m, r);
uhalf.col(iy).segment(1, nx) = algebra::tridiagonal(std::move(m), std::move(r));
}
......@@ -236,7 +236,7 @@ namespace finite_differences {
r(0) += ryy * u(ix, 0);
r(ny-1) += ryy * u(ix, ny+1);
u_new_trans.col(ix).segment(1, ny) = algebra::tridiagonal(m, r);
u_new_trans.col(ix).segment(1, ny) = algebra::tridiagonal(std::move(m), std::move(r));
}
array_2D u_new {u_new_trans.transpose()};
......
......@@ -16,7 +16,8 @@ PYBIND11_MODULE(_solver, m) {
py::arg("fp").noconvert(),
py::arg("f").noconvert(),
py::arg("up").noconvert(),
py::arg("u").noconvert() );
py::arg("u").noconvert(),
py::return_value_policy::move );
m.def("step2d_A0F",
&fd::step2d_A0F,
......@@ -26,7 +27,8 @@ PYBIND11_MODULE(_solver, m) {
py::arg("fp").noconvert(),
py::arg("f").noconvert(),
py::arg("up").noconvert(),
py::arg("u").noconvert() );
py::arg("u").noconvert(),
py::return_value_policy::move );
m.def("step1d_AAF_sym",
&fd::step1d_AAF_sym,
......@@ -36,6 +38,7 @@ PYBIND11_MODULE(_solver, m) {
py::arg("fp").noconvert(),
py::arg("f").noconvert(),
py::arg("up").noconvert(),
py::arg("u").noconvert() );
py::arg("u").noconvert(),
py::return_value_policy::move );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment