Mathematical functions¶
The functions described below implement common mathematical functions which can be applied element-wise to the elements of a matrix
such as cos, sqrt, etc.
abs¶
acos¶
acosd¶
acosh¶
-
template<typename S>
auto castor::acosh(matrix<S> const &X)¶ Inverse hyperbolic cosine.
acosh(X) is the inverse hyperbolic cosine of the elements of X.
matrix<> X = {{1,2,3},{4,5,6}}; matrix<> Y = acosh(X); disp(Y);
See cosh.
angle¶
-
template<typename S>
auto castor::angle(matrix<S> const &X)¶ Phase angle.
angle(X) returns the phase angles, in radians, of a matrix with complex elements.
matrix<> A = {{1,0,-1},{1,0,-1}}; matrix<> B = {{0,0,0},{1,1,1}}; auto X = A + M_1I*B; matrix<> Y = angle(X); disp(Y);
See abs.
asin¶
asind¶
asinh¶
-
template<typename S>
auto castor::asinh(matrix<S> const &X)¶ Inverse hyperbolic sine.
asinh(X) is the inverse hyperbolic sine of the elements of X.
matrix<> X = {{1,2,3},{4,5,6}}; matrix<> Y = asinh(X); disp(Y);
See sinh.
atan¶
atand¶
atanh¶
-
template<typename S>
auto castor::atanh(matrix<S> const &X)¶ Inverse hyperbolic tangent.
atanh(X) is the inverse hyperbolic tangent of the elements of X.
matrix<> X = {{1,2,3},{4,5,6}}; matrix<> Y = atanh(X); disp(Y);
See tanh.
ceil¶
conj¶
cos¶
cosd¶
cosh¶
-
template<typename S>
auto castor::cosh(matrix<S> const &X)¶ Hyperbolic cosine.
cosh(X) is the hyperbolic cosine of the elements of X.
matrix<> X = {{1,2,3},{4,5,6}}; matrix<> Y = cosh(X); disp(Y);
See acosh.
deg2rad¶
-
template<typename T>
matrix<T> castor::deg2rad(matrix<T> const &X)¶ Convert angles from degrees to radians.
deg2rad(X) converts angle units from degrees to radians for each element of X.
matrix<> X = {0,90,180,-90}; matrix<> Y = deg2rad(X); disp(Y);
See rad2deg.
exp¶
floor¶
imag¶
log¶
log2¶
log10¶
pow¶
-
template<typename R, typename S>
auto castor::pow(matrix<R> const &X, matrix<S> const &Y)¶ Power of argument.
pow(A,B) denotes element-by-element powers. A and B must have compatible sizes. In the simplest cases, they can be the same size or one can be a scalar. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the inputs are either the same or one of them is 1.
matrix<> A = {-2,-1,0,1,2}; matrix<> B = {-2,-1,0,1,2}; matrix<> C = pow(A,B); matrix<> D = pow(A,2); disp(C); disp(D);
rad2deg¶
-
template<typename T>
matrix<T> castor::rad2deg(matrix<T> const &X)¶ Convert angles from radians to degrees.
rad2deg(X) converts angle units from radians to degrees for each element of X.
matrix<> X = {0,M_PI/2,M_PI,-M_PI/2}; matrix<> Y = rad2deg(X); disp(Y);
See deg2rad.
real¶
round¶
sign¶
-
template<typename S>
auto castor::sign(matrix<S> const &X)¶ Signum function.
For each element of X, sign(X) returns 1 if the element is greater than zero, 0 if it equals zero and -1 if it is less than zero. For the nonzero elements of complex X, sign(X) = X ./ ABS(X).
matrix<> X = {{-1,-2,0},{3,4,0}}; matrix<> Y = sign(X); disp(Y);
See abs.
sin¶
sind¶
sinh¶
-
template<typename S>
auto castor::sinh(matrix<S> const &X)¶ Hyperbolic sine.
sinh(X) is the hyperbolic sine of the elements of X.
matrix<> X = {0,1,2,3}; matrix<> Y = sinh(X); disp(Y);
See asinh.
sqrt¶
-
template<typename S>
auto castor::sqrt(matrix<S> const &X)¶ Square root.
sqrt(X) is the square root of the elements of X.
matrix<> X = {-1,0,1,2,4}; auto Y = sqrt(X); disp(Y);
See pow.
tan¶
tand¶
tanh¶
-
template<typename S>
auto castor::tanh(matrix<S> const &X)¶ Hyperbolic tangent.
tanh(X) is the hyperbolic tangent of the elements of X.
matrix<> X = {0,1,2,3}; matrix<> Y = tanh(X); disp(Y);
See atanh.