solver_bspline< Real > Struct Template Reference

#include <solver_uv_bspline.hpp>

List of all members.

Public Member Functions

Public Attributes


Detailed Description

template<class Real>
struct mmx::solver_bspline< Real >

Definition at line 30 of file solver_uv_bspline.hpp.


Constructor & Destructor Documentation

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, mmx::N(), and Real.

00036                                                         : m_n(n), maxn(N+n), m_d(d), eps(1e-7) { 
00037     m_t= new Real[2*n+N]; 
00038     for(unsigned i=0; i< 2*n+N; i++) m_t[i]=Real(1);
00039     m_c = new Real[n+N];
00040     for(unsigned i=0; i< n+N; i++) m_c[i]=Real(0);
00041   }


Member Function Documentation

Real first_root ( void   )  [inline]

Definition at line 79 of file solver_uv_bspline.hpp.

References mmx::diff(), solver_bspline< Real >::eps, solver_bspline< Real >::insert_knot(), mmx::knotSum(), solver_bspline< Real >::m_c, solver_bspline< Real >::m_d, solver_bspline< Real >::m_k, solver_bspline< Real >::m_n, solver_bspline< Real >::m_t, mmx::max(), solver_bspline< Real >::maxn, mmx::min(), NO_ROOT, and Real.

Referenced by solver< Ring, Bspline >::first_root().

00080 {
00081 
00082   unsigned k = 1;
00083   Real x = NO_ROOT;
00084     
00085   for ( ;  m_n < maxn; ++m_n ) {
00086     
00087     while( k<m_n && (m_c[k-1]*m_c[k] > 0.0) )
00088       ++k;
00089     
00090     
00091     // Off end?
00092     if ( k >= m_n ) {
00093       //if (x!= NO_ROOT)
00094       //x = -x; // NO_ROOT;
00095       x = NO_ROOT;
00096       break;
00097     }
00098     
00099     // Interval converged?
00100     const Real diff = m_t[k+m_d]-m_t[k];
00101 
00102     if (diff<eps) {
00103       x = m_t[k];
00104       break;
00105     }
00106     
00107     const Real av = knotSum(m_t,k-1, m_d);
00108     const Real lambda = m_c[k-1]/(m_c[k-1]-m_c[k]);
00109     x = (av + lambda*diff)/Real(m_d);
00110 
00111     // Stopping criterion
00112     const Real e = std::max(x, m_t[k+m_d-1]) - std::min(x, m_t[k+1] );
00113     // const Real e = max(fabs(x-t[k+1]),fabs(x-t[k+m_d-1]));
00114     if (e < eps)
00115       break;
00116     
00117     // Refine spline
00118     insert_knot(x,k);
00119   }
00120   
00121   //  dx = d*(m_c[k]-m_c[k-1])/(t[k+m_d]-t[k]);
00122   m_k  = k;
00123   return x;
00124 }

int insert_knot ( const Real &  x,
int  mu 
) [inline]

Definition at line 53 of file solver_uv_bspline.hpp.

References solver_bspline< Real >::m_c, solver_bspline< Real >::m_d, solver_bspline< Real >::m_n, solver_bspline< Real >::m_t, mmx::max(), and Real.

Referenced by solver_bspline< Real >::first_root().

00054 {
00055   mu = std::max(mu,m_d);
00056   while ( x>=m_t[mu+1]) mu++;
00057   
00058   for ( int i=m_n; i>mu; i--) {
00059     m_c[i] = m_c[i-1];
00060   }
00061   
00062   for ( int i=mu; i>=mu-m_d+1; i--) {
00063     const Real alpha = (x-m_t[i])/(m_t[i+m_d]-m_t[i]);
00064     m_c[i] = (1.0-alpha) * m_c[i-1] + alpha * m_c[i];
00065   }
00066 
00067   m_t[m_n+m_d] = 1.0;
00068   
00069   for ( int i=m_n; i>mu+1; --i)
00070     m_t[i] = m_t[i-1];
00071   m_t[mu+1] = x;
00072   
00073   //    n++;
00074   return mu;
00075 }


Member Data Documentation

Real eps

Definition at line 34 of file solver_uv_bspline.hpp.

Referenced by solver_bspline< Real >::first_root().

Real * m_c
int m_d
unsigned m_k

Definition at line 32 of file solver_uv_bspline.hpp.

Referenced by solver_bspline< Real >::first_root().

unsigned m_n
Real* m_t
unsigned maxn

Definition at line 32 of file solver_uv_bspline.hpp.

Referenced by solver_bspline< Real >::first_root().


The documentation for this struct was generated from the following file:

Generated on 6 Dec 2012 for realroot by  doxygen 1.6.1