Skip to content

Commit

Permalink
GeneratorProfile: slight math-related improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 22, 2024
1 parent 8308d8e commit becf20e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
42 changes: 12 additions & 30 deletions src/generatorprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
mCommonLogarithmString = "log10";
mCeilingString = "ceil";
mFloorString = "floor";
mMinString = "min";
mMaxString = "max";
mMinString = "fmin";
mMaxString = "fmax";
mRemString = "fmod";

mHasPowerOperator = false;
Expand Down Expand Up @@ -123,7 +123,7 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi

mTrueString = "1.0";
mFalseString = "0.0";
mEString = convertToString(exp(1.0));
mEString = convertToString(M_E);
mPiString = convertToString(M_PI);
mInfString = "INFINITY";
mNanString = "NAN";
Expand All @@ -143,14 +143,8 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
" return (x != 0.0) ^ (y != 0.0);\n"
"}\n";
mNotFunctionString = "";
mMinFunctionString = "double min(double x, double y)\n"
"{\n"
" return (x < y)?x:y;\n"
"}\n";
mMaxFunctionString = "double max(double x, double y)\n"
"{\n"
" return (x > y)?x:y;\n"
"}\n";
mMinFunctionString = "";
mMaxFunctionString = "";

// Trigonometric functions.

Expand Down Expand Up @@ -192,21 +186,15 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
"}\n";
mAsechFunctionString = "double asech(double x)\n"
"{\n"
" double oneOverX = 1.0/x;\n"
"\n"
" return log(oneOverX+sqrt(oneOverX*oneOverX-1.0));\n"
" return acosh(1.0/x);\n"
"}\n";
mAcschFunctionString = "double acsch(double x)\n"
"{\n"
" double oneOverX = 1.0/x;\n"
"\n"
" return log(oneOverX+sqrt(oneOverX*oneOverX+1.0));\n"
" return asinh(1.0/x);\n"
"}\n";
mAcothFunctionString = "double acoth(double x)\n"
"{\n"
" double oneOverX = 1.0/x;\n"
"\n"
" return 0.5*log((1.0+oneOverX)/(1.0-oneOverX));\n"
" return atanh(1.0/x);\n"
"}\n";

// Miscellaneous.
Expand Down Expand Up @@ -636,7 +624,7 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi

mTrueString = "1.0";
mFalseString = "0.0";
mEString = convertToString(exp(1.0));
mEString = convertToString(M_E);
mPiString = convertToString(M_PI);
mInfString = "inf";
mNanString = "nan";
Expand Down Expand Up @@ -711,19 +699,13 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi
" return atan(1.0/x)\n";
mAsechFunctionString = "\n"
"def asech(x):\n"
" one_over_x = 1.0/x\n"
"\n"
" return log(one_over_x+sqrt(one_over_x*one_over_x-1.0))\n";
" return acosh(1.0/x)\n";
mAcschFunctionString = "\n"
"def acsch(x):\n"
" one_over_x = 1.0/x\n"
"\n"
" return log(one_over_x+sqrt(one_over_x*one_over_x+1.0))\n";
" return asinh(1.0/x)\n";
mAcothFunctionString = "\n"
"def acoth(x):\n"
" one_over_x = 1.0/x\n"
"\n"
" return 0.5*log((1.0+one_over_x)/(1.0-one_over_x))\n";
" return atanh(1.0/x)\n";

// Miscellaneous.

Expand Down
4 changes: 2 additions & 2 deletions src/generatorprofilesha1values.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace libcellml {
* The content of this file is generated, do not edit this file directly.
* See docs/dev_utilities.rst for further information.
*/
static const char C_GENERATOR_PROFILE_SHA1[] = "f0d3add475025d2d4b805747828dbaf2f1345b2f";
static const char PYTHON_GENERATOR_PROFILE_SHA1[] = "35838d23a1b89fe47293f75e2684ba6d230cf4a8";
static const char C_GENERATOR_PROFILE_SHA1[] = "e0be7345a3da30625ef6f2316ea4280323703566";
static const char PYTHON_GENERATOR_PROFILE_SHA1[] = "dece9fc3241b5a84a4e1ab67972501af0e550b35";

} // namespace libcellml

0 comments on commit becf20e

Please sign in to comment.