source: trunk/source/global/HEPNumerics/test/testPolynomRoot.cc@ 1203

Last change on this file since 1203 was 1199, checked in by garnier, 16 years ago

nvx fichiers dans CVS

File size: 2.8 KB
Line 
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// Test program for G4JTPolynomialSolver class.
28//
29
30#include "G4ios.hh"
31#include "globals.hh"
32#include "G4JTPolynomialSolver.hh"
33
34int main()
35{
36
37 G4cout << "root finding starts ... " << G4endl ;
38
39 // double c[5] = { 1, 0.99778585, 26.793624, 17.923849, -1.6282041} ;
40 // double c[5] = { 1, 1.3062095 , -1.8130575, -8.5895246 , -2.5500752 } ;
41 // double c[5] = {1, -0.56733739, 1.8378874 , 3.9504828 , 0.61193337 } ;
42 // double c[5] = { 1,-3.1634943 , -1.1041289, 10.876123 ,-3.6351417 } ;
43 // double c[5] = { 1, 7.5099001 , 26.263224, -14.43852 , -13.015633 } ;
44 // double c[5] = { 1, -0.53770864, -7.7970002, -4.4380489 ,-0.65266367 } ;
45
46 G4double c[5] = { 1, 5.0977493 , 3.0361937, -11.452036, -2.6873796 } ;
47 G4double sr[4] ; // real part
48 G4double si[4] ; // imaginary part
49
50 G4int degree = 4 ;
51 G4int num ; // number of roots
52
53 // solve the polynom analytically
54 G4JTPolynomialSolver trapEq ;
55 num = trapEq.FindRoots(c, degree, sr, si) ;
56
57
58 G4cout.precision(16) ;
59 G4cout << "number of roots found = " << num << G4endl ;
60
61 for ( int i = 0 ; i < num ; i++ ) {
62 G4cout << "solution " << i << " = " << sr[i] << " + " << si[i] << "i" << G4endl ;
63 }
64
65
66 return 1 ;
67
68}
Note: See TracBrowser for help on using the repository browser.