14MultiJac::MultiJac(OneDim& r)
15 : BandMatrix(r.size(),r.bandwidth(),r.bandwidth())
18 m_points = r.points();
21 m_ssdiag.resize(m_size);
22 m_mask.resize(m_size);
26 m_atol = sqrt(std::numeric_limits<double>::epsilon());
30void MultiJac::updateTransient(doublereal rdt, integer* mask)
32 for (
size_t n = 0; n < m_size; n++) {
33 value(n,n) = m_ssdiag[n] - mask[n]*rdt;
37void MultiJac::incrementDiagonal(
int j, doublereal d)
40 value(j,j) = m_ssdiag[j];
43void MultiJac::eval(doublereal* x0, doublereal* resid0, doublereal rdt)
50 for (
size_t j = 0; j < m_points; j++) {
51 size_t nv = m_resid->nVars(j);
52 for (
size_t n = 0; n < nv; n++) {
54 double xsave = x0[ipt];
57 dx = xsave*m_rtol + m_atol;
59 dx = xsave*m_rtol - m_atol;
66 m_resid->eval(j, x0, m_r1.data(), rdt, 0);
69 for (
size_t i = j - 1; i != j+2; i++) {
70 if (i !=
npos && i < m_points) {
71 size_t mv = m_resid->nVars(i);
72 size_t iloc = m_resid->loc(i);
73 for (
size_t m = 0; m < mv; m++) {
74 value(m+iloc,ipt) = (m_r1[m+iloc] - resid0[m+iloc])*rdx;
83 for (
size_t n = 0; n < m_size; n++) {
84 m_ssdiag[n] = value(n,n);
87 m_elapsed += double(clock() - t0)/CLOCKS_PER_SEC;
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"