00001
00002
00003
00004
00005
00006
00007 #ifndef _PHYSSIM_LINALG_H
00008 #define _PHYSSIM_LINALG_H
00009
00010 #include <Physsim/Constants.h>
00011 #include <Physsim/Matrix3.h>
00012 #include <Physsim/VectorN.h>
00013
00014 namespace Physsim {
00015
00017
00020 class LinAlg
00021 {
00022 public:
00023 static Real cond(const MatrixN& x);
00024 static MatrixN to_matrix(const std::string& s);
00025 static VectorN to_vector(const std::string& s);
00026 static VectorN solve(const MatrixNN& A, const VectorN& b);
00027 static VectorN solve_symmetric(const MatrixNN& A, const VectorN& b);
00028 static VectorN solve_PD(const MatrixNN& A, const VectorN& b);
00029 static void solve_iterative(const MatrixNN& A, const VectorN& b, VectorN& x, unsigned iter);
00030 static void svd(const MatrixN& A, MatrixN& U, VectorN& S, MatrixN& V);
00031 static MatrixNN inverse(const MatrixNN& mat);
00032 static MatrixNN inverse_symmetric(const MatrixNN& mat);
00033 static MatrixNN inverse_PD(const MatrixNN& mat);
00034 static MatrixN pseudo_inverse(const MatrixNN& A, Real tol=0);
00035 static MatrixN pseudo_inverse(const MatrixN& A, Real tol=0);
00036 static MatrixN right_pseudo_inverse(const MatrixN& A);
00037 static MatrixN left_pseudo_inverse(const MatrixN& A);
00038 static unsigned calc_rank(const MatrixN& x, Real tol=1e-10);
00039 static Matrix3 rot_X(Real angle);
00040 static Matrix3 rot_Y(Real angle);
00041 static Matrix3 rot_Z(Real angle);
00042 static void eig_symm(const MatrixNN& A, VectorN& evals);
00043 static bool is_PSD(const MatrixNN& A, Real tolerance);
00044 static bool is_PD(const MatrixNN& A, Real tolerance);
00045 };
00046
00047 }
00048
00049 #endif