B.7 Simple mathematical functions
The following statements are used to transform data contained in matrices or datasets.
Syntax | Arguments and performed function |
W = exp(X); | W is a matrix with entries equal to the exponentials of the entries of X. The function works element-wise.
|
W = log(X); | W is a matrix with entries equal to the natural logarithms of the entries of X. The function works element-wise.
|
W = sqrt(X); | W is a matrix with entries equal to the square roots of the entries of X. The function works element-wise.
|
W = abs(X); | W is a matrix with entries equal to the absolute values of the entries of X. The function works element-wise.
|
W = mod(X, Y); | W is a matrix with entries equal to modula of the element-wise division X./Y
|
W = sin(X); | W is a matrix with entries equal to the sines of the entries of X. The function works element-wise.
|
W = cos(X); | W is a matrix with entries equal to cosines of the entries of X. The function works element-wise.
|
W = tan(X); | W is a matrix with entries equal to the tangents of the entries of X. The function works element-wise.
|
W = asin(X); | W is a matrix with entries equal to the arcsines of the entries of X. The function works element-wise.
|
W = acos(X); | W is a matrix with entries equal to the arccosines of the entries of X. The function works element-wise.
|
W = atan(X); | W is a matrix with entries equal to the arctangents of the entries of X. The function works element-wise.
|
W = inv(X); | W is the inverse of X.
|
W = invpd(X); | W is the inverse of X, where X is symmetric and positive definite. This function works faster and is more precise than the general inv() function, taking advantage of the structure of X.
|
W = det(X); | W is an matrix with value equal to the determinant of X.
|
W = trace(X); | W is an matrix with value equal to the trace of X.
|
W = diag(X); | The function’s return value depends on the size of X:
|