Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/DiffEq/OrnsteinUhlenbeck/OrnsteinUhlenbeckCoeffPolicy.cpp
4 : : \copyright 2012-2015 J. Bakosi,
5 : : 2016-2018 Los Alamos National Security, LLC.,
6 : : 2019-2020 Triad National Security, LLC.
7 : : All rights reserved. See the LICENSE file for details.
8 : : \brief Ornstein-Uhlenbeck coefficients policies
9 : : \details This file defines coefficients policy classes for the diagonal
10 : : Ornstein-Uhlenbeck SDE, defined in
11 : : DiffEq/OrnsteinUhlenbeck/OrnsteinUhlenbeck.h. For general
12 : : requirements on the diagonal Ornstein-Uhlenbeck SDE coefficients
13 : : policy classes see the header file.
14 : : */
15 : : // *****************************************************************************
16 : :
17 : : #include "OrnsteinUhlenbeckCoeffPolicy.hpp"
18 : :
19 : 46 : walker::OrnsteinUhlenbeckCoeffConst::OrnsteinUhlenbeckCoeffConst(
20 : : tk::ctr::ncomp_t ncomp,
21 : : const std::vector< kw::sde_sigmasq::info::expect::type >& sigmasq_,
22 : : const std::vector< kw::sde_theta::info::expect::type >& theta_,
23 : : const std::vector< kw::sde_mu::info::expect::type >& mu_,
24 : : std::vector< kw::sde_sigmasq::info::expect::type >& sigmasq,
25 : : std::vector< kw::sde_theta::info::expect::type >& theta,
26 : : std::vector< kw::sde_mu::info::expect::type >& mu )
27 : : // *****************************************************************************
28 : : // Constructor: initialize coefficients
29 : : //! \param[in] ncomp Number of scalar components in this SDE system
30 : : //! \param[in] sigmasq_ Vector used to initialize coefficient vector sigmasq
31 : : //! \param[in] theta_ Vector used to initialize coefficient vector theta
32 : : //! \param[in] mu_ Vector used to initialize coefficient vector mu
33 : : //! \param[in,out] sigmasq Coefficient vector to be initialized
34 : : //! \param[in,out] theta Coefficient vector to be initialized
35 : : //! \param[in,out] mu Coefficient vector to be initialized
36 : : // *****************************************************************************
37 : : {
38 [ - + ][ - - ]: 46 : ErrChk( sigmasq_.size() == ncomp*(ncomp+1)/2,
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
39 : : "Wrong number of Ornstein-Uhlenbeck SDE parameters 'sigmasq'");
40 [ - + ][ - - ]: 46 : ErrChk( theta_.size() == ncomp,
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
41 : : "Wrong number of Ornstein-Uhlenbeck SDE parameters 'theta'");
42 [ - + ][ - - ]: 46 : ErrChk( mu_.size() == ncomp,
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ]
43 : : "Wrong number of Ornstein-Uhlenbeck SDE parameters 'mu'");
44 : :
45 : : // Prepare upper triangle for Cholesky-decomposition using LAPACK
46 : 46 : sigmasq.resize( ncomp * ncomp );
47 : : std::size_t c = 0;
48 [ + + ]: 184 : for (tk::ctr::ncomp_t i=0; i<ncomp; ++i)
49 [ + + ]: 552 : for (tk::ctr::ncomp_t j=0; j<ncomp; ++j)
50 [ + + ]: 414 : if (i<=j)
51 : 276 : sigmasq[ i*ncomp+j ] = sigmasq_[ c++ ];
52 : : else
53 : 138 : sigmasq[ i*ncomp+j ] = 0.0;
54 : :
55 : 46 : theta = theta_;
56 : 46 : mu = mu_;
57 : 46 : }
|