Commit b345c349 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

avoid unnecessary initialisation of conditional masks

1 merge request!3release v0.1.0
Pipeline #43475 passed with stage
in 2 minutes and 31 seconds
Showing with 13 additions and 8 deletions
+13 -8
...@@ -292,18 +292,19 @@ namespace evalhyd ...@@ -292,18 +292,19 @@ namespace evalhyd
} }
// retrieve dimensions // retrieve dimensions
std::size_t n_sit = q_prd_.shape(0);
std::size_t n_ltm = q_prd_.shape(1);
std::size_t n_tim = q_prd_.shape(3); std::size_t n_tim = q_prd_.shape(3);
std::size_t n_msk = t_msk_.size() > 0 ? t_msk_.shape(2) :
(m_cdt.size() > 0 ? m_cdt.shape(1) : 1);
// generate masks from conditions if provided // generate masks from conditions if provided
auto gen_msk = [&]() auto gen_msk = [&]()
{ {
XB4 c_msk = xt::zeros<bool>({n_sit, n_ltm, n_msk, n_tim}); if ((t_msk_.size() < 1) && (m_cdt.size() > 0))
if (m_cdt.size() > 0)
{ {
std::size_t n_sit = q_prd_.shape(0);
std::size_t n_ltm = q_prd_.shape(1);
std::size_t n_msk = m_cdt.shape(1);
XB4 c_msk = xt::zeros<bool>({n_sit, n_ltm, n_msk, n_tim});
for (std::size_t s = 0; s < n_sit; s++) for (std::size_t s = 0; s < n_sit; s++)
{ {
for (std::size_t l = 0; l < n_ltm; l++) for (std::size_t l = 0; l < n_ltm; l++)
...@@ -319,9 +320,13 @@ namespace evalhyd ...@@ -319,9 +320,13 @@ namespace evalhyd
} }
} }
} }
}
return c_msk; return c_msk;
}
else
{
return XB4({});
}
}; };
const XB4 c_msk = gen_msk(); const XB4 c_msk = gen_msk();
......
Supports Markdown
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