|
||||
File indexing completed on 2025-01-18 09:58:33
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4JTPolynomialSolver 0027 // 0028 // Class description: 0029 // 0030 // G4JTPolynomialSolver implements the Jenkins-Traub algorithm 0031 // for real polynomial root finding. 0032 // The solver returns -1, if the leading coefficient is zero, 0033 // the number of roots found, otherwise. 0034 // 0035 // ----------------------------- INPUT -------------------------------- 0036 // 0037 // op - double precision vector of coefficients in order of 0038 // decreasing powers 0039 // degree - integer degree of polynomial 0040 // 0041 // ----------------------------- OUTPUT ------------------------------- 0042 // 0043 // zeror,zeroi - double precision vectors of the 0044 // real and imaginary parts of the zeros 0045 // 0046 // ---------------------------- EXAMPLE ------------------------------- 0047 // 0048 // G4JTPolynomialSolver trapEq ; 0049 // G4double coef[8] ; 0050 // G4double zr[7] , zi[7] ; 0051 // G4int num = trapEq.FindRoots(coef,7,zr,zi); 0052 // 0053 // Translated from original TOMS493 Fortran77 routine (ANSI C, by C.Bond). 0054 0055 // Author: Oliver Link, 15.02.2005 0056 // Translated to C++ and adapted to use STL vectors. 0057 // -------------------------------------------------------------------- 0058 #ifndef G4JTPOLYNOMIALSOLVER_HH 0059 #define G4JTPOLYNOMIALSOLVER_HH 1 0060 0061 #include <cmath> 0062 #include <vector> 0063 0064 #include "globals.hh" 0065 0066 class G4JTPolynomialSolver 0067 { 0068 public: 0069 G4JTPolynomialSolver() = default; 0070 ~G4JTPolynomialSolver() = default; 0071 0072 G4int FindRoots(G4double* op, G4int degree, G4double* zeror, G4double* zeroi); 0073 0074 private: 0075 void Quadratic(G4double a, G4double b1, G4double c, G4double* sr, 0076 G4double* si, G4double* lr, G4double* li); 0077 void ComputeFixedShiftPolynomial(G4int l2, G4int* nz); 0078 void QuadraticPolynomialIteration(G4double* uu, G4double* vv, G4int* nz); 0079 void RealPolynomialIteration(G4double* sss, G4int* nz, G4int* iflag); 0080 void ComputeScalarFactors(G4int* type); 0081 void ComputeNextPolynomial(G4int* type); 0082 void ComputeNewEstimate(G4int type, G4double* uu, G4double* vv); 0083 void QuadraticSyntheticDivision(G4int n, G4double* u, G4double* v, 0084 std::vector<G4double>& p, 0085 std::vector<G4double>& q, G4double* a, 0086 G4double* b); 0087 0088 private: 0089 std::vector<G4double> p; 0090 std::vector<G4double> qp; 0091 std::vector<G4double> k; 0092 std::vector<G4double> qk; 0093 std::vector<G4double> svk; 0094 0095 G4double sr = 0.0; 0096 G4double si = 0.0; 0097 G4double u = 0.0, v = 0.0; 0098 G4double a = 0.0, b = 0.0, c = 0.0, d = 0.0; 0099 G4double a1 = 0.0, a3 = 0.0, a7 = 0.0; 0100 G4double e = 0.0, f = 0.0, g = 0.0, h = 0.0; 0101 G4double szr = 0.0, szi = 0.0; 0102 G4double lzr = 0.0, lzi = 0.0; 0103 G4int n = 0; 0104 0105 /* The following statements set machine constants */ 0106 0107 static const G4double base; 0108 static const G4double eta; 0109 static const G4double infin; 0110 static const G4double smalno; 0111 static const G4double are; 0112 static const G4double mre; 0113 static const G4double lo; 0114 }; 0115 0116 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |