complex numbers for JS via GNU Scientific Library. The original C code was transpiled to JS via emscripten.
Installation
Via npm:
npm install gsl-complex
To use it inside node:
var complex = require("gsl-complex");
API
See https://www.gnu.org/software/gsl/manual/html_node/Complex-Numbers.html for a description of the following functions. The prefix gsl_complex_ was removed from the original function definitions. For example, while in C you would call gsl_complex_abs() to retrieve the magnitude of the complex number, the function is exported simply as abs().
Example:
var x = complex.rect(3,2);
complex.abs(x);
Output:
3.605551275463989
Complex numbers
Function
Parameters
Description
rect
(real, imag)
creates a complex number, real+i*imag
polar
(r, theta)
creates a complex number in polar form, r e^(i theta)
Two following getter and setter functions have been defined for the complex number object: