Commit 993043d8 authored by Over_score's avatar Over_score

Merge branch...

Merge branch '377-with-complex-numbers-in-polar-notation-there-seems-to-be-a-little-chaos-c' into 'master'

Use 39 digit angle conversion in RE->CX function

See merge request !458
parents 5c0dbc8f 5bb11ea7
...@@ -2109,7 +2109,7 @@ void closeNim(void) { ...@@ -2109,7 +2109,7 @@ void closeNim(void) {
} }
} }
} }
else { else { // nimInputIs not Real34
reallocateRegister(REGISTER_X, dtComplex16, COMPLEX16_SIZE, AM_NONE); reallocateRegister(REGISTER_X, dtComplex16, COMPLEX16_SIZE, AM_NONE);
stringToReal16(nimBuffer, REGISTER_REAL16_DATA(REGISTER_X)); stringToReal16(nimBuffer, REGISTER_REAL16_DATA(REGISTER_X));
......
...@@ -106,19 +106,21 @@ void fnReToCx(uint16_t unusedParamButMandatory) { ...@@ -106,19 +106,21 @@ void fnReToCx(uint16_t unusedParamButMandatory) {
real16Zero(VARIABLE_IMAG16_DATA(&temp)); real16Zero(VARIABLE_IMAG16_DATA(&temp));
} }
else { else {
real16_t magnitude16, theta16; realIc_t magnitude, theta;
real16Copy(VARIABLE_REAL16_DATA(&temp), &magnitude16); real16ToRealIc(VARIABLE_REAL16_DATA(&temp), &magnitude);
real16Copy(VARIABLE_IMAG16_DATA(&temp), &theta16); real16ToRealIc(VARIABLE_IMAG16_DATA(&temp), &theta);
if(xIsAReal) { if(xIsAReal) {
convertAngle16FromTo(&theta16, currentAngularMode, AM_RADIAN); convertAngleIcFromTo(&theta, currentAngularMode, AM_RADIAN);
} }
if(real16CompareLessThan(&magnitude16, const16_0)) { if(realIcCompareLessThan(&magnitude, const_0)) {
real16SetPositiveSign(&magnitude16); realIcSetPositiveSign(&magnitude);
real16Add(&theta16, const_pi, &theta16); realIcAdd(&theta, const_pi, &theta);
real16DivideRemainder(&theta16, const_2pi, &theta16); realIcDivideRemainder(&theta, const_2pi, &theta);
} }
real16PolarToRectangular(&magnitude16, &theta16, REGISTER_REAL16_DATA(REGISTER_X), REGISTER_IMAG16_DATA(REGISTER_X)); // theta16 in radian realIcPolarToRectangular(&magnitude, &theta, &magnitude, &theta); // theta in radian
realIcToReal16(&magnitude, REGISTER_REAL16_DATA(REGISTER_X));
realIcToReal16(&theta, REGISTER_IMAG16_DATA(REGISTER_X));
} }
} }
else { else {
...@@ -137,19 +139,21 @@ void fnReToCx(uint16_t unusedParamButMandatory) { ...@@ -137,19 +139,21 @@ void fnReToCx(uint16_t unusedParamButMandatory) {
real34Zero(VARIABLE_IMAG34_DATA(&temp)); real34Zero(VARIABLE_IMAG34_DATA(&temp));
} }
else { else {
real34_t magnitude34, theta34; realIc_t magnitude, theta;
real34Copy(VARIABLE_REAL34_DATA(&temp), &magnitude34); real34ToRealIc(VARIABLE_REAL34_DATA(&temp), &magnitude);
real34Copy(VARIABLE_IMAG34_DATA(&temp), &theta34); real34ToRealIc(VARIABLE_IMAG34_DATA(&temp), &theta);
if(xIsAReal) { if(xIsAReal) {
convertAngle34FromTo(&theta34, currentAngularMode, AM_RADIAN); convertAngleIcFromTo(&theta, currentAngularMode, AM_RADIAN);
} }
if(real34CompareLessThan(&magnitude34, const34_0)) { if(realIcCompareLessThan(&magnitude, const_0)) {
real34SetPositiveSign(&magnitude34); realIcSetPositiveSign(&magnitude);
real34Add(&theta34, const_pi, &theta34); realIcAdd(&theta, const_pi, &theta);
real34DivideRemainder(&theta34, const34_2pi, &theta34); realIcDivideRemainder(&theta, const_2pi, &theta);
} }
real34PolarToRectangular(&magnitude34, &theta34, REGISTER_REAL34_DATA(REGISTER_X), REGISTER_IMAG34_DATA(REGISTER_X)); // theta34 in radian realIcPolarToRectangular(&magnitude, &theta, &magnitude, &theta); // theta in radian
realIcToReal34(&magnitude, REGISTER_REAL34_DATA(REGISTER_X));
realIcToReal34(&theta, REGISTER_IMAG34_DATA(REGISTER_X));
} }
} }
else { else {
......
...@@ -151,4 +151,3 @@ void realIcPolarToRectangular(const realIc_t *mag, const realIc_t *theta, realIc ...@@ -151,4 +151,3 @@ void realIcPolarToRectangular(const realIc_t *mag, const realIc_t *theta, realIc
realIcMultiply(&magnitude, &cos, real); realIcMultiply(&magnitude, &cos, real);
realIcMultiply(&magnitude, &sin, imag); realIcMultiply(&magnitude, &sin, imag);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment