MCPcopy Create free account
hub / github.com/cogentcore/core / Offset

Method Offset

tensor/shape.go:134–140  ·  view source on GitHub ↗

Offset returns the "flat" 1D array index into an element at the given n-dimensional index. No checking is done on the length or size of the index values relative to the shape of the tensor.

(index []int)

Source from the content-addressed store, hash-verified

132// Offset returns the "flat" 1D array index into an element at the given n-dimensional index.
133// No checking is done on the length or size of the index values relative to the shape of the tensor.
134func (sh *Shape) Offset(index []int) int {
135 var offset int
136 for i, v := range index {
137 offset += v * sh.Strides[i]
138 }
139 return offset
140}
141
142// Index returns the n-dimensional index from a "flat" 1D array index.
143func (sh *Shape) Index(offset int) []int {

Callers 15

ValueMethod · 0.80
SetMethod · 0.80
FloatMethod · 0.80
SetFloatMethod · 0.80
StringValueMethod · 0.80
SetStringMethod · 0.80
Projection2DIndexFunction · 0.80
AddScalarMethod · 0.80
MulScalarMethod · 0.80
SetStringMethod · 0.80
FloatMethod · 0.80
SetFloatMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected