Base (i.e., lower-level) math operators.
var ns = require( '@stdlib/math/base/ops' );Namespace for "base" (i.e., lower-level) math operators.
var operators = ns;
// returns {...}The namespace contains the following functions:
cdiv( z1, z2 ): divide two double-precision complex floating-point numbers.cneg( z ): negate a double-precision complex floating-point number.cnegf( z ): negate a single-precision complex floating-point number.csub( z1, z2 ): subtract two double-precision complex floating-point numbers.csubf( z1, z2 ): subtract two single-precision complex floating-point numbers.imul( a, b ): perform C-like multiplication of two signed 32-bit integers.imuldw( a, b ): compute the double word product of two signed 32-bit integers.umuldw( a, b ): compute the double word product of two unsigned 32-bit integers.
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var ns = require( '@stdlib/math/base/ops' );
console.log( ns.sub( 1.25, 0.45 ) );
// => 0.8
console.log( ns.divf( 1.2, 0.4 ) );
// => 3.0
// Operations for complex numbers:
var z1 = new Complex128( 5.0, 3.0 );
var z2 = new Complex128( -2.0, 1.0 );
console.log( ns.cmul( z1, z2 ) ); // { 're': -13.0, 'im': -1.0 }
// => <Complex128>
// Operations for signed 32-bit integers:
// 2^30 * -5 = -5368709120 => 32-bit integer overflow
console.log( ns.imul( 1073741824|0, -5|0 ) );
// => -1073741824
// Operations for double word product:
// -(2^31) * 2^30 = -2305843009213694000 => 32-bit integer overflow
console.log( ns.imuldw( 0x80000000|0, 0x40000000|0 ) );
// => [ -536870912, 0 ]