npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@santi100a/complexia-lib

v0.0.2

Published

Santi's Complex Number Library: "To Complexia!" said Morphocular.

Downloads

5

Readme

Santi's Complex Number Library

Build Status npm homepage GitHub stars License Bundlephobia stats

  • 🚀 Lightweight and fast
  • 👴 ES3-compliant
  • 💻 Portable between the browser and Node.js

What's this?

This library is a small, simple utility for working with complex numbers.

The name comes from the videos of a YouTube channel called Morphocular, where some character always said "To Complexia!" before addressing topics involving complex numbers.

Installation

  • Via NPM: npm install @santi100a/complexia-lib
  • Via Yarn: yarn add @santi100a/complexia-lib
  • Via PNPM: pnpm install @santi100a/complexia-lib

API

  • class ComplexNumber; A complex number.

    • Property ComplexNumber.real: number; The real part of the complex number.

    • Property ComplexNumber.imaginary: number; The imaginary part of the complex number.

    • constructor ComplexNumber(real: number, imaginary: number): ComplexNumber; Represents a complex number with real and
      imaginary parts.

      | Name | Type | Description | Optional? | Default | | ----------- | -------- | ----------------------------------------- | --------- | ------- | | real | number | The real part of the complex number. | No | N/A | | imaginary | number | The imaginary part of the complex number. | No | N/A |

    • ComplexNumber.conjugate(): ComplexNumber; Returns the conjugate of the complex number.

    • ComplexNumber.modulus(): number; Returns the modulus (magnitude or distance to the origin) of the complex number.

    • ComplexNumber.argument(): number; Returns the argument (phase or angle with the positive x-axis) of the complex number in radians.

  • Static method ComplexNumber.fromPolar(modulus: number, argument: number): ComplexNumber; Creates a complex number from polar coordinates (modulus and argument).

    | Name | Type | Description | Optional? | Default | | ---------- | -------- | ----------------------------------- | --------- | ------- | | modulus | number | The modulus of the complex number. | No | N/A | | argument | number | The argument of the complex number. | No | N/A |

  • function complexAdd(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Adds two complex numbers together.

    | Name | Type | Description | Optional? | Default | | ---- | --------------- | -------------------------------- | --------- | ------- | | z1 | ComplexNumber | The first term of the addition. | No | N/A | | z2 | ComplexNumber | The second term of the addition. | No | N/A |

  • function complexSubtract(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Subracts z2 from z1.

    | Name | Type | Description | Optional? | Default | | ---- | --------------- | ----------------------------------- | --------- | ------- | | z1 | ComplexNumber | The first term of the subtraction. | No | N/A | | z2 | ComplexNumber | The second term of the subtraction. | No | N/A |

  • function complexMultiply(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Multiplies two complex numbers together.

    | Name | Type | Description | Optional? | Default | | ---- | --------------- | -------------------------------------- | --------- | ------- | | z1 | ComplexNumber | The first term of the multiplication. | No | N/A | | z2 | ComplexNumber | The second term of the multiplication. | No | N/A |

  • function complexDivide(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Divides z1 by z2.

    | Name | Type | Description | Optional? | Default | | ---- | --------------- | -------------------------------- | --------- | ------- | | z1 | ComplexNumber | The numerator of the division. | No | N/A | | z2 | ComplexNumber | The denominator of the division. | No | N/A |

Usage

const { ComplexNumber } = require('@santi100a/complexia-lib'); // CommonJS
import { ComplexNumber } from '@santi100a/complexia-lib'; // ESM/TypeScript

// Create a complex number with real part 2 and imaginary part 3
const complexNumber = new ComplexNumber(2, 3);

// Get the conjugate of the complex number
const conjugate = complexNumber.conjugate(); // returns ComplexNumber { real: 2, imaginary: -3 }

// Get the modulus of the complex number
const modulus = complexNumber.modulus(); // returns 3.605551275463989

// Get the argument of the complex number
const argument = complexNumber.argument(); // returns 0.982793723247329

// Create a complex number from polar coordinates
const polarComplexNumber = ComplexNumber.fromPolar(4, Math.PI / 4); // returns ComplexNumber { real: 2.8284271247461903, imaginary: 2.8284271247461903 }

Contribute

Wanna contribute? File an issue or pull request! Look at the contribution instructions and make sure you follow the contribution Code of Conduct.