<commit_before>#pragma once

#include <memory>

#include <anyode/anyode.hpp>
#include <anyode/anyode_blas_lapack.hpp>  // dgemv, dgesvd
#include <anyode/anyode_matrix.hpp> // DenseMatrix
#include <anyode/anyode_decomposition.hpp>  // SVD

namespace AnyODE {

    template <typename Real_t=double, typename JacMat_t=DenseMatrix<Real_t>, typename Decomp_t=SVD<Real_t>>
    struct OdeSysIterativeBase : public OdeSysBase<Real_t> {
        int m_njacvec_dot=0, m_nprec_setup=0, m_nprec_solve=0;
        std::unique_ptr<JacMat_t> m_jac_cache {nullptr};
        std::unique_ptr<JacMat_t> m_M_cache {nullptr};
        std::unique_ptr<Decomp_t> m_decomp_cache {nullptr};

        virtual Status jac_times_vec(const Real_t * const __restrict__ vec,
                                     Real_t * const __restrict__ out,
                                     Real_t t,
                                     const Real_t * const __restrict__ y,
                                     const Real_t * const __restrict__ fy
                                     ) override
        {
            // See "Jacobian information (matrix-vector product)"
            //     (4.6.8 in cvs_guide.pdf for sundials 2.7.0)
            auto status = AnyODE::Status::success;
            const int ny = this->get_ny();
            if (m_jac_cache == nullptr){
                m_jac_cache = std::make_unique<JacMat_t>(nullptr, ny, ny, ny, true);
            }
            status = this->dense_jac_cmaj(t, y, fy, m_jac_cache->m_data, m_jac_cache->m_ld);
            m_jac_cache->dot_vec(vec, out);
            m_njacvec_dot++;
            return status;
        }

        virtual Status prec_setup(Real_t t,
                                  const Real_t * const __restrict__ y,
                                  const Real_t * const __restrict__ fy,<commit_msg>Change iterative base<commit_after>#pragma once

#include <memory>

#include <anyode/anyode.hpp>
#include <anyode/anyode_blas_lapack.hpp>  // dgemv, dgesvd
#include <anyode/anyode_matrix.hpp> // DenseMatrix
#include <anyode/anyode_decomposition.hpp>  // SVD

namespace AnyODE {

    template <typename Real_t=double, typename JacMat_t=DenseMatrix<Real_t>, typename Decomp_t=SVD<Real_t>>
    struct OdeSysIterativeBase : public OdeSysBase<Real_t> {
        int m_njacvec_dot=0, m_nprec_setup=0, m_nprec_solve=0;
        std::unique_ptr<JacMat_t> m_jac_cache {nullptr};
        std::unique_ptr<JacMat_t> m_M_cache {nullptr};
        std::unique_ptr<Decomp_t> m_decomp_cache {nullptr};

        virtual Status jac_times_vec(const Real_t * const __restrict__ vec,
                                     Real_t * const __restrict__ out,
                                     Real_t t,
                                     const Real_t * const __restrict__ y,
                                     const Real_t * const __restrict__ fy
                                     ) override
        {
            // See "Jacobian information (matrix-vector product)"
            //     (4.6.8 in cvs_guide.pdf for sundials 2.7.0)
            auto status = AnyODE::Status::success;
            const int ny = this->get_ny();
            auto jac = std::make_unique<JacMat_t>(nullptr, ny, ny, ny, true);
            status = this->dense_jac_cmaj(t, y, fy, jac->m_data, jac->m_ld);
            jac->dot_vec(vec, out);
            m_njacvec_dot++;
            return status;
        }

        virtual Status prec_setup(Real_t t,
                                  const Real_t * const __restrict__ y,
                                  const Real_t * const __restrict__ fy,
{'fraction_non_alphanumeric': 0.09055338177752935, 'fraction_numerical': 0.005030743432084964, 'mean_word_length': 1.851792828685259, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4133767', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1123, 'n_words': 235}