00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <sstream>
00024
00025
00026 #include "Solver.hpp"
00027 #include "GaussianElimination.hpp"
00028
00029 namespace kn{
00030
00031 void solveSystemSVD(const Matrix<double>& a,
00032 Vector<double>& x,
00033 const Vector<double>& b){
00034
00035 Vector<double> w(a.columns());
00036 Matrix<double> v(a.columns(),a.columns());
00037 Matrix<double> atmp(a);
00038 decompositionSVD(atmp,w,v);
00039 solveSVD(atmp,w,v,b,x);
00040 }
00041
00042
00043 void solveNullSystemSVD(const Matrix<double>& a,
00044 Vector<double>& x){
00045
00046 Vector<double> w(a.columns());
00047 Matrix<double> v(a.columns(),a.columns());
00048 Matrix<double> atmp(a);
00049 decompositionSVD(atmp,w,v);
00050 sortSingularValuesSVD(atmp,w,v);
00051
00052 x = v.getColumn(v.columns()-1);
00053 x.setHomogeneousNormalForm();
00054 }
00055
00056
00057 void solveSystemGaussianElimination(const Matrix<double>& a,
00058 Vector<double>& x,
00059 const Vector<double>& b,
00060 const bool total){
00061 kn::Matrix<double> aInv(a.rows(), a.columns());
00062 gaussianEliminationInverseMatrix(a,aInv,total);
00063
00064 x = aInv * b;
00065 }
00066
00067
00068 }
00069