-
Notifications
You must be signed in to change notification settings - Fork 2
/
data_convert.go
89 lines (74 loc) · 2 KB
/
data_convert.go
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
//go:build !series_f32
package series
import "github.com/WinPooh32/series/vek"
// IndexAsInt32 returns copy of underlying index slice converted to int32 array.
func (d Data) IndexAsInt32() (index []int32) {
index = make([]int32, len(d.index))
for i, v := range d.index {
index[i] = int32(v)
}
return index
}
// IndexAsFloat32 returns copy of underlying index slice converted to float32 array.
func (d Data) IndexAsFloat32() (index []float32) {
index = make([]float32, len(d.index))
for i, v := range d.index {
index[i] = float32(v)
}
return index
}
// IndexAsFloat64 returns copy of underlying index slice converted to float64 array.
func (d Data) IndexAsFloat64() (index []float64) {
index = make([]float64, len(d.index))
for i, v := range d.index {
index[i] = float64(v)
}
return index
}
// ValuesAsInt32 returns copy of underlying values slice converted to int32 array.
func (d Data) ValuesAsInt32() (values []int32) {
values = make([]int32, len(d.values))
switch {
case EnabledAVX2:
vek.ToInt32(values, d.values)
return values
default:
values = make([]int32, len(d.values))
for i, v := range d.values {
values[i] = int32(v)
}
return values
}
}
// ValuesAsInt64 returns copy of underlying values slice converted to float32 array.
func (d Data) ValuesAsInt64() (values []int64) {
values = make([]int64, len(d.values))
switch {
case EnabledAVX2:
vek.ToInt64(values, d.values)
return values
default:
for i, v := range d.values {
values[i] = int64(v)
}
return values
}
}
// ValuesAsFloat32 returns copy of underlying values slice converted to float32 array.
func (d Data) ValuesAsFloat32() (values []float32) {
values = make([]float32, len(d.values))
switch {
case EnabledAVX2:
vek.ToFloat32(values, d.values)
return values
default:
for i, v := range d.values {
values[i] = float32(v)
}
return values
}
}
// DataAsFloat64 returns copy of underlying values slice converted to float64 array.
func (d Data) ValuesAsFloat64() (values []float64) {
return d.values
}