Skip to content

Commit 64a2e47

Browse files
committed
Add cPolar
1 parent cec965d commit 64a2e47

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/libs/stdlib.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ inline function cSub(a, b) => a - b;
230230
231231
//Raises a real number to a complex power.
232232
inline function cPowRC(real, complex) {
233-
const p1 = cos(cI(complex) * ln(real));
234-
const p2 = sin(cI(complex) * ln(real));
233+
const p1 = cos(cI(complex));
234+
const p2 = sin(cI(complex));
235235
236236
const mul = (real^cR(complex), 0);
237237
238-
cMul(mul, (p1, p2))
238+
cMul(mul, ln(real) * (p1, p2))
239239
}
240240
241241
//Raises a complex number to a real power.
@@ -274,6 +274,11 @@ inline function cLn(a) {
274274
(p1, p2)
275275
}
276276
277+
//Creates a complex number from polar form.
278+
inline function cPolar(abs, arg) {
279+
abs * (cos(arg), sin(arg))
280+
}
281+
277282
//The complex sine function.
278283
inline function cSin(a) {
279284
const p1 = sin(cR(a)) * cosh(cI(a));

0 commit comments

Comments
 (0)