Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stdlib/math-base-special-cabs

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/math-base-special-cabs

Compute an absolute value of a complex number.

Source
npmnpm
Version
0.0.3
Version published
Maintainers
4
Created
Source

Absolute Value

NPM version Build Status Coverage Status dependencies

Compute an absolute value of a complex number.

The absolute value of a complex number is defined as

Absolute value

which corresponds to the length of a vector from the origin to a complex value plotted in the complex plane.

Installation

npm install @stdlib/math-base-special-cabs

Usage

var cabs = require( '@stdlib/math-base-special-cabs' );

cabs( re, im )

Computes an absolute value of a complex number comprised of a real component re and an imaginary component im.

var y = cabs( 5.0, 3.0 );
// returns ~5.83

Examples

var Complex128 = require( '@stdlib/complex-float64' );
var randu = require( '@stdlib/random-base-randu' );
var round = require( '@stdlib/math-base-special-round' );
var real = require( '@stdlib/complex-real' );
var imag = require( '@stdlib/complex-imag' );
var cabs = require( '@stdlib/math-base-special-cabs' );

var re;
var im;
var z;
var i;

for ( i = 0; i < 100; i++ ) {
    re = round( randu()*100.0 ) - 50.0;
    im = round( randu()*100.0 ) - 50.0;
    z = new Complex128( re, im );
    console.log( 'cabs(%s) = %d', z.toString(), cabs( real(z), imag(z) ) );
}

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

License

See LICENSE.

Copyright © 2016-2021. The Stdlib Authors.

Keywords

stdlib

FAQs

Package last updated on 16 Jun 2021

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