Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@stdlib/math-base-special-cabs2f
Advanced tools
Compute the squared absolute value of a single-precision complex floating-point number.
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Compute the squared absolute value of a single-precision complex floating-point number.
The absolute value of a complex number is defined as
which corresponds to the length of a vector from the origin to a complex value plotted in the complex plane.
npm install @stdlib/math-base-special-cabs2f
var cabs2f = require( '@stdlib/math-base-special-cabs2f' );
Computes the squared absolute value of a single-precision complex floating-point number.
var Complex64 = require( '@stdlib/complex-float32-ctor' );
var y = cabs2f( new Complex64( 5.0, 3.0 ) );
// returns 34.0
cabs2f()
over cabsf()
.var Complex64 = require( '@stdlib/complex-float32-ctor' );
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
var cabs2f = require( '@stdlib/math-base-special-cabs2f' );
// Create a PRNG to generate uniformly distributed pseudorandom integers:
var rand = discreteUniform( -50, 50 );
// Compute the squared absolute value for a set of random numbers...
var z;
var i;
for ( i = 0; i < 100; i++ ) {
z = new Complex64( rand(), rand() );
console.log( 'cabs2f(%s) = %d', z.toString(), cabs2f( z ) );
}
#include "stdlib/math/base/special/cabs2f.h"
Computes the squared absolute value of a single-precision complex floating-point number.
#include <complex.h>
float y = stdlib_base_cabs2f( 5.0+3.0*I );
// returns 34.0f
The function accepts the following arguments:
[in] float complex
input value.float stdlib_base_cabs2f( const float complex z );
#include "stdlib/math/base/special/cabs2f.h"
#include <stdio.h>
#include <complex.h>
int main( void ) {
const float complex x[] = { 3.14f+1.0f*I, -3.14f-1.0f*I, 0.0f+0.0f*I, 0.0f/0.0f+0.0f/0.0f*I };
float complex v;
float y;
int i;
for ( i = 0; i < 4; i++ ) {
v = x[ i ];
y = stdlib_base_cabs2f( v );
printf( "f(%f + %f) = %f\n", crealf( v ), cimagf( v ), y );
}
}
@stdlib/math-base/special/cabs2
: compute the squared absolute value of a double-precision complex floating-point number.@stdlib/math-base/special/cabsf
: compute the absolute value of a single-precision complex floating-point number.@stdlib/math-base/special/abs2f
: compute the squared absolute value of a single-precision floating-point number.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.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
0.2.2 (2024-07-27)
<section class="commits">8d4c46b
- refactor: update paths (by Athan Reines)ed9c0a5
- refactor: update paths (by Athan Reines)3a3b1e0
- docs: update package URLs (#2269) (by stdlib-bot)8089b88
- docs: update paths (by Athan Reines)038b199
- docs: update paths (by Athan Reines)75d4f83
- refactor: update require and include paths (by Athan Reines)41d41e9
- test: include trailing newlines in Julia-generated JSON fixtures (by Philipp Burckhardt)9ed7d0e
- chore: add missing trailing newlines (by Philipp Burckhardt)A total of 2 people contributed to this release. Thank you to the following contributors:
FAQs
Compute the squared absolute value of a single-precision complex floating-point number.
We found that @stdlib/math-base-special-cabs2f demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.