Subversion Repositories gelsvn

Rev

Rev 23 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 jab 1
#include <iostream>
2
 
3
#include "QEM.h"
31 jab 4
#include "LinAlg/LapackFunc.h"
23 jab 5
 
31 jab 6
using namespace LinAlg;
23 jab 7
using namespace CGLA;
8
using namespace std;
9
 
10
namespace Geometry
11
{
12
	Vec3f QEM::opt_pos(double sv_thresh) const
13
	{
31 jab 14
		CMatrix A_num(A);
15
		CVector b_num(b);
16
 
17
		CMatrix U;
18
		CMatrix V;
19
		CVector s;
20
		SVD(A_num,U,s,V);
21
 
22
// 		double sm = sv_thresh*s[0];
23
// 		for(int i=1;i<3;++i)
24
// 			{
25
// 				if(fabs(s[i])< sm)
26
// 					s[i] = 0;
27
// 			}
28
 
29
		CMatrix A_inv = (V * s) * U;
30
 
31
		CVector x(3);
32
		x = A_inv * b_num;
33
		Vec3f p(-x[0], -x[1], -x[2]);
34
		if(s[0] == 0)
23 jab 35
			{
31 jab 36
				cout << A << b << s << U << V << endl;
23 jab 37
			}
31 jab 38
 
23 jab 39
 
40
		return p;
41
	}
42
}