-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix_branch.cpp
49 lines (41 loc) · 1.15 KB
/
matrix_branch.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <boost/numeric/ublas/matrix_vector.hpp>
#include <stdio.h>
#include "matrix_branch.h"
//std::forward_list<std::unique_ptr<MatrixBranch> > MatrixBranch::stock;
MatrixBranch::MatrixBranch() :
my_matrix(),
shift(),
parent(),
volume()
{
}
MatrixBranch::MatrixBranch(const boost::numeric::ublas::matrix<double>& matrix_,
const boost::numeric::ublas::vector<double>& shift_,
MatrixBranch* parent_) :
my_matrix(matrix_),
shift(shift_),
parent(),
volume(0)
{
using namespace boost::numeric::ublas;
parent = parent_;
for (int i = my_matrix.size1() - 1; i >= 0; --i) {
vector<double> v1(matrix_row<matrix<double> >(my_matrix, i));
volume += log2(norm_2(v1));
}
}
void MatrixBranch::transform(boost::numeric::ublas::vector<double>& vec) const {
using namespace boost::numeric::ublas;
vec = prod(vec, my_matrix) + shift;
if (parent) {
parent->transform(vec);
}
//std::cout << "Transformed vector size is: " << vec.size() << std::endl;
}
double MatrixBranch::get_volume() const {
if (parent) {
return volume + parent->get_volume();
} else {
return volume;
}
}