--User changes

-cosh, coth, csch, sech, sinh, tanh: Scale inputs by PI/4. This will produce different results, but is technically more correct.

--Code changes
 -cos, csch: move position of sign flip, shouldn't change output.
 -cot, coth, csc, csch, sec, sech, tan, tanh: add optimization.
This commit is contained in:
Person 2019-06-02 14:33:42 -07:00
parent 460dd6254f
commit a117432762
6 changed files with 206 additions and 146 deletions

View File

@ -50,6 +50,7 @@ namespace EmberNs
#define RAD_2_DEG_T (T(180) / T(M_PI)) #define RAD_2_DEG_T (T(180) / T(M_PI))
#define M_2PI (T(M_PI * 2)) #define M_2PI (T(M_PI * 2))
#define M_3PI (T(M_PI * 3)) #define M_3PI (T(M_PI * 3))
#define M_PI4 (T(M_PI_4))
#define SQRT5 T(2.2360679774997896964091736687313) #define SQRT5 T(2.2360679774997896964091736687313)
#define M_PHI T(1.61803398874989484820458683436563) #define M_PHI T(1.61803398874989484820458683436563)
#define M_1_2PI T(0.15915494309189533576888376337251) #define M_1_2PI T(0.15915494309189533576888376337251)

View File

@ -301,6 +301,17 @@ public:
return v2T(a.x + x, a.y); return v2T(a.x + x, a.y);
} }
/// <summary>
/// Subtract complex from complex.
/// </summary>
/// <param name="a">The first complex number</param>
/// <param name="b">The second complex number</param>
/// <returns>a - b</returns>
static v2T ComplexMinusComplex(v2T a, v2T b)
{
return v2T(a.x - b.x, a.y - b.y);
}
/// <summary> /// <summary>
/// Subtract real from complex. /// Subtract real from complex.
/// </summary> /// </summary>
@ -333,6 +344,16 @@ public:
return v2T(T(0.5) * std::log(a.x * a.x + a.y * a.y), std::atan2(a.y, a.x)); return v2T(T(0.5) * std::log(a.x * a.x + a.y * a.y), std::atan2(a.y, a.x));
} }
/// <summary>
/// Compute the inverse of the natural logarithm of a complex number.
/// </summary>
/// <param name="a">The complex number</param>
/// <returns>exp(a)</returns>
static v2T ComplexExp(v2T a)
{
return v2T(std::cos(a.y), std::sin(a.y)) * std::exp(a.x);
}
/// <summary> /// <summary>
/// Retrieve information about a piece of shared data by looking /// Retrieve information about a piece of shared data by looking
/// up its name. /// up its name.

View File

