-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapost_det.h
107 lines (71 loc) · 2.38 KB
/
apost_det.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Copyright (c) 2016 The Caroline authors. All rights reserved.
# Use of this source file is governed by a MIT license that can be found in the
# LICENSE file.
# Author: Glazachev Vladimir <[email protected]>
#ifndef DET_H
#define DET_H
#include <algorithm>
#include "matrix.h"
#include "apost.h"
#include "apost_statical.h"
#include "gauss.h"
namespace interval {
//--------------------------------DETERMENANTS----------------------------------
//--------------------------------LINEAREQUATS----------------------------------
/*-----------------------------------------------------------------------------*/
namespace apost {
Matrix<ProxyIntervalResult> detsGauss(Matrix<ProxyInterval<ArbInterval>> matrix) {
size_t n = matrix.nrow();
Matrix<ProxyInterval<ArbInterval>> L(n, n);
std::vector<ProxyInterval<ArbInterval>> dets(n);
std::vector<ProxyIntervalResult> finaldets(n);
dets[0] = matrix.at(0, 0);
// TODO
// finaldets[0].data_ = dets[0];
// finaldets[0].result_ = ((ArbInterval)dets[0]);
for (size_t i = 0; i < n; ++i) {
if (i != 0) {
dets[i] = matrix.at(i, i) * dets[i - 1];
finaldets[i] = matrix.at(i, i) * dets[i - 1];
}
for (size_t j = i + 1; j < n; ++j) {
ProxyInterval<ArbInterval> z = matrix.at(j, i) / matrix.at(i, i);
z = -z;
matrix.at(j, i) = z;
L.at(j, i) = z;
for (size_t k = i + 1; k < n; ++k) {
ProxyInterval<ArbInterval> t = matrix.at(i, k) * z;
matrix.at(j, k) = matrix.at(j, k) + t;
L.at(j, k) = matrix.at(j, k);
}
}
}
for (size_t k = 0; k < n; ++k)
for (size_t i = k + 1; i < n; ++i)
for (size_t j = i + 1; j < n; ++j) {
ProxyInterval<ArbInterval> t = L.at(i, k) * matrix.at(j, i);
L.at(j, k) = L.at(j, k) + t;
}
Matrix<ProxyIntervalResult> L2(n, n);
// TODO
/*
L2.at(0, 0).data_ = ArbInterval(1);
L2.at(0, 0).result_ = L2.at(0, 0).data_;
for (size_t j = 0; j < n; ++j) {
for (size_t k = 0; k < j; ++k) {
if (j == 0) {
L2.at(j, k) = L.at(j, k);
} else {
L2.at(j, k) = L.at(j, k) * dets[j - 1];
}
}
if (j != 0) {
L2.at(j, j) = finaldets[j - 1];
}
}
*/
return L2;
}
} // namespace apost
} // namespace interval
#endif // DET_H