BayES BayES

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.

  • X must be a matrix or dataset



W = log(X);

W is a matrix with entries equal to the natural logarithms of the entries of X. The function works element-wise.

  • X must be a matrix or dataset
  • If X contains non-positive entries then the corresponding entries of W are set to nan



W = sqrt(X);

W is a matrix with entries equal to the square roots of the entries of X. The function works element-wise.

  • X must be a matrix or dataset
  • If X contains negative entries then the corresponding entries of W are set to nan



W = abs(X);

W is a matrix with entries equal to the absolute values of the entries of X. The function works element-wise.

  • X must be a matrix or dataset



W = mod(X, Y);

W is a matrix with entries equal to modula of the element-wise division X./Y

  • X must be a matrix or dataset
  • Y must be a matrix or dataset
  • The dimensions of X and Y must be equal



W = sin(X);

W is a matrix with entries equal to the sines of the entries of X. The function works element-wise.

  • X must be a matrix or dataset



W = cos(X);

W is a matrix with entries equal to cosines of the entries of X. The function works element-wise.

  • X must be a matrix or dataset



W = tan(X);

W is a matrix with entries equal to the tangents of the entries of X. The function works element-wise.

  • X must be a matrix or dataset



W = asin(X);

W is a matrix with entries equal to the arcsines of the entries of X. The function works element-wise.

  • X must be a matrix or dataset
  • If X contains entries outside the interval 1,1 then the corresponding entries of W are set to nan



W = acos(X);

W is a matrix with entries equal to the arccosines of the entries of X. The function works element-wise.

  • X must be a matrix or dataset
  • If X contains entries outside the interval 1,1 then the corresponding entries of W are set to nan



W = atan(X);

W is a matrix with entries equal to the arctangents of the entries of X. The function works element-wise.

  • X must be a matrix or dataset



W = inv(X);

W is the inverse of X.

  • X must be a square matrix or dataset
  • If X is singular an error is produced



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.

  • X must be a symmetric and positive-definite matrix or dataset
  • If X is not positive definite an error is produced



W = det(X);

W is an 1 ×1 matrix with value equal to the determinant of X.

  • X must be a square matrix



W = trace(X);

W is an 1 ×1 matrix with value equal to the trace of X.

  • X must be a square matrix



W = diag(X);

The function’s return value depends on the size of X:
if X is an M ×M matrix then W is an M ×1 vector that contains the values on the diagonal of X
if X is vector of length M then W is a diagonal M ×M matrix that contains the entries of X on its diagonal.

  • X must be either a square matrix (or dataset) or a vector


Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis