Update elish_function.hpp

This commit is contained in:
Adam Kropp
2023-11-14 07:32:13 -05:00
parent 62cedfdb4b
commit a389184f48
@@ -111,11 +111,16 @@ class ElishFunction
{
// simplified the x>=0 part to be in terms of x and y -- maybe
// the x<0 part can be as well?
dy.set_size(arma::size(y));
arma::uvec ltz = arma::find(x < 0);
InputVecType ex = arma::exp(x(ltz));
dy(ltz) = (ex - 2 / (1 + ex) + 2 / arma::pow(1 + ex, 2));
if (!ltz.empty()) {
InputVecType ex = arma::exp(x(ltz));
dy(ltz) = (ex - 2 / (1 + ex) + 2 / arma::pow(1 + ex, 2));
}
arma::uvec gtz = arma::find(x > 0);
dy(gtz) = (y(gtz) / x(gtz)) % (1.0 + x(gtz) - y(gtz));
if (!gtz.empty()) {
dy(gtz) = (y(gtz) / x(gtz)) % (1.0 + x(gtz) - y(gtz));
}
dy(arma::find(x == 0)).fill(0.5);
// the expression above is indeterminate at 0, even though
// the expression solely in terms of x is defined (= 0.5)