Simbody
3.4 (development)
|
00001 #ifndef SimTK_SimTKCOMMON_POLYNOMIALROOTFINDER_H_ 00002 #define SimTK_SimTKCOMMON_POLYNOMIALROOTFINDER_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * Simbody(tm): SimTKcommon * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. * 00011 * * 00012 * Portions copyright (c) 2007-12 Stanford University and the Authors. * 00013 * Authors: Peter Eastman * 00014 * Contributors: * 00015 * * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 00017 * not use this file except in compliance with the License. You may obtain a * 00018 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 00019 * * 00020 * Unless required by applicable law or agreed to in writing, software * 00021 * distributed under the License is distributed on an "AS IS" BASIS, * 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00023 * See the License for the specific language governing permissions and * 00024 * limitations under the License. * 00025 * -------------------------------------------------------------------------- */ 00026 00027 #include "SimTKcommon/basics.h" 00028 #include "SimTKcommon/Simmatrix.h" 00029 00030 namespace SimTK { 00031 00057 class SimTK_SimTKCOMMON_EXPORT PolynomialRootFinder { 00058 public: 00059 class ZeroLeadingCoefficient; 00066 template <class T> 00067 static void findRoots(const Vec<3,T>& coefficients, Vec<2,complex<T> >& roots); 00074 template <class T> 00075 static void findRoots(const Vec<3,complex<T> >& coefficients, Vec<2,complex<T> >& roots); 00082 template <class T> 00083 static void findRoots(const Vec<4,T>& coefficients, Vec<3,complex<T> >& roots); 00090 template <class T> 00091 static void findRoots(const Vec<4,complex<T> >& coefficients, Vec<3,complex<T> >& roots); 00098 template <class T> 00099 static void findRoots(const Vector_<T>& coefficients, Vector_<complex<T> >& roots); 00106 template <class T> 00107 static void findRoots(const Vector_<complex<T> >& coefficients, Vector_<complex<T> >& roots); 00108 }; 00109 00116 class PolynomialRootFinder::ZeroLeadingCoefficient : public Exception::Base { 00117 public: 00118 ZeroLeadingCoefficient(const char* fn, int ln) : Base(fn,ln) { 00119 setMessage("Attempting to find roots of a polynomial whose leading coefficient is 0."); 00120 } 00121 virtual ~ZeroLeadingCoefficient() throw() { } 00122 }; 00123 00124 } // namespace SimTK 00125 00126 #endif // SimTK_SimTKCOMMON_POLYNOMIALROOTFINDER_H_