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

@santi100a/complexia-lib

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@santi100a/complexia-lib

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

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

      NameTypeDescriptionOptional?Default
      realnumberThe real part of the complex number.NoN/A
      imaginarynumberThe imaginary part of the complex number.NoN/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).

    NameTypeDescriptionOptional?Default
    modulusnumberThe modulus of the complex number.NoN/A
    argumentnumberThe argument of the complex number.NoN/A
  • function complexAdd(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Adds two complex numbers together.

    NameTypeDescriptionOptional?Default
    z1ComplexNumberThe first term of the addition.NoN/A
    z2ComplexNumberThe second term of the addition.NoN/A
  • function complexSubtract(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Subracts z2 from z1.

    NameTypeDescriptionOptional?Default
    z1ComplexNumberThe first term of the subtraction.NoN/A
    z2ComplexNumberThe second term of the subtraction.NoN/A
  • function complexMultiply(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Multiplies two complex numbers together.

    NameTypeDescriptionOptional?Default
    z1ComplexNumberThe first term of the multiplication.NoN/A
    z2ComplexNumberThe second term of the multiplication.NoN/A
  • function complexDivide(z1: ComplexNumber, z2: ComplexNumber): ComplexNumber; Divides z1 by z2.

    NameTypeDescriptionOptional?Default
    z1ComplexNumberThe numerator of the division.NoN/A
    z2ComplexNumberThe denominator of the division.NoN/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.

Keywords

FAQs

Package last updated on 20 Jun 2024

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