47 lines
1.5 KiB
Markdown
47 lines
1.5 KiB
Markdown
# Mathematical functions
|
||
|
||
The following mathematical functions can be applied to matrices and vectors: MathAbs, MathArccos, MathArcsin, MathArctan, MathCeil, MathCos, MathExp, MathFloor, MathLog, MathLog10, MathMod, MathPow, MathRound, MathSin, MathSqrt, MathTan, MathExpm1, MathLog1p, MathArccosh, MathArcsinh, MathArctanh, MathCosh, MathSinh, MathTanh. Such operations imply element-wise processing of matrices and vectors.
|
||
|
||
For MathMod and MathPow, the second element can be either a scalar or a matrix/vector of the appropriate size.
|
||
|
||
```
|
||
matrix<T> mat1(128,128);
|
||
matrix<T> mat3(mat1.Rows(),mat1.Cols());
|
||
ulong n,size=mat1.Rows()*mat1.Cols();
|
||
...
|
||
mat2=MathPow(mat1,(T)1.9);
|
||
for(n=0; n<size; n++)
|
||
{
|
||
T res=MathPow(mat1.Flat(n),(T)1.9);
|
||
if(res!=mat2.Flat(n))
|
||
errors++;
|
||
}
|
||
mat2=MathPow(mat1,mat3);
|
||
for(n=0; n<size; n++)
|
||
{
|
||
T res=MathPow(mat1.Flat(n),mat3.Flat(n));
|
||
if(res!=mat2.Flat(n))
|
||
errors++;
|
||
}
|
||
...
|
||
vector<T> vec1(16384);
|
||
vector<T> vec3(vec1.Size());
|
||
ulong n,size=vec1.Size();
|
||
...
|
||
vec2=MathPow(vec1,(T)1.9);
|
||
for(n=0; n<size; n++)
|
||
{
|
||
T res=MathPow(vec1[n],(T)1.9);
|
||
if(res!=vec2[n])
|
||
errors++;
|
||
}
|
||
vec2=MathPow(vec1,vec3);
|
||
for(n=0; n<size; n++)
|
||
{
|
||
T res=MathPow(vec1[n],vec3[n]);
|
||
if(res!=vec2[n])
|
||
errors++;
|
||
}
|
||
|
||
```
|