Rosetta
Namespaces | Classes | Enumerations | Functions
numeric::interpolation Namespace Reference

Namespaces

 periodic_range
 
 spline
 

Classes

class  Histogram
 A histogram with fixed-width bins. More...
 
struct  HistogramOP
 
struct  HistogramCOP
 
struct  HistogramAP
 
struct  HistogramCAP
 
class  InterpolatedPotential
 
struct  TempStruct
 
struct  TempStruct< T, 1 >
 

Enumerations

enum  CatmullRomSplineBoundaryType { PERIODIC , FLAT , LINEAR }
 
enum class  SplineFromStreamMode { none = 0 , x_axis , y_axis , lb_or_ub_function }
 A little helper enum to determine what I'm reading right now in the spline_from_stream() function. More...
 

Functions

template<Size N>
void polycubic_interpolation (numeric::interpolation::InterpolatedPotential< N > const &interpolated_potential, utility::fixedsizearray1< Real, N > const &values, Real &score, utility::fixedsizearray1< Real, N > &dscoreddof)
 
template<typename X , typename F >
interpolated (X const &x, X const &x1, X const &x2, F const &f1, F const &f2)
 Linearly interpolated value: f( x ) More...
 
template<typename X , typename F >
interpolated (X const &a, F const &f1, F const &f2)
 Linearly interpolated value: f( x ) More...
 
template<typename X , typename F >
interpolated_delta (X const &a, F const &f1, F const &f2)
 Linearly interpolated delta value: f( x ) - f1. More...
 
template<typename X , typename Y , typename F >
bilinearly_interpolated (X const &x, X const &x1, X const &x2, Y const &y, Y const &y1, Y const &y2, F const &f11, F const &f12, F const &f21, F const &f22)
 Bilinearly interpolated value: f( x, y ) More...
 
template<typename X , typename Y , typename F >
bilinearly_interpolated (X const &ax, Y const &ay, F const &f11, F const &f12, F const &f21, F const &f22)
 Bilinearly interpolated value. More...
 
template<typename X , typename Y , typename F >
bilinearly_interpolated (X const &ax, Y const &ay, X const &bx, Y const &by, F const &f11, F const &f12, F const &f21, F const &f22)
 Bilinearly interpolated value. More...
 
template<typename T , numeric::Size N>
Real multilinear_interpolation (MathNTensor< T, N > const &tensor, utility::fixedsizearray1< Real, N > const &minval, utility::fixedsizearray1< Real, N > const &binwidth, utility::fixedsizearray1< Real, N > const &xs, utility::fixedsizearray1< Real, N > &deriv, bool const &compute_deriv=true)
 Perform multilinear interpolation over an N-dimensional tensor, with derivatives. More...
 
template<typename T , numeric::Size N>
numeric::Real multilinear_interpolation (numeric::MathNTensor< T, N > const &tensor, utility::fixedsizearray1< numeric::Real, N > const &minval, utility::fixedsizearray1< numeric::Real, N > const &binwidth, utility::fixedsizearray1< numeric::Real, N > const &xs)
 Perform multilinear interpolation over an N-dimensional tensor (without derivative computation) More...
 
template<Size N>
void polycubic_interpolation (utility::fixedsizearray1< utility::fixedsizearray1< Real,(1<< N) >,(1<< N) > n_derivs, utility::fixedsizearray1< Real, N > dbbp, utility::fixedsizearray1< Real, N > binwbb, Real &val, utility::fixedsizearray1< Real, N > &dvaldbb)
 Perform cubic interpolation over each of N axes, using the 2^N derivatives at 2^N gridpoints. More...
 
std::string to_string (CatmullRomSplineBoundaryType const &type)
 
template<typename T >
T catmull_rom_interpolate_basic (utility::fixedsizearray1< T, 4 > const &p, Real const &x, Real &dval_dx, utility::fixedsizearray1< T, 4 > &dval_dp, bool const compute_deriv=true)
 
template<typename T >
T catmull_rom_interpolate_basic (utility::fixedsizearray1< T, 4 > const &p, T const &x, T &dval_dx, bool const compute_deriv=true)
 
template<typename T >
T catmull_rom_interpolate_basic (utility::fixedsizearray1< T, 4 > const &p, T const &x)
 
template<typename T , numeric::Size N>
T catmull_rom_interpolate (utility::fixedsizearray1< T, 1<<(2 *N) > const &F_patch, utility::fixedsizearray1< T, N > const &d, utility::fixedsizearray1< T, N > &deriv, bool const compute_deriv)
 
