ocra-recipes
Doxygen documentation for the ocra-recipes repository
OrthonormalFamily.cpp
Go to the documentation of this file.
1 
10 
11 using namespace Eigen;
12 
13 #include <iostream>
14 
15 namespace gocra
16 {
17 OrthonormalFamily::OrthonormalFamily(const MatrixXd& fam, const double eps)
18 {
19  family = fam;
20  epsilon = eps;
21 }
22 
23 OrthonormalFamily::~OrthonormalFamily()
24 {
25 
26 }
27 
28 void OrthonormalFamily::computeOrthonormalFamily()
29 {
30  int n = family.cols();
31  int m = family.rows();
32  onf = MatrixXd::Zero(n,n);
33  origin = -VectorXi::Zero(n);
34  origin.setConstant(-1);
35 
36  int i = 0;
37  for (int k=0; k<m; ++k)
38  {
39  if (i>=n)
40  break;
41  onf.row(i) = family.row(k);
42  for (int j=0; j<i;++j)
43  {
44 
45  onf.row(i)-= onf.row(j) * VectorXd(onf.row(i)).dot(VectorXd(onf.row(j)));
46  }
47  double nrm = VectorXd(onf.row(i)).norm();
48  if (nrm > epsilon)
49  {
50  onf.row(i) /= nrm;
51  origin(i) = k;
52  i += 1;
53  }
54 
55  }
56  index = i;
57 
58 }
59 
60 
61 int OrthonormalFamily::getIndex() const
62 {
63  return index;
64 }
65 
66 
67 const VectorXi& OrthonormalFamily::getOrigin() const
68 {
69  return origin;
70 }
71 
72 
73 const MatrixXd& OrthonormalFamily::getOnf() const
74 {
75  return onf;
76 }
77 
78 
79 void OrthonormalFamily::setFamily(const MatrixXd& f)
80 {
81  family = f;
82 }
83 
84 
85 void OrthonormalFamily::setEpsilon(const double eps)
86 {
87  epsilon = eps;
88 }
89 } // namespace gocra