-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmatrixExample.cpp
94 lines (65 loc) · 2.4 KB
/
matrixExample.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
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
// Copyright (c) 2019 Shapelets.io
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <arrayfire.h>
#include <khiva.h>
void stompIgnoreTrivialOneSeries() {
float data[] = {10, 10, 11, 11, 10, 11, 10, 10, 11, 11, 10, 11, 10, 10};
af::array tss = af::array(14, data);
long m = 3;
af::array distance;
af::array index;
khiva::matrix::stomp(tss, m, distance, index);
auto *resultingDistance = distance.host<float>();
unsigned int resultingIndex[12];
index.host(&resultingIndex);
af::freeHost(resultingDistance);
}
void stompIgnoreTrivialMultipleSeries() {
float data[] = {10, 10, 11, 11, 10, 11, 10, 10, 11, 11, 10, 11, 10, 10,
11, 10, 10, 11, 10, 11, 11, 10, 11, 11, 10, 10, 11, 10};
af::array tss = af::array(14, 2, data);
long m = 3;
af::array distance;
af::array index;
khiva::matrix::stomp(tss, m, distance, index);
auto *resultingDistance = distance.host<float>();
unsigned int resultingIndex[24];
index.host(&resultingIndex);
af::freeHost(resultingDistance);
}
void stompConsiderTrivialOneSeries() {
float data[] = {10, 10, 11, 11, 10, 11, 10, 10};
af::array t = af::array(8, data);
long m = 3;
af::array distance;
af::array index;
khiva::matrix::stomp(t, t, m, distance, index);
auto *resultingDistance = distance.host<float>();
unsigned int resultingIndex[6];
index.host(&resultingIndex);
af::freeHost(resultingDistance);
}
void stompConsiderTrivialMultipleSeries() {
float dataA[] = {10, 10, 11, 11, 10, 11, 10, 10, 10, 10, 11, 11, 10, 11, 10, 10, 11, 10, 10, 11, 10, 11, 11, 10};
af::array ta = af::array(8, 3, dataA);
float dataB[] = {10, 10, 11, 11, 10, 11, 10, 10, 11, 10, 10, 11, 10, 11, 11, 10};
af::array tb = af::array(8, 2, dataB);
long m = 3;
af::array distance;
af::array index;
khiva::matrix::stomp(ta, tb, m, distance, index);
auto *resultingDistance = distance.host<float>();
unsigned int resultingIndex[36];
index.host(&resultingIndex);
af::freeHost(resultingDistance);
}
int main() {
stompIgnoreTrivialOneSeries();
stompIgnoreTrivialMultipleSeries();
stompConsiderTrivialOneSeries();
stompConsiderTrivialMultipleSeries();
return 0;
}