Plug-ins in this package/subpackages provide elementary math & statistical functions available in scripts of the Vnano (VCSSL nano).
Features provided by these plug-ins is a subset (*) of the VCSSL Math Library and
the math.StatisticalFunction Library which are a standard libraries of the VCSSL,
so same features are also available in scripts of the VCSSL by default, with importing them at the head of the script as:
" import Math; import math.StatisticalFunction; "
* Features of some math functions (e.g.: sin) provided by plug-ins in this package are extended to make it possible to get/return arrays. It has not been supported yet on the VCSSL, so it is only available on the Vnano.
All of the above plug-ins are released under CC0.
The plug-in providing elementary math functions.
Variable | PI |
---|---|
Value | Storing the value of the circle ratio π. |
Data Type | float (constant) |
Function | rad( degree ) |
---|---|
Feature | The conversion function from degree to radian. Converts the value in the unit of degree passed as an argument "degree" to the value in the unit of radian, and returns it. When an array is passed, converts each elements of it, stores them in another array, and returns it. Please note that, the conversion result will not be shifted automatically to taking value in the range of [0, 2π), so you will get the result value exceeding 2π if you will pass the argument exceeding 360°. |
Signature | float[]...[] rad( const float °ree[]...[] ) |
Params | (float type, any rank) degree: The value in the unit of degree to be converted to the value in the unit of radian. |
Return value | (float type, having same rank/length with the param) The converted value in the unit of radian. |
Example | print( rad(180.0) ); // 3.14... |
Function | deg( radian ) |
---|---|
Feature | The conversion function from radian to degree. Converts the value in the unit of degree passed as an argument "degree" to the value in the unit of radian, and returns it. When an array is passed, converts each elements of it, stores them in another array, and returns it. Please note that, the conversion result will not be shifted automatically to taking value in the range of [0, 360), so you will get the result value exceeding 360° if you will pass the argument exceeding 2π. |
Signature | float[]...[] deg( const float &radian[]...[] ) |
Params | (float type, any rank) radian: The value in the unit of radian to be converted to the value in the unit of degree. |
Return | (float type, having same rank/length with the param) The converted value in the unit of degree. |
Example | print( deg(PI) ); // 180.0 |
Function | sin( x ) |
---|---|
Feature | The sine function. The unit of the argument "x" is radian. When an array is passed, computes the value of sin(x[i]) for each elements x[i], stores them in another array, and returns it. |
Singature | float[]...[] sin( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the sine function in the unit of radian. |
Return | (float type, having same rank/length with the param) The value of the sine function. |
Example | print( sin(PI/2.0) ); // 1.0 |
Function | cos( x ) |
---|---|
Feature | The cosine function. The unit of the argument "x" is radian. When an array is passed, computes the value of cos(x[i]) for each elements x[i], stores them in another array, and returns it. |
Singature | float[]...[] cos( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the cosine function in the unit of radian. |
Return | (float type, having same rank/length with the param) The value of the cosine function. |
Example | print( cos(PI*2.0) ); // 1.0 |
Function | tan( x ) |
---|---|
Feature | The tangent function. The unit of the argument "x" is radian. When an array is passed, computes the value of tan(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] tan( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the tangent function in the unit of radian. |
Return | (float type, having same rank/length with the param) The value of the tangent function. |
Example | print( tan(PI/4.0) ); // 0.99999... (The true value is 1. The difference between the result and the true value is caused by tiny numerical error related with precisions of data/algorithm/etc., so it is not a bug.) |
Function | asin( x ) |
---|---|
Feature | The inverse function of sine (arc-sine). The unit of the result is radian. When an array is passed, computes the value of asin(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] asin( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the arc-sine function. |
Return | (float type, having same rank/length with the param) The value of the arc-sine function in the unit of radian. |
Example | print( asin(1.0) ); // 1.5707963... (≒π/2) |
Function | acos( x ) |
---|---|
Feature | The inverse function of cosine (arc-cosine). The unit of the result is radian. When an array is passed, computes the value of acos(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] acos( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the arc-cosine function. |
Return | (float type, having same rank/length with the param) The value of the arc-cosine function in the unit of radian. |
Example | print( acos(-1.0) ); // 3.14... (≒π) |
Function | atan( x ) |
---|---|
Feature | The inverse function of cosine (arc-tangent). The unit of the result is radian. When an array is passed, computes the value of atan(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] atan( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the arc-tangent function. |
Return | (float type, having same rank/length with the param) The value of the arc-tangent function in the unit of radian. |
Example | print( atan(1.0) ); // 0.78539... (≒π/4) |
Function | sqrt( x ) |
---|---|
Feature | The square-root function. When an array is passed, computes the value of sqrt(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] sqrt( const float &x[]...[] ) |
Params | (float type, any rank) x: The value of which square root should be computed. |
Return | (float type, having same rank/length with the param) The square root value of the argument. |
Example | print( sqrt(4.0) ); // 2.0 |
Function | ln( x ) |
---|---|
Feature | The logarithm function with the base "e" (napier number). When an array is passed, computes the value of ln(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] ln( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the logarithm function. |
Return | (float type, having same rank/length with the param) The value of the logarithm function with the base "e" (napier number). |
Example | print( ln(10.0) ); // 2.3025... |
Function | log10( x ) |
---|---|
Feature | The logarithm function with the base 10. When an array is passed, computes the value of ln(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] log10( const float &x[]...[] ) |
Params | (float type, any rank) x: The argument of the logarithm function. |
Return | (float type, having same rank/length with the param) The value of the logarithm function with the base 10. |
Example | print( log10(10.0) ); // 1.0 |
Function | pow( x, exponent ) |
---|---|
Feature | The function which returns the value of &qupt;x&qupt; to &qupt;exponent&qupt;-power. When an array is passed, computes the value of pow(x[i], exponent) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] pow( const float &x[]...[], const float &exponent ) |
Params |
(float type, any rank) x: see "Feature" section.
(float type) exponent: see "Feature" section. |
Return | (float type, having same rank/length with the param x) The value of &qupt;x&qupt; to &qupt;exponent&qupt;-power. |
Example | print( pow(2.0,3.0) ); // 8.0 |
Function | exp( exponent ) |
---|---|
Fearure | The function which returns the value of &qupt;e&qupt; (napier number) to &qupt;exponent&qupt;-power. When an array is passed, computes the value of exp(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] exp( const float &exponent[]...[] ) |
Params | (float type, any rank) exponent: see "Feature" section. |
Return | (float type, having same rank/length with the param) The value of &qupt;e&qupt; (napier number) to &qupt;exponent&qupt;-power. |
Example | print( exp(2.0) ); // 7.38905... (≒ squared value of "e") |
Function | abs( x ) |
---|---|
Feature | The absolute-value function. When an array is passed, computes the value of abs(x[i]) for each elements x[i], stores them in another array, and returns it. |
Signature | float[]...[] abs( const float &x[]...[] ) |
Params | (float type, any rank) x: The value of which absolute value should be computed. |
Return | (float type, having same rank/length with the param) The absolute value. |
Example | print( abs(-1.23) ); // 1.23 |
The plug-in providing elementary statistical functions.
Function | sum(...) |
---|---|
Feature | Computes the summation value. |
Signature | float sum( ... float ) |
Params | (float type, can pass any number of values) Values of which summation value should be computed. |
Return | (float type) The summation value. |
Example | print( sum(1.0, 2.5, 4.0) ); // 7.5 |
Function | sum( array ) |
---|---|
Feature | Computes the summation value of the values stored in the specified array. |
Signature | float sum( float array[] ) |
Params | (float type, 1-D array) The array storing the values of which summation value should be computed. |
Return | (float type) The summation value. |
Example |
float array[3];
array[0] = 1.0; array[1] = 2.5; array[2] = 4.0; print( sum(array) ); // 7.5 |
Function | mean(...) |
---|---|
Feature | Computes the arithmetic mean value. |
Signature | float mean( ... float ) |
Params | (float type, can pass any number of values) Values of which arithmetic mean value should be computed. |
Return | (float type) The arithmetic mean value. |
Example | print( mean(1.0, 2.5, 4.0) ); // 2.5 |
Function | mean( array ) |
---|---|
Feature | Computes the arithmetic mean value of the values stored in the specified array. |
Signature | float mean( float array[] ) |
Params | (float type, 1-D array) The array storing the values of which arithmetic mean value should be computed. |
Return | (float type) The arithmetic mean value. |
Example |
float array[3];
array[0] = 1.0; array[1] = 2.5; array[2] = 4.0; print( mean(array) ); // 2.5 |
Function | van(...) |
---|---|
Fearure | Computes the value of the variance ( denominator : N ). |
Signature | float van( ... float ) |
Params | (float type, can pass any number of values) Values of which value of the variable should be computed. |
Return | (float type) The value of the variance ( denominator : N ). |
Example | print( van(1.0, 2.5, 4.0) ); // 1.5 |
Function | van( array ) |
---|---|
Fearure | Computes the value of the variance ( denominator : N ). |
Signature | float van( float array[] ) |
Params | (float type, 1-D array ) The array storing the values of which value of the variable should be computed. |
Return | (float type) The value of the variance ( denominator : N ). |
Example |
float array[3];
array[0] = 1.0; array[1] = 2.5; array[2] = 4.0; print( van(array) ); // 1.5 |
Function | van1(...) |
---|---|
Fearure | Computes the value of the variance ( denominator : N-1 ). |
Signature | float van( ... float ) |
Params | (float type, can pass any number of values) Values of which value of the variable should be computed. |
Return | (float type) The value of the variance ( denominator : N-1 ). |
Example | print( van1(1.0, 2.5, 4.0) ); // 2.25 |
Function | van1( array ) |
---|---|
Fearure | Computes the value of the variance ( denominator : N-1 ). |
Signature | float van1( float array[] ) |
Params | (float type, 1-D array ) The array storing the values of which value of the variable should be computed. |
Return | (float type) The value of the variance ( denominator : N-1 ). |
Example |
float array[3];
array[0] = 1.0; array[1] = 2.5; array[2] = 4.0; print( van1(array) ); // 2.25 |
Function | sdn(...) |
---|---|
Feature | Computes the value of the standard-deviation ( denominator : N ). |
Signature | float sdn( ... float ) |
Params | (float type, can pass any number of values) Values of which value of the standard-deviation should be computed. |
Return | (float type) The value of the standard-deviation ( denominator : N ). |
Example | print( sdn(1.0, 2.5, 4.0) ); // 1.2247... (≒√1.5) |
Function | sdn( array ) |
---|---|
Feature | Computes the value of the standard-deviation ( denominator : N ), of the values stored in the specifed array. |
Signature | float sdn( float array[] ) |
Params | (float type, 1-D array) The array storing the values of which value of the standard-deviation should be computed. |
Return | (float type) The value of the standard-deviation ( denominator : N ). |
Example |
float array[3];
array[0] = 1.0; array[1] = 2.5; array[2] = 4.0; print( sdn(array) ); // 1.2247... (≒√1.5) |
Function | sdn1(...) |
---|---|
Feature | Computes the value of the standard-deviation ( denominator : N-1 ). |
Signature | float sdn1( ... float ) |
Params | (float type, can pass any number of values) Values of which value of the standard-deviation should be computed. |
Return | (float type) The value of the standard-deviation ( denominator : N-1 ). |
Example | print( sdn1(1.0, 2.5, 4.0) ); // 1.5 (=√2.25) |
Function | sdn1( array ) |
---|---|
Feature | Computes the value of the standard-deviation ( denominator : N-1 ), of the values stored in the specifed array. |
Signature | float sdn1( float array[] ) |
Params | (float type, 1-D array) The array storing the values of which value of the standard-deviation should be computed. |
Return | (float type) The value of the standard-deviation ( denominator : N-1 ). |
Example |
float array[3];
array[0] = 1.0; array[1] = 2.5; array[2] = 4.0; print( sdn1(array) ); // 1.5 (=√2.25) |