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

Method Index

tensor/shape.go:143–154  ·  view source on GitHub ↗

Index returns the n-dimensional index from a "flat" 1D array index.

(offset int)

Source from the content-addressed store, hash-verified

141
142// Index returns the n-dimensional index from a "flat" 1D array index.
143func (sh *Shape) Index(offset int) []int {
144 nd := len(sh.Sizes)
145 index := make([]int, nd)
146 rem := offset
147 for i := nd - 1; i >= 0; i-- {
148 s := sh.Sizes[i]
149 iv := rem % s
150 rem /= s
151 index[i] = iv
152 }
153 return index
154}
155
156// String satisfies the fmt.Stringer interface
157func (sh *Shape) String() string {

Callers 15

TableHeadersMethod · 0.95
SetHTMLPreMethod · 0.45
PropertiesStringMethod · 0.45
packageAndNameFunction · 0.45
SlEditsMethMoveFunction · 0.45
MathReplaceAllFunction · 0.45
ScpMethod · 0.45
DeleteJobMethod · 0.45
ValueMethod · 0.45
Value1DMethod · 0.45
FloatMethod · 0.45
StringValueMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected