2#ifndef STORMM_LOG_SCALE_SPLINE_H
3#define STORMM_LOG_SCALE_SPLINE_H
8#include "Accelerator/gpu_details.h"
9#include "Accelerator/hybrid.h"
10#include "Constants/behavior.h"
11#include "Constants/symbol_values.h"
12#include "DataTypes/common_types.h"
13#include "DataTypes/stormm_vector_types.h"
14#include "Math/matrix_ops.h"
15#include "Parsing/parse.h"
16#include "Parsing/parsing_enumerators.h"
17#include "Potential/pme_util.h"
18#include "Reporting/error_format.h"
19#include "math_enumerators.h"
24using card::GpuDetails;
26using card::HybridTargetLevel;
27using constants::ExceptionResponse;
28using constants::PrecisionModel;
29using symbols::amber_ancient_bioq;
30using energy::minimum_ewald_coefficient;
31using energy::maximum_ewald_coefficient;
32using parse::minimalRealFormat;
33using parse::NumberFormat;
34using parse::realToString;
39constexpr int default_logtab_mantissa_bits = 5;
40constexpr double default_logtab_max_range = 64.0;
41constexpr double default_logtab_min_range = 0.00390625;
50 LogSplineTable(BasisFunctions basis_in, TableIndexing lookup_in,
int detail_bits_in,
51 int index_bound_in, uint sp_detail_mask_in, ullint dp_detail_mask_in,
52 const float arg_offset_in,
const T4* table_in);
101 const ullint dp_detail_mask;
159 double coulomb_constant_in = amber_ancient_bioq,
160 int mantissa_bits_in = default_logtab_mantissa_bits,
161 double max_range_in = default_logtab_max_range,
162 double min_range_in = default_logtab_min_range,
163 TableIndexing indexing_method_in = TableIndexing::SQUARED_ARG,
164 BasisFunctions basis_set_in = BasisFunctions::POLYNOMIAL,
165 int ulp_optimization_depth_in = 2,
166 float indexing_offset_in = 0.0,
167 ExceptionResponse policy = ExceptionResponse::DIE);
170 const std::vector<std::vector<double2>> &custom_form_in,
171 int mantissa_bits_in = default_logtab_mantissa_bits,
172 double max_range_in = default_logtab_max_range,
173 double min_range_in = default_logtab_min_range,
174 TableIndexing indexing_method_in = TableIndexing::SQUARED_ARG,
175 BasisFunctions basis_set_in = BasisFunctions::POLYNOMIAL,
176 int ulp_optimization_depth_in = 2,
177 float indexing_offset_in = 0.0,
178 ExceptionResponse policy = ExceptionResponse::WARN);
316 LogSplineForm target_form;
318 TableIndexing indexing_method;
320 BasisFunctions basis_set;
327 ullint dp_detail_bitmask;
336 uint sp_detail_bitmask;
337 int segments_per_stride;
341 double ewald_coefficient;
343 double coulomb_constant;
345 double maximum_range;
347 double minimum_absolute_range;
357 double minimum_significant_range;
365 float indexing_offset;
372 int ulp_optimization_depth;
377 PrecisionModel precision;
387 double mean_overall_error;
389 double stdev_overall_error;
391 double max_overall_error;
393 std::vector<double> mean_segment_error;
396 std::vector<double> stdev_segment_error;
398 std::vector<double> max_segment_error;
401 void setPrecisionModel();
408 void setTargetForm(LogSplineForm target_form_in,
409 const std::vector<std::vector<double2>> &custom_form_in = {});
416 void setEwaldCoefficient(
double ewald_coefficient_in,
417 ExceptionResponse policy = ExceptionResponse::DIE);
423 void setMantissaBits(
int mantissa_bits_in,
424 ExceptionResponse policy = ExceptionResponse::WARN);
433 void setMinimumAbsoluteRange(
double min_range_in);
440 void setULPDepth(
int ulp_optimization_depth_in);
446 float checkIndexingOffset(
float indexing_offset_in);
454 void allocate(
double max_range_in,
const std::vector<std::vector<double2>> &custom_form_in = {},
455 const ExceptionResponse policy = ExceptionResponse::WARN);
458 void evaluatePrescribedTable();
463 void evaluateCustomTable();
474 void evaluateTargetInSegment(std::vector<double> *bwrk, std::vector<double> *bref,
double r2_i,
487 void evaluateSplineInSegment(std::vector<double> *estm,
const T4 spl_tmp,
double r2_i,
491 void evaluateOverallError();
498ullint doublePrecisionSplineDetailMask(
int mantissa_bits);
504uint singlePrecisionSplineDetailMask(
int mantissa_bits);
514double doublePrecisionSplineArgument(
double arg,
int mantissa_bits, ullint detail_mask);
519float singlePrecisionSplineArgument(
float arg,
int mantissa_bits, uint detail_mask);
526template <
typename T4> LogSplineTable<T4> restoreType(
const LogSplineTable<void> *rasa);
528template <
typename T4> LogSplineTable<T4> restoreType(
const LogSplineTable<void> &rasa);
534#include "log_scale_spline.tpp"
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
LogScaleSpline(LogSplineForm target_form_in, double ewald_coefficient_in, double coulomb_constant_in=amber_ancient_bioq, int mantissa_bits_in=default_logtab_mantissa_bits, double max_range_in=default_logtab_max_range, double min_range_in=default_logtab_min_range, TableIndexing indexing_method_in=TableIndexing::SQUARED_ARG, BasisFunctions basis_set_in=BasisFunctions::POLYNOMIAL, int ulp_optimization_depth_in=2, float indexing_offset_in=0.0, ExceptionResponse policy=ExceptionResponse::DIE)
The constructor needs an indication of the functional form to render. The number of bits will be deci...
float getIndexingOffset() const
Get the indexing offset.
double getEwaldCoefficient() const
Get the Ewald coefficient in use for this spline table. A check will be made to ensure that the splin...
void setMinimumSignificantRange(double min_range_in)
Set the minimum significant range. This is purely for error analysis and will not affect the array in...
int getOptimizationDepth() const
Get the optimization depth.
double evaluateByRealArg(double r) const
Evaluate the underlying function represented by the spline at a point on the natural axis of the unde...
int getBitStride() const
Get the number of leading bits in the mantissa used to determine the array index.
int getSplineIndexByRealArg(double r) const
Get the spline index for a particular value of the argument of the tabulated function....
BasisFunctions getBasisSet() const
Get the basis functions used to construt each spline.
double getMinimumRange() const
Get the minimum absolute range of the spline.
double interpolateByValue(double r) const
Get the value of the underlying function based on a value of the function argument....
double3 getErrorEstimate() const
Get the estimated error as a function of the distance at which the splines are evaluated....
double getMaximumRange() const
Get the maximum range of the spline.
double evaluate(double r) const
Evaluate the underlying function represented by the spline at a point expressed in the object's nativ...
LogSplineForm getForm() const
Get the target form of the function represented by the table.
const LogSplineTable< T4 > data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the object's abstract for the CPU host or GPU device in either of two precision modes.
int getSplineDensity() const
Get the number of spline segments per stride. This is two raised to the power of the result of getBit...
const LogSplineTable< void > templateFreeData(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the object's abstract with templating removed.
LogScaleSpline(LogSplineForm target_form_in, double ewald_coefficient_in, double coulomb_constant_in=amber_ancient_bioq, int mantissa_bits_in=default_logtab_mantissa_bits, double max_range_in=default_logtab_max_range, double min_range_in=default_logtab_min_range, TableIndexing indexing_method_in=TableIndexing::SQUARED_ARG, BasisFunctions basis_set_in=BasisFunctions::POLYNOMIAL, int ulp_optimization_depth_in=2, float indexing_offset_in=0.0, ExceptionResponse policy=ExceptionResponse::DIE)
The constructor needs an indication of the functional form to render. The number of bits will be deci...
LogScaleSpline(const LogScaleSpline &original)=default
With no pointers to repair and no const members, the default copy and move constructors as well as as...
const LogScaleSpline< T4 > * getSelfPointer() const
Get a pointer to the original object.
double interpolateBySquaredValue(double r2) const
Get the value of the underlying function based on a squared value of the function argument....
int getSplineIndex(double r) const
Get the spline index for a particular value of the argument of the tabulated function which has alrea...
TableIndexing getIndexingMethod() const
Get the method of indexing the table, an expression based on the target function's argument,...
double getCoulombConstant() const
Get the value of Coulomb's constant in use by the spline. A check will be made to ensure that the spl...
Definition stormm_vector_types.h:117
LogSplineTable(BasisFunctions basis_in, TableIndexing lookup_in, int detail_bits_in, int index_bound_in, uint sp_detail_mask_in, ullint dp_detail_mask_in, const float arg_offset_in, const T4 *table_in)
As with other abstracts, the constructor takes a straight list of inputs for each member variable.
Abstract for the logarithmic splined function object, containing the table and critical constants for...
Definition log_scale_spline.h:46
const BasisFunctions basis
Definition log_scale_spline.h:65
const int index_bound
The maximum index of the table, for bounds checking.
Definition log_scale_spline.h:79
LogSplineTable(const LogSplineTable &original)=default
The const-ness of member variables implicitly deletes the copy and move assignment operators,...
const T4 * table
The table of cubic spline coefficients.
Definition log_scale_spline.h:111
const TableIndexing lookup
Definition log_scale_spline.h:69
const int detail_bits
Definition log_scale_spline.h:76
const uint sp_detail_mask
Definition log_scale_spline.h:100
LogSplineTable(BasisFunctions basis_in, TableIndexing lookup_in, int detail_bits_in, int index_bound_in, uint sp_detail_mask_in, ullint dp_detail_mask_in, const float arg_offset_in, const T4 *table_in)
As with other abstracts, the constructor takes a straight list of inputs for each member variable.
const float arg_offset
Definition log_scale_spline.h:108