Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-complex

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-complex

a simple complex number library

  • 0.1.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Description

a simple complex number library

Examples

import Complex from 'simple-complex'

//constructor
const z = new Complex(2, 3) // 2 + 3i
const ζ = new Complex(z)

// create a number from modulus & argument
const z = Complex.fromAngle(2, Math.PI) // -2

// clone
const z = new Complex(1, 1)
const ζ = z.clone()

// set value
const z = new Complex()
z.set(2, 3)

// static sum
const z = new Complex(4, 3)
const ζ = new Complex(1, 2)
const sum = Complex.sum(z, ζ)

// add
const z = new Complex(0, 0)
const ζ = new Complex(1, 2)
z.add(ζ)

// static multiply
const z = new Complex(1, 3)
const ζ = new Complex(-4, 2)
const result = Complex.multiply(z, ζ)

// multiplyBy
const z = new Complex(1, 3)
const ζ = new Complex(-4, 2)
z.multiplyBy(ζ)

// rotate
const z = new Complex(1, 0)
z.rotate(Math.PI / 2) // i
z.rotate(Math.PI / 2) // -1
z.rotate(Math.PI / 2) // -i
z.rotate(Math.PI / 2) // 1

// getters and setters
const ζ = new Complex(2, 2)
const { argument, modulus } = ζ

const z = new Complex(0, 0)
z.modulus = 10
z.argument = Math.PI / 2

// some functions
const z = new Complex(1, 3)
const exponential = Complex.exp(z)
const square = Complex.square(z)

// toString
const z = Complex.fromAngle(2, 0)
const value = z.toString() // '2'

FAQs

Package last updated on 08 May 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc