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

Method Range

tensor/string.go:184–202  ·  view source on GitHub ↗

Range returns the min, max (and associated indexes, -1 = no values) for the tensor. This is needed for display and is thus in the core api in optimized form Other math operations can be done using gonum/floats package.

()

Source from the content-addressed store, hash-verified

182// This is needed for display and is thus in the core api in optimized form
183// Other math operations can be done using gonum/floats package.
184func (tsr *String) Range() (min, max float64, minIndex, maxIndex int) {
185 minIndex = -1
186 maxIndex = -1
187 for j, vl := range tsr.Values {
188 fv := StringToFloat64(vl)
189 if math.IsNaN(fv) {
190 continue
191 }
192 if fv < min || minIndex < 0 {
193 min = fv
194 minIndex = j
195 }
196 if fv > max || maxIndex < 0 {
197 max = fv
198 maxIndex = j
199 }
200 }
201 return
202}
203
204// SetZeros is simple convenience function initialize all values to 0
205func (tsr *String) SetZeros() {

Callers

nothing calls this directly

Calls 1

StringToFloat64Function · 0.85

Tested by

no test coverage detected