-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev-PR137' into dev-tmp
- Loading branch information
Showing
6 changed files
with
72 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include <boost/math/special_functions/expint.hpp> | ||
#include <gsl/gsl_sf_expint.h> | ||
#include <cmath> | ||
|
||
/* Basis function used for building a thin plate spline. boost::math::expint is used here instead | ||
* of gsl_sf_expint because it automatically works with Boost's automatic differentiation */ | ||
template <typename T> | ||
T TPSBasis(T x){ | ||
T gamma = 0.5772156649015328606; | ||
// gsl_sf_expint_E1(x) < epsilon_double and ln(x) > 1 for x > 32 | ||
// so -(log(x) + c + gsl_sf_expint_E1(x)) == -(log(x) + c) is true for x > 32 | ||
return (x <= 32) ? -(log(x) + gamma + boost::math::expint(1,x)) : -(log(x) + gamma); | ||
} | ||
|
||
|
||
/* TODO OLD_TPSBasis exists solely for timing FunC's LUTs against direct evaluation. It can be safely removed. | ||
* The following two lines are needed if x>800 for OLD_TPSBasis because gsl_sf_expint_E1 overflows for x>800; | ||
* however, old_error_handler is set to gsl_set_error_handler_off() somewhere else in CHM */ | ||
//#include <gsl/gsl_errno.h> | ||
//static gsl_error_handler_t *old_error_handler=gsl_set_error_handler_off(); | ||
template <typename T> | ||
T OLD_TPSBasis(T x){ | ||
return -(log(x) + 0.577215 + gsl_sf_expint_E1(x)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,5 +75,4 @@ class thin_plate_spline : public interp_base | |
double weight; | ||
bool uninit_lu_decomp; | ||
size_t size; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
#pragma once | ||
#include <func/EvaluationFunctor.hpp> | ||
#include <cmath> | ||
#define FREEZE 2.7316e2 | ||
#define FUNC_I(x) (pow(1.e1, -9.09718 * ((FREEZE / x) - 1.) - 3.56654 * log(FREEZE / x) / log(1.e1) + 8.76793e-1 * (1. - (x / FREEZE)) + log(6.1071) / log(1.e1)) * 100.0) | ||
#define FUNCNAME_I "pow(1.e1, -9.09718 * ((FREEZE / x) - 1.) - 3.56654 * log(FREEZE / x) / log(1.e1) + 8.76793e-1 * (1. - (x / FREEZE)) + log(6.1071) / log(1.e1)) * 100.0" | ||
#define SATI_MACRO(x) (pow(1.e1, -9.09718 * ((FREEZE / x) - 1.) - 3.56654 * log(FREEZE / x) / log(1.e1) + 8.76793e-1 * (1. - (x / FREEZE)) + log(6.1071) / log(1.e1)) * 100.0) | ||
#define FUNCNAME_I "sati" | ||
|
||
class MyFunction_sati final : public EvaluationFunctor<double,double> | ||
{ | ||
public: | ||
double operator()(double x) override { return FUNC_I(x); } | ||
double deriv(double x) override | ||
{ | ||
return 100.0 * log(1.e1) * pow(1.e1, -9.09718 * ((FREEZE / x) - 1.) - 3.56654 * log(FREEZE / x) / log(1.e1) + 8.76793e-1 * (1. - (x / FREEZE)) + log(6.1071) / log(1.e1)) * (9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE); | ||
} | ||
double deriv2(double x) override | ||
{ | ||
return 100.0 * log(1.e1) * pow(1.e1, -9.09718 * ((FREEZE / x) - 1.) - 3.56654 * log(FREEZE / x) / log(1.e1) + 8.76793e-1 * (1. - (x / FREEZE)) + log(6.1071) / log(1.e1)) * ((9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE) * (9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE) * log(1.e1) + (-18.19436 * FREEZE / x / x / x - 3.56654 / x / x / log(1.e1))); | ||
} | ||
double deriv3(double x) override | ||
{ | ||
return 100.0 * log(1.e1) * pow(1.e1, -9.09718 * ((FREEZE / x) - 1.) - 3.56654 * log(FREEZE / x) / log(1.e1) + 8.76793e-1 * (1. - (x / FREEZE)) + log(6.1071) / log(1.e1)) * ((9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE) * (9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE) * (9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE) * log(1.e1) * log(1.e1) + 3.0 * log(1.e1) * (9.09718 * FREEZE / x / x + 3.56654 / x / log(1.e1) - 8.76793e-1 / FREEZE) * (-18.19436 * FREEZE / x / x / x - 3.56654 / x / x / log(1.e1)) + (54.58308 * FREEZE / x / x / x / x + 7.13308 / x / x / x / log(1.e1))); | ||
} | ||
}; | ||
template <typename T> | ||
T MyFunction_sati(T x){ return SATI_MACRO(x); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,9 @@ | ||
#pragma once | ||
#include <func/EvaluationFunctor.hpp> | ||
#include <cmath> | ||
#define SEA_LEVEL 1.013246e5 | ||
#define BOIL 3.7315e2 | ||
#define FUNC_W(x) (pow(1.e1, -7.90298 * (BOIL / x - 1.) + 5.02808 * log(BOIL / x) / log(1.e1) - 1.3816e-7 * (pow(1.e1, 1.1344e1 * (1. - x / BOIL)) - 1.) + 8.1328e-3 * (pow(1.e1, -3.49149 * (BOIL / x - 1.)) - 1.) + log(SEA_LEVEL) / log(1.e1))) | ||
#define FUNCNAME_W "pow(1.e1, -7.90298 * (BOIL / x - 1.) + 5.02808 * log(BOIL / x) / log(1.e1) - 1.3816e-7 * (pow(1.e1, 1.1344e1 * (1. - x / BOIL)) - 1.) + 8.1328e-3 * (pow(1.e1, -3.49149 * (BOIL / x - 1.)) - 1.) + log(SEA_LEVEL) / log(1.e1))" | ||
#define SATW_MACRO(x) (pow(1.e1, -7.90298 * (BOIL / x - 1.) + 5.02808 * log(BOIL / x) / log(1.e1) - 1.3816e-7 * (pow(1.e1, 1.1344e1 * (1. - x / BOIL)) - 1.) + 8.1328e-3 * (pow(1.e1, -3.49149 * (BOIL / x - 1.)) - 1.) + log(SEA_LEVEL) / log(1.e1))) | ||
#define FUNCNAME_W "satw" | ||
|
||
class MyFunction_satw final : public EvaluationFunctor<double,double> | ||
{ | ||
public: | ||
double operator()(double x) override { return FUNC_W(x); } | ||
double deriv(double x) override | ||
{ | ||
return log(1.e1) * pow(1.e1, -7.90298 * (BOIL / x - 1.) + 5.02808 * log(BOIL / x) / log(1.e1) - 1.3816e-7 * (pow(1.e1, 1.1344e1 * (1. - x / BOIL)) - 1.) + 8.1328e-3 * (pow(1.e1, -3.49149 * (BOIL / x - 1.)) - 1.) + log(SEA_LEVEL) / log(1.e1)) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)); | ||
} | ||
double deriv2(double x) override | ||
{ | ||
return log(1.e1) * pow(1.e1, -7.90298 * (BOIL / x - 1.) + 5.02808 * log(BOIL / x) / log(1.e1) - 1.3816e-7 * (pow(1.e1, 1.1344e1 * (1. - x / BOIL)) - 1.) + 8.1328e-3 * (pow(1.e1, -3.49149 * (BOIL / x - 1.)) - 1.) + log(SEA_LEVEL) / log(1.e1)) * (log(1.e1) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)) + (-15.80596 * BOIL / x / x / x + 5.02808 / log(1.e1) / x / x - 1.3816e-7 * log(1.e1) * log(1.e1) * pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x) * (3.49149 * BOIL / x / x) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (-6.98298 * BOIL / x / x / x))); | ||
} | ||
double deriv3(double x) override | ||
{ | ||
return log(1.e1) * pow(1.e1, -7.90298 * (BOIL / x - 1.) + 5.02808 * log(BOIL / x) / log(1.e1) - 1.3816e-7 * (pow(1.e1, 1.1344e1 * (1. - x / BOIL)) - 1.) + 8.1328e-3 * (pow(1.e1, -3.49149 * (BOIL / x - 1.)) - 1.) + log(SEA_LEVEL) / log(1.e1)) * (log(1.e1) * log(1.e1) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)) + 3 * log(1.e1) * (7.90298 * BOIL / x / x - 5.02808 / log(1.e1) / x - 1.3816e-7 * log(1.e1)* pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x)) * (-15.80596 * BOIL / x / x / x + 5.02808 / log(1.e1) / x / x - 1.3816e-7 * log(1.e1) * log(1.e1) * pow(1.e1, 1.1344e1 * (1. - x / BOIL)) * (-1.1344e1 / BOIL) * (-1.1344e1 / BOIL) + 8.1328e-3 * log(1.e1) * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (3.49149 * BOIL / x / x) * (3.49149 * BOIL / x / x) + 8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (-6.98298 * BOIL / x / x / x)) + (8.1328e-3 * log(1.e1) * pow(1.e1, -3.49149 * (BOIL / x - 1.)) * (log(1.e1) * log(1.e1) * (3.49149 * BOIL / x / x) * (3.49149 * BOIL / x / x) * (3.49149 * BOIL / x / x) + 3 * log(1.e1) * (3.49149 * BOIL / x / x) * (-6.98298 * BOIL / x / x / x) + (20.94894 * BOIL / x / x / x / x)))); | ||
} | ||
}; | ||
template <typename T> | ||
T MyFunction_satw(T x){ return SATW_MACRO(x); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters