ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4JTPolynomialSolver.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4JTPolynomialSolver.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 // Class description:
29 //
30 // G4JTPolynomialSolver implements the Jenkins-Traub algorithm
31 // for real polynomial root finding.
32 // The solver returns -1, if the leading coefficient is zero,
33 // the number of roots found, otherwise.
34 //
35 // ----------------------------- INPUT --------------------------------
36 //
37 // op - double precision vector of coefficients in order of
38 // decreasing powers
39 // degree - integer degree of polynomial
40 //
41 // ----------------------------- OUTPUT -------------------------------
42 //
43 // zeror,zeroi - double precision vectors of the
44 // real and imaginary parts of the zeros
45 //
46 // ---------------------------- EXAMPLE -------------------------------
47 //
48 // G4JTPolynomialSolver trapEq ;
49 // G4double coef[8] ;
50 // G4double zr[7] , zi[7] ;
51 // G4int num = trapEq.FindRoots(coef,7,zr,zi);
52 
53 // ---------------------------- HISTORY -------------------------------
54 //
55 // Translated from original TOMS493 Fortran77 routine (ANSI C, by C.Bond).
56 // Translated to C++ and adapted to use STL vectors,
57 // by Oliver Link (Oliver.Link@cern.ch)
58 //
59 // --------------------------------------------------------------------
60 
61 #ifndef G4JTPOLYNOMIALSOLVER_HH
62 #define G4JTPOLYNOMIALSOLVER_HH
63 
64 #include <cmath>
65 #include <vector>
66 
67 #include "globals.hh"
68 
70 {
71 
72  public:
73 
76 
78  G4double *zeror, G4double *zeroi);
79 
80  private:
81 
82  std::vector<G4double> p;
83  std::vector<G4double> qp;
84  std::vector<G4double> k;
85  std::vector<G4double> qk;
86  std::vector<G4double> svk;
87 
97 
98  /* The following statements set machine constants */
99 
100  static const G4double base;
101  static const G4double eta;
102  static const G4double infin;
103  static const G4double smalno;
104  static const G4double are;
105  static const G4double mre;
106  static const G4double lo;
107 
109  G4double *sr,G4double *si, G4double *lr,G4double *li);
112  void RealPolynomialIteration(G4double *sss, G4int *nz, G4int *iflag);
113  void ComputeScalarFactors(G4int *type);
114  void ComputeNextPolynomial(G4int *type);
115  void ComputeNewEstimate(G4int type,G4double *uu,G4double *vv);
117  std::vector<G4double> &p,
118  std::vector<G4double> &q,
119  G4double *a, G4double *b);
120 };
121 
122 #endif