@ -6271,9 +6271,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
//clamp fabs x and y to 7.104760e+002 for cosh, and |x| 7.104760e+002 for sinh
helper.Out.x = m_Weight * std::cos(helper.In.x) * std::cosh(helper.In.y); helper.Out.x = m_Weight * std::cos(helper.In.x) * std::cosh(helper.In.y);
helper.Out.y = -(m_Weight * std::sin(helper.In.x) * std::sinh(helper.In.y)); helper.Out.y = m_Weight * -std::sin(helper.In.x) * std::sinh(helper.In.y);
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6284,7 +6283,7 @@ public:
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\tvOut.x = " << weight << " * cos(vIn.x) * cosh(vIn.y);\n" << "\t\tvOut.x = " << weight << " * cos(vIn.x) * cosh(vIn.y);\n"
<< "\t\tvOut.y = -(" << weight << " * sin(vIn.x) * sinh(vIn.y));\n" << "\t\tvOut.y = " << weight << " * -sin(vIn.x) * sinh(vIn.y);\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6305,12 +6304,14 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T tansin, tancos, tansinh, tancosh, tanden; T tansin, tancos, tansinh, tancosh, tanden;
sincos(2 * helper.In.x, &tansin, &tancos); T x2 = 2 * helper.In.x;
tansinh = std::sinh(2 * helper.In.y); T y2 = 2 * helper.In.y;
tancosh = std::cosh(2 * helper.In.y); sincos(x2, &tansin, &tancos);
tanden = 1 / Zeps(tancos + tancosh); tansinh = std::sinh(y2);
helper.Out.x = m_Weight * tanden * tansin; tancosh = std::cosh(y2);
helper.Out.y = m_Weight * tanden * tansinh; tanden = m_Weight / Zeps(tancos + tancosh);
helper.Out.x = tanden * tansin;
helper.Out.y = tanden * tansinh;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6320,14 +6321,16 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t tansin = sin((real_t)(2.0) * vIn.x);\n" << "\t\treal_t x2 = (real_t)(2.0) * vIn.x;\n"
<< "\t\treal_t tancos = cos((real_t)(2.0) * vIn.x);\n" << "\t\treal_t y2 = (real_t)(2.0) * vIn.y;\n"
<< "\t\treal_t tansinh = sinh((real_t)(2.0) * vIn.y);\n" << "\t\treal_t tansin = sin(x2);\n"
<< "\t\treal_t tancosh = cosh((real_t)(2.0) * vIn.y);\n" << "\t\treal_t tancos = cos(x2);\n"
<< "\t\treal_t tanden = (real_t)(1.0) / Zeps(tancos + tancosh);\n" << "\t\treal_t tansinh = sinh(y2);\n"
<< "\t\treal_t tancosh = cosh(y2);\n"
<< "\t\treal_t tanden = " << weight << " / Zeps(tancos + tancosh);\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * tanden * tansin;\n" << "\t\tvOut.x = tanden * tansin;\n"
<< "\t\tvOut.y = " << weight << " * tanden * tansinh;\n" << "\t\tvOut.y = tanden * tansinh;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6356,9 +6359,9 @@ public:
sincos(helper.In.x, &secsin, &seccos); sincos(helper.In.x, &secsin, &seccos);
secsinh = std::sinh(helper.In.y); secsinh = std::sinh(helper.In.y);
seccosh = std::cosh(helper.In.y); seccosh = std::cosh(helper.In.y);
secden = 2 / Zeps(std::cos(2 * helper.In.x) + std::cosh(2 * helper.In.y)); secden = (m_Weight * 2) / Zeps(std::cos(2 * helper.In.x) + std::cosh(2 * helper.In.y));
helper.Out.x = m_Weight * secden * seccos * seccosh; helper.Out.x = secden * seccos * seccosh;
helper.Out.y = m_Weight * secden * secsin * secsinh; helper.Out.y = secden * secsin * secsinh;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6372,10 +6375,10 @@ public:
<< "\t\treal_t seccos = cos(vIn.x);\n" << "\t\treal_t seccos = cos(vIn.x);\n"
<< "\t\treal_t secsinh = sinh(vIn.y);\n" << "\t\treal_t secsinh = sinh(vIn.y);\n"
<< "\t\treal_t seccosh = cosh(vIn.y);\n" << "\t\treal_t seccosh = cosh(vIn.y);\n"
<< "\t\treal_t secden = (real_t)(2.0) / Zeps(cos((real_t)(2.0) * vIn.x) + cosh((real_t)(2.0) * vIn.y));\n" << "\t\treal_t secden = (" << weight << " * (real_t)(2.0)) / Zeps(cos((real_t)(2.0) * vIn.x) + cosh((real_t)(2.0) * vIn.y));\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * secden * seccos * seccosh;\n" << "\t\tvOut.x = secden * seccos * seccosh;\n"
<< "\t\tvOut.y = " << weight << " * secden * secsin * secsinh;\n" << "\t\tvOut.y = secden * secsin * secsinh;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6404,9 +6407,9 @@ public:
sincos(helper.In.x, &cscsin, &csccos); sincos(helper.In.x, &cscsin, &csccos);
cscsinh = std::sinh(helper.In.y); cscsinh = std::sinh(helper.In.y);
csccosh = std::cosh(helper.In.y); csccosh = std::cosh(helper.In.y);
cscden = 2 / Zeps(std::cosh(2 * helper.In.y) - std::cos(2 * helper.In.x)); cscden = (m_Weight * 2) / Zeps(std::cosh(2 * helper.In.y) - std::cos(2 * helper.In.x));
helper.Out.x = m_Weight * cscden * cscsin * csccosh; helper.Out.x = cscden * cscsin * csccosh;
helper.Out.y = -(m_Weight * cscden * csccos * cscsinh); helper.Out.y = -(cscden * csccos * cscsinh);//Chaotica does not flip the sign, but uses completely different code which is possibly a mistake. Leave the flip to be compatible with flam3.
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6420,10 +6423,10 @@ public:
<< "\t\treal_t csccos = cos(vIn.x);\n" << "\t\treal_t csccos = cos(vIn.x);\n"
<< "\t\treal_t cscsinh = sinh(vIn.y);\n" << "\t\treal_t cscsinh = sinh(vIn.y);\n"
<< "\t\treal_t csccosh = cosh(vIn.y);\n" << "\t\treal_t csccosh = cosh(vIn.y);\n"
<< "\t\treal_t cscden = (real_t)(2.0) / Zeps(cosh((real_t)(2.0) * vIn.y) - cos((real_t)(2.0) * vIn.x));\n" << "\t\treal_t cscden = (" << weight << " * (real_t)(2.0)) / Zeps(cosh((real_t)(2.0) * vIn.y) - cos((real_t)(2.0) * vIn.x));\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * cscden * cscsin * csccosh;\n" << "\t\tvOut.x = cscden * cscsin * csccosh;\n"
<< "\t\tvOut.y = -(" << weight << " * cscden * csccos * cscsinh);\n" << "\t\tvOut.y = -(cscden * csccos * cscsinh);\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6449,12 +6452,14 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T cotsin, cotcos, cotsinh, cotcosh, cotden; T cotsin, cotcos, cotsinh, cotcosh, cotden;
sincos(2 * helper.In.x, &cotsin, &cotcos); T x2 = 2 * helper.In.x;
cotsinh = std::sinh(2 * helper.In.y); T y2 = 2 * helper.In.y;
cotcosh = std::cosh(2 * helper.In.y); sincos(x2, &cotsin, &cotcos);
cotden = 1 / Zeps(cotcosh - cotcos); cotsinh = std::sinh(y2);
helper.Out.x = m_Weight * cotden * cotsin; cotcosh = std::cosh(y2);
helper.Out.y = m_Weight * cotden * -1 * cotsinh; cotden = m_Weight / Zeps(cotcosh - cotcos);
helper.Out.x = cotden * cotsin;
helper.Out.y = -cotden * cotsinh;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6464,14 +6469,16 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t cotsin = sin((real_t)(2.0) * vIn.x);\n" << "\t\treal_t x2 = (real_t)(2.0) * vIn.x;\n"
<< "\t\treal_t cotcos = cos((real_t)(2.0) * vIn.x);\n" << "\t\treal_t y2 = (real_t)(2.0) * vIn.y;\n"
<< "\t\treal_t cotsinh = sinh((real_t)(2.0) * vIn.y);\n" << "\t\treal_t cotsin = sin(x2);\n"
<< "\t\treal_t cotcosh = cosh((real_t)(2.0) * vIn.y);\n" << "\t\treal_t cotcos = cos(x2);\n"
<< "\t\treal_t cotden = (real_t)(1.0) / Zeps(cotcosh - cotcos);\n" << "\t\treal_t cotsinh = sinh(y2);\n"
<< "\t\treal_t cotcosh = cosh(y2);\n"
<< "\t\treal_t cotden = " << weight << " / Zeps(cotcosh - cotcos);\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * cotden * cotsin;\n" << "\t\tvOut.x = cotden * cotsin;\n"
<< "\t\tvOut.y = " << weight << " * cotden * -1 * cotsinh;\n" << "\t\tvOut.y = -cotden * cotsinh;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6497,9 +6504,11 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T sinhsin, sinhcos, sinhsinh, sinhcosh; T sinhsin, sinhcos, sinhsinh, sinhcosh;
sincos(helper.In.y, &sinhsin, &sinhcos); T xpi4 = helper.In.x * M_PI4;
sinhsinh = std::sinh(helper.In.x); T ypi4 = helper.In.y * M_PI4;
sinhcosh = std::cosh(helper.In.x); sincos(ypi4, &sinhsin, &sinhcos);
sinhsinh = std::sinh(xpi4);
sinhcosh = std::cosh(xpi4);
helper.Out.x = m_Weight * sinhsinh * sinhcos; helper.Out.x = m_Weight * sinhsinh * sinhcos;
helper.Out.y = m_Weight * sinhcosh * sinhsin; helper.Out.y = m_Weight * sinhcosh * sinhsin;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
@ -6511,10 +6520,12 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t sinhsin = sin(vIn.y);\n" << "\t\treal_t xpi4 = vIn.x * MPI4;\n"
<< "\t\treal_t sinhcos = cos(vIn.y);\n" << "\t\treal_t ypi4 = vIn.y * MPI4;\n"
<< "\t\treal_t sinhsinh = sinh(vIn.x);\n" << "\t\treal_t sinhsin = sin(ypi4);\n"
<< "\t\treal_t sinhcosh = cosh(vIn.x);\n" << "\t\treal_t sinhcos = cos(ypi4);\n"
<< "\t\treal_t sinhsinh = sinh(xpi4);\n"
<< "\t\treal_t sinhcosh = cosh(xpi4);\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * sinhsinh * sinhcos;\n" << "\t\tvOut.x = " << weight << " * sinhsinh * sinhcos;\n"
<< "\t\tvOut.y = " << weight << " * sinhcosh * sinhsin;\n" << "\t\tvOut.y = " << weight << " * sinhcosh * sinhsin;\n"
@ -6538,9 +6549,11 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T coshsin, coshcos, coshsinh, coshcosh; T coshsin, coshcos, coshsinh, coshcosh;
sincos(helper.In.y, &coshsin, &coshcos); T xpi4 = helper.In.x * M_PI4;
coshsinh = std::sinh(helper.In.x); T ypi4 = helper.In.y * M_PI4;
coshcosh = std::cosh(helper.In.x); sincos(ypi4, &coshsin, &coshcos);
coshsinh = std::sinh(xpi4);
coshcosh = std::cosh(xpi4);
helper.Out.x = m_Weight * coshcosh * coshcos; helper.Out.x = m_Weight * coshcosh * coshcos;
helper.Out.y = m_Weight * coshsinh * coshsin; helper.Out.y = m_Weight * coshsinh * coshsin;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
@ -6552,10 +6565,12 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t coshsin = sin(vIn.y);\n" << "\t\treal_t xpi4 = vIn.x * MPI4;\n"
<< "\t\treal_t coshcos = cos(vIn.y);\n" << "\t\treal_t ypi4 = vIn.y * MPI4;\n"
<< "\t\treal_t coshsinh = sinh(vIn.x);\n" << "\t\treal_t coshsin = sin(ypi4);\n"
<< "\t\treal_t coshcosh = cosh(vIn.x);\n" << "\t\treal_t coshcos = cos(ypi4);\n"
<< "\t\treal_t coshsinh = sinh(xpi4);\n"
<< "\t\treal_t coshcosh = cosh(xpi4);\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * coshcosh * coshcos;\n" << "\t\tvOut.x = " << weight << " * coshcosh * coshcos;\n"
<< "\t\tvOut.y = " << weight << " * coshsinh * coshsin;\n" << "\t\tvOut.y = " << weight << " * coshsinh * coshsin;\n"
@ -6579,12 +6594,14 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T tanhsin, tanhcos, tanhsinh, tanhcosh, tanhden; T tanhsin, tanhcos, tanhsinh, tanhcosh, tanhden;
sincos(2 * helper.In.y, &tanhsin, &tanhcos); T x2pi4 = helper.In.x * M_PI4 * 2;
tanhsinh = std::sinh(2 * helper.In.x); T y2pi4 = helper.In.y * M_PI4 * 2;
tanhcosh = std::cosh(2 * helper.In.x); sincos(y2pi4, &tanhsin, &tanhcos);
tanhden = 1 / Zeps(tanhcos + tanhcosh); tanhsinh = std::sinh(x2pi4);
helper.Out.x = m_Weight * tanhden * tanhsinh; tanhcosh = std::cosh(x2pi4);
helper.Out.y = m_Weight * tanhden * tanhsin; tanhden = m_Weight / Zeps(tanhcos + tanhcosh);
helper.Out.x = tanhden * tanhsinh;
helper.Out.y = tanhden * tanhsin;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6594,14 +6611,16 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t tanhsin = sin((real_t)(2.0) * vIn.y);\n" << "\t\treal_t x2pi4 = (real_t)(2.0) * vIn.x * MPI4;\n"
<< "\t\treal_t tanhcos = cos((real_t)(2.0) * vIn.y);\n" << "\t\treal_t y2pi4 = (real_t)(2.0) * vIn.y * MPI4;\n"
<< "\t\treal_t tanhsinh = sinh((real_t)(2.0) * vIn.x);\n" << "\t\treal_t tanhsin = sin(y2pi4);\n"
<< "\t\treal_t tanhcosh = cosh((real_t)(2.0) * vIn.x);\n" << "\t\treal_t tanhcos = cos(y2pi4);\n"
<< "\t\treal_t tanhden = (real_t)(1.0) / Zeps(tanhcos + tanhcosh);\n" << "\t\treal_t tanhsinh = sinh(x2pi4);\n"
<< "\t\treal_t tanhcosh = cosh(x2pi4);\n"
<< "\t\treal_t tanhden = " << weight << " / Zeps(tanhcos + tanhcosh);\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * tanhden * tanhsinh;\n" << "\t\tvOut.x = tanhden * tanhsinh;\n"
<< "\t\tvOut.y = " << weight << " * tanhden * tanhsin;\n" << "\t\tvOut.y = tanhden * tanhsin;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6686,14 +6705,14 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T sechsin, sechcos, sechsinh, sechcosh, sechden; T sechsin, sechcos, sechsinh, sechcosh, sechden;
T x = T(M_PI / 4) * helper.In.x; T xpi4 = helper.In.x * M_PI4;
T y = T(M_PI / 4) * helper.In.y; T ypi4 = helper.In.y * M_PI4;
sincos(y, &sechsin, &sechcos); sincos(ypi4, &sechsin, &sechcos);
sechsinh = std::sinh(x); sechsinh = std::sinh(xpi4);
sechcosh = std::cosh(x); sechcosh = std::cosh(xpi4);
sechden = 2 / Zeps(std::cos(y * 2) + std::cosh(x * 2)); sechden = (m_Weight * 2) / Zeps(std::cos(ypi4 * 2) + std::cosh(xpi4 * 2));
helper.Out.x = m_Weight * sechden * sechcos * sechcosh; helper.Out.x = sechden * sechcos * sechcosh;
helper.Out.y = m_Weight * sechden * sechsin * sechsinh; helper.Out.y = -sechden * sechsin * sechsinh;//Flam3 flips the sign, but Chaotica does not. Leave to be compatible with flam3.
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6703,16 +6722,16 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t x = MPI / (real_t)(4.0) * vIn.x;\n" << "\t\treal_t xpi4 = vIn.x * MPI4;\n"
<< "\t\treal_t y = MPI / (real_t)(4.0) * vIn.y;\n" << "\t\treal_t ypi4 = vIn.y * MPI4;\n"
<< "\t\treal_t sechsin = sin(y);\n" << "\t\treal_t sechsin = sin(ypi4);\n"
<< "\t\treal_t sechcos = cos(y);\n" << "\t\treal_t sechcos = cos(ypi4);\n"
<< "\t\treal_t sechsinh = sinh(x);\n" << "\t\treal_t sechsinh = sinh(xpi4);\n"
<< "\t\treal_t sechcosh = cosh(x);\n" << "\t\treal_t sechcosh = cosh(xpi4);\n"
<< "\t\treal_t sechden = (real_t)(2.0) / Zeps(cos(y * (real_t)(2.0)) + cosh(x * (real_t)(2.0)));\n" << "\t\treal_t sechden = (" << weight << " * (real_t)(2.0)) / Zeps(cos(ypi4 * (real_t)(2.0)) + cosh(xpi4 * (real_t)(2.0)));\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * sechden * sechcos * sechcosh;\n" << "\t\tvOut.x = sechden * sechcos * sechcosh;\n"
<< "\t\tvOut.y = " << weight << " * sechden * sechsin * sechsinh;\n" << "\t\tvOut.y = -sechden * sechsin * sechsinh;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6738,12 +6757,14 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T cschsin, cschcos, cschsinh, cschcosh, cschden; T cschsin, cschcos, cschsinh, cschcosh, cschden;
sincos(helper.In.y, &cschsin, &cschcos); T xpi4 = helper.In.x * M_PI4;
cschsinh = std::sinh(helper.In.x); T ypi4 = helper.In.y * M_PI4;
cschcosh = std::cosh(helper.In.x); sincos(ypi4, &cschsin, &cschcos);
cschden = 2 / Zeps(std::cosh(2 * helper.In.x) - std::cos(2 * helper.In.y)); cschsinh = std::sinh(xpi4);
helper.Out.x = m_Weight * cschden * cschsinh * cschcos; cschcosh = std::cosh(xpi4);
helper.Out.y = -(m_Weight * cschden * cschcosh * cschsin); cschden = (m_Weight * 2) / Zeps(std::cosh(2 * xpi4) - std::cos(2 * ypi4));
helper.Out.x = cschden * cschsinh * cschcos;
helper.Out.y = -cschden * cschcosh * cschsin;//Chaotica does not flip the sign, but uses completely different code which is possibly a mistake. Leave the flip to be compatible with flam3.
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6753,14 +6774,16 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t cschsin = sin(vIn.y);\n" << "\t\treal_t xpi4 = vIn.x * MPI4;\n"
<< "\t\treal_t cschcos = cos(vIn.y);\n" << "\t\treal_t ypi4 = vIn.y * MPI4;\n"
<< "\t\treal_t cschsinh = sinh(vIn.x);\n" << "\t\treal_t cschsin = sin(ypi4);\n"
<< "\t\treal_t cschcosh = cosh(vIn.x);\n" << "\t\treal_t cschcos = cos(ypi4);\n"
<< "\t\treal_t cschden = (real_t)(2.0) / Zeps(cosh((real_t)(2.0) * vIn.x) - cos((real_t)(2.0) * vIn.y));\n" << "\t\treal_t cschsinh = sinh(xpi4);\n"
<< "\t\treal_t cschcosh = cosh(xpi4);\n"
<< "\t\treal_t cschden = (" << weight << " * (real_t)(2.0)) / Zeps(cosh((real_t)(2.0) * xpi4) - cos((real_t)(2.0) * ypi4));\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * cschden * cschsinh * cschcos;\n" << "\t\tvOut.x = cschden * cschsinh * cschcos;\n"
<< "\t\tvOut.y = -(" << weight << " * cschden * cschcosh * cschsin);\n" << "\t\tvOut.y = -cschden * cschcosh * cschsin;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -6786,12 +6809,14 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T cothsin, cothcos, cothsinh, cothcosh, cothden; T cothsin, cothcos, cothsinh, cothcosh, cothden;
sincos(2 * helper.In.y, &cothsin, &cothcos); T x2pi4 = helper.In.x * M_PI4 * 2;
cothsinh = std::sinh(2 * helper.In.x); T y2pi4 = helper.In.y * M_PI4 * 2;
cothcosh = std::cosh(2 * helper.In.x); sincos(y2pi4, &cothsin, &cothcos);
cothden = 1 / Zeps(cothcosh - cothcos); cothsinh = std::sinh(x2pi4);
helper.Out.x = m_Weight * cothden * cothsinh; cothcosh = std::cosh(x2pi4);
helper.Out.y = m_Weight * cothden * cothsin; cothden = m_Weight / Zeps(cothcosh - cothcos);
helper.Out.x = cothden * cothsinh;
helper.Out.y = cothden * cothsin;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -6801,14 +6826,16 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
intmax_t varIndex = IndexInXform(); intmax_t varIndex = IndexInXform();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t cothsin = sin((real_t)(2.0) * vIn.y);\n" << "\t\treal_t x2pi4 = (real_t)(2.0) * vIn.x * MPI4;\n"
<< "\t\treal_t cothcos = cos((real_t)(2.0) * vIn.y);\n" << "\t\treal_t y2pi4 = (real_t)(2.0) * vIn.y * MPI4;\n"
<< "\t\treal_t cothsinh = sinh((real_t)(2.0) * vIn.x);\n" << "\t\treal_t cothsin = sin(y2pi4);\n"
<< "\t\treal_t cothcosh = cosh((real_t)(2.0) * vIn.x);\n" << "\t\treal_t cothcos = cos(y2pi4);\n"
<< "\t\treal_t cothden = (real_t)(1.0) / Zeps(cothcosh - cothcos);\n" << "\t\treal_t cothsinh = sinh(x2pi4);\n"
<< "\t\treal_t cothcosh = cosh(x2pi4);\n"
<< "\t\treal_t cothden = " << weight << " / Zeps(cothcosh - cothcos);\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * cothden * cothsinh;\n" << "\t\tvOut.x = cothden * cothsinh;\n"
<< "\t\tvOut.y = " << weight << " * cothden * cothsin;\n" << "\t\tvOut.y = cothden * cothsin;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();

