Home > @josh-brown/vector > ScalarOperations
A class which encapsulates the basic arithmetic operations for an arbitrary scalar type.
Signature:
export declare abstract class ScalarOperations<S>
This must be implemented for each scalar to be used in a Vector or Matrix
Method | Modifiers | Description |
---|---|---|
add(first, second) | Returns the sum of two scalars first and second . |
|
conjugate(scalar) | Returns the complex conjugate of a scalar. | |
divide(numerator, denominator) | Returns the quotient of two scalars numerator and denominator , or undefined if the quotient does not exist. |
|
equals(first, second) | Tests if the scalars are equal. Implementors should ensure that the operation is reflexive, associative, and transitive. | |
fromComplex(real, imaginary) | Returns an instance of the scalar type from its real and imaginary parts. If the scalar type does not support complex numbers, then an error will be thrown. | |
fromNumber(num) | Returns an instance of the scalar type which most accurately corresponds to the value of num |
|
getAdditiveIdentity() | Returns the unique scalar that, when added to another scalar, returns that scalar | |
getAdditiveInverse(x) | Returns the unique value that, when added to x , returns the additive identity |
|
getMultiplicativeIdentity() | Returns the unique scalar that, when multiplied by another scalar, returns that scalar | |
getMultiplicativeInverse(x) | Returns the unique scalar that, when multiplied by scalar , returns the multiplicative identity |
|
getPrincipalSquareRoot(x) | Returns the principal square root of a scalar. | |
multiply(first, second) | Returns the product of two scalars first and second . |
|
negativeOne() | Returns the additive inverse of the multiplicative identity. | |
norm(x) | Returns the norm (absolute value or magnitude) of a scalar | |
one() | Alias for ScalarOperations.getMultiplicativeIdentity() | |
prettyPrint(x) | Returns a readable string that represents the value of the scalar | |
random(min, max) | Returns a random scalar value between min and max |
|
randomNormal(mean, standardDeviation) | Returns a random scalar value from a normal distribution centered on mean with standard deviation standardDeviation |
|
subtract(first, second) | Returns the difference of two scalars. | |
zero() | Alias for ScalarOperations.getAdditiveIdentity() |