Geom::SBasis Class Reference
#include <sbasis.h>
Public Types | |
| typedef double | output_type |
Public Member Functions | |
| size_t | size () const |
| Linear | operator[] (unsigned i) const |
| Linear & | operator[] (unsigned i) |
| Linear const * | begin () const |
| Linear const * | end () const |
| Linear * | begin () |
| Linear * | end () |
| bool | empty () const |
| Linear & | back () |
| Linear const & | back () const |
| void | pop_back () |
| void | resize (unsigned n) |
| void | resize (unsigned n, Linear const &l) |
| void | reserve (unsigned n) |
| void | clear () |
| void | insert (Linear *before, const Linear *src_begin, const Linear *src_end) |
| Linear & | at (unsigned i) |
| bool | operator== (SBasis const &B) const |
| bool | operator!= (SBasis const &B) const |
| operator std::vector< Linear > () | |
| SBasis () | |
| SBasis (double a) | |
| SBasis (double a, double b) | |
| SBasis (SBasis const &a) | |
| SBasis (Linear const &bo) | |
| SBasis (Linear *bo) | |
| SBasis (size_t n, Linear const &l) | |
| bool | isZero () const |
| bool | isConstant () const |
| bool | isFinite () const |
| test all coefficients are finite | |
| double | at0 () const |
| double | at1 () const |
| int | degreesOfFreedom () const |
| double | valueAt (double t) const |
| double | operator() (double t) const |
| std::vector< double > | valueAndDerivatives (double t, unsigned n) const |
| Compute the value and the first n derivatives. | |
| SBasis | toSBasis () const |
| double | tailError (unsigned tail) const |
| bound the error from term truncation | |
| SBasis | operator() (SBasis const &g) const |
| void | normalize () |
| void | truncate (unsigned k) |
Private Member Functions | |
| void | push_back (Linear const &l) |
| void | derive () |
| Compute the derivative of this inplace (Exact). | |
Private Attributes | |
| std::vector< Linear > | d |
Detailed Description
Definition at line 67 of file sbasis.h.
Member Typedef Documentation
| typedef double Geom::SBasis::output_type |
Constructor & Destructor Documentation
| Geom::SBasis::SBasis | ( | double | a | ) | [inline, explicit] |
| Geom::SBasis::SBasis | ( | SBasis const & | a | ) | [inline] |
| Geom::SBasis::SBasis | ( | Linear const & | bo | ) | [inline] |
| Geom::SBasis::SBasis | ( | Linear * | bo | ) | [inline] |
| Geom::SBasis::SBasis | ( | size_t | n, | |
| Linear const & | l | |||
| ) | [inline, explicit] |
Member Function Documentation
| Linear& Geom::SBasis::at | ( | unsigned | i | ) | [inline] |
| double Geom::SBasis::at0 | ( | ) | const [inline] |
Definition at line 135 of file sbasis.h.
Referenced by Geom::arc_length_parametrization(), Geom::centroid(), and Geom::sqrt_internal().
00135 { 00136 if(empty()) return 0; else return (*this)[0][0]; 00137 }
| double Geom::SBasis::at1 | ( | ) | const [inline] |
Definition at line 138 of file sbasis.h.
Referenced by Geom::arc_length_parametrization(), Geom::centroid(), and Geom::sqrt_internal().
00138 { 00139 if(empty()) return 0; else return (*this)[0][1]; 00140 }
| Linear const& Geom::SBasis::back | ( | ) | const [inline] |
| Linear& Geom::SBasis::back | ( | ) | [inline] |
| Linear* Geom::SBasis::begin | ( | ) | [inline] |
| Linear const* Geom::SBasis::begin | ( | ) | const [inline] |
Definition at line 78 of file sbasis.h.
References d.
Referenced by divide_by_sk().
00078 { return (Linear const*)&*d.begin();}
| void Geom::SBasis::clear | ( | ) | [inline] |
Definition at line 89 of file sbasis.h.
References d.
Referenced by Geom::bezier_to_sbasis(), and Geom::NL::LFMSBasis::instance().
00089 {d.clear();}
| int Geom::SBasis::degreesOfFreedom | ( | ) | const [inline] |
| void Geom::SBasis::derive | ( | ) | [private] |
Compute the derivative of this inplace (Exact).
Definition at line 345 of file sbasis.cpp.
References isZero(), pop_back(), and size().
Referenced by valueAndDerivatives().
00345 { // in place version 00346 if(isZero()) return; 00347 for(unsigned k = 0; k < size()-1; k++) { 00348 double d = (2*k+1)*((*this)[k][1] - (*this)[k][0]); 00349 00350 (*this)[k][0] = d + (k+1)*(*this)[k+1][0]; 00351 (*this)[k][1] = d - (k+1)*(*this)[k+1][1]; 00352 } 00353 int k = size()-1; 00354 double d = (2*k+1)*((*this)[k][1] - (*this)[k][0]); 00355 if(d == 0) 00356 pop_back(); 00357 else { 00358 (*this)[k][0] = d; 00359 (*this)[k][1] = d; 00360 } 00361 }
| bool Geom::SBasis::empty | ( | ) | const [inline] |
Definition at line 82 of file sbasis.h.
References d.
Referenced by Geom::force_continuity().
00082 {return d.empty();}
| Linear* Geom::SBasis::end | ( | ) | [inline] |
| Linear const* Geom::SBasis::end | ( | ) | const [inline] |
Definition at line 79 of file sbasis.h.
References d.
Referenced by divide_by_sk().
00079 { return (Linear const*)&*d.end();}
| void Geom::SBasis::insert | ( | Linear * | before, | |
| const Linear * | src_begin, | |||
| const Linear * | src_end | |||
| ) | [inline] |
Definition at line 90 of file sbasis.h.
References d.
Referenced by divide_by_sk().
00090 { d.insert(std::vector<Linear>::iterator(before), src_begin, src_end);}
| bool Geom::SBasis::isConstant | ( | ) | const [inline] |
| bool Geom::SBasis::isFinite | ( | ) | const |
test all coefficients are finite
Definition at line 52 of file sbasis.cpp.
References Barcode::Code39Ext::i, and size().
| bool Geom::SBasis::isZero | ( | ) | const [inline] |
Definition at line 119 of file sbasis.h.
References Barcode::Code39Ext::i.
Referenced by Geom::compose(), derive(), and Geom::sqrt_internal().
| void Geom::SBasis::normalize | ( | ) | [inline] |
| Geom::SBasis::operator std::vector< Linear > | ( | ) | [inline] |
| bool Geom::SBasis::operator!= | ( | SBasis const & | B | ) | const [inline] |
Definition at line 346 of file sbasis.h.
References Geom::compose().
00346 { 00347 return compose(*this, g); 00348 }
| bool Geom::SBasis::operator== | ( | SBasis const & | B | ) | const [inline] |
| Linear& Geom::SBasis::operator[] | ( | unsigned | i | ) | [inline] |
| Linear Geom::SBasis::operator[] | ( | unsigned | i | ) | const [inline] |
| void Geom::SBasis::pop_back | ( | ) | [inline] |
| void Geom::SBasis::push_back | ( | Linear const & | l | ) | [inline, private] |
Definition at line 69 of file sbasis.h.
References d.
Referenced by Geom::cheb(), and Geom::subdiv_sbasis().
00069 { d.push_back(l); }
| void Geom::SBasis::reserve | ( | unsigned | n | ) | [inline] |
| void Geom::SBasis::resize | ( | unsigned | n, | |
| Linear const & | l | |||
| ) | [inline] |
| void Geom::SBasis::resize | ( | unsigned | n | ) | [inline] |
Definition at line 86 of file sbasis.h.
References d.
Referenced by Geom::bezier_to_sbasis(), Geom::NL::LFMSBasis::instance(), and Geom::sqrt_internal().
| size_t Geom::SBasis::size | ( | ) | const [inline] |
Definition at line 73 of file sbasis.h.
References d.
Referenced by derive(), divide_by_sk(), isFinite(), Geom::multi_roots_internal(), Geom::sqrt_internal(), and Geom::unitVector().
00073 {return d.size();}
| double Geom::SBasis::tailError | ( | unsigned | tail | ) | const |
bound the error from term truncation
- Parameters:
-
tail first term to chop
- Returns:
- the largest possible error this truncation could give
Definition at line 45 of file sbasis.cpp.
References Geom::bounds_fast(), Geom::Interval::max(), Geom::max(), and Geom::Interval::min().
Referenced by Geom::sqrt_internal(), Geom::subdiv_sbasis(), and Geom::unitVector().
00045 { 00046 Interval bs = *bounds_fast(*this, tail); 00047 return std::max(fabs(bs.min()),fabs(bs.max())); 00048 }
| SBasis Geom::SBasis::toSBasis | ( | ) | const [inline] |
| void Geom::SBasis::truncate | ( | unsigned | k | ) | [inline] |
Definition at line 176 of file sbasis.h.
Referenced by Geom::sqrt_internal().
| std::vector< double > Geom::SBasis::valueAndDerivatives | ( | double | t, | |
| unsigned | n | |||
| ) | const |
Compute the value and the first n derivatives.
- Parameters:
-
t position to evaluate n number of derivatives (not counting value)
- Returns:
- a vector with the value and the n derivative evaluations
There is an elegant way to compute the value and n derivatives for a polynomial using a variant of horner's rule. Someone will someday work out how for sbasis.
Definition at line 67 of file sbasis.cpp.
References derive(), Barcode::Code39Ext::i, and valueAt().
Definition at line 144 of file sbasis.h.
Referenced by valueAndDerivatives().
00144 { 00145 double s = t*(1-t); 00146 double p0 = 0, p1 = 0; 00147 for(unsigned k = size(); k > 0; k--) { 00148 const Linear &lin = (*this)[k-1]; 00149 p0 = p0*s + lin[0]; 00150 p1 = p1*s + lin[1]; 00151 } 00152 return (1-t)*p0 + t*p1; 00153 }
Member Data Documentation
std::vector<Linear> Geom::SBasis::d [private] |
Definition at line 68 of file sbasis.h.
Referenced by at(), back(), begin(), clear(), empty(), end(), insert(), operator std::vector< Linear >(), operator!=(), operator==(), operator[](), pop_back(), push_back(), reserve(), resize(), and size().
The documentation for this class was generated from the following files:
