# numdart library

## Classes

Array
Class to create 1 dimension Array. Constructors: [...]
Array2d
Class to create 2 dimensions Array. Constructors: [...]
Array3d
Class to create 3 dimensions Array. Constructors: [...]
ArrayComplex
Class to create 1 dimension ArrayComplex. Constructors: [...]
Complex
Class to create and handle a complex numbers. Constructors: [...]
FloatInfo
LU
LU Decomposition. For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length m so that A(piv,:) = L*U. If m < n, then L is m-by-m and U is m-by-n. The LU decomposition with pivoting always exists, even if the matrix is singular, so the constructor will never fail. The primary use of the LU decomposition is in the solution of square systems of simultaneous linear equations. This will fail if isNonsingular() returns false. References [...]
PolyFit
The {@code PolynomialRegression} class performs a polynomial regression on an set of N data points (yi, xi). That is, it fits a polynomial y = β0 + β1 x + β2 x2 + ... + βd xd (where y is the response variable, x is the predictor variable, and the βi are the regression coefficients) that minimizes the sum of squared residuals of the multiple regression model. It also computes associated the coefficient of determination R2.

This implementation performs a QR-decomposition of the underlying Vandermonde matrix, so it is neither the fastest nor the most numerically stable way to perform the polynomial regression. References

[...]
QR
QR Decomposition. For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n orthogonal matrix Q and an n-by-n upper triangular matrix R so that A = Q*R. The QR decompostion always exists, even if the matrix does not have full rank, so the constructor will never fail. The primary use of the QR decomposition is in the least squares solution of nonsquare systems of simultaneous linear equations. This will fail if isFullRank() returns false. References [...]
SVD
Singular Value Decomposition.

For an m-by-n matrix A with m >= n, the singular value decomposition is an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and an n-by-n orthogonal matrix V so that A = USV'.

The singular values, sigma[k] = S[k][k], are ordered so that sigma >= sigma >= ... >= sigma[n-1].

The singular value decompostion always exists, so the constructor will never fail. The matrix condition number and the effective numerical rank can be computed from this decomposition. References

[...]

## Constants

