alashworth / test-issue-import

0 stars 0 forks source link

remove code-generated loops in ctor_body and replace with functions #135

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by bob-carpenter Friday Mar 31, 2017 at 16:49 GMT Originally opened as https://github.com/stan-dev/stan/issues/2257


Summary:

For a matrix[3,3] y type declaration, the The code generator generates the following for ctor_body:

        validate_non_negative_index("y", "3", 3);
        validate_non_negative_index("y", "3", 3);
        context__.validate_dims("data initialization", "y", "matrix_d", context__.to_vec(3,3));
        validate_non_negative_index("y", "3", 3);
        validate_non_negative_index("y", "3", 3);
        y = matrix_d(static_cast<Eigen::VectorXd::Index>(3),static_cast<Eigen::VectorXd::Index>(3));
        vals_r__ = context__.vals_r("y");
        pos__ = 0;
        size_t y_m_mat_lim__ = 3;
        size_t y_n_mat_lim__ = 3;
        for (size_t n_mat__ = 0; n_mat__ < y_n_mat_lim__; ++n_mat__) {
            for (size_t m_mat__ = 0; m_mat__ < y_m_mat_lim__; ++m_mat__) {
                y(m_mat__,n_mat__) = vals_r__[pos__++];
            }
        }

Current Version:

v2.14.0