They must also have the same Scalar type, as Eigen doesn't do automatic type promotion. The left hand side and right hand side must, of course, have the same numbers of rows and of columns. As a result you will get the inverse calculated. Reduce the left matrix to row echelon form using elementary row operations for the whole matrix (including the right one). Set the matrix (must be square) and append the identity matrix of the same dimension to it. If you want to perform all kinds of array operations, not linear algebra, see the next page. To calculate inverse matrix you need to do the following steps. For example, matrix1 * matrix2 means matrix-matrix product, and vector + scalar is just not allowed. Using determinant and adjoint, we can easily find the inverse of a square matrix using the below formula, If det(A) 0 A-1 adj(A)/det(A) Else 'Inverse doesnt exist' Inverse is used to find the solution to a system of linear equations. For the Matrix class (matrices and vectors), operators are only overloaded to support linear-algebraic operations. Inverse of a matrix exists only if the matrix is non-singular i.e., determinant should not be 0. This page aims to provide an overview and some details on how to perform arithmetic between matrices, vectors and scalars with Eigen.Įigen offers matrix/vector arithmetic operations either through overloads of common C++ arithmetic operators such as +, -, *, or through special methods such as dot(), cross(), etc.