acos → const acos
`math.acos`
acre → const double
`43560 * foot * foot`
alpha → const double
fine-structure constant
`7.2973525693e-3`
angstrom → const double
`1e-10`
arcmin → const double
`degree / 60`
arcminute → const double
`arcmin`
arcsec → const double
`arcmin / 60`
arcsecond → const double
`arcsec`
asin → const asin
`math.asin`
astronomicalUnit → const double
`au`
atan2 → const atan2
`math.atan2`
atm → const int
`101325`
atmosphere → const int
`atm`
atomicMass → const double
`u`
atto → const double
`1e-18`
au → const double
`149597870700.0`
`NA`
bar → const double
`1e5`
barrel → const double
`bbl`
bbl → const double
`42 * gallonUS`
blob → const double
`pound * g / 0.0254`
Boltzmann → const double
`k`
Btu → const double
`pound * degreeFahrenheit * calorieIT / gram`
BtuIT → const double
`Btu`
BtuTh → const double
`pound * degreeFahrenheit * calorieTh / gram`
c → const int
speed of light in vacuum
`299792458`
calorie → const double
`4.184`
calorieIT → const double
`4.1868`
calorieTh → const double
`calorie`
carat → const double
`200e-6`
centi → const double
`1e-2`
cos → const cos
`math.cos`
day → const double
`24 * hour`
deci → const double
`1e-1`
degree → const double
`pi / 180`
degreeFahrenheit → const double
`1 / 1.8`
deka → const double
`1e1`
dyn → const double
`1e-5`
dyne → const double
`dyn`
e → const double
Base of the natural logarithms. Typically written as "e".
`math.e`
eC → const double
elementary charge
`1.602176634e-19`
electron_volt → const double
`eV`
electronMass → const double
`mE`
elementaryCharge → const double
`eC`
epsilon0 → const double
`1 / (mu0 * c * c)`
erg → const double
`1e-7`
eV → const double
`elementaryCharge`
exa → const double
`1e18`
exbi → const double
`1.152921504606847e18`
exp → const exp
`math.exp`
femto → const double
`1e-15`
fermi → const double
`1e-15`
fineStructure → const double
`alpha`
fluid_ounce_imp → const double
`gallonImp / 160`
fluidOunce → const double
`gallonUS / 128`
fluidOunceUS → const double
`fluidOunce`
`12 * inch`
G → const double
Newtonian constant of gravitation
`6.67430e-11`
g → const double
Standard acceleration of gravity
`9.80665`
gallon → const double
`231 * inch * inch * inch`
gallonImp → const double
`4.54609e-3`
gallonUS → const double
`gallon`
gasConstant → const double
`R`
gibi → const int
`1073741824`
giga → const double
`1e9`
golden → const double
`(1 + 2.23606797749979) / 2`
goldenRatio → const double
`golden`
grain → const double
`64.79891e-6`
gram → const double
`1e-3`
gravitationalConstant → const double
`G`
h → const double
Planck constant
`6.62607015e-34`
hbar → const double
`h / (2 * pi)`
hectare → const double
`1e4`
hecto → const double
`1e2`
horsepower → const double
`hp`
hour → const double
`60 * minute`
hp → const double
`550 * foot * pound * g`
inch → const double
`0.0254`
JulianYear → const double
`365.25 * day`
k → const double
Boltzmann constant
`1.380649e23`
kgf → const double
`g`
kibi → const int
`1024`
kilo → const double
`1e3`
kilogram_force → const double
`kgf`
kmh → const double
`1e3 / hour`
knot → const double
`nauticalMile / hour`
lb → const double
`7000 * grain`
lbf → const double
`pound * g`
lightYear → const double
`JulianYear * c`
liter → const double
`litre`
litre → const double
`1e-3`
ln2 → const double
`math.ln2`
ln10 → const double
`math.ln10`
log → const log
`math.log`
log2e → const double
`math.log2e`
log10e → const double
`math.log10e`
longTon → const double
`2240 * pound`
mach → const double
`340.5`
max → const max<T>
`math.max`
mE → const double
electron mass
`9.1093837015e-31`
mebi → const int
`1048576`
mega → const double
`1e6`
metricTon → const double
`1e3`
micro → const double
`1e-6`
micron → const double
`1e-6`
mil → const double
`inch / 1000`
mile → const double
`1760 * yard`
milli → const double
`1e-3`
min → const min<T>
`math.min`
minute → const double
`60.0`
mmHg → const double
`torr`
mN → const double
neutron mass
`1.67492749804e-27`
mP → const double
proton mass
`1.67262192369e-27`
mph → const double
`mile / hour`
mU → const double
atomic mass constant
`1.66053906660e-27`
mu0 → const double
`4e-7 * pi`
NA → const double
`6.02214076e23`
nano → const double
`1e-9`
nauticalMile → const double
`1852.0`
neutronMass → const double
`mN`
ounce → const double
`oz`
oz → const double
`pound / 16`
parsec → const double
`au / arcsec`
pebi → const int
`1125899906842624`
peta → const double
`1e15`
pi → const double
The PI constant.
`math.pi`
pico → const double
`1e-12`
Planck → const double
`h`
point → const double
`pt`
pound → const double
`lb`
poundForce → const double
`lbf`
pow → const pow
`math.pow`
protonMass → const double
`mP`
psi → const double
`pound * g / (inch * inch)`
pt → const double
`inch / 72`
R → const double
molar gas constant
`8.314462618`
Rydberg → const double
Rydberg constant
`10973731.568160`
shortTon → const double
`2000 * pound`
sigma → const double
Stefan-Boltzmann constant
`5.670374419e-8`
sin → const sin
`math.sin`
slinch → const double
`blob`
slug → const double
`blob / 12`
speedOfLight → const int
`c`
speedOfSound → const double
`mach`
sqrt → const sqrt
`math.sqrt`
sqrt1_2 → const double
`math.sqrt1_2`
sqrt2 → const double
`math.sqrt2`
Stefan_Boltzmann → const double
`sigma`
stone → const double
`14 * pound`
surveyFoot → const double
`1200.0 / 3937`
surveyMile → const double
`5280 * surveyFoot`
tan → const tan
`math.tan`
tebi → const int
`1099511627776`
tera → const double
`1e12`
ton_TNT → const double
`1e9 * calorieTh`
torr → const double
`atm / 760`
troyOunce → const double
`480 * grain`
troyPound → const double
`12 * troyOunce`
u → const double
`mU`
week → const double
`7 * day`
Wien → const double
Wien wavelength displacement law constant
`2.897771955e-3`
yard → const double
`3 * foot`
year → const double
`365 * day`
yobi → const double
`1.208925819614629e24`
yotta → const double
`1e24`
zebi → const double
`1.180591620717411e21`
zepto → const double
`1e-21`
zero_Celsius → const double
`273.15`
zetta → const double
`1e21`