View File

@ -2185,9 +2185,9 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_Rad, prefix + "hypercrop_rad", 1)); m_Params.push_back(ParamWithName<T>(&m_Rad, prefix + "hypercrop_rad", 1));
m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "hypercrop_zero")); m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "hypercrop_zero"));
m_Params.push_back(ParamWithName<T>(true, &m_Coeff, prefix + "hypercrop_coeff"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Coeff, prefix + "hypercrop_coeff"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_A0, prefix + "hypercrop_a0"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_A0, prefix + "hypercrop_a0"));
m_Params.push_back(ParamWithName<T>(true, &m_Len, prefix + "hypercrop_len"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Len, prefix + "hypercrop_len"));
m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "hypercrop_d"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "hypercrop_d"));
} }
private: private:

View File

@ -177,6 +177,11 @@ FunctionMapper::FunctionMapper()
"{\n" "{\n"
" return (real2)(a.x - x, a.y);\n" " return (real2)(a.x - x, a.y);\n"
"}\n"; "}\n";
s_GlobalMap["ComplexMinusComplex"] =
"inline real2 ComplexMinusComplex(real2 a, real2 b)\n"
"{\n"
" return (real2)(a.x - b.x, a.y - b.y);\n"
"}\n";
s_GlobalMap["ComplexSqrt"] = s_GlobalMap["ComplexSqrt"] =
"inline real2 ComplexSqrt(real2 a)\n" "inline real2 ComplexSqrt(real2 a)\n"
"{\n" "{\n"
@ -188,6 +193,11 @@ FunctionMapper::FunctionMapper()
"{\n" "{\n"
" return (real2)(0.5 * log(fma(a.x, a.x, a.y * a.y)), atan2(a.y, a.x));\n" " return (real2)(0.5 * log(fma(a.x, a.x, a.y * a.y)), atan2(a.y, a.x));\n"
"}\n"; "}\n";
s_GlobalMap["ComplexExp"] =
"inline real2 ComplexExp(real2 a)\n"
"{\n"
" return (real2)(cos(a.y), sin(a.y)) * exp(a.x);\n"
"}\n";
s_GlobalMap["Hash"] = s_GlobalMap["Hash"] =
"inline real_t Hash(int a)\n" "inline real_t Hash(int a)\n"
"{\n" "{\n"

View File

@ -59,6 +59,7 @@ namespace apoconv
{ "pow(", "std::pow(" }, { "pow(", "std::pow(" },
{ "fabs(", "std::abs(" }, { "fabs(", "std::abs(" },
{ "log(", "std::log(" }, { "log(", "std::log(" },
{ "exp(", "std::exp(" },
{ "sqr(", "Sqr(" }, { "sqr(", "Sqr(" },
@ -69,7 +70,7 @@ namespace apoconv
{ "M_LN10", "T(M_LN10)" }, { "M_LN10", "T(M_LN10)" },
{ "M_PI", "T(M_PI)" }, { "M_PI", "T(M_PI)" },
{ "M_PI_2", "T(M_PI_2)" }, { "M_PI_2", "T(M_PI_2)" },
{ "M_PI_4", "T(M_PI_4)" }, { "M_PI_4", "M_PI4" },
{ "M_1_PI", "T(M_1_PI)" }, { "M_1_PI", "T(M_1_PI)" },
{ "M_2_PI", "T(M_2_PI)" }, { "M_2_PI", "T(M_2_PI)" },
{ "M_2_SQRTPI", "T(M_2_SQRTPI)" }, { "M_2_SQRTPI", "T(M_2_SQRTPI)" },