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.
()
| 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. |
| 184 | func (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 |
| 205 | func (tsr *String) SetZeros() { |
nothing calls this directly
no test coverage detected