-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixMulti.cpp
More file actions
75 lines (62 loc) · 2.32 KB
/
Copy pathMatrixMulti.cpp
File metadata and controls
75 lines (62 loc) · 2.32 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Copyright 2014 Wouter Spekkink
Authors : Wouter Spekkink <wouter.spekkink@gmail.com>
Website : http://www.wouterspekkink.org
This file is part of Dynamic Networks.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2014 Wouter Spekkink. All rights reserved.
Dynamic Networks is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dynamic Networks is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MatrixMulti.h"
MatrixMulti::MatrixMulti(InputTable *table, int begin, int end)
: mainTable(table), frameBegin(begin), frameEnd(end)
{
partData = CalcMatrix();
}
std::vector<std::vector <short> > MatrixMulti::CalcMatrix()
{
std::vector<std::vector <short> > orgMatrix = mainTable->GetRowData();
std::vector<std::vector <short> > newMatrix;
std::vector<std::vector <short> >::iterator it;
for(it = orgMatrix.begin(); it < orgMatrix.end(); it++) {
std::vector<short> numbers;
std::vector<short> tempVector = *it;
for(int i = frameBegin - 1; i != frameEnd; i++) {
numbers.push_back(tempVector[i]);
}
newMatrix.push_back(numbers);
}
std::vector<std::vector <short> > adjMatrix;
for(it = newMatrix.begin(); it != newMatrix.end(); it++) {
std::vector<short> firstRow = *it;
std::vector<std::vector <short> >::iterator it2;
std::vector<short> newRow;
for(it2 = newMatrix.begin(); it2 != newMatrix.end(); it2++) {
std::vector<short> secondRow = *it2;
int sum = 0;
for(std::vector<short>::size_type i = 0; i != (frameEnd - frameBegin + 1); i++) {
sum = sum + (firstRow[i] * secondRow[i]);
}
newRow.push_back(sum);
}
adjMatrix.push_back(newRow);
}
return adjMatrix;
}
const std::vector<std::vector <short> > MatrixMulti::GetPartData()
{
return partData;
}
const std::vector<std::string> MatrixMulti::GetPartRows()
{
return mainTable->GetRowNames();
}