Libraryless. Click here for Pure Java version (3903L/22K).
srecord Complex(double re, double im) { double abs() { ret sqrt(re*re+im*im); } double re() { ret re; } double im() { ret im; } double phase aka angle() { ret Math.atan2(im, re); } double fracAngle() { ret fracNonNeg(angle()/twoPi()); } // angle as 0 to 1 toString { if (im != 0) ret re == 0 ? im + "i" : re + plusPrefixUnlessMinus(str(im)) + "i"; else ret str(re); } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032421 |
Snippet name: | Complex - complex number (double precision) |
Eternal ID of this version: | #1032421/9 |
Text MD5: | 3bcbc50bbbdf01ab0141ad750c5eb901 |
Transpilation MD5: | 79209f398970f622aee026078ec23a06 |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-18 10:24:53 |
Source code size: | 427 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 271 / 1761 |
Version history: | 8 change(s) |
Referenced in: | [show references] |