25 class NuclearResponses {
29 NuclearResponses() : rCC_( 0. ), rLL_( 0. ), rCL_( 0. ), rTvv_( 0. ),
30 rTaa_( 0. ), rTprime_( 0. ) {}
32 NuclearResponses(
double rCC,
double rLL,
double rCL,
double rTvv,
33 double rTaa,
double rTprime ) : rCC_( rCC ), rLL_( rLL ),
34 rCL_( rCL ), rTvv_( rTvv ), rTaa_( rTaa ), rTprime_( rTprime ) {}
36 inline double RCC()
const {
return rCC_; }
37 inline double RLL()
const {
return rLL_; }
38 inline double RCL()
const {
return rCL_; }
39 inline double RT()
const {
return rTvv_ + rTaa_; }
40 inline double RTvv()
const {
return rTvv_; }
41 inline double RTaa()
const {
return rTaa_; }
42 inline double RTprime()
const {
return rTprime_; }
44 inline void set_RCC(
double val) { rCC_ = val; }
45 inline void set_RLL(
double val) { rLL_ = val; }
46 inline void set_RCL(
double val) { rCL_ = val; }
47 inline void set_RTvv(
double val) { rTvv_ = val; }
48 inline void set_RTaa(
double val) { rTaa_ = val; }
49 inline void set_RTprime(
double val) { rTprime_ = val; }
52 NuclearResponses operator*(
double d)
const
53 {
return apply_to_members(d, [](
double a,
double b)
54 ->
double {
return a * b; }); }
56 NuclearResponses operator/(
double d)
const
57 {
return apply_to_members(d, [](
double a,
double b)
58 ->
double {
return a / b; }); }
61 NuclearResponses operator+(
const NuclearResponses& other)
const
62 {
return apply_to_members(other, [](
double a,
double b)
63 ->
double {
return a + b; }); }
65 NuclearResponses operator-(
const NuclearResponses& other)
const
66 {
return apply_to_members(other, [](
double a,
double b)
67 ->
double {
return a - b; }); }
69 NuclearResponses operator*(
const NuclearResponses& other)
const
70 {
return apply_to_members(other, [](
double a,
double b)
71 ->
double {
return a * b; }); }
73 NuclearResponses operator/(
const NuclearResponses& other)
const
74 {
return apply_to_members(other, [](
double a,
double b)
75 ->
double {
return a / b; }); }
77 bool operator==(
const NuclearResponses& other)
const {
78 bool are_equal = this->rCC_ == other.rCC_;
79 if ( are_equal ) are_equal = this->rLL_ == other.rLL_;
80 if ( are_equal ) are_equal = this->rCL_ == other.rCL_;
81 if ( are_equal ) are_equal = this->rTvv_ == other.rTvv_;
82 if ( are_equal ) are_equal = this->rTaa_ == other.rTaa_;
83 if ( are_equal ) are_equal = this->rTprime_ == other.rTprime_;
87 bool operator!=(
const NuclearResponses& other)
const {
88 return !operator==( other );
91 inline void print(std::ostream& out)
const {
92 out << rCC_ <<
' ' << rLL_ <<
' ' << rCL_ <<
' '
93 << rTvv_ <<
' ' << rTaa_ <<
' ' << rTprime_;
98 NuclearResponses apply_to_members(
double d,
99 const std::function<
double(
double,
double)>& my_function )
const
103 NuclearResponses result;
105 result.rCC_ = my_function( this->rCC_, d );
106 result.rLL_ = my_function( this->rLL_, d );
107 result.rCL_ = my_function( this->rCL_, d );
108 result.rTvv_ = my_function( this->rTvv_, d );
109 result.rTaa_ = my_function( this->rTaa_, d );
110 result.rTprime_ = my_function( this->rTprime_, d );
115 NuclearResponses apply_to_members(
const NuclearResponses& other,
116 const std::function<
double(
double,
double)>& my_function )
const
120 NuclearResponses result;
122 result.rCC_ = my_function( this->rCC_, other.rCC_ );
123 result.rLL_ = my_function( this->rLL_, other.rLL_ );
124 result.rCL_ = my_function( this->rCL_, other.rCL_ );
125 result.rTvv_ = my_function( this->rTvv_, other.rTvv_ );
126 result.rTaa_ = my_function( this->rTaa_, other.rTaa_ );
127 result.rTprime_ = my_function( this->rTprime_, other.rTprime_ );