|
|
|||
File indexing completed on 2026-11-07 10:17:46
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file geocel/g4/GeantTypes.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <cmath> 0010 #include <G4ThreeVector.hh> 0011 0012 #include "corecel/Assert.hh" 0013 #include "corecel/Types.hh" 0014 #include "corecel/cont/Array.hh" 0015 0016 namespace celeritas 0017 { 0018 //---------------------------------------------------------------------------// 0019 //! Convert a Geant4 vector to a Celeritas array with full precision 0020 inline Array<double, 3> to_array(G4ThreeVector const& v) 0021 { 0022 return {v.x(), v.y(), v.z()}; 0023 } 0024 0025 //---------------------------------------------------------------------------// 0026 //! Convert a native Celeritas 3-vector to a Geant4 equivalent 0027 inline G4ThreeVector to_g4vector(Array<double, 3> const& arr) 0028 { 0029 return {arr[0], arr[1], arr[2]}; 0030 } 0031 0032 //! \cond (CELERITAS_DOC_DEV) 0033 //---------------------------------------------------------------------------// 0034 //! Let y <- a * x + y 0035 inline void axpy(double a, G4ThreeVector const& x, G4ThreeVector* y) 0036 { 0037 CELER_EXPECT(y); 0038 for (int i = 0; i < 3; ++i) 0039 { 0040 (*y)[i] = std::fma(a, x[i], (*y)[i]); 0041 } 0042 } 0043 //! \endcond 0044 0045 //---------------------------------------------------------------------------// 0046 } // namespace celeritas
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|