-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMatriplexVector.h
81 lines (59 loc) · 1.59 KB
/
MatriplexVector.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
#ifndef MatriplexVector_H
#define MatriplexVector_H
#include "Matriplex.h"
#include <vector>
#include <cassert>
template<typename T, idx_t D1, idx_t D2, idx_t N>
class MatriplexVector
{
typedef Matriplex<T, D1, D2, N> MP;
std::vector<MP> fV;
public:
MatriplexVector() {}
MatriplexVector(idx_t n) : fV(n) {}
size_t size() const { return fV.size(); }
MP& mplex(int i) { return fV[i]; }
MP& operator[](int i) { return fV[i]; }
const MP& mplex(int i) const { return fV[i]; }
const MP& operator[](int i) const { return fV[i]; }
void SetVal(T v)
{
for (idx_t i = 0; i < kTotSize; ++i)
{
fArray[i] = v;
}
}
T& At(idx_t i, idx_t j, idx_t n) { return fV[n/N].At(i, j, n%N); }
T& operator()(idx_t i, idx_t j, idx_t n) { return fV[n/N].At(i, j, n%N); }
void Assign(idx_t n, T *arr) { fV[n/N].Assign(n%N, arr); }
};
template<typename T, idx_t D1, idx_t D2, idx_t D3, idx_t N>
void Multiply(const MatriplexVector<T, D1, D2, N>& A,
const MatriplexVector<T, D2, D3, N>& B,
MatriplexVector<T, D1, D3, N>& C)
{
assert(A.size() == B.size());
assert(A.size() == C.size());
int np = A.size();
for (int i = 0; i < np; ++i)
{
Multiply(A[i], B[i], C[i]);
}
}
template<typename T, idx_t D, idx_t N>
void InvertChol(const MatriplexVector<T, D, D, N>& A)
{
int np = A.size();
for (int i = 0; i < np; ++i)
{
InvertChol(A[i]);
}
}
template<class M>
class MatriplexVector2 : public std::vector<M>
{
public:
MatriplexVector2() {}
MatriplexVector2(idx_t n) : std::vector<M>(n) {}
};
#endif