#ifndef __vnl_sd_matrix_tools_h #define __vnl_sd_matrix_tools_h #include #include /** * A set of non-obvious matrix functions. Includes the equivalent of * Matlab's logm and expm. * * \author Vincent Arsigny, INRIA, Olivier Commowick, INRIA, and Tom Vercauteren, MKT */ namespace sdtools { /** * Computation of the square root of a reasonnable matrix. * Essential part in the general computation of the matrix logarithm. * Based on a variant (product form) of the classical Denman-Beavers (DB) iteration. **/ template vnl_matrix GetSquareRoot(const vnl_matrix & m, const T precision, vnl_matrix & resultM); /** * Final part of the computation of the log. Estimates the log * with a Pade approximation for a matrix m such that \|m-Id\| <= 0.5. **/ template vnl_matrix GetPadeLogarithm(const vnl_matrix & m, const int numApprox); /** * Computation of the matrix logarithm. Algo: inverse scaling * and squaring, variant proposed by Cheng et al., SIAM Matrix Anal., 2001. **/ template vnl_matrix GetLogarithm(const vnl_matrix & m, const T square_root_precision=1e-11, const int numApprox=1); /** * Computation of the matrix exponential. Algo: classical scaling * and squaring, as in Matlab. See Higham, SIAM Matr. Anal., 2004. */ template vnl_matrix GetExponential(const vnl_matrix & m, const int numApprox=3); /** * Computation of the Log-Euclidean barycenter of matrices, ie the * exponential of the arithmetic mean of their logarithms. **/ template vnl_matrix GetLogEuclideanBarycenter(const std::vector< vnl_matrix > & matrices, const std::vector & weights); /** * Computation of the group barycenter of matrices, ie the left-, * right- and inverse-invariant barycenter. It is similar to the Log-Euclidean * barycenter. Its computation is iterative, whereas there is a closed * form for the LE barycenter. **/ template vnl_matrix GetGroupBarycenter(const std::vector< vnl_matrix > & matrices, const std::vector & weights, const T precision=0.000001); /** * Computation of the Arithmetic barycenter of matrices, ie the * arithmetic mean of the matrices! **/ template vnl_matrix GetArithmeticBarycenter(const std::vector< vnl_matrix > & matrices, const std::vector & weights); } // end namespace #include "vnl_sd_matrix_tools.txx" #endif