## Functions

arange({int start: 0, int stop: 10, int step: 1 })
Return evenly spaced values within a given interval. Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). When using a non-integer step, such as 0.1, It is better to use linspace. Parameters: [...]
array2dTruncateEachElement(Array2d a, int fractionDigits, { bool returnNewArray: false }) → dynamic
Trucate all the elements of the array Examples [...]
arrayArgMax() → int
Return the index of the first greater element of the array Examples [...]
arrayComplexAbs()
Absolute value of all elements of the current array Examples [...]
arrayComplexConcat( )
Concatenate X in to the current array Examples [...]
arrayComplexConjugate()
Conjugate of all elements of the current array Examples [...]
arrayComplexCos()
Compute the cos for each element of the array Examples [...]
arrayComplexDivisionToScalar( num b)
Divide all the array elements for a number Examples [...]
arrayComplexMultiplyToScalar( num b)
Multiply all the array elements for a number Examples [...]
Add zeros at begging of the array Examples [...]
arrayComplexSum( )
Sum two arrays Examples [...]
arrayComplexTruncateEachElement( int fractionDigits, { bool returnNewArray: false }) → dynamic
Truncate all the numbers of the array Examples [...]
arrayComplexTruncateLast()
Return a Array without the last element Examples [...]
arrayConcat(Array a, )
Concatenate a and b and return Examples [...]
arrayCos()
Compute the cos for each element of the array Examples [...]
arrayCumSum()
Return the array with accumulative sum of all elements of the array Examples [...]
arrayDiff()
Calculate the n-th discrete difference of a Array using the formula `out[i] = a[i+1] - a[i]`. Parameters [...]
arrayDivisionToScalar(Array a, num b)
Divide all the array elements for a number Examples [...]
arrayLog()
Compute the natural logarithm for each element of the array Examples [...]
arrayLog10()
Compute the log10 for each element of the array Examples [...]
arrayMax() → double
Return the greater element in the array Examples [...]
arrayMin() → double
Return the sum of all elements of the array Examples [...]
arrayMultiplyToScalar(Array a, num b)
Multiply all the array elements for a number Examples [...]
Add zeros at begging of the array Examples [...]
arrayPow(Array a, double exponent)
Compute the square root for each element of the array Examples [...]
arrayReshapeToMatrix(Array a, int order)
Reshape a Array to a matrix with a given order Examples [...]
arraySin()
Compute the sin for each element of the array Examples [...]
arraySinc()
Compute the sinc for each element of the array Examples [...]
arraySqrt()
Compute the square root for each element of the array Examples [...]
arraySubToScalar(Array a, num b)
Multiply all the array elements for a number Examples [...]
arraySum() → double
Return the sum of all elements of the array Examples [...]
arrayToColumnMatrix()
Convert a Array to a matrix with one column Examples [...]
arrayToComplexArray()
Convert a Array to ArrayComplex Examples [...]
arrayTruncateEachElement(Array a, int fractionDigits, { bool returnNewArray: false }) → dynamic
Truncate all the numbers of the array Examples [...]
arrayTruncateLast()
Return a Array without the last element Examples [...]
atan2Fast(double y, double x) → double
Two arguments arctangent function [...]
atanFast(double xa, [ double xb = 0.0, bool leftPlane = false ]) → double
Internal helper function to compute arctangent. [...]
bitReverse(int n, int bits) → int
Rotate to left the bits of a int number n times `n`: number `bits` : number of rotations Examples [...]
boolToInt(bool a) → int
Convert a bool to int, if true return 1, else 0
checkParamsGetRangeArray(Array y, Array x, int dx) → void
complexAbs() → double
Return a double that represent the absolute value of a complex number Examples [...]
complexConjugate()
Return the conjugate of a complex number Examples [...]
complexCos()
Compute the cosine of this complex number. [...]
complexDivideScalar(Complex a, num b)
Divide real part and imaginary for a double number `b` : a scalar number, can be int or double Examples [...]
complexMultiplyScalar(Complex a, num b)
Multiply real part and imaginary for a double number `b` : a scalar number, can be int or double Examples [...]
complexTruncate(Complex val, int fractionDigits)
Truncate the real and imaginary part of a imaginary number. This function is very useful for compere two double numbers. `val` : a Complex value `fractionDigits` : number of decimal digits Examples [...]
copySign(double magnitude, double sign) → double
Returns the first argument with the sign of the second argument. A NaN `sign` argument is treated as positive. [...]
cosh(double x) → double
Compute the hyperbolic cosine of a number.
cumIntegration(Array y, { Array x, int dx: 1, double initial })
Compute the numerical accumulative integration of a Array using the trapezoidal rule. `y` : input array to integrate `x` : The sample points corresponding to the y values. If x is null, the sample points are assumed to be evenly spaced dx apart. The default is null. `dx` : The spacing between sample points when x is None. The default is 1. `initial` : optional. If given, uses this value as the first value in the returned result. Typically this value should be 0. Default is null, which means no value at x`0` is returned and return has one element less than y along the axis of integration. References [...]
differentiateArray(Array y, )
Compute the numerical derivative of two arrays `y` : a Array with y points `x` : a Array with x points References [...]
differentiateFunction(double x, Function f, { double dx: 0.00000001 }) → double
Compute the numerical derivative of a function in a certain point `x` : point in the function to calculate the derivative `f` : function to derivate `dx` : optional, interval between the points of the derivative, need be very small numbers, default is 0.00000001 References [...]
expFast(double x, [ double extra = 0.0, List<double> hiPrec ]) → double
Internal helper method for exponential function. [...]
expm1(double x, { List<double> hiPrecOut }) → double
Compute `exp(x) - 1`.
highestOneBit(int n) → int
Reurn the highest one bit of a int `n` : input number References [...]
hypotenuse(double x, double y) → double
Calculate the hypotenuse with pythagorean theorem `x` : cathetus X `y` : cathetus Y Examples [...]
intToBool(int a) → bool
Convert a int to bool, if 0 return false, else true
linspace(double start, double stop, { int num: 50, bool endpoint: true })
Return evenly spaced numbers over a specified interval. Returns `num` evenly spaced samples, calculated over the interval ``start`, `stop``. Parameters [...]
matrixColumnToArray(Array2d a, int column)
Get matrix column. return Array Examples [...]
matrixDeterminant() → double
Matrix determinant return determinant
matrixDivideColumns(Array2d a, )
Divide all the columns by a Array Examples [...]
matrixDot(Array2d a, )
Multiply two matrix References [...]
matrixIdentity(int row, int column)
Generate identity matrix `row` Number of rows. `column` Number of colums. return An m-by-n matrix with ones on the diagonal and zeros elsewhere. Examples [...]
matrixInverse()
Matrix inverse or pseudoinverse return inverse(A) if A is square, pseudoinverse otherwise. Examples [...]
matrixMultiplyColumns(Array2d a, )
Multiply all the columns by a Array Examples [...]
matrixNormOne() → double
One norm return maximum column sum. Examples [...]
matrixNormTwo() → double
Two norm return maximum singular value. Examples [...]
matrixQR() QR
Generate a QR decomposition of the matrix Examples [...]
matrixRank() → int
Matrix rank return rank, obtained from SVD.
matrixSolve(Array2d a, )
Solve A*X = B `b` right hand side return solution if A is square, least squares solution otherwise Examples [...]
matrixSub(Array2d a, int i0, int i1, int j0, int j1)
generate a submatrix from a given interval Examples [...]
matrixSubFromArray(Array2d a, Array rows, int col0, int col1)
Get a submatrix where each element of `rows` array represent a column on current matrix. `rows` Array of row indices. `col0` Initial column index `col1` Final column index return A(r(:),j0:j1) exception ArrayIndexOutOfBoundsException Submatrix indices Examples [...]
matrixSumColumns()
Sum the all columns of the array Examples [...]
matrixTranspose()
Matrix transpose. return A' Examples [...]
matrixVander(Array x, { int N, bool increasing: false })
Generate a Vandermonde matrix. The columns of the output matrix are powers of the input vector. The order of the powers is determined by the `increasing` boolean argument. Specifically, when `increasing` is False, the `i`-th output column is the input vector raised element-wise to the power of `N - i - 1`. Such a matrix with a geometric progression in each row is named for Alexandre- Theophile Vandermonde. Parameters [...]
mean() → double
Return the mean of all elements of the array Examples [...]
median() → double
Return the median of a array Examples [...]
mode() → double
Return the mode of all elements of the array Examples [...]
ones(int num)
Return a new array of given shape and type, filled with ones. Parameters [...]
parabolic(Array y, int x) → List
Quadratic interpolation for estimating the true position of an inter-sample maximum when nearby samples are known. `y` : is a vector `x` : is an index point for that vector. Return [...]
randomArray(int n)
Generates a Array with n elements containing non-negative random floating point value uniformly distributed in the range from 0.0, inclusive, to 1.0, exclusive. `n` : length of array References [...]
randomArray2d(int rows, int columns)
Generates a Array with n elements containing non-negative random floating point value uniformly distributed in the range from 0.0, inclusive, to 1.0, exclusive. `rows` : number of rows `columns` : number of columns Examples [...]
randomArrayComplex(int n)
Generates a ArrayComplex with n elements containing non-negative random floating point value uniformly distributed complex numbers in the range from 0.0, inclusive, to 1.0, exclusive. `n` : length of array Examples [...]
simpsArray(Array y, { Array x, int dx: 1, Even even: Even.last }) → double
Integrate y(x) using samples along the given axis and the composite Simpson's rule. If x is None, spacing of dx is assumed. If there are an even number of samples, N, then there are an odd number of intervals (N-1), but Simpson's rule requires an even number of intervals. The parameter 'even' controls how this is handled. Parameters [...]
simpsFunction(double a, double b, int n, Function f) → double
Compute the numerical integration of f() using the Simpson's rule. `a` : start interval of the integration `b` : final interval of the integration `n` : number of the points between the interval `f` : function to integrate References [...]
sinc(double x) → double
compute nomilized sinc function of x
sinh(double x) → double
Compute the hyperbolic sine of a number.
standardDeviation() → double
Return the standard deviation of sample array Examples [...]
timeit(Function function) → Duration
Return the time necessary to compute a function. Examples [...]
trapzArray(Array y, { Array x, int dx: 1 }) → double
Compute the numerical integration of a Array using the trapezoidal rule. `y` : input array to integrate `x` : The sample points corresponding to the y values. If x is null, the sample points are assumed to be evenly spaced dx apart. The default is null. `dx` : The spacing between sample points when x is None. The default is 1. References [...]
trapzFunction(double a, double b, int n, Function f) → double
Compute the numerical integration of f() using the trapezoidal rule. `a` : start interval of the integration `b` : final interval of the integration `n` : number of the points between the interval `f` : function to integrate References [...]
truncate(double val, int fractionDigits) → double
Truncate the decimal part of a double number. This function is very useful for compere two double numbers. `val` : a double value `fractionDigits` : number of decimal digits References [...]
variance() → double
Return the variance of the array Examples [...]
zeros(int num)
Return a new array of given shape and type, filled with zeros. Parameters: [...]

Even