Compute the trace of the product of two matrices, \( \text{tr}(A \cdot B) = \sum_{i,j} A_{ij} B_{ji} \).
This is more efficient than computing the full product and taking the trace, as it avoids forming the intermediate matrix.
- Template Parameters
-
| EigMat1 | A type either inheriting from Eigen::DenseBase or a var_value with an inner type inheriting from Eigen::DenseBase |
| EigMat2 | A type either inheriting from Eigen::DenseBase or a var_value with an inner type inheriting from Eigen::DenseBase |
- Parameters
-
| A | first matrix (m x n) |
| B | second matrix (n x m) |
- Returns
- trace of A * B
- Exceptions
-
| std::invalid_argument | if A and B have incompatible dimensions |
Definition at line 30 of file trace_dot.hpp.