17#include "marley/Error.hh"
18#include "marley/ResponseTable.hh"
27 throw marley::Error(
"Outside of grid bounds in marley::ResponseTable::"
34 size_t iw_low, iw_hi, iq_low, iq_high;
40 double w1 =
wvec_->at( iw_low );
41 double w2 =
wvec_->at( iw_hi );
42 double q1 =
qvec_->at( iq_low );
43 double q2 =
qvec_->at( iq_high );
62 const std::vector<double>& vec,
double val,
size_t& lower_index,
63 size_t& upper_index )
const
65 if ( vec.size() < 2u ) {
66 throw marley::Error(
"Vector with fewer than two entries passed to"
67 " marley::ResponseTable::get_neighbor_indices()" );
72 auto begin = vec.cbegin();
73 auto end = vec.cend();
77 auto not_less_point = std::lower_bound( begin, end, val );
79 decltype( begin ) lower_point;
82 if ( not_less_point == begin ) {
85 if ( *begin != val ) within =
false;
87 else if ( not_less_point == end ) {
90 lower_point = end - 2;
94 lower_point = not_less_point - 1;
97 lower_index = std::distance( begin, lower_point );
98 upper_index = lower_index + 1;
Base class for all exceptions thrown by MARLEY functions.
double q_max() const
Retrieve the maximum q value.
double w_max() const
Retrieve the maximum ω value.
std::shared_ptr< std::vector< double > > wvec_
Grid points along the w-axis.
size_t response_index(size_t iw, size_t iq) const
bool get_neighbor_indices(const std::vector< double > &vec, double val, size_t &lower_index, size_t &upper_index) const
std::shared_ptr< std::vector< NuclearResponses > > responses_
Sets of nuclear responses evaluated at each grid point.
std::shared_ptr< std::vector< double > > qvec_
Grid points along the q-axis.
double w_min() const
Retrieve the minimum ω value.
NuclearResponses interpolate(double w, double q) const
double q_min() const
Retrieve the minimum q value.