12 #ifndef RTCTK_EXAMPLEDATATASK_COMPUTATION_HPP
13 #define RTCTK_EXAMPLEDATATASK_COMPUTATION_HPP
36 m_n_slopes = n_slopes;
40 m_IM.resize(m_n_acts, m_n_slopes);
41 m_CM.resize(m_n_slopes, m_n_acts);
42 m_ipiv.resize(m_n_acts);
45 LOG4CPLUS_DEBUG(
GetLogger(),
"m_n_slopes: " << m_n_slopes);
46 LOG4CPLUS_DEBUG(
GetLogger(),
"m_n_acts: " << m_n_acts);
50 m_IM = std::move(data);
52 if (m_n_acts != (
int)m_IM.GetNrows() || m_n_slopes != (
int)m_IM.GetNcols()) {
53 std::stringstream err_text;
54 err_text <<
"IM wrong shape, "
55 <<
"expected:" << m_n_acts <<
" x " << m_n_slopes
56 <<
"received: " << m_IM.GetNrows() <<
" x " << m_IM.GetNcols();
66 std::chrono::duration<double> elapsed;
71 auto time_start = std::chrono::system_clock::now();
73 if (algorithm == SimpleInversion) {
75 memcpy((
void*)m_CM.data(), (
void*)m_IM.data(), m_n_slopes * m_n_acts *
sizeof(
float));
77 LAPACK_ROW_MAJOR, m_n_acts, m_n_slopes, m_CM.data(), m_n_slopes, m_ipiv.data());
78 LAPACKE_sgetri(LAPACK_ROW_MAJOR, m_n_slopes, m_CM.data(), m_n_acts, m_ipiv.data());
81 py::scoped_interpreter py_guard;
83 auto py_compute_module = py::module::import(
"rtctkExampleDataTaskPyLib");
84 auto py_inversion = py_compute_module.attr(
"inversion");
86 py_inversion(&m_IM, &m_CM);
89 auto elapsed = std::chrono::system_clock::now() - time_start;
91 return {m_CM, elapsed};
105 std::vector<int> m_ipiv;
108 #endif // RTCTK_EXAMPLEDATATASK_COMPUTATION_HPP