Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-14 08:50:58

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 corecel/random/distribution/DeltaDistribution.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Types.hh"
0010 
0011 namespace celeritas
0012 {
0013 //---------------------------------------------------------------------------//
0014 /*!
0015  * Distribution where the "sampled" value is just the given value.
0016  */
0017 template<class T>
0018 class DeltaDistribution
0019 {
0020   public:
0021     //!@{
0022     //! \name Type aliases
0023     using value_type = T;
0024     //!@}
0025 
0026   public:
0027     // Constructor
0028     explicit CELER_FUNCTION DeltaDistribution(value_type value) : value_(value)
0029     {
0030     }
0031 
0032     // "Sample" the value
0033     template<class Generator>
0034     CELER_FUNCTION value_type operator()(Generator&) const
0035     {
0036         return value_;
0037     }
0038 
0039   private:
0040     value_type value_;
0041 };
0042 
0043 //---------------------------------------------------------------------------//
0044 }  // namespace celeritas