[1199] | 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 | #include "globals.hh" |
---|
| 28 | #include "G4ios.hh" |
---|
| 29 | #include "G4Timer.hh" |
---|
| 30 | #include "G4Pow.hh" |
---|
| 31 | |
---|
| 32 | #include <fstream> |
---|
| 33 | #include <string> |
---|
| 34 | #include <iostream> |
---|
| 35 | #include <sstream> |
---|
| 36 | #include <iomanip> |
---|
| 37 | |
---|
| 38 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 39 | |
---|
| 40 | int main(int argc, char** argv) |
---|
| 41 | { |
---|
| 42 | if(argc < 2) { |
---|
| 43 | G4cout << "Name is not specified! Exit" << G4endl; |
---|
| 44 | exit(1); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | G4double onethird = 1.0/3.0; |
---|
| 48 | G4int zmax = 255; |
---|
| 49 | const G4int n = 2551; |
---|
| 50 | G4int nn = 10000; |
---|
| 51 | |
---|
| 52 | G4cout.setf( std::ios::scientific, std::ios::floatfield ); |
---|
| 53 | |
---|
| 54 | G4cout << "Loop Z = 1-256 over " << n << " points in " << nn << " seria " << G4endl; |
---|
| 55 | G4cout << "Time comparison of G4Pow calculation of " << argv[1] << G4endl; |
---|
| 56 | |
---|
| 57 | G4int i, j; |
---|
| 58 | G4double x[n]; |
---|
| 59 | G4double y[n]; |
---|
| 60 | G4double z[n]; |
---|
| 61 | |
---|
| 62 | G4double del = G4double(zmax)/G4double(n-1); |
---|
| 63 | G4double t = 0.5; |
---|
| 64 | for (i=0; i<n; i++) { |
---|
| 65 | x[i] = t; |
---|
| 66 | t += del; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | G4Pow* power = G4Pow::GetInstance(); |
---|
| 70 | G4Timer* timer1 = new G4Timer(); |
---|
| 71 | |
---|
| 72 | timer1->Start(); |
---|
| 73 | for(j=0; j<nn; j++) { |
---|
| 74 | for (i=0; i<n; i++) { |
---|
| 75 | t = x[i]; |
---|
| 76 | //y[i] = power->A13(t); |
---|
| 77 | // y[i] = power->A23(t); |
---|
| 78 | y[i] = power->logA(t); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | timer1->Stop(); |
---|
| 83 | G4cout << "======= G4pow "; |
---|
| 84 | G4cout << *timer1 << std::endl; |
---|
| 85 | |
---|
| 86 | timer1->Start(); |
---|
| 87 | for(j=0; j<nn; j++) { |
---|
| 88 | for (i=0; i<n; i++) { |
---|
| 89 | t = x[i]; |
---|
| 90 | //z[i] = std::pow(t,onethird); |
---|
| 91 | z[i] = std::log(t); |
---|
| 92 | // G4cout << "d[" << x << "] = " << d << G4endl; |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | timer1->Stop(); |
---|
| 97 | G4cout << std::endl; |
---|
| 98 | G4cout << "======= std: "; |
---|
| 99 | G4cout << *timer1 << std::endl; |
---|
| 100 | |
---|
| 101 | nn *= 10; |
---|
| 102 | |
---|
| 103 | timer1->Start(); |
---|
| 104 | for(j=0; j<nn; j++) { |
---|
| 105 | for (i=1; i<256; i++) { |
---|
| 106 | //y[i] = power->Z13(i); |
---|
| 107 | // y[i] = power->Z23(i); |
---|
| 108 | y[i] = power->logZ(i); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | timer1->Stop(); |
---|
| 113 | G4cout << std::endl; |
---|
| 114 | G4cout << "======= G4pow Z "; |
---|
| 115 | G4cout << *timer1 << std::endl; |
---|
| 116 | |
---|
| 117 | timer1->Start(); |
---|
| 118 | for(j=0; j<nn; j++) { |
---|
| 119 | for (i=1; i<256; i++) { |
---|
| 120 | //z[i] = std::pow(G4double(i),onethird); |
---|
| 121 | z[i] = std::log(G4double(i)); |
---|
| 122 | // G4cout << "d[" << x << "] = " << d << G4endl; |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | timer1->Stop(); |
---|
| 127 | G4cout << std::endl; |
---|
| 128 | G4cout << "======= std: "; |
---|
| 129 | G4cout << *timer1 << std::endl; |
---|
| 130 | |
---|
| 131 | delete timer1; |
---|
| 132 | return 0; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|