-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge master with latest code #158
Merge master with latest code #158
Conversation
…ding standards of ID
Only perturbation and tierazon files now use ManpWIN's complex library Cleanup some function names in tierazon.cpp
I only tested the merge on Windows code and don't know how to test the Linux version. The help files may need some work as per issue #159. |
@@ -70,7 +70,7 @@ | |||
|
|||
// routines in this module | |||
static void perform_worklist(); | |||
static int potential(double, long); | |||
int potential(double, long); // no longer static as it is called by perturbation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this declaration from calcfrac.cpp to calcfrac.h and delete the comment
@@ -1194,14 +1194,20 @@ static void perform_worklist() | |||
boundary_trace(); | |||
break; | |||
case 'g': | |||
solid_guess(); | |||
if (g_calc_status != calc_status_value::COMPLETED) // horrible cludge preventing crash when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark the comment with TODO so we can find it as a cleanup item later.
Always use {}
to surround statements in control blocks (e.g. if
, while
, etc.) like this:
if (g_calc_status != calc_status_value::COMPLETED)
{
solid_guess();
}
break; | ||
case 'd': | ||
diffusion_scan(); | ||
break; | ||
case 'o': | ||
sticky_orbits(); | ||
break; | ||
case 'p': | ||
if (bit_set (g_cur_fractal_specific->flags, fractal_flags::PERTURB)) // we already finished perturbation, so let's get outa here | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{}
with control statements
@@ -2518,7 +2524,7 @@ static void decomposition() | |||
// controlling the level and slope of the continuous potential | |||
// surface. Returns color. | |||
// | |||
static int potential(double mag, long iterations) | |||
int potential(double mag, long iterations) // no longer static as it is called by perturbation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete the comment
@@ -0,0 +1,536 @@ | |||
// SPDX-License-Identifier: GPL-3.0-only | |||
// | |||
// Complex.cpp: interface for the Complex class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the file (and header) to Complex.cpp
from complex.cpp
The easiest way to do this is with git:
cd libid
git mv complex.cpp Complex.cpp
cd include
git mv complex.h Complex.h
temp.x = x; | ||
temp.y = y; | ||
temp1 = temp.CLog()*expon; | ||
// x = temp1.x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete all commented-out code throughout
x+=1; | ||
return *this; | ||
} | ||
// end new stuff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this comment
sin(x+iy) = sin(x)cosh(y) + icos(x)sinh(y) | ||
***************************************************************************/ | ||
|
||
Complex Complex::CSin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a free function instead of a member function and just named sin
instead of CSin
. Same for the other trig functions.
Always prefer a free (e.g. plain) function over a member function when possible.
{ | ||
Complex a; | ||
|
||
a.x = sin(x) * cosh(y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include <cmath>
and qualify math functions with std::
(a + bi)^n = r^n(cos nθ + i sin nθ). | ||
|
||
In particular, if n = ½, we have | ||
√a + bi = √r [cos θ/2 + i sin θ/2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use only ASCII characters in source files. No unicode. This marks the file as binary and prevents diffing and merging. I explained this in an earlier email when I tried to rebase your branch, I believe.
This has probably 'tainted' this entire pull request because the file will be permanently marked as binary as-is. Maybe there's a way for a git guru to undo it, but what I saw when attempting to rebase your branch was that it was very difficult to undo this and honestly, I think it will be easier if you just create a new branch, remove the unicode BOM at the front of the file and remove all unicode characters before you add the file.
Because of this situation, I'm going to ask that you try recreating a branch without unicode in the source files and make a new pull request before I continue reviewing this one. This is a show stopper, unfortunately.
Hi Richard,
I did have a Unicode version of Complex.cpp initially and ran into trouble, but I’m sure I fixed it. When I check my version in:
C:\github\id\iterated-dynamics\libid\Complex.cpp
It shows as UTF-8. Is this not ASCII? Did one of the Unicode versions sneak through?
I have attached the original file after I converted to UTF-8. Will that solve the problem?
Thanks
Paul.
----------------------------------------------------------
Paul de Leeuw Computers NSW Central Coast, Australia
Email: ***@***.*** ***@***.***>
www: <https://deleeuw.com.au>
ABN 72 360 822 562
----------------------------------------------------------
From: Richard Thomson ***@***.***>
Sent: Monday, 11 November 2024 9:45 AM
To: LegalizeAdulthood/iterated-dynamics ***@***.***>
Cc: PaulTheLionHeart ***@***.***>; Author ***@***.***>
Subject: Re: [LegalizeAdulthood/iterated-dynamics] Merge master with latest code (PR #158)
@LegalizeAdulthood commented on this pull request.
_____
In libid/calcfrac.cpp <#158 (comment)> :
@@ -70,7 +70,7 @@
// routines in this module
static void perform_worklist();
-static int potential(double, long);
+ int potential(double, long); // no longer static as it is called by perturbation
Move this declaration from calcfrac.cpp to calcfrac.h and delete the comment
_____
In libid/calcfrac.cpp <#158 (comment)> :
@@ -1194,14 +1194,20 @@ static void perform_worklist()
boundary_trace();
break;
case 'g':
- solid_guess();
+ if (g_calc_status != calc_status_value::COMPLETED) // horrible cludge preventing crash when
Mark the comment with TODO so we can find it as a cleanup item later.
Always use {} to surround statements in control blocks (e.g. if, while, etc.) like this:
if (g_calc_status != calc_status_value::COMPLETED)
{
solid_guess();
}
_____
In libid/calcfrac.cpp <#158 (comment)> :
break;
case 'd':
diffusion_scan();
break;
case 'o':
sticky_orbits();
break;
+ case 'p':
+ if (bit_set (g_cur_fractal_specific->flags, fractal_flags::PERTURB)) // we already finished perturbation, so let's get outa here
+ return;
{} with control statements
_____
In libid/calcfrac.cpp <#158 (comment)> :
@@ -2518,7 +2524,7 @@ static void decomposition()
// controlling the level and slope of the continuous potential
// surface. Returns color.
//
-static int potential(double mag, long iterations)
+int potential(double mag, long iterations) // no longer static as it is called by perturbation
delete the comment
_____
In libid/complex.cpp <#158 (comment)> :
@@ -0,0 +1,536 @@
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
Rename the file (and header) to Complex.cpp from complex.cpp
The easiest way to do this is with git:
cd libid
git mv complex.cpp Complex.cpp
cd include
git mv complex.h Complex.h
_____
In libid/complex.cpp <#158 (comment)> :
@@ -0,0 +1,536 @@
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
Delete all commented-out code
_____
In libid/complex.cpp <#158 (comment)> :
@@ -0,0 +1,536 @@
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
In C++, there's never any need to use (void) as an argument list like C requires. Just write ().
Furthermore, since this destructor doesn't do anything, declare that the compiler should explicitly provide a destructor by writing in the class declaration (in the header):
class Complex
{
public:
~Complex() = default;
...
};
_____
In libid/complex.cpp <#158 (comment)> :
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
+ {
+ }
+
+Complex Complex::operator=(const double & value) // Assignment to double Operator
+ {
Outdent braces here and throughout. It is probably going to be easiest just to select the entire file in Visual Studio and select "Format Selection" from the context menu.
clang-format will take care of everything.
_____
In libid/complex.cpp <#158 (comment)> :
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
+ {
+ }
+
+Complex Complex::operator=(const double & value) // Assignment to double Operator
There's no benefit to accepting a simple value like double by const reference; just use operator=(double value)
The return type of operator= is Complex & not Complex
_____
In libid/complex.cpp <#158 (comment)> :
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
+ {
+ }
+
+Complex Complex::operator=(const double & value) // Assignment to double Operator
+ {
+ x = value;
+ y = 0.0;
+ return *this;
+ }
+
+Complex Complex::operator=(const Complex & Cmplx1) // Assignment Operator
I prefer to name the argument rhs for "right-hand side", because it is the argument to the right of the assignment operator.`
This should return Complex & not Complex
_____
In libid/complex.cpp <#158 (comment)> :
+Complex Complex::operator=(const double & value) // Assignment to double Operator
+ {
+ x = value;
+ y = 0.0;
+ return *this;
+ }
+
+Complex Complex::operator=(const Complex & Cmplx1) // Assignment Operator
+ {
+ x = Cmplx1.x;
+ y = Cmplx1.y;
+ return *this;
+ }
+
+// new stuff
+Complex Complex::operator+=(const Complex & Cmplx1)
Returns Complex &, not Complex.
Same for operator-=, operator*=, and similar operators.
See https://en.cppreference.com/w/cpp/language/operators for details.
_____
In libid/complex.cpp <#158 (comment)> :
+ return *this;
+ }
+
+bool Complex::operator==(Complex & rvalue)
+ {
+ return (x==rvalue.x && y==rvalue.y);
+ }
+
+Complex Complex::operator^(double & expon)
+ {
+ Complex temp, temp1;
+
+ temp.x = x;
+ temp.y = y;
+ temp1 = temp.CLog()*expon;
+// x = temp1.x;
delete all commented-out code throughout
_____
In libid/complex.cpp <#158 (comment)> :
+ temp.x = x;
+ temp.y = y;
+ temp1 = temp.CLog()*expon;
+ temp = temp1.CExp();
+ // temp.x = x;
+ // temp.y = y;
+ // temp = CExp(CLog(temp)*expon);
+ return temp;
+ }
+
+Complex Complex::operator++(void)
+ {
+ x+=1;
+ return *this;
+ }
+// end new stuff
delete this comment
_____
In libid/complex.cpp <#158 (comment)> :
+ double d;
+
+ if (divisor == 0.0)
+ d = zerotol; // prevent divide by zero
+ else
+ d = divisor;
+ temp.x = x / d;
+ temp.y = y / d;
+ return temp;
+ }
+
+/**************************************************************************
+ sin(x+iy) = sin(x)cosh(y) + icos(x)sinh(y)
+***************************************************************************/
+
+Complex Complex::CSin()
This should be a free function instead of a member function and just named sin instead of CSin. Same for the other trig functions.
Always prefer a free (e.g. plain) function over a member function when possible.
_____
In libid/complex.cpp <#158 (comment)> :
+ else
+ d = divisor;
+ temp.x = x / d;
+ temp.y = y / d;
+ return temp;
+ }
+
+/**************************************************************************
+ sin(x+iy) = sin(x)cosh(y) + icos(x)sinh(y)
+***************************************************************************/
+
+Complex Complex::CSin()
+ {
+ Complex a;
+
+ a.x = sin(x) * cosh(y);
Include <cmath> and qualify math functions with std::
_____
In libid/complex.cpp <#158 (comment)> :
+ double temp;
+
+ a.x = (x * x) - (y * y);
+ temp = x * y;
+ a.y = temp + temp;
+ return a;
+ }
+
+/**************************************************************************
+ sqrt(x+iy) =
+
+DeMoivre’s Theorem states that if n is any positive real number, then
+(a + bi)^n = r^n(cos nθ + i sin nθ).
+
+In particular, if n = ½, we have
+√a + bi = √r [cos θ/2 + i sin θ/2]
Use only ASCII characters in source files. No unicode. This marks the file as binary and prevents diffing and merging. I explained this in an earlier email when I tried to rebase your branch, I believe.
This has probably 'tainted' this entire pull request because the file will be permanently marked as binary as-is. Maybe there's a way for a git guru to undo it, but what I saw when attempting to rebase your branch was that it was very difficult to undo this and honestly, I think it will be easier if you just create a new branch, remove the unicode BOM at the front of the file and remove all unicode characters before you add the file.
Because of this situation, I'm going to ask that you try recreating a branch without unicode in the source files and make a new pull request before I continue reviewing this one. This is a show stopper, unfortunately.
—
Reply to this email directly, view it on GitHub <#158 (review)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJDBBKUZ3OQM7GG53UPDI7TZ77OYRAVCNFSM6AAAAABQFKU3GKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDIMRVHA3DOMRRGQ> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AJDBBKWD63U2N62ETEETBZDZ77OYRA5CNFSM6AAAAABQFKU3GKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUQS7F44.gif> Message ID: ***@***.*** ***@***.***> >
// SPDX-License-Identifier: GPL-3.0-only
//
// Complex.cpp: interface for the Complex class.
//
//////////////////////////////////////////////////////////////////////
#include "Complex.h"
//Complex::Complex(void)
// {
// }
Complex::~Complex(void)
{
}
Complex Complex::operator=(const double & value) // Assignment to double Operator
{
x = value;
y = 0.0;
return *this;
}
Complex Complex::operator=(const Complex & Cmplx1) // Assignment Operator
{
x = Cmplx1.x;
y = Cmplx1.y;
return *this;
}
// new stuff
Complex Complex::operator+=(const Complex & Cmplx1)
{
x+=Cmplx1.x;
y+=Cmplx1.y;
return *this;
}
Complex Complex::operator+=(double & rvalue)
{
x+=rvalue;
return *this;
}
Complex Complex::operator-=(const Complex & Cmplx1)
{
x-=Cmplx1.x;
y-=Cmplx1.y;
return *this;
}
Complex Complex::operator-=(double & rvalue)
{
x-=rvalue;
return *this;
}
Complex Complex::operator*=(const Complex & Cmplx1)
{
double t;
t = Cmplx1.x*x-Cmplx1.y*y;
y = Cmplx1.x*y+Cmplx1.y*x;
x = t;
return *this;
}
Complex Complex::operator*=(double & rvalue)
{
x*=rvalue;
y*=rvalue;
return *this;
}
bool Complex::operator==(Complex & rvalue)
{
return (x==rvalue.x && y==rvalue.y);
}
Complex Complex::operator^(double & expon)
{
Complex temp, temp1;
temp.x = x;
temp.y = y;
temp1 = temp.CLog()*expon;
// x = temp1.x;
// y = temp1.y;
temp = temp1.CExp();
// temp.x = x;
// temp.y = y;
// temp = CExp(CLog(temp)*expon);
return temp;
}
Complex Complex::operator^(Complex & expon)
{
Complex temp, temp1;
temp.x = x;
temp.y = y;
temp1 = temp.CLog()*expon;
temp = temp1.CExp();
// temp.x = x;
// temp.y = y;
// temp = CExp(CLog(temp)*expon);
return temp;
}
Complex Complex::operator++(void)
{
x+=1;
return *this;
}
// end new stuff
Complex Complex::operator+(const Complex & Cmplx1) // complex add Operator
{
Complex temp;
temp.x = x + Cmplx1.x;
temp.y = y + Cmplx1.y;
return temp;
}
Complex Complex::operator+(const double & Sum) // complex add double Operator
{
Complex temp;
temp.x = x + Sum;
temp.y = y;
return temp;
}
Complex Complex::operator-(const Complex & Cmplx1) // complex subtract Operator
{
Complex temp;
temp.x = x - Cmplx1.x;
temp.y = y - Cmplx1.y;
return temp;
}
Complex Complex::operator-(const double & Difference) // complex subtract double Operator
{
Complex temp;
temp.x = x - Difference;
temp.y = y;
return temp;
}
Complex Complex::operator-(void) // unary minus
{
Complex temp;
temp.x = -x;
temp.y = -y;
return temp;
}
Complex Complex::operator*(const Complex & Cmplx1) // complex multiply Operator
{
Complex temp;
temp.x = x * Cmplx1.x - y * Cmplx1.y;
temp.y = y * Cmplx1.x + x * Cmplx1.y;
return temp;
}
Complex Complex::operator*(const double & Multiplier) // complex multiply by double Operator
{
Complex temp;
temp.x = x * Multiplier;
temp.y = y * Multiplier;
return temp;
}
Complex Complex::operator/(const Complex & Cmplx1) // complex divide Operator
{
double d;
Complex temp;
if (Cmplx1.x == 0.0 && Cmplx1.y == 0.0)
d = zerotol; // prevent divide by zero
else
d = Cmplx1.x * Cmplx1.x + Cmplx1.y * Cmplx1.y;
temp.x = (x * Cmplx1.x + y * Cmplx1.y) / d;
temp.y = (y * Cmplx1.x - x * Cmplx1.y) / d;
return temp;
}
Complex Complex::operator/(const double & divisor) // complex divide by double Operator
{
Complex temp;
double d;
if (divisor == 0.0)
d = zerotol; // prevent divide by zero
else
d = divisor;
temp.x = x / d;
temp.y = y / d;
return temp;
}
/**************************************************************************
sin(x+iy) = sin(x)cosh(y) + icos(x)sinh(y)
***************************************************************************/
Complex Complex::CSin()
{
Complex a;
a.x = sin(x) * cosh(y);
a.y = cos(x) * sinh(y);
return a;
}
/**************************************************************************
cos(x+iy) = cos(x)cosh(y) - isin(x)sinh(y)
***************************************************************************/
Complex Complex::CCos()
{
Complex a;
a.x = cos(x) * cosh(y);
a.y = -sin(x) * sinh(y);
return a;
}
/**************************************************************************
tan(x+iy) = (tan(x) -i tanh(-y)) / (1 +i tanh(-y) tan(x))
***************************************************************************/
Complex Complex::CTan(void)
{
Complex a;
double denom;
x *= 2;
y *= 2;
denom = cos(x) + cosh(y);
if (fabs(denom) <= DBL_MIN)
a = DBL_MAX;
else
{
a.x = sin(x) / denom;
a.y = sinh(y) / denom;
}
return a;
}
/**************************************************************************
sinh(x+iy) = sinh(x)cos(y) + icosh(x)sin(y)
***************************************************************************/
Complex Complex::CSinh(void)
{
Complex a;
a.x = sinh(x) * cos(y);
a.y = cosh(x) * sin(y);
return a;
}
/**************************************************************************
cosh(x+iy) = cosh(x)cos(y) - isinh(x)sin(y)
***************************************************************************/
Complex Complex::CCosh(void)
{
Complex a;
a.x = cosh(x) * cos(y);
a.y = -sinh(x) * sin(y);
return a;
}
/**************************************************************************
tanh(x+iy) = (tanh(x) + i tan(y)) / (1 +i tanh(x) tan(y))
***************************************************************************/
Complex Complex::CTanh(void)
{
Complex a;
double denom;
x *= 2;
y *= 2;
denom = cosh(x) + cos(y);
if (fabs(denom) <= DBL_MIN)
a = DBL_MAX;
else
{
a.x = sinh(x) / denom;
a.y = sin(y) / denom;
}
return a;
}
/**************************************************************************
Complex Exponent: e^(x+iy) = (e^x) * cos(y) + i * (e^x) * sin(y)
***************************************************************************/
Complex Complex::CExp()
{
Complex a;
a.x = exp(x) * cos(y);
a.y = exp(x) * sin(y);
return a;
}
/**************************************************************************
sqr(x+iy) = x*x-y*y + i(x*y)*2
***************************************************************************/
Complex Complex::CSqr()
{
Complex a;
double temp;
a.x = (x * x) - (y * y);
temp = x * y;
a.y = temp + temp;
return a;
}
/**************************************************************************
sqrt(x+iy) =
DeMoivre’s Theorem states that if n is any positive real number, then
(a + bi)^n = r^n(cos nθ + i sin nθ).
In particular, if n = ½, we have
√a + bi = √r [cos θ/2 + i sin θ/2]
If we apply the half-angle formula:
cos (θ/2) = ± √[(1 + cos θ) / 2]
and
sin (θ/2) = ± √[(1 - cos θ) / 2]
This gives us a straightforward way to calculate √(a + bi)
√(a + bi) = √r [√[(1 + cos θ) / 2] ± i√[(1 - cos θ) / 2]]
√(a + bi) = √r [√[(1 + a/r)/ 2] ± i√[(1 - a/r) / 2]]
Simplifying you get:
√(a + bi) = √[(r + a) / 2] ± i √[(r - a) / 2]
***************************************************************************/
Complex Complex::CSqrt(void)
{
Complex a;
a.x = sqrt(sqrt(x*x+y*y)) * cos(atan2(y,x)/2);
a.y = sqrt(sqrt(x*x+y*y)) * sin(atan2(y,x)/2);
return a;
}
/**************************************************************************
sumsqr(x+iy) = x*x+y*y
***************************************************************************/
double Complex::CSumSqr(void)
{
return (x * x) + (y * y);
}
/**************************************************************************
Abs(x+iy) = sqrt(x*x+y*y)
***************************************************************************/
double Complex::CFabs(void)
{
Complex temp;
temp = (Complex(x, y));
return sqrt(temp.CSumSqr());
}
/**************************************************************************
CFlip(x+iy) = (y+ix) i.e. swap real and imaginary
***************************************************************************/
Complex Complex::CFlip(void)
{
return Complex(y, x);
}
/**************************************************************************
Complex Power Function
**************************************************************************/
void Complex::CPower(Complex & result, Complex & base, int exp)
{
double xt, yt, t2;
xt = base.x; yt = base.y;
if (exp & 1)
{
result.x = xt;
result.y = yt;
}
else
{
result.x = 1.0;
result.y = 0.0;
}
exp >>= 1;
while (exp)
{
t2 = (xt + yt) * (xt - yt);
yt = xt * yt;
yt = yt + yt;
xt = t2;
if (exp & 1)
{
t2 = xt * result.x - yt * result.y;
result.y = result.y * xt + yt * result.x;
result.x = t2;
}
exp >>= 1;
}
}
/**************************************************************************
Evaluate a Complex Polynomial
**************************************************************************/
Complex Complex::CPolynomial(int degree)
{
Complex temp, temp1;
temp1.x = x;
temp1.y = y;
if (degree < 0)
degree = 0;
CPower(temp, temp1, degree);
return temp;
}
/**************************************************************************
invert c + jd = (1 + j0) / (a + jb)
***************************************************************************/
Complex Complex::CInvert(void)
{
double d;
Complex temp;
if (x == 0.0 && y == 0.0)
d = zerotol; // prevent divide by zero
else
d = x * x + y * y;
temp.x = x / d;
temp.y = - y / d;
return temp;
}
/**************************************************************************
Cube c + jd = (a + jb) * (a + jb) * (a + jb)
***************************************************************************/
Complex Complex::CCube()
{
Complex temp;
double sqr_real, sqr_imag;
sqr_real = x * x;
sqr_imag = y * y;
temp.x = x * (sqr_real - (sqr_imag + sqr_imag + sqr_imag));
temp.y = y * ((sqr_real + sqr_real + sqr_real) - sqr_imag);
return temp;
}
/**************************************************************************
Evaluate a Complex Log: ln(x+i y) = 0.5*ln(x²+y²) + i atan(x/y)
**************************************************************************/
Complex Complex::CLog()
{
Complex a, t;
double mod,zx,zy;
t.x = x;
t.y = y;
mod = t.CSumSqr();
mod = sqrt(mod);
zx = log(mod);
zy = atan2(y,x);
a.x = zx;
a.y = zy;
return a;
}
/**************************************************************************
Evaluate a Complex Polynomial with a complex power
**************************************************************************/
// now replaced with operator z^x where z and x are both complex.
//void SinCos(double *Angle, double *Sin, double *Cos)
// {
// *Sin = sin(*Angle);
// *Cos = cos(*Angle);
// }
//Complex CComplexPower(Complex & Cmplx1, Complex & power)
//
// {
// static Complex z;
// Complex t;
// double e2x, siny, cosy;
// double e2x;
// t = 0;
// t = power*CLog(Cmplx1);
// e2x = exp(t.x);
// SinCos(&t.y, &siny, &cosy);
// z.x = e2x * cos(t.y);
// z.y = e2x * sin(t.y);
// return(z);
// }
|
Hi Richard,
What’s your phone number, I’ll give you a call.
Thanks
Paul.
----------------------------------------------------------
Paul de Leeuw Computers NSW Central Coast, Australia
Email: ***@***.*** ***@***.***>
www: <https://deleeuw.com.au>
ABN 72 360 822 562
----------------------------------------------------------
From: Richard Thomson ***@***.***>
Sent: Monday, 11 November 2024 9:45 AM
To: LegalizeAdulthood/iterated-dynamics ***@***.***>
Cc: PaulTheLionHeart ***@***.***>; Author ***@***.***>
Subject: Re: [LegalizeAdulthood/iterated-dynamics] Merge master with latest code (PR #158)
@LegalizeAdulthood commented on this pull request.
_____
In libid/calcfrac.cpp <#158 (comment)> :
@@ -70,7 +70,7 @@
// routines in this module
static void perform_worklist();
-static int potential(double, long);
+ int potential(double, long); // no longer static as it is called by perturbation
Move this declaration from calcfrac.cpp to calcfrac.h and delete the comment
_____
In libid/calcfrac.cpp <#158 (comment)> :
@@ -1194,14 +1194,20 @@ static void perform_worklist()
boundary_trace();
break;
case 'g':
- solid_guess();
+ if (g_calc_status != calc_status_value::COMPLETED) // horrible cludge preventing crash when
Mark the comment with TODO so we can find it as a cleanup item later.
Always use {} to surround statements in control blocks (e.g. if, while, etc.) like this:
if (g_calc_status != calc_status_value::COMPLETED)
{
solid_guess();
}
_____
In libid/calcfrac.cpp <#158 (comment)> :
break;
case 'd':
diffusion_scan();
break;
case 'o':
sticky_orbits();
break;
+ case 'p':
+ if (bit_set (g_cur_fractal_specific->flags, fractal_flags::PERTURB)) // we already finished perturbation, so let's get outa here
+ return;
{} with control statements
_____
In libid/calcfrac.cpp <#158 (comment)> :
@@ -2518,7 +2524,7 @@ static void decomposition()
// controlling the level and slope of the continuous potential
// surface. Returns color.
//
-static int potential(double mag, long iterations)
+int potential(double mag, long iterations) // no longer static as it is called by perturbation
delete the comment
_____
In libid/complex.cpp <#158 (comment)> :
@@ -0,0 +1,536 @@
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
Rename the file (and header) to Complex.cpp from complex.cpp
The easiest way to do this is with git:
cd libid
git mv complex.cpp Complex.cpp
cd include
git mv complex.h Complex.h
_____
In libid/complex.cpp <#158 (comment)> :
@@ -0,0 +1,536 @@
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
Delete all commented-out code
_____
In libid/complex.cpp <#158 (comment)> :
@@ -0,0 +1,536 @@
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
In C++, there's never any need to use (void) as an argument list like C requires. Just write ().
Furthermore, since this destructor doesn't do anything, declare that the compiler should explicitly provide a destructor by writing in the class declaration (in the header):
class Complex
{
public:
~Complex() = default;
...
};
_____
In libid/complex.cpp <#158 (comment)> :
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
+ {
+ }
+
+Complex Complex::operator=(const double & value) // Assignment to double Operator
+ {
Outdent braces here and throughout. It is probably going to be easiest just to select the entire file in Visual Studio and select "Format Selection" from the context menu.
clang-format will take care of everything.
_____
In libid/complex.cpp <#158 (comment)> :
+// SPDX-License-Identifier: GPL-3.0-only
+//
+// Complex.cpp: interface for the Complex class.
+//
+//////////////////////////////////////////////////////////////////////
+#include "Complex.h"
+
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
+ {
+ }
+
+Complex Complex::operator=(const double & value) // Assignment to double Operator
There's no benefit to accepting a simple value like double by const reference; just use operator=(double value)
The return type of operator= is Complex & not Complex
_____
In libid/complex.cpp <#158 (comment)> :
+//Complex::Complex(void)
+// {
+// }
+
+Complex::~Complex(void)
+ {
+ }
+
+Complex Complex::operator=(const double & value) // Assignment to double Operator
+ {
+ x = value;
+ y = 0.0;
+ return *this;
+ }
+
+Complex Complex::operator=(const Complex & Cmplx1) // Assignment Operator
I prefer to name the argument rhs for "right-hand side", because it is the argument to the right of the assignment operator.`
This should return Complex & not Complex
_____
In libid/complex.cpp <#158 (comment)> :
+Complex Complex::operator=(const double & value) // Assignment to double Operator
+ {
+ x = value;
+ y = 0.0;
+ return *this;
+ }
+
+Complex Complex::operator=(const Complex & Cmplx1) // Assignment Operator
+ {
+ x = Cmplx1.x;
+ y = Cmplx1.y;
+ return *this;
+ }
+
+// new stuff
+Complex Complex::operator+=(const Complex & Cmplx1)
Returns Complex &, not Complex.
Same for operator-=, operator*=, and similar operators.
See https://en.cppreference.com/w/cpp/language/operators for details.
_____
In libid/complex.cpp <#158 (comment)> :
+ return *this;
+ }
+
+bool Complex::operator==(Complex & rvalue)
+ {
+ return (x==rvalue.x && y==rvalue.y);
+ }
+
+Complex Complex::operator^(double & expon)
+ {
+ Complex temp, temp1;
+
+ temp.x = x;
+ temp.y = y;
+ temp1 = temp.CLog()*expon;
+// x = temp1.x;
delete all commented-out code throughout
_____
In libid/complex.cpp <#158 (comment)> :
+ temp.x = x;
+ temp.y = y;
+ temp1 = temp.CLog()*expon;
+ temp = temp1.CExp();
+ // temp.x = x;
+ // temp.y = y;
+ // temp = CExp(CLog(temp)*expon);
+ return temp;
+ }
+
+Complex Complex::operator++(void)
+ {
+ x+=1;
+ return *this;
+ }
+// end new stuff
delete this comment
_____
In libid/complex.cpp <#158 (comment)> :
+ double d;
+
+ if (divisor == 0.0)
+ d = zerotol; // prevent divide by zero
+ else
+ d = divisor;
+ temp.x = x / d;
+ temp.y = y / d;
+ return temp;
+ }
+
+/**************************************************************************
+ sin(x+iy) = sin(x)cosh(y) + icos(x)sinh(y)
+***************************************************************************/
+
+Complex Complex::CSin()
This should be a free function instead of a member function and just named sin instead of CSin. Same for the other trig functions.
Always prefer a free (e.g. plain) function over a member function when possible.
_____
In libid/complex.cpp <#158 (comment)> :
+ else
+ d = divisor;
+ temp.x = x / d;
+ temp.y = y / d;
+ return temp;
+ }
+
+/**************************************************************************
+ sin(x+iy) = sin(x)cosh(y) + icos(x)sinh(y)
+***************************************************************************/
+
+Complex Complex::CSin()
+ {
+ Complex a;
+
+ a.x = sin(x) * cosh(y);
Include <cmath> and qualify math functions with std::
_____
In libid/complex.cpp <#158 (comment)> :
+ double temp;
+
+ a.x = (x * x) - (y * y);
+ temp = x * y;
+ a.y = temp + temp;
+ return a;
+ }
+
+/**************************************************************************
+ sqrt(x+iy) =
+
+DeMoivre’s Theorem states that if n is any positive real number, then
+(a + bi)^n = r^n(cos nθ + i sin nθ).
+
+In particular, if n = ½, we have
+√a + bi = √r [cos θ/2 + i sin θ/2]
Use only ASCII characters in source files. No unicode. This marks the file as binary and prevents diffing and merging. I explained this in an earlier email when I tried to rebase your branch, I believe.
This has probably 'tainted' this entire pull request because the file will be permanently marked as binary as-is. Maybe there's a way for a git guru to undo it, but what I saw when attempting to rebase your branch was that it was very difficult to undo this and honestly, I think it will be easier if you just create a new branch, remove the unicode BOM at the front of the file and remove all unicode characters before you add the file.
Because of this situation, I'm going to ask that you try recreating a branch without unicode in the source files and make a new pull request before I continue reviewing this one. This is a show stopper, unfortunately.
—
Reply to this email directly, view it on GitHub <#158 (review)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJDBBKUZ3OQM7GG53UPDI7TZ77OYRAVCNFSM6AAAAABQFKU3GKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDIMRVHA3DOMRRGQ> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AJDBBKWD63U2N62ETEETBZDZ77OYRA5CNFSM6AAAAABQFKU3GKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUQS7F44.gif> Message ID: ***@***.*** ***@***.***> >
|
I have created a new pull request with a "fixed" Complex.cpp and a temporary fix for the help file issues: New Merge of Paul's files with master #160. |
Closing this pull request as it has been replaced by another attempt. |
I have added a few fractals:
Mandelbrot derivatives: Burning ship, mandelbar and celtic.
Tierazon: Talis, newton apple, newton cross, newton polygon, nova, newton flower, newton variation and a few quartets.
Art Matrix: Cubic
The three Mandelbrot derivatives also have bigfloat versions.
Perturbation is applied to the three Mandelbrot derivatives, Mandelbrot itself and ManzPower where the exponent is an integer