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

Method At

tensor/string.go:160–173  ·  view source on GitHub ↗

At is the gonum/mat.Matrix interface method for returning 2D matrix element at given row, column index. Assumes Row-major ordering and logs an error if NumDims < 2.

(i, j int)

Source from the content-addressed store, hash-verified

158// At is the gonum/mat.Matrix interface method for returning 2D matrix element at given
159// row, column index. Assumes Row-major ordering and logs an error if NumDims < 2.
160func (tsr *String) At(i, j int) float64 {
161 nd := tsr.NumDims()
162 if nd < 2 {
163 log.Println("tensor Dims gonum Matrix call made on Tensor with dims < 2")
164 return 0
165 } else if nd == 2 {
166 return tsr.Float([]int{i, j})
167 } else {
168 ix := make([]int, nd)
169 ix[nd-2] = i
170 ix[nd-1] = j
171 return tsr.Float(ix)
172 }
173}
174
175// T is the gonum/mat.Matrix transpose method.
176// It performs an implicit transpose by returning the receiver inside a Transpose.

Callers

nothing calls this directly

Calls 3

FloatMethod · 0.95
PrintlnMethod · 0.80
NumDimsMethod · 0.65

Tested by

no test coverage detected