- Matrix Arithmetic
- Coefficient-Wise Operations
- Reductions
- Minimum/ Maximum Element In The Matrix
- Minimum/ Maximum Element Row-wise/Col-wise in the Matrix
- Sum Of All Elements
- Mean Of The Matrix
- Mean Of The Matrix Row-wise/Col-wise
- The Trace Of The Matrix
- The Multiplication Of All Elements
- Norm 2 of The Matrix
- Norm Infinity Of The Matrix
- Checking If All Elements Are Positive
- Checking If Any Elements Is Positive
- Counting Elements
- Matrix Condition Number and Numerical Stability
- Matrix Rank
- Broadcasting
matrix.array() - 2;
.abs()
sqrt() array1.sqrt() sqrt(array1) array1.square() array1.cube() array1.pow(array2) pow(array1,array2) array1.pow(scalar) pow(array1,scalar) pow(scalar,array2)
array1.log() log(array1) array1.log10() log10(array1) array1.exp() exp(array1)
.min(.) max
If you have two arrays of the same size, you can call .min(.) to construct the array whose coefficients are the minimum of the corresponding coefficients of the two given arrays.
array1.isFinite() isfinite(array1) array1.isInf() isinf(array1) array1.isNaN()
array1.sin() sin(array1) array1.cos() cos(array1) array1.tan() tan(array1) array1.asin() asin(array1) array1.acos() acos(array1) array1.atan() atan(array1) array1.sinh() sinh(array1) array1.cosh() cosh(array1) array1.tanh() tanh(array1) array1.arg() arg(array1)
array1.floor() floor(array1) array1.ceil() ceil(array1) array1.round() round(aray1)
In the following, we want to replace the element of our matrix, with an element from the either matrices P
or Q
. If the value in our matrix is smaller than a threshold, we replace it with an element from P
otherwise from Q
.
int cols, rows;
cols=2; rows=3;
Eigen::MatrixXf R=Eigen::MatrixXf::Random(rows, cols);
Eigen::MatrixXf Q=Eigen::MatrixXf::Zero(rows, cols);
Eigen::MatrixXf P=Eigen::MatrixXf::Constant(rows, cols,1.0);
double threshold=0.5;
Eigen::MatrixXf masked=(R.array() < threshold).select(P,Q ); // (R < threshold ? P : Q)
int min_element_row_index,min_element_col_index;
matrix.minCoeff(&min_element_row_index,&min_element_col_index);
matrix.rowwise().maxCoeff();
matrix.sum();
matrix.mean()
matrix.colwise().mean();
matrix.trace();
matrix.prod();
matrix.lpNorm<2>()
matrix.lpNorm<Eigen::Infinity>()
(matrix.array()>0).all();
(matrix.array()>0).any();
(matrix.array()>1).count();
The column rank of a matrix is the maximal number of linearly independent columns of that matrix. The column rank of a matrix is in the dimension of the column space, while the row rank of A is the dimension of the row space. It can be proven that
Full rank: if its rank equals the largest possible for a matrix of the same dimensions, which is the lesser of the number of rows and columns
A matrix is said to be rank-deficient if it does not have full rank. The rank deficiency of a matrix is the difference between the lesser the number of rows and columns, and the rank.
Decomposing the matrix is the most common way to get the rank
Gaussian Elimination (row reduction):
This method can also be used to compute the rank of a matrix the determinant of a square matrix the inverse of an invertible matrix
Row echelon form: means that Gaussian elimination has operated on the rows Column echelon form