]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Code generated by tensor/numeric.gen.go.tmpl. DO NOT EDIT. |
2 | ||
3 | // Licensed to the Apache Software Foundation (ASF) under one | |
4 | // or more contributor license agreements. See the NOTICE file | |
5 | // distributed with this work for additional information | |
6 | // regarding copyright ownership. The ASF licenses this file | |
7 | // to you under the Apache License, Version 2.0 (the | |
8 | // "License"); you may not use this file except in compliance | |
9 | // with the License. You may obtain a copy of the License at | |
10 | // | |
11 | // http://www.apache.org/licenses/LICENSE-2.0 | |
12 | // | |
13 | // Unless required by applicable law or agreed to in writing, software | |
14 | // distributed under the License is distributed on an "AS IS" BASIS, | |
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | // See the License for the specific language governing permissions and | |
17 | // limitations under the License. | |
18 | ||
19 | package tensor | |
20 | ||
21 | import ( | |
22 | "github.com/apache/arrow/go/v6/arrow" | |
23 | "github.com/apache/arrow/go/v6/arrow/array" | |
24 | ) | |
25 | ||
26 | // Int8 is an n-dim array of int8s. | |
27 | type Int8 struct { | |
28 | tensorBase | |
29 | values []int8 | |
30 | } | |
31 | ||
32 | // NewInt8 returns a new n-dimensional array of int8s. | |
33 | // If strides is nil, row-major strides will be inferred. | |
34 | // If names is nil, a slice of empty strings will be created. | |
35 | func NewInt8(data *array.Data, shape, strides []int64, names []string) *Int8 { | |
36 | tsr := &Int8{tensorBase: *newTensor(arrow.PrimitiveTypes.Int8, data, shape, strides, names)} | |
37 | vals := tsr.data.Buffers()[1] | |
38 | if vals != nil { | |
39 | tsr.values = arrow.Int8Traits.CastFromBytes(vals.Bytes()) | |
40 | beg := tsr.data.Offset() | |
41 | end := beg + tsr.data.Len() | |
42 | tsr.values = tsr.values[beg:end] | |
43 | } | |
44 | return tsr | |
45 | } | |
46 | ||
47 | func (tsr *Int8) Value(i []int64) int8 { j := int(tsr.offset(i)); return tsr.values[j] } | |
48 | func (tsr *Int8) Int8Values() []int8 { return tsr.values } | |
49 | ||
50 | // Int16 is an n-dim array of int16s. | |
51 | type Int16 struct { | |
52 | tensorBase | |
53 | values []int16 | |
54 | } | |
55 | ||
56 | // NewInt16 returns a new n-dimensional array of int16s. | |
57 | // If strides is nil, row-major strides will be inferred. | |
58 | // If names is nil, a slice of empty strings will be created. | |
59 | func NewInt16(data *array.Data, shape, strides []int64, names []string) *Int16 { | |
60 | tsr := &Int16{tensorBase: *newTensor(arrow.PrimitiveTypes.Int16, data, shape, strides, names)} | |
61 | vals := tsr.data.Buffers()[1] | |
62 | if vals != nil { | |
63 | tsr.values = arrow.Int16Traits.CastFromBytes(vals.Bytes()) | |
64 | beg := tsr.data.Offset() | |
65 | end := beg + tsr.data.Len() | |
66 | tsr.values = tsr.values[beg:end] | |
67 | } | |
68 | return tsr | |
69 | } | |
70 | ||
71 | func (tsr *Int16) Value(i []int64) int16 { j := int(tsr.offset(i)); return tsr.values[j] } | |
72 | func (tsr *Int16) Int16Values() []int16 { return tsr.values } | |
73 | ||
74 | // Int32 is an n-dim array of int32s. | |
75 | type Int32 struct { | |
76 | tensorBase | |
77 | values []int32 | |
78 | } | |
79 | ||
80 | // NewInt32 returns a new n-dimensional array of int32s. | |
81 | // If strides is nil, row-major strides will be inferred. | |
82 | // If names is nil, a slice of empty strings will be created. | |
83 | func NewInt32(data *array.Data, shape, strides []int64, names []string) *Int32 { | |
84 | tsr := &Int32{tensorBase: *newTensor(arrow.PrimitiveTypes.Int32, data, shape, strides, names)} | |
85 | vals := tsr.data.Buffers()[1] | |
86 | if vals != nil { | |
87 | tsr.values = arrow.Int32Traits.CastFromBytes(vals.Bytes()) | |
88 | beg := tsr.data.Offset() | |
89 | end := beg + tsr.data.Len() | |
90 | tsr.values = tsr.values[beg:end] | |
91 | } | |
92 | return tsr | |
93 | } | |
94 | ||
95 | func (tsr *Int32) Value(i []int64) int32 { j := int(tsr.offset(i)); return tsr.values[j] } | |
96 | func (tsr *Int32) Int32Values() []int32 { return tsr.values } | |
97 | ||
98 | // Int64 is an n-dim array of int64s. | |
99 | type Int64 struct { | |
100 | tensorBase | |
101 | values []int64 | |
102 | } | |
103 | ||
104 | // NewInt64 returns a new n-dimensional array of int64s. | |
105 | // If strides is nil, row-major strides will be inferred. | |
106 | // If names is nil, a slice of empty strings will be created. | |
107 | func NewInt64(data *array.Data, shape, strides []int64, names []string) *Int64 { | |
108 | tsr := &Int64{tensorBase: *newTensor(arrow.PrimitiveTypes.Int64, data, shape, strides, names)} | |
109 | vals := tsr.data.Buffers()[1] | |
110 | if vals != nil { | |
111 | tsr.values = arrow.Int64Traits.CastFromBytes(vals.Bytes()) | |
112 | beg := tsr.data.Offset() | |
113 | end := beg + tsr.data.Len() | |
114 | tsr.values = tsr.values[beg:end] | |
115 | } | |
116 | return tsr | |
117 | } | |
118 | ||
119 | func (tsr *Int64) Value(i []int64) int64 { j := int(tsr.offset(i)); return tsr.values[j] } | |
120 | func (tsr *Int64) Int64Values() []int64 { return tsr.values } | |
121 | ||
122 | // Uint8 is an n-dim array of uint8s. | |
123 | type Uint8 struct { | |
124 | tensorBase | |
125 | values []uint8 | |
126 | } | |
127 | ||
128 | // NewUint8 returns a new n-dimensional array of uint8s. | |
129 | // If strides is nil, row-major strides will be inferred. | |
130 | // If names is nil, a slice of empty strings will be created. | |
131 | func NewUint8(data *array.Data, shape, strides []int64, names []string) *Uint8 { | |
132 | tsr := &Uint8{tensorBase: *newTensor(arrow.PrimitiveTypes.Uint8, data, shape, strides, names)} | |
133 | vals := tsr.data.Buffers()[1] | |
134 | if vals != nil { | |
135 | tsr.values = arrow.Uint8Traits.CastFromBytes(vals.Bytes()) | |
136 | beg := tsr.data.Offset() | |
137 | end := beg + tsr.data.Len() | |
138 | tsr.values = tsr.values[beg:end] | |
139 | } | |
140 | return tsr | |
141 | } | |
142 | ||
143 | func (tsr *Uint8) Value(i []int64) uint8 { j := int(tsr.offset(i)); return tsr.values[j] } | |
144 | func (tsr *Uint8) Uint8Values() []uint8 { return tsr.values } | |
145 | ||
146 | // Uint16 is an n-dim array of uint16s. | |
147 | type Uint16 struct { | |
148 | tensorBase | |
149 | values []uint16 | |
150 | } | |
151 | ||
152 | // NewUint16 returns a new n-dimensional array of uint16s. | |
153 | // If strides is nil, row-major strides will be inferred. | |
154 | // If names is nil, a slice of empty strings will be created. | |
155 | func NewUint16(data *array.Data, shape, strides []int64, names []string) *Uint16 { | |
156 | tsr := &Uint16{tensorBase: *newTensor(arrow.PrimitiveTypes.Uint16, data, shape, strides, names)} | |
157 | vals := tsr.data.Buffers()[1] | |
158 | if vals != nil { | |
159 | tsr.values = arrow.Uint16Traits.CastFromBytes(vals.Bytes()) | |
160 | beg := tsr.data.Offset() | |
161 | end := beg + tsr.data.Len() | |
162 | tsr.values = tsr.values[beg:end] | |
163 | } | |
164 | return tsr | |
165 | } | |
166 | ||
167 | func (tsr *Uint16) Value(i []int64) uint16 { j := int(tsr.offset(i)); return tsr.values[j] } | |
168 | func (tsr *Uint16) Uint16Values() []uint16 { return tsr.values } | |
169 | ||
170 | // Uint32 is an n-dim array of uint32s. | |
171 | type Uint32 struct { | |
172 | tensorBase | |
173 | values []uint32 | |
174 | } | |
175 | ||
176 | // NewUint32 returns a new n-dimensional array of uint32s. | |
177 | // If strides is nil, row-major strides will be inferred. | |
178 | // If names is nil, a slice of empty strings will be created. | |
179 | func NewUint32(data *array.Data, shape, strides []int64, names []string) *Uint32 { | |
180 | tsr := &Uint32{tensorBase: *newTensor(arrow.PrimitiveTypes.Uint32, data, shape, strides, names)} | |
181 | vals := tsr.data.Buffers()[1] | |
182 | if vals != nil { | |
183 | tsr.values = arrow.Uint32Traits.CastFromBytes(vals.Bytes()) | |
184 | beg := tsr.data.Offset() | |
185 | end := beg + tsr.data.Len() | |
186 | tsr.values = tsr.values[beg:end] | |
187 | } | |
188 | return tsr | |
189 | } | |
190 | ||
191 | func (tsr *Uint32) Value(i []int64) uint32 { j := int(tsr.offset(i)); return tsr.values[j] } | |
192 | func (tsr *Uint32) Uint32Values() []uint32 { return tsr.values } | |
193 | ||
194 | // Uint64 is an n-dim array of uint64s. | |
195 | type Uint64 struct { | |
196 | tensorBase | |
197 | values []uint64 | |
198 | } | |
199 | ||
200 | // NewUint64 returns a new n-dimensional array of uint64s. | |
201 | // If strides is nil, row-major strides will be inferred. | |
202 | // If names is nil, a slice of empty strings will be created. | |
203 | func NewUint64(data *array.Data, shape, strides []int64, names []string) *Uint64 { | |
204 | tsr := &Uint64{tensorBase: *newTensor(arrow.PrimitiveTypes.Uint64, data, shape, strides, names)} | |
205 | vals := tsr.data.Buffers()[1] | |
206 | if vals != nil { | |
207 | tsr.values = arrow.Uint64Traits.CastFromBytes(vals.Bytes()) | |
208 | beg := tsr.data.Offset() | |
209 | end := beg + tsr.data.Len() | |
210 | tsr.values = tsr.values[beg:end] | |
211 | } | |
212 | return tsr | |
213 | } | |
214 | ||
215 | func (tsr *Uint64) Value(i []int64) uint64 { j := int(tsr.offset(i)); return tsr.values[j] } | |
216 | func (tsr *Uint64) Uint64Values() []uint64 { return tsr.values } | |
217 | ||
218 | // Float32 is an n-dim array of float32s. | |
219 | type Float32 struct { | |
220 | tensorBase | |
221 | values []float32 | |
222 | } | |
223 | ||
224 | // NewFloat32 returns a new n-dimensional array of float32s. | |
225 | // If strides is nil, row-major strides will be inferred. | |
226 | // If names is nil, a slice of empty strings will be created. | |
227 | func NewFloat32(data *array.Data, shape, strides []int64, names []string) *Float32 { | |
228 | tsr := &Float32{tensorBase: *newTensor(arrow.PrimitiveTypes.Float32, data, shape, strides, names)} | |
229 | vals := tsr.data.Buffers()[1] | |
230 | if vals != nil { | |
231 | tsr.values = arrow.Float32Traits.CastFromBytes(vals.Bytes()) | |
232 | beg := tsr.data.Offset() | |
233 | end := beg + tsr.data.Len() | |
234 | tsr.values = tsr.values[beg:end] | |
235 | } | |
236 | return tsr | |
237 | } | |
238 | ||
239 | func (tsr *Float32) Value(i []int64) float32 { j := int(tsr.offset(i)); return tsr.values[j] } | |
240 | func (tsr *Float32) Float32Values() []float32 { return tsr.values } | |
241 | ||
242 | // Float64 is an n-dim array of float64s. | |
243 | type Float64 struct { | |
244 | tensorBase | |
245 | values []float64 | |
246 | } | |
247 | ||
248 | // NewFloat64 returns a new n-dimensional array of float64s. | |
249 | // If strides is nil, row-major strides will be inferred. | |
250 | // If names is nil, a slice of empty strings will be created. | |
251 | func NewFloat64(data *array.Data, shape, strides []int64, names []string) *Float64 { | |
252 | tsr := &Float64{tensorBase: *newTensor(arrow.PrimitiveTypes.Float64, data, shape, strides, names)} | |
253 | vals := tsr.data.Buffers()[1] | |
254 | if vals != nil { | |
255 | tsr.values = arrow.Float64Traits.CastFromBytes(vals.Bytes()) | |
256 | beg := tsr.data.Offset() | |
257 | end := beg + tsr.data.Len() | |
258 | tsr.values = tsr.values[beg:end] | |
259 | } | |
260 | return tsr | |
261 | } | |
262 | ||
263 | func (tsr *Float64) Value(i []int64) float64 { j := int(tsr.offset(i)); return tsr.values[j] } | |
264 | func (tsr *Float64) Float64Values() []float64 { return tsr.values } | |
265 | ||
266 | // Date32 is an n-dim array of date32s. | |
267 | type Date32 struct { | |
268 | tensorBase | |
269 | values []arrow.Date32 | |
270 | } | |
271 | ||
272 | // NewDate32 returns a new n-dimensional array of date32s. | |
273 | // If strides is nil, row-major strides will be inferred. | |
274 | // If names is nil, a slice of empty strings will be created. | |
275 | func NewDate32(data *array.Data, shape, strides []int64, names []string) *Date32 { | |
276 | tsr := &Date32{tensorBase: *newTensor(arrow.PrimitiveTypes.Date32, data, shape, strides, names)} | |
277 | vals := tsr.data.Buffers()[1] | |
278 | if vals != nil { | |
279 | tsr.values = arrow.Date32Traits.CastFromBytes(vals.Bytes()) | |
280 | beg := tsr.data.Offset() | |
281 | end := beg + tsr.data.Len() | |
282 | tsr.values = tsr.values[beg:end] | |
283 | } | |
284 | return tsr | |
285 | } | |
286 | ||
287 | func (tsr *Date32) Value(i []int64) arrow.Date32 { j := int(tsr.offset(i)); return tsr.values[j] } | |
288 | func (tsr *Date32) Date32Values() []arrow.Date32 { return tsr.values } | |
289 | ||
290 | // Date64 is an n-dim array of date64s. | |
291 | type Date64 struct { | |
292 | tensorBase | |
293 | values []arrow.Date64 | |
294 | } | |
295 | ||
296 | // NewDate64 returns a new n-dimensional array of date64s. | |
297 | // If strides is nil, row-major strides will be inferred. | |
298 | // If names is nil, a slice of empty strings will be created. | |
299 | func NewDate64(data *array.Data, shape, strides []int64, names []string) *Date64 { | |
300 | tsr := &Date64{tensorBase: *newTensor(arrow.PrimitiveTypes.Date64, data, shape, strides, names)} | |
301 | vals := tsr.data.Buffers()[1] | |
302 | if vals != nil { | |
303 | tsr.values = arrow.Date64Traits.CastFromBytes(vals.Bytes()) | |
304 | beg := tsr.data.Offset() | |
305 | end := beg + tsr.data.Len() | |
306 | tsr.values = tsr.values[beg:end] | |
307 | } | |
308 | return tsr | |
309 | } | |
310 | ||
311 | func (tsr *Date64) Value(i []int64) arrow.Date64 { j := int(tsr.offset(i)); return tsr.values[j] } | |
312 | func (tsr *Date64) Date64Values() []arrow.Date64 { return tsr.values } | |
313 | ||
314 | var ( | |
315 | _ Interface = (*Int8)(nil) | |
316 | _ Interface = (*Int16)(nil) | |
317 | _ Interface = (*Int32)(nil) | |
318 | _ Interface = (*Int64)(nil) | |
319 | _ Interface = (*Uint8)(nil) | |
320 | _ Interface = (*Uint16)(nil) | |
321 | _ Interface = (*Uint32)(nil) | |
322 | _ Interface = (*Uint64)(nil) | |
323 | _ Interface = (*Float32)(nil) | |
324 | _ Interface = (*Float64)(nil) | |
325 | _ Interface = (*Date32)(nil) | |
326 | _ Interface = (*Date64)(nil) | |
327 | ) |