Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
js-math-complex
Advanced tools
Complex Number for JavaScript
<script src="math-complex.js" charset="UTF-8"></script>
require('./math-complex.js');
var cplx = Math.Complex, // for convenience
j = cplx(0, 1);
j.mul(Math.PI).exp() + ''; // -1+1.2246063538223773e-16i
// ditto
Math.Complex.exp(cplx(0, Math.PI));
This module implements complex number arithmetics. Basic arithmetics + All arithmetic functions in Math
are supported.
Constructor. im === 0 if omitted.
var z = Math.Complex(1,2);
z.re === 1;
z.im === 2;
Constructor in polar form.
In the followin example z is a complex number object. Unless otherwise stated, all methods below return complex number objects.
returns true
if z equals z1, false
otherwise.
The opposite of z.eq( *z1 *)
returns the absolute value in Number
.
returns the argument in Number
.
returns - z
returns the conjugate.
Math.Complex(re, im).con().eq(Math.Complex(re, -im));
returns the norm in Number
.
z + z1. z1 can be either complex number or real number If z1 is a real number (Number
object, that is), it is automatically converted to complex number before the calculation. This applies to all binary methods.
z - z1
z * z1
z / z1
Copmplex version of Math.exp( z ) .
Copmplex version of Math.log( z ) .
Copmplex version of Math.exp( z, z1 ) .
Copmplex version of Math.sin( z ) .
Copmplex version of Math.cos( z ) .
Copmplex version of Math.tan( z ) .
Copmplex version of Math.asin( z ) .
Copmplex version of Math.acos( z ) .
Copmplex version of Math.atan( z ) .
z is approximately equal to z1.
delta abs(z - z1)
------- < EPSILON <=> ----------- < 2*EPSILON
average abs(z + z1)
All methods above can also be accessed in functional form which is handy with with
.
// does not work in strict mode
with(Math.Complex){
console.log(atan2(1,1)) // { re: 0.7853981633974483, im: 0 }
}
FAQs
Complex Number for JavaScript
We found that js-math-complex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.