template<typename T , numeric::Size N>
T get_val (MathNTensor< T, N > const &F, utility::fixedsizearray1< int, N > &idx, utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &boundary, Size const which_dim)
 
template<typename T , numeric::Size N>
void get_patch (utility::fixedsizearray1< T, 1<<(2 *N) > &F_patch, utility::fixedsizearray1< Real, N > &d, MathNTensor< T, N > const &F, utility::fixedsizearray1< Real, N > const &minval, utility::fixedsizearray1< Real, N > const &binwidth, utility::fixedsizearray1< Real, N > const &xs, utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &boundary)
 
template<typename T , numeric::Size N>
T polycubic_interpolate_catmull_rom (MathNTensor< T, N > const &F, utility::fixedsizearray1< Real, N > const &minval, utility::fixedsizearray1< Real, N > const &binwidth, utility::fixedsizearray1< Real, N > const &xs, utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &boundary, utility::fixedsizearray1< Real, N > &deriv, bool const &compute_deriv=true)
 Catmull-Rom spline interpolation of an N-dimensional tensor defined on a equispaced grid. More...
 
template<typename T , numeric::Size N>
T polycubic_interpolate_catmull_rom (MathNTensor< T, N > const &F, utility::fixedsizearray1< Real, N > const &minval, utility::fixedsizearray1< Real, N > const &binwidth, utility::fixedsizearray1< Real, N > const &xs, utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &boundary)
 Catmull-Rom spline interpolation of an N-dimensional tensor defined on a equispaced grid, without derivative computation. More...
 
spline::SplineGenerator make_spline (utility::vector1< platform::Real > const &bins_vect, utility::vector1< platform::Real > const &potential_vect, platform::Real const bin_size, utility::vector1< std::tuple< std::string, platform::Real, platform::Real, platform::Real >> const &boundary_functions=utility::vector1< std::tuple< std::string, platform::Real, platform::Real, platform::Real >>())
 given a file, return a 2D spline More...
 
spline::SplineGenerator spline_from_file (std::string const &filename, platform::Real const bin_size)
 
spline::SplineGenerator spline_from_stream (std::istream &iss, platform::Real const bin_size)
 Initialize a SplineGenerator from a std::istream. Note: only reads from the currenet line of the istream. More...
 

Enumeration Type Documentation

◆ CatmullRomSplineBoundaryType

Enumerator
PERIODIC 
FLAT 
LINEAR 

◆ SplineFromStreamMode

A little helper enum to determine what I'm reading right now in the spline_from_stream() function.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).
Enumerator
none 
x_axis 
y_axis 
lb_or_ub_function 

Function Documentation

◆ bilinearly_interpolated() [1/3]

template<typename X , typename Y , typename F >
F numeric::interpolation::bilinearly_interpolated ( X const &  ax,
Y const &  ay,
F const &  f11,
F const &  f12,
F const &  f21,
F const &  f22 
)
inline

◆ bilinearly_interpolated() [2/3]

template<typename X , typename Y , typename F >
F numeric::interpolation::bilinearly_interpolated ( X const &  ax,
Y const &  ay,
X const &  bx,
Y const &  by,
F const &  f11,
F const &  f12,
F const &  f21,
F const &  f22 
)
inline

◆ bilinearly_interpolated() [3/3]

template<typename X , typename Y , typename F >
F numeric::interpolation::bilinearly_interpolated ( X const &  x,
X const &  x1,
X const &  x2,
Y const &  y,
Y const &  y1,
Y const &  y2,
F const &  f11,
F const &  f12,
F const &  f21,
F const &  f22 
)
inline

◆ catmull_rom_interpolate()

template<typename T , numeric::Size N>
T numeric::interpolation::catmull_rom_interpolate ( )
inline

◆ catmull_rom_interpolate_basic() [1/3]

template<typename T >
T numeric::interpolation::catmull_rom_interpolate_basic ( utility::fixedsizearray1< T, 4 > const &  p,
Real const &  x,
Real dval_dx,
utility::fixedsizearray1< T, 4 > &  dval_dp,
bool const  compute_deriv = true 
)
inline

◆ catmull_rom_interpolate_basic() [2/3]

template<typename T >
T numeric::interpolation::catmull_rom_interpolate_basic ( utility::fixedsizearray1< T, 4 > const &  p,
T const &  x 
)
inline

◆ catmull_rom_interpolate_basic() [3/3]

template<typename T >
T numeric::interpolation::catmull_rom_interpolate_basic ( utility::fixedsizearray1< T, 4 > const &  p,
T const &  x,
T dval_dx,
bool const  compute_deriv = true 
)
inline

◆ get_patch()

template<typename T , numeric::Size N>
void numeric::interpolation::get_patch ( )
inline

◆ get_val()

template<typename T , numeric::Size N>
T numeric::interpolation::get_val ( MathNTensor< T, N > const &  F,
utility::fixedsizearray1< int, N > &  idx,
utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &  boundary,
Size const  which_dim 
)
inline

◆ interpolated() [1/2]

template<typename X , typename F >
F numeric::interpolation::interpolated ( X const &  a,
F const &  f1,
F const &  f2 
)
inline

Linearly interpolated value: f( x )

Note
Extrapolates if a not in [ 0, 1 ]

References a, and vancomycin::f2.

◆ interpolated() [2/2]

template<typename X , typename F >
F numeric::interpolation::interpolated ( X const &  x,
X const &  x1,
X const &  x2,
F const &  f1,
F const &  f2 
)
inline

◆ interpolated_delta()

template<typename X , typename F >
F numeric::interpolation::interpolated_delta ( X const &  a,
F const &  f1,
F const &  f2 
)
inline

Linearly interpolated delta value: f( x ) - f1.

Note
Extrapolates if a not in [ 0, 1 ]

References a, and vancomycin::f2.

◆ make_spline()

spline::SplineGenerator numeric::interpolation::make_spline ( utility::vector1< platform::Real > const &  bins_vect,
utility::vector1< platform::Real > const &  potential_vect,
platform::Real const  bin_size,
utility::vector1< std::tuple< std::string, platform::Real, platform::Real, platform::Real >> const &  boundary_functions 
)

◆ multilinear_interpolation() [1/2]

template<typename T , numeric::Size N>
Real numeric::interpolation::multilinear_interpolation ( MathNTensor< T, N > const &  tensor,
utility::fixedsizearray1< Real, N > const &  minval,
utility::fixedsizearray1< Real, N > const &  binwidth,
utility::fixedsizearray1< Real, N > const &  xs,
utility::fixedsizearray1< Real, N > &  deriv,
bool const &  compute_deriv = true 
)

Perform multilinear interpolation over an N-dimensional tensor, with derivatives.

Straightforward generalization of bilinear interpolation. Currently extrapolates linearly when asked for point outside tensor range TODO: allow periodic; allow different extrapolation behavior (e.g., constant).

Parameters
[in]tensoris the data array, using MathNTensor
[in]minvalis the tensor's minimum value in each direction.
[in]binwidthis the bin width in each direction
[in]xsis the position
[out]derivis the interpolated derivative
[in]compute_deriv– set to false to reduce computation
Author
rhiju

References a, numeric::interpolation::periodic_range::half::bin(), create_a3b_hbs::i, kmeans_adaptive_kernel_density_bb_dependent_rotlib::m, max(), min(), kmeans_adaptive_kernel_density_bb_dependent_rotlib::n, N, numeric::MathNTensor< T, N >::n_bins(), offset, and kmeans_adaptive_kernel_density_bb_dependent_rotlib::xs.

Referenced by check_multilinear_interpolation(), and multilinear_interpolation().

◆ multilinear_interpolation() [2/2]

template<typename T , numeric::Size N>
numeric::Real numeric::interpolation::multilinear_interpolation ( numeric::MathNTensor< T, N > const &  tensor,
utility::fixedsizearray1< numeric::Real, N > const &  minval,
utility::fixedsizearray1< numeric::Real, N > const &  binwidth,
utility::fixedsizearray1< numeric::Real, N > const &  xs 
)
inline

Perform multilinear interpolation over an N-dimensional tensor (without derivative computation)

Straightforward generalization of bilinear interpolation. Currently extrapolates linearly when asked for point outside tensor range TODO: allow periodic; allow different extrapolation behavior (e.g., constant).

Parameters
[in]tensoris the data array, using MathNTensor
[in]minvalis the tensor's minimum value in each direction.
[in]xsis the position at which to evaluate spline
[in]binwidthis the bin width in each direction
Author
rhiju

References multilinear_interpolation(), and kmeans_adaptive_kernel_density_bb_dependent_rotlib::xs.

◆ polycubic_interpolate_catmull_rom() [1/2]

template<typename T , numeric::Size N>
T numeric::interpolation::polycubic_interpolate_catmull_rom ( MathNTensor< T, N > const &  F,
utility::fixedsizearray1< Real, N > const &  minval,
utility::fixedsizearray1< Real, N > const &  binwidth,
utility::fixedsizearray1< Real, N > const &  xs,
utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &  boundary 
)
inline

Catmull-Rom spline interpolation of an N-dimensional tensor defined on a equispaced grid, without derivative computation.

References ObjexxFCL::format::F(), polycubic_interpolate_catmull_rom(), and kmeans_adaptive_kernel_density_bb_dependent_rotlib::xs.

◆ polycubic_interpolate_catmull_rom() [2/2]

template<typename T , numeric::Size N>
T numeric::interpolation::polycubic_interpolate_catmull_rom ( MathNTensor< T, N > const &  F,
utility::fixedsizearray1< Real, N > const &  minval,
utility::fixedsizearray1< Real, N > const &  binwidth,
utility::fixedsizearray1< Real, N > const &  xs,
utility::fixedsizearray1< CatmullRomSplineBoundaryType, N > const &  boundary,
utility::fixedsizearray1< Real, N > &  deriv,
bool const &  compute_deriv = true 
)
inline

◆ polycubic_interpolation() [1/2]

template<Size N>
void numeric::interpolation::polycubic_interpolation ( numeric::interpolation::InterpolatedPotential< N > const &  interpolated_potential,
utility::fixedsizearray1< Real, N > const &  values,
Real score,
utility::fixedsizearray1< Real, N > &  dscoreddof 
)

◆ polycubic_interpolation() [2/2]

template<Size N>
void numeric::interpolation::polycubic_interpolation ( utility::fixedsizearray1< utility::fixedsizearray1< Real,(1<< N) >,(1<< N) >  n_derivs,
utility::fixedsizearray1< Real, N dbbp,
utility::fixedsizearray1< Real, N binwbb,
Real val,
utility::fixedsizearray1< Real, N > &  dvaldbb 
)

Perform cubic interpolation over each of N axes, using the 2^N derivatives at 2^N gridpoints.

The way encoding gridpoints and derivatives into a linear structure like this is actually pretty simple. Imagine the "right or left" part of a cube, or the "derivative taken or not" on a particular variable, as zero or one. Then "just the actual function value" maps to 000, the z derivative (for example) maps to 001, d2/dydz maps to 011, etc.

Parameters
[in]n_derivsis a 2^N x 2^N matrix: 2^N derivatives at 2^N gridpoints
[in]dbbpis how far along the bin our target point is, in each direction
[in]binwbbis the bin width in each direction
[out]valis the interpolated value
[out]dvaldbbare the interpolated derivatives

References create_a3b_hbs::ii, beta_nonlocal::jj, and N.

◆ spline_from_file()

spline::SplineGenerator numeric::interpolation::spline_from_file ( std::string const &  filename,
platform::Real const  bin_size 
)

read in a file, read out a spline. The file should be tab separated, and have two lines The first field of one line should be "x_axis", the next fields should be the x values of the points for the spline The first field of the other line should be "y_axis", the next fields should be the y values for the points on the spline For an example, see "scoring/constraints/epr_distance_potential.histogram"

References a3b_test::bin_size, count, extract_by_sidechain_sasa_score::cutoff, lactamize::filename, utility::from_string(), getline(), line, make_spline(), PB_potential::potential_file, challenge::ss, utility::string_split(), basic::options::OptionKeys::sc::trim, and utility_exit_with_message.

◆ spline_from_stream()

spline::SplineGenerator numeric::interpolation::spline_from_stream ( std::istream &  iss,
platform::Real const  bin_size 
)

Initialize a SplineGenerator from a std::istream. Note: only reads from the currenet line of the istream.

Assumes that the stream contains only the following: "x_axis" followed by N values – mandatory. "y_axis" followed by N values – mandatory. N must match "xaxis". "lb_function" [cutoff] [slope] [intercept] – optional. "ub_function" [cutoff] [slope] [intercept] – optional.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

References a3b_test::bin_size, extract_by_sidechain_sasa_score::cutoff, debug_assert, errmsg(), getline(), test.T008_Serialization::iss, make_spline(), SmotifHasher::mode, none, runtime_assert_string_msg, challenge::ss, x_axis, and y_axis.

◆ to_string()

std::string numeric::interpolation::to_string ( CatmullRomSplineBoundaryType const &  type)
inline