|
realroot_doc 0.1.1
|
#include <solver_uv_bspline.hpp>
Definition at line 30 of file solver_uv_bspline.hpp.
| solver_bspline | ( | unsigned | n, |
| unsigned | d, | ||
| unsigned | N = 100 |
||
| ) | [inline] |
Definition at line 36 of file solver_uv_bspline.hpp.
References solver_bspline< Real >::m_c, solver_bspline< Real >::m_t, and mmx::N().
| Real first_root | ( | void | ) |
Definition at line 79 of file solver_uv_bspline.hpp.
References mmx::diff(), mmx::knotSum(), mmx::max(), mmx::min(), and NO_ROOT.
Referenced by solver< Ring, Bspline >::first_root().
{
unsigned k = 1;
Real x = NO_ROOT;
for ( ; m_n < maxn; ++m_n ) {
while( k<m_n && (m_c[k-1]*m_c[k] > 0.0) )
++k;
// Off end?
if ( k >= m_n ) {
//if (x!= NO_ROOT)
//x = -x; // NO_ROOT;
x = NO_ROOT;
break;
}
// Interval converged?
const Real diff = m_t[k+m_d]-m_t[k];
if (diff<eps) {
x = m_t[k];
break;
}
const Real av = knotSum(m_t,k-1, m_d);
const Real lambda = m_c[k-1]/(m_c[k-1]-m_c[k]);
x = (av + lambda*diff)/Real(m_d);
// Stopping criterion
const Real e = std::max(x, m_t[k+m_d-1]) - std::min(x, m_t[k+1] );
// const Real e = max(fabs(x-t[k+1]),fabs(x-t[k+m_d-1]));
if (e < eps)
break;
// Refine spline
insert_knot(x,k);
}
// dx = d*(m_c[k]-m_c[k-1])/(t[k+m_d]-t[k]);
m_k = k;
return x;
}
| int insert_knot | ( | const Real & | x, |
| int | mu | ||
| ) |
Definition at line 53 of file solver_uv_bspline.hpp.
References mmx::max().
{
mu = std::max(mu,m_d);
while ( x>=m_t[mu+1]) mu++;
for ( int i=m_n; i>mu; i--) {
m_c[i] = m_c[i-1];
}
for ( int i=mu; i>=mu-m_d+1; i--) {
const Real alpha = (x-m_t[i])/(m_t[i+m_d]-m_t[i]);
m_c[i] = (1.0-alpha) * m_c[i-1] + alpha * m_c[i];
}
m_t[m_n+m_d] = 1.0;
for ( int i=m_n; i>mu+1; --i)
m_t[i] = m_t[i-1];
m_t[mu+1] = x;
// n++;
return mu;
}
| Real eps |
Definition at line 34 of file solver_uv_bspline.hpp.
| Real * m_c |
Definition at line 31 of file solver_uv_bspline.hpp.
Referenced by solver< Ring, Bspline >::first_root(), and solver_bspline< Real >::solver_bspline().
| int m_d |
Definition at line 33 of file solver_uv_bspline.hpp.
| unsigned m_k |
Definition at line 32 of file solver_uv_bspline.hpp.
| unsigned m_n |
Definition at line 32 of file solver_uv_bspline.hpp.
| Real* m_t |
Definition at line 31 of file solver_uv_bspline.hpp.
Referenced by solver< Ring, Bspline >::first_root(), and solver_bspline< Real >::solver_bspline().
| unsigned maxn |
Definition at line 32 of file solver_uv_bspline.hpp.