etensor

package
v1.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2020 License: BSD-3-Clause Imports: 19 Imported by: 268

Documentation

Overview

Package etensor provides a basic set of tensor data structures (n-dimensional arrays of data), based on apache/arrow/go/tensor and intercompatible with those structures.

The primary differences are:

  • pure simple unidimensional Go slice used as the backing data array, auto allocated
  • fully modifiable data -- arrow is designed to be read-only
  • Shape struct is fully usable separate from the tensor data
  • Everything exported, e.g., Offset method on Shape
  • int used instead of int64 to make everything easier -- target platforms are all 64bit and have 64bit int in Go by default

Index

Constants

This section is empty.

Variables

View Source
var KiT_Type = kit.Enums.AddEnum(TypeN, kit.NotBitFlag, nil)

Functions

func BoolToFloat64

func BoolToFloat64(bv bool) float64

func ColMajorStrides

func ColMajorStrides(shape []int) []int

ColMajorStrides returns strides for shape where the first dimension is inner-most and subsequent dimensions are progressively outer

func CopyDense added in v1.0.0

func CopyDense(to Tensor, dm *mat.Dense)

CopyDense copies a gonum mat.Dense matrix into given Tensor using standard Float64 interface

func CopyInts

func CopyInts(a []int) []int

CopyInts makes a copy of an int slice

func CopyInts64

func CopyInts64(a []int64) []int

CopyInts64 makes a copy of an int64 slice to an int slice

func CopyStrings

func CopyStrings(a []string) []string

CopyStrings makes a copy of a string slice

func EqualInts

func EqualInts(a, b []int) bool

EqualInts compares two int slices and returns true if they are equal

func Float64ToBool

func Float64ToBool(val float64) bool

func Float64ToString

func Float64ToString(val float64) string

func IntTo64

func IntTo64(isl []int) []int64

IntTo64 converts an []int slice to an []int64 slice

func OpenCSV added in v1.0.0

func OpenCSV(tsr Tensor, filename gi.FileName, delim rune) error

OpenCSV reads a tensor from a comma-separated-values (CSV) file (where comma = any delimiter, specified in the delim arg), using the Go standard encoding/csv reader conforming to the official CSV standard. Reads all values and assigns as many as fit.

func Prjn2DCoords added in v1.0.0

func Prjn2DCoords(shp *Shape, oddRow bool, row, col int) (rowCoords, colCoords []int)

Prjn2DCoords returns the corresponding full-dimensional coordinates that go into the given row, col coords for a 2D projection of the given tensor, collapsing higher dimensions down to 2D (and 1D up to 2D).

func Prjn2DIdx added in v1.0.0

func Prjn2DIdx(shp *Shape, oddRow bool, row, col int) int

Prjn2DIdx returns the flat 1D index for given row, col coords for a 2D projection of the given tensor shape, collapsing higher dimensions down to 2D (and 1D up to 2D). For any odd number of dimensions, the remaining outer-most dimension can either be multipliexed across the row or column, given the oddRow arg. Even multiples of inner-most dimensions are assumed to be row, then column. RowMajor and ColMajor layouts are handled appropriately.

func Prjn2DSet

func Prjn2DSet(tsr Tensor, oddRow bool, row, col int, val float64)

Prjn2DSet sets a float64 value at given row, col coords for a 2D projection of the given tensor, collapsing higher dimensions down to 2D (and 1D up to 2D). For any odd number of dimensions, the remaining outer-most dimension can either be multipliexed across the row or column, given the oddRow arg. Even multiples of inner-most dimensions are assumed to be row, then column. RowMajor and ColMajor layouts are handled appropriately.

func Prjn2DShape

func Prjn2DShape(shp *Shape, oddRow bool) (rows, cols, rowEx, colEx int)

Prjn2DShape returns the size of a 2D projection of the given tensor Shape, collapsing higher dimensions down to 2D (and 1D up to 2D). For any odd number of dimensions, the remaining outer-most dimension can either be multipliexed across the row or column, given the oddRow arg. Even multiples of inner-most dimensions are assumed to be row, then column. RowMajor and ColMajor layouts are handled appropriately. rowEx returns the number of "extra" (higher dimensional) rows and colEx returns the number of extra cols

func Prjn2DVal

func Prjn2DVal(tsr Tensor, oddRow bool, row, col int) float64

Prjn2DVal returns the float64 value at given row, col coords for a 2D projection of the given tensor, collapsing higher dimensions down to 2D (and 1D up to 2D). For any odd number of dimensions, the remaining outer-most dimension can either be multipliexed across the row or column, given the oddRow arg. Even multiples of inner-most dimensions are assumed to be row, then column. RowMajor and ColMajor layouts are handled appropriately.

func ReadCSV added in v1.0.0

func ReadCSV(tsr Tensor, r io.Reader, delim rune) error

ReadCSV reads a tensor from a comma-separated-values (CSV) file (where comma = any delimiter, specified in the delim arg), using the Go standard encoding/csv reader conforming to the official CSV standard. Reads all values and assigns as many as fit.

func RowMajorStrides

func RowMajorStrides(shape []int) []int

RowMajorStrides returns strides for shape where the first dimension is outer-most and subsequent dimensions are progressively inner

func SaveCSV added in v1.0.0

func SaveCSV(tsr Tensor, filename gi.FileName, delim rune) error

SaveCSV writes a tensor to a comma-separated-values (CSV) file (where comma = any delimiter, specified in the delim arg). Outer-most dims are rows in the file, and inner-most is column -- Reading just grabs all values and doesn't care about shape.

func StringToFloat64

func StringToFloat64(str string) float64

func WriteCSV added in v1.0.0

func WriteCSV(tsr Tensor, w io.Writer, delim rune) error

WriteCSV writes a tensor to a comma-separated-values (CSV) file (where comma = any delimiter,

specified in the delim arg).

Outer-most dims are rows in the file, and inner-most is column -- Reading just grabs all values and doesn't care about shape.

Types

type AggFunc

type AggFunc func(idx int, val float64, agg float64) float64

AggFunc is an aggregation function that incrementally updates agg value from each element in the tensor in turn -- returns new agg value that will be passed into next item as agg

type Bits

type Bits struct {
	Shape
	Values bitslice.Slice
	Meta   map[string]string
}

etensor.Bits is a tensor of bits backed by a bitslice.Slice for efficient storage of binary data

func NewBits

func NewBits(shape, strides []int, names []string) *Bits

NewBits returns a new n-dimensional array of bits If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created.

func NewBitsShape

func NewBitsShape(shape *Shape) *Bits

NewBitsShape returns a new n-dimensional array of bits If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created.

func (*Bits) Agg

func (tsr *Bits) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Bits) At

func (tsr *Bits) At(i, j int) float64

At is the gonum/mat.Matrix interface method for returning 2D matrix element at given row, column index. Not supported for Bits -- do not call!

func (*Bits) Clone

func (tsr *Bits) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Bits) CopyCellsFrom

func (tsr *Bits) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Bits) CopyFrom

func (tsr *Bits) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Bits) CopyMetaData added in v1.0.0

func (tsr *Bits) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Bits) CopyShapeFrom added in v1.0.0

func (tsr *Bits) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Bits) DataType

func (tsr *Bits) DataType() Type

func (*Bits) Dims

func (tsr *Bits) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Not supported for Bits -- do not call!

func (*Bits) Eval

func (tsr *Bits) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor, using float64 conversions of the values, and puts the results into given float64 slice, which is ensured to be of the proper length

func (*Bits) FloatVal

func (tsr *Bits) FloatVal(i []int) float64

func (*Bits) FloatVal1D

func (tsr *Bits) FloatVal1D(off int) float64

func (*Bits) FloatValRowCell added in v1.0.0

func (tsr *Bits) FloatValRowCell(row, cell int) float64

func (*Bits) Floats

func (tsr *Bits) Floats(flt *[]float64)

func (*Bits) IsNull

func (tsr *Bits) IsNull(i []int) bool

Null not supported for bits

func (*Bits) IsNull1D

func (tsr *Bits) IsNull1D(i int) bool

func (*Bits) Label added in v1.0.1

func (tsr *Bits) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Bits) MetaData added in v1.0.0

func (tsr *Bits) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Bits) MetaDataMap added in v1.0.0

func (tsr *Bits) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Bits) Range

func (tsr *Bits) Range() (min, max float64, minIdx, maxIdx int)

Range is not applicable to Bits tensor

func (*Bits) Set

func (tsr *Bits) Set(i []int, val bool)

func (*Bits) Set1D added in v1.0.0

func (tsr *Bits) Set1D(i int, val bool)

func (*Bits) SetFloat

func (tsr *Bits) SetFloat(i []int, val float64)

func (*Bits) SetFloat1D

func (tsr *Bits) SetFloat1D(off int, val float64)

func (*Bits) SetFloatRowCell added in v1.0.0

func (tsr *Bits) SetFloatRowCell(row, cell int, val float64)

func (*Bits) SetFloats

func (tsr *Bits) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Bits) SetFunc

func (tsr *Bits) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor, using float64 conversions of the values, and writes the results back into the same tensor values

func (*Bits) SetMetaData added in v1.0.0

func (tsr *Bits) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Bits) SetNull

func (tsr *Bits) SetNull(i []int, nul bool)

func (*Bits) SetNull1D

func (tsr *Bits) SetNull1D(i int, nul bool)

func (*Bits) SetNumRows

func (tsr *Bits) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Bits) SetShape

func (tsr *Bits) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Bits) SetString

func (tsr *Bits) SetString(i []int, val string)

func (*Bits) SetString1D

func (tsr *Bits) SetString1D(off int, val string)

func (*Bits) SetStringRowCell added in v1.0.0

func (tsr *Bits) SetStringRowCell(row, cell int, val string)

func (*Bits) SetZeros

func (tsr *Bits) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Bits) ShapeObj

func (tsr *Bits) ShapeObj() *Shape

func (*Bits) String added in v1.0.1

func (tsr *Bits) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Bits) StringVal

func (tsr *Bits) StringVal(i []int) string

func (*Bits) StringVal1D

func (tsr *Bits) StringVal1D(off int) string

func (*Bits) StringValRowCell added in v1.0.0

func (tsr *Bits) StringValRowCell(row, cell int) string

func (*Bits) SubSpace

func (tsr *Bits) SubSpace(offs []int) Tensor

SubSpace is not applicable to Bits tensor

func (*Bits) SubSpaceTry

func (tsr *Bits) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry is not applicable to Bits tensor

func (*Bits) T

func (tsr *Bits) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. Not supported for Bits -- do not call!

func (*Bits) Value

func (tsr *Bits) Value(i []int) bool

Value returns value at given tensor index

func (*Bits) Value1D

func (tsr *Bits) Value1D(i int) bool

Value1D returns value at given tensor 1D (flat) index

type BoolType

type BoolType struct{}

func (*BoolType) BitWidth

func (t *BoolType) BitWidth() int

func (*BoolType) ID

func (t *BoolType) ID() arrow.Type

func (*BoolType) Name

func (t *BoolType) Name() string

type EvalFunc

type EvalFunc func(idx int, val float64) float64

EvalFunc is an evaluation function that computes a function on each element value, returning the computed value

type Float32

type Float32 struct {
	Shape
	Values []float32
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Float32 is an n-dim array of float32s.

func NewFloat32

func NewFloat32(shape, strides []int, names []string) *Float32

NewFloat32 returns a new n-dimensional array of float32s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewFloat32Shape

func NewFloat32Shape(shape *Shape, vals []float32) *Float32

NewFloat32Shape returns a new n-dimensional array of float32s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Float32) Agg

func (tsr *Float32) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Float32) At

func (tsr *Float32) At(i, j int) float64

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.

func (*Float32) Clone

func (tsr *Float32) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Float32) CopyCellsFrom

func (tsr *Float32) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Float32) CopyFrom

func (tsr *Float32) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Float32) CopyMetaData added in v1.0.0

func (tsr *Float32) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Float32) CopyShapeFrom added in v1.0.0

func (tsr *Float32) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Float32) DataType

func (tsr *Float32) DataType() Type

func (*Float32) Dims

func (tsr *Float32) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Float32) Eval

func (tsr *Float32) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Float32) FloatVal

func (tsr *Float32) FloatVal(i []int) float64

func (*Float32) FloatVal1D

func (tsr *Float32) FloatVal1D(off int) float64

func (*Float32) FloatValRowCell added in v1.0.0

func (tsr *Float32) FloatValRowCell(row, cell int) float64

func (*Float32) Floats

func (tsr *Float32) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Float32) FromArrow

func (tsr *Float32) FromArrow(arw *tensor.Float32, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Float32) IsNull

func (tsr *Float32) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Float32) IsNull1D

func (tsr *Float32) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Float32) Label

func (tsr *Float32) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Float32) MetaData added in v1.0.0

func (tsr *Float32) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Float32) MetaDataMap added in v1.0.0

func (tsr *Float32) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Float32) Range

func (tsr *Float32) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Float32) Set

func (tsr *Float32) Set(i []int, val float32)

func (*Float32) Set1D added in v1.0.0

func (tsr *Float32) Set1D(i int, val float32)

func (*Float32) SetFloat

func (tsr *Float32) SetFloat(i []int, val float64)

func (*Float32) SetFloat1D

func (tsr *Float32) SetFloat1D(off int, val float64)

func (*Float32) SetFloatRowCell added in v1.0.0

func (tsr *Float32) SetFloatRowCell(row, cell int, val float64)

func (*Float32) SetFloats

func (tsr *Float32) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Float32) SetFunc

func (tsr *Float32) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Float32) SetMetaData added in v1.0.0

func (tsr *Float32) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Float32) SetNull

func (tsr *Float32) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Float32) SetNull1D

func (tsr *Float32) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Float32) SetNumRows

func (tsr *Float32) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Float32) SetShape

func (tsr *Float32) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Float32) SetString

func (tsr *Float32) SetString(i []int, val string)

func (*Float32) SetString1D

func (tsr *Float32) SetString1D(off int, val string)

func (*Float32) SetStringRowCell added in v1.0.0

func (tsr *Float32) SetStringRowCell(row, cell int, val string)

func (*Float32) SetZeros

func (tsr *Float32) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Float32) ShapeObj

func (tsr *Float32) ShapeObj() *Shape

func (*Float32) String

func (tsr *Float32) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Float32) StringVal

func (tsr *Float32) StringVal(i []int) string

func (*Float32) StringVal1D

func (tsr *Float32) StringVal1D(off int) string

func (*Float32) StringValRowCell added in v1.0.0

func (tsr *Float32) StringValRowCell(row, cell int) string

func (*Float32) SubSpace

func (tsr *Float32) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Float32) SubSpaceTry

func (tsr *Float32) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Float32) Symmetric added in v1.0.0

func (tsr *Float32) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Float32) T

func (tsr *Float32) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Float32) ToArrow

func (tsr *Float32) ToArrow() *tensor.Float32

ToArrow returns the apache arrow equivalent of the tensor

func (*Float32) Value

func (tsr *Float32) Value(i []int) float32

func (*Float32) Value1D

func (tsr *Float32) Value1D(i int) float32

type Float64

type Float64 struct {
	Shape
	Values []float64
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Float64 is an n-dim array of float64s.

func NewFloat64

func NewFloat64(shape, strides []int, names []string) *Float64

NewFloat64 returns a new n-dimensional array of float64s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewFloat64Shape

func NewFloat64Shape(shape *Shape, vals []float64) *Float64

NewFloat64Shape returns a new n-dimensional array of float64s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Float64) Agg

func (tsr *Float64) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Float64) At

func (tsr *Float64) At(i, j int) float64

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.

func (*Float64) Clone

func (tsr *Float64) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Float64) CopyCellsFrom

func (tsr *Float64) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Float64) CopyFrom

func (tsr *Float64) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Float64) CopyMetaData added in v1.0.0

func (tsr *Float64) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Float64) CopyShapeFrom added in v1.0.0

func (tsr *Float64) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Float64) DataType

func (tsr *Float64) DataType() Type

func (*Float64) Dims

func (tsr *Float64) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Float64) Eval

func (tsr *Float64) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Float64) FloatVal

func (tsr *Float64) FloatVal(i []int) float64

func (*Float64) FloatVal1D

func (tsr *Float64) FloatVal1D(off int) float64

func (*Float64) FloatValRowCell added in v1.0.0

func (tsr *Float64) FloatValRowCell(row, cell int) float64

func (*Float64) Floats

func (tsr *Float64) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Float64) FromArrow

func (tsr *Float64) FromArrow(arw *tensor.Float64, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Float64) IsNull

func (tsr *Float64) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Float64) IsNull1D

func (tsr *Float64) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Float64) Label

func (tsr *Float64) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Float64) MetaData added in v1.0.0

func (tsr *Float64) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Float64) MetaDataMap added in v1.0.0

func (tsr *Float64) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Float64) Range

func (tsr *Float64) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Float64) Set

func (tsr *Float64) Set(i []int, val float64)

func (*Float64) Set1D added in v1.0.0

func (tsr *Float64) Set1D(i int, val float64)

func (*Float64) SetFloat

func (tsr *Float64) SetFloat(i []int, val float64)

func (*Float64) SetFloat1D

func (tsr *Float64) SetFloat1D(off int, val float64)

func (*Float64) SetFloatRowCell added in v1.0.0

func (tsr *Float64) SetFloatRowCell(row, cell int, val float64)

func (*Float64) SetFloats

func (tsr *Float64) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Float64) SetFunc

func (tsr *Float64) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Float64) SetMetaData added in v1.0.0

func (tsr *Float64) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Float64) SetNull

func (tsr *Float64) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Float64) SetNull1D

func (tsr *Float64) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Float64) SetNumRows

func (tsr *Float64) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Float64) SetShape

func (tsr *Float64) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Float64) SetString

func (tsr *Float64) SetString(i []int, val string)

func (*Float64) SetString1D

func (tsr *Float64) SetString1D(off int, val string)

func (*Float64) SetStringRowCell added in v1.0.0

func (tsr *Float64) SetStringRowCell(row, cell int, val string)

func (*Float64) SetZeros

func (tsr *Float64) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Float64) ShapeObj

func (tsr *Float64) ShapeObj() *Shape

func (*Float64) String

func (tsr *Float64) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Float64) StringVal

func (tsr *Float64) StringVal(i []int) string

func (*Float64) StringVal1D

func (tsr *Float64) StringVal1D(off int) string

func (*Float64) StringValRowCell added in v1.0.0

func (tsr *Float64) StringValRowCell(row, cell int) string

func (*Float64) SubSpace

func (tsr *Float64) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Float64) SubSpaceTry

func (tsr *Float64) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Float64) Symmetric added in v1.0.0

func (tsr *Float64) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix.

func (*Float64) T

func (tsr *Float64) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Float64) ToArrow

func (tsr *Float64) ToArrow() *tensor.Float64

ToArrow returns the apache arrow equivalent of the tensor

func (*Float64) Value

func (tsr *Float64) Value(i []int) float64

func (*Float64) Value1D

func (tsr *Float64) Value1D(i int) float64

type Int added in v1.0.0

type Int struct {
	Shape
	Values []int
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Int is an n-dim array of ints, which are assumed to be 64bit in various places so usage on non-64bit platforms is not recommended. However, convenience of avoiding the constant casting is worth it in some cases.

func NewInt added in v1.0.0

func NewInt(shape, strides []int, names []string) *Int

NewInt returns a new n-dimensional array of ints. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewIntShape added in v1.0.0

func NewIntShape(shape *Shape, vals []int) *Int

NewIntShape returns a new n-dimensional array of ints. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Int) Agg added in v1.0.0

func (tsr *Int) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Int) At added in v1.0.0

func (tsr *Int) At(i, j int) float64

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.

func (*Int) Clone added in v1.0.0

func (tsr *Int) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Int) CopyCellsFrom added in v1.0.0

func (tsr *Int) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Int) CopyFrom added in v1.0.0

func (tsr *Int) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Int) CopyMetaData added in v1.0.0

func (tsr *Int) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Int) CopyShapeFrom added in v1.0.0

func (tsr *Int) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Int) DataType added in v1.0.0

func (tsr *Int) DataType() Type

func (*Int) Dims added in v1.0.0

func (tsr *Int) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Int) Eval added in v1.0.0

func (tsr *Int) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Int) FloatVal added in v1.0.0

func (tsr *Int) FloatVal(i []int) float64

func (*Int) FloatVal1D added in v1.0.0

func (tsr *Int) FloatVal1D(off int) float64

func (*Int) FloatValRowCell added in v1.0.0

func (tsr *Int) FloatValRowCell(row, cell int) float64

func (*Int) Floats added in v1.0.0

func (tsr *Int) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Int) FromArrow added in v1.0.0

func (tsr *Int) FromArrow(arw *tensor.Int64, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Int) IsNull added in v1.0.0

func (tsr *Int) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Int) IsNull1D added in v1.0.0

func (tsr *Int) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Int) Label added in v1.0.0

func (tsr *Int) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Int) MetaData added in v1.0.0

func (tsr *Int) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Int) MetaDataMap added in v1.0.0

func (tsr *Int) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Int) Range added in v1.0.0

func (tsr *Int) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Int) Set added in v1.0.0

func (tsr *Int) Set(i []int, val int)

func (*Int) Set1D added in v1.0.0

func (tsr *Int) Set1D(i int, val int)

func (*Int) SetFloat added in v1.0.0

func (tsr *Int) SetFloat(i []int, val float64)

func (*Int) SetFloat1D added in v1.0.0

func (tsr *Int) SetFloat1D(off int, val float64)

func (*Int) SetFloatRowCell added in v1.0.0

func (tsr *Int) SetFloatRowCell(row, cell int, val float64)

func (*Int) SetFloats added in v1.0.0

func (tsr *Int) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Int) SetFunc added in v1.0.0

func (tsr *Int) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Int) SetMetaData added in v1.0.0

func (tsr *Int) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Int) SetNull added in v1.0.0

func (tsr *Int) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int) SetNull1D added in v1.0.0

func (tsr *Int) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int) SetNumRows added in v1.0.0

func (tsr *Int) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Int) SetShape added in v1.0.0

func (tsr *Int) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Int) SetString added in v1.0.0

func (tsr *Int) SetString(i []int, val string)

func (*Int) SetString1D added in v1.0.0

func (tsr *Int) SetString1D(off int, val string)

func (*Int) SetStringRowCell added in v1.0.0

func (tsr *Int) SetStringRowCell(row, cell int, val string)

func (*Int) SetZeros added in v1.0.0

func (tsr *Int) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Int) ShapeObj added in v1.0.0

func (tsr *Int) ShapeObj() *Shape

func (*Int) String added in v1.0.0

func (tsr *Int) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Int) StringVal added in v1.0.0

func (tsr *Int) StringVal(i []int) string

func (*Int) StringVal1D added in v1.0.0

func (tsr *Int) StringVal1D(off int) string

func (*Int) StringValRowCell added in v1.0.0

func (tsr *Int) StringValRowCell(row, cell int) string

func (*Int) SubSpace added in v1.0.0

func (tsr *Int) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int) SubSpaceTry added in v1.0.0

func (tsr *Int) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int) Symmetric added in v1.0.0

func (tsr *Int) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Int) T added in v1.0.0

func (tsr *Int) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Int) ToArrow added in v1.0.0

func (tsr *Int) ToArrow() *tensor.Int64

ToArrow returns the apache arrow equivalent of the tensor

func (*Int) Value added in v1.0.0

func (tsr *Int) Value(i []int) int

func (*Int) Value1D added in v1.0.0

func (tsr *Int) Value1D(i int) int

type Int16

type Int16 struct {
	Shape
	Values []int16
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Int16 is an n-dim array of int16s.

func NewInt16

func NewInt16(shape, strides []int, names []string) *Int16

NewInt16 returns a new n-dimensional array of int16s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewInt16Shape

func NewInt16Shape(shape *Shape, vals []int16) *Int16

NewInt16Shape returns a new n-dimensional array of int16s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Int16) Agg

func (tsr *Int16) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Int16) At

func (tsr *Int16) At(i, j int) float64

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.

func (*Int16) Clone

func (tsr *Int16) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Int16) CopyCellsFrom

func (tsr *Int16) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Int16) CopyFrom

func (tsr *Int16) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Int16) CopyMetaData added in v1.0.0

func (tsr *Int16) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Int16) CopyShapeFrom added in v1.0.0

func (tsr *Int16) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Int16) DataType

func (tsr *Int16) DataType() Type

func (*Int16) Dims

func (tsr *Int16) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Int16) Eval

func (tsr *Int16) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Int16) FloatVal

func (tsr *Int16) FloatVal(i []int) float64

func (*Int16) FloatVal1D

func (tsr *Int16) FloatVal1D(off int) float64

func (*Int16) FloatValRowCell added in v1.0.0

func (tsr *Int16) FloatValRowCell(row, cell int) float64

func (*Int16) Floats

func (tsr *Int16) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Int16) FromArrow

func (tsr *Int16) FromArrow(arw *tensor.Int16, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Int16) IsNull

func (tsr *Int16) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Int16) IsNull1D

func (tsr *Int16) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Int16) Label

func (tsr *Int16) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Int16) MetaData added in v1.0.0

func (tsr *Int16) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Int16) MetaDataMap added in v1.0.0

func (tsr *Int16) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Int16) Range

func (tsr *Int16) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Int16) Set

func (tsr *Int16) Set(i []int, val int16)

func (*Int16) Set1D added in v1.0.0

func (tsr *Int16) Set1D(i int, val int16)

func (*Int16) SetFloat

func (tsr *Int16) SetFloat(i []int, val float64)

func (*Int16) SetFloat1D

func (tsr *Int16) SetFloat1D(off int, val float64)

func (*Int16) SetFloatRowCell added in v1.0.0

func (tsr *Int16) SetFloatRowCell(row, cell int, val float64)

func (*Int16) SetFloats

func (tsr *Int16) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Int16) SetFunc

func (tsr *Int16) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Int16) SetMetaData added in v1.0.0

func (tsr *Int16) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Int16) SetNull

func (tsr *Int16) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int16) SetNull1D

func (tsr *Int16) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int16) SetNumRows

func (tsr *Int16) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Int16) SetShape

func (tsr *Int16) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Int16) SetString

func (tsr *Int16) SetString(i []int, val string)

func (*Int16) SetString1D

func (tsr *Int16) SetString1D(off int, val string)

func (*Int16) SetStringRowCell added in v1.0.0

func (tsr *Int16) SetStringRowCell(row, cell int, val string)

func (*Int16) SetZeros

func (tsr *Int16) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Int16) ShapeObj

func (tsr *Int16) ShapeObj() *Shape

func (*Int16) String

func (tsr *Int16) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Int16) StringVal

func (tsr *Int16) StringVal(i []int) string

func (*Int16) StringVal1D

func (tsr *Int16) StringVal1D(off int) string

func (*Int16) StringValRowCell added in v1.0.0

func (tsr *Int16) StringValRowCell(row, cell int) string

func (*Int16) SubSpace

func (tsr *Int16) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int16) SubSpaceTry

func (tsr *Int16) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int16) Symmetric added in v1.0.0

func (tsr *Int16) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Int16) T

func (tsr *Int16) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Int16) ToArrow

func (tsr *Int16) ToArrow() *tensor.Int16

ToArrow returns the apache arrow equivalent of the tensor

func (*Int16) Value

func (tsr *Int16) Value(i []int) int16

func (*Int16) Value1D

func (tsr *Int16) Value1D(i int) int16

type Int32

type Int32 struct {
	Shape
	Values []int32
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Int32 is an n-dim array of int32s.

func NewInt32

func NewInt32(shape, strides []int, names []string) *Int32

NewInt32 returns a new n-dimensional array of int32s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewInt32Shape

func NewInt32Shape(shape *Shape, vals []int32) *Int32

NewInt32Shape returns a new n-dimensional array of int32s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Int32) Agg

func (tsr *Int32) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Int32) At

func (tsr *Int32) At(i, j int) float64

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.

func (*Int32) Clone

func (tsr *Int32) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Int32) CopyCellsFrom

func (tsr *Int32) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Int32) CopyFrom

func (tsr *Int32) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Int32) CopyMetaData added in v1.0.0

func (tsr *Int32) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Int32) CopyShapeFrom added in v1.0.0

func (tsr *Int32) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Int32) DataType

func (tsr *Int32) DataType() Type

func (*Int32) Dims

func (tsr *Int32) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Int32) Eval

func (tsr *Int32) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Int32) FloatVal

func (tsr *Int32) FloatVal(i []int) float64

func (*Int32) FloatVal1D

func (tsr *Int32) FloatVal1D(off int) float64

func (*Int32) FloatValRowCell added in v1.0.0

func (tsr *Int32) FloatValRowCell(row, cell int) float64

func (*Int32) Floats

func (tsr *Int32) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Int32) FromArrow

func (tsr *Int32) FromArrow(arw *tensor.Int32, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Int32) IsNull

func (tsr *Int32) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Int32) IsNull1D

func (tsr *Int32) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Int32) Label

func (tsr *Int32) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Int32) MetaData added in v1.0.0

func (tsr *Int32) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Int32) MetaDataMap added in v1.0.0

func (tsr *Int32) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Int32) Range

func (tsr *Int32) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Int32) Set

func (tsr *Int32) Set(i []int, val int32)

func (*Int32) Set1D added in v1.0.0

func (tsr *Int32) Set1D(i int, val int32)

func (*Int32) SetFloat

func (tsr *Int32) SetFloat(i []int, val float64)

func (*Int32) SetFloat1D

func (tsr *Int32) SetFloat1D(off int, val float64)

func (*Int32) SetFloatRowCell added in v1.0.0

func (tsr *Int32) SetFloatRowCell(row, cell int, val float64)

func (*Int32) SetFloats

func (tsr *Int32) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Int32) SetFunc

func (tsr *Int32) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Int32) SetMetaData added in v1.0.0

func (tsr *Int32) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Int32) SetNull

func (tsr *Int32) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int32) SetNull1D

func (tsr *Int32) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int32) SetNumRows

func (tsr *Int32) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Int32) SetShape

func (tsr *Int32) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Int32) SetString

func (tsr *Int32) SetString(i []int, val string)

func (*Int32) SetString1D

func (tsr *Int32) SetString1D(off int, val string)

func (*Int32) SetStringRowCell added in v1.0.0

func (tsr *Int32) SetStringRowCell(row, cell int, val string)

func (*Int32) SetZeros

func (tsr *Int32) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Int32) ShapeObj

func (tsr *Int32) ShapeObj() *Shape

func (*Int32) String

func (tsr *Int32) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Int32) StringVal

func (tsr *Int32) StringVal(i []int) string

func (*Int32) StringVal1D

func (tsr *Int32) StringVal1D(off int) string

func (*Int32) StringValRowCell added in v1.0.0

func (tsr *Int32) StringValRowCell(row, cell int) string

func (*Int32) SubSpace

func (tsr *Int32) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int32) SubSpaceTry

func (tsr *Int32) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int32) Symmetric added in v1.0.0

func (tsr *Int32) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Int32) T

func (tsr *Int32) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Int32) ToArrow

func (tsr *Int32) ToArrow() *tensor.Int32

ToArrow returns the apache arrow equivalent of the tensor

func (*Int32) Value

func (tsr *Int32) Value(i []int) int32

func (*Int32) Value1D

func (tsr *Int32) Value1D(i int) int32

type Int64

type Int64 struct {
	Shape
	Values []int64
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Int64 is an n-dim array of int64s.

func NewInt64

func NewInt64(shape, strides []int, names []string) *Int64

NewInt64 returns a new n-dimensional array of int64s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewInt64Shape

func NewInt64Shape(shape *Shape, vals []int64) *Int64

NewInt64Shape returns a new n-dimensional array of int64s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Int64) Agg

func (tsr *Int64) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Int64) At

func (tsr *Int64) At(i, j int) float64

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.

func (*Int64) Clone

func (tsr *Int64) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Int64) CopyCellsFrom

func (tsr *Int64) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Int64) CopyFrom

func (tsr *Int64) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Int64) CopyMetaData added in v1.0.0

func (tsr *Int64) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Int64) CopyShapeFrom added in v1.0.0

func (tsr *Int64) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Int64) DataType

func (tsr *Int64) DataType() Type

func (*Int64) Dims

func (tsr *Int64) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Int64) Eval

func (tsr *Int64) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Int64) FloatVal

func (tsr *Int64) FloatVal(i []int) float64

func (*Int64) FloatVal1D

func (tsr *Int64) FloatVal1D(off int) float64

func (*Int64) FloatValRowCell added in v1.0.0

func (tsr *Int64) FloatValRowCell(row, cell int) float64

func (*Int64) Floats

func (tsr *Int64) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Int64) FromArrow

func (tsr *Int64) FromArrow(arw *tensor.Int64, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Int64) IsNull

func (tsr *Int64) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Int64) IsNull1D

func (tsr *Int64) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Int64) Label

func (tsr *Int64) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Int64) MetaData added in v1.0.0

func (tsr *Int64) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Int64) MetaDataMap added in v1.0.0

func (tsr *Int64) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Int64) Range

func (tsr *Int64) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Int64) Set

func (tsr *Int64) Set(i []int, val int64)

func (*Int64) Set1D added in v1.0.0

func (tsr *Int64) Set1D(i int, val int64)

func (*Int64) SetFloat

func (tsr *Int64) SetFloat(i []int, val float64)

func (*Int64) SetFloat1D

func (tsr *Int64) SetFloat1D(off int, val float64)

func (*Int64) SetFloatRowCell added in v1.0.0

func (tsr *Int64) SetFloatRowCell(row, cell int, val float64)

func (*Int64) SetFloats

func (tsr *Int64) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Int64) SetFunc

func (tsr *Int64) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Int64) SetMetaData added in v1.0.0

func (tsr *Int64) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Int64) SetNull

func (tsr *Int64) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int64) SetNull1D

func (tsr *Int64) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int64) SetNumRows

func (tsr *Int64) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Int64) SetShape

func (tsr *Int64) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Int64) SetString

func (tsr *Int64) SetString(i []int, val string)

func (*Int64) SetString1D

func (tsr *Int64) SetString1D(off int, val string)

func (*Int64) SetStringRowCell added in v1.0.0

func (tsr *Int64) SetStringRowCell(row, cell int, val string)

func (*Int64) SetZeros

func (tsr *Int64) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Int64) ShapeObj

func (tsr *Int64) ShapeObj() *Shape

func (*Int64) String

func (tsr *Int64) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Int64) StringVal

func (tsr *Int64) StringVal(i []int) string

func (*Int64) StringVal1D

func (tsr *Int64) StringVal1D(off int) string

func (*Int64) StringValRowCell added in v1.0.0

func (tsr *Int64) StringValRowCell(row, cell int) string

func (*Int64) SubSpace

func (tsr *Int64) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int64) SubSpaceTry

func (tsr *Int64) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int64) Symmetric added in v1.0.0

func (tsr *Int64) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Int64) T

func (tsr *Int64) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Int64) ToArrow

func (tsr *Int64) ToArrow() *tensor.Int64

ToArrow returns the apache arrow equivalent of the tensor

func (*Int64) Value

func (tsr *Int64) Value(i []int) int64

func (*Int64) Value1D

func (tsr *Int64) Value1D(i int) int64

type Int8

type Int8 struct {
	Shape
	Values []int8
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Int8 is an n-dim array of int8s.

func NewInt8

func NewInt8(shape, strides []int, names []string) *Int8

NewInt8 returns a new n-dimensional array of int8s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewInt8Shape

func NewInt8Shape(shape *Shape, vals []int8) *Int8

NewInt8Shape returns a new n-dimensional array of int8s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Int8) Agg

func (tsr *Int8) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Int8) At

func (tsr *Int8) At(i, j int) float64

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.

func (*Int8) Clone

func (tsr *Int8) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Int8) CopyCellsFrom

func (tsr *Int8) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Int8) CopyFrom

func (tsr *Int8) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Int8) CopyMetaData added in v1.0.0

func (tsr *Int8) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Int8) CopyShapeFrom added in v1.0.0

func (tsr *Int8) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Int8) DataType

func (tsr *Int8) DataType() Type

func (*Int8) Dims

func (tsr *Int8) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Int8) Eval

func (tsr *Int8) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Int8) FloatVal

func (tsr *Int8) FloatVal(i []int) float64

func (*Int8) FloatVal1D

func (tsr *Int8) FloatVal1D(off int) float64

func (*Int8) FloatValRowCell added in v1.0.0

func (tsr *Int8) FloatValRowCell(row, cell int) float64

func (*Int8) Floats

func (tsr *Int8) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Int8) FromArrow

func (tsr *Int8) FromArrow(arw *tensor.Int8, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Int8) IsNull

func (tsr *Int8) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Int8) IsNull1D

func (tsr *Int8) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Int8) Label

func (tsr *Int8) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Int8) MetaData added in v1.0.0

func (tsr *Int8) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Int8) MetaDataMap added in v1.0.0

func (tsr *Int8) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Int8) Range

func (tsr *Int8) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Int8) Set

func (tsr *Int8) Set(i []int, val int8)

func (*Int8) Set1D added in v1.0.0

func (tsr *Int8) Set1D(i int, val int8)

func (*Int8) SetFloat

func (tsr *Int8) SetFloat(i []int, val float64)

func (*Int8) SetFloat1D

func (tsr *Int8) SetFloat1D(off int, val float64)

func (*Int8) SetFloatRowCell added in v1.0.0

func (tsr *Int8) SetFloatRowCell(row, cell int, val float64)

func (*Int8) SetFloats

func (tsr *Int8) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Int8) SetFunc

func (tsr *Int8) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Int8) SetMetaData added in v1.0.0

func (tsr *Int8) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Int8) SetNull

func (tsr *Int8) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int8) SetNull1D

func (tsr *Int8) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Int8) SetNumRows

func (tsr *Int8) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Int8) SetShape

func (tsr *Int8) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Int8) SetString

func (tsr *Int8) SetString(i []int, val string)

func (*Int8) SetString1D

func (tsr *Int8) SetString1D(off int, val string)

func (*Int8) SetStringRowCell added in v1.0.0

func (tsr *Int8) SetStringRowCell(row, cell int, val string)

func (*Int8) SetZeros

func (tsr *Int8) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Int8) ShapeObj

func (tsr *Int8) ShapeObj() *Shape

func (*Int8) String

func (tsr *Int8) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Int8) StringVal

func (tsr *Int8) StringVal(i []int) string

func (*Int8) StringVal1D

func (tsr *Int8) StringVal1D(off int) string

func (*Int8) StringValRowCell added in v1.0.0

func (tsr *Int8) StringValRowCell(row, cell int) string

func (*Int8) SubSpace

func (tsr *Int8) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int8) SubSpaceTry

func (tsr *Int8) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Int8) Symmetric added in v1.0.0

func (tsr *Int8) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Int8) T

func (tsr *Int8) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Int8) ToArrow

func (tsr *Int8) ToArrow() *tensor.Int8

ToArrow returns the apache arrow equivalent of the tensor

func (*Int8) Value

func (tsr *Int8) Value(i []int) int8

func (*Int8) Value1D

func (tsr *Int8) Value1D(i int) int8

type Shape

type Shape struct {
	Shp  []int
	Strd []int
	Nms  []string
}

Shape manages a tensor's shape information, including strides and dimension names and can compute the flat index into an underlying 1D data storage array based on an n-dimensional index (and vice-versa). This is fully compatible with (and largely taken from) apache/arrow tensors. except that we use plain int instead of int64, because on all relevant platforms int is *already* 64 and using plain int is much easier. Per C / Go / Python conventions (and unlike emergent) by default indexes are ordered from outer to inner left-to-right, so the inner-most is right-most. This is called Row-Major order, and is the default. It is also possible to use Column-Major order, which is used in R, Julia, and MATLAB, and emergent, where the inner-most index is first and outer-most last. In either case, the internal memory is always organized with the inner-most dimension contiguous in memory -- thus there is no underlying difference between the different indexing systems in terms of underlying memory -- just in the order of indexes used to access this memory.

func AddShapes

func AddShapes(shape1, shape2 *Shape) *Shape

AddShapes returns a new shape by adding two shapes one after the other. uses Row / Col order of the first shape for resulting shape

func NewShape

func NewShape(shape, strides []int, names []string) *Shape

NewShape returns a new shape object initialized with params. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created.

func (*Shape) CopyShape

func (sh *Shape) CopyShape(cp *Shape)

CopyShape copies the shape parameters from another Shape struct. copies the data so it is not accidentally subject to updates.

func (*Shape) Dim

func (sh *Shape) Dim(i int) int

Dim returns the size of given dimension.

func (*Shape) DimName

func (sh *Shape) DimName(i int) string

DimName returns the name of given dimension.

func (*Shape) DimNames

func (sh *Shape) DimNames() []string

DimNames returns slice of dimension names This is *not* a copy -- modifications will change the shape.

func (*Shape) IdxIsValid added in v1.0.0

func (sh *Shape) IdxIsValid(idx []int) bool

IdxIsValid() returns true if given index is valid (within ranges for all dimensions)

func (*Shape) Index

func (sh *Shape) Index(offset int) []int

Index returns the n-dimensional index from a "flat" 1D array index. Only works for RowMajor or ColMajor organization.

func (*Shape) IsColMajor

func (sh *Shape) IsColMajor() bool

IsColMajor returns true if shape is column-major organized: first dimension is column, i.e., inner-most storage dimension. Values *along a row* are contiguous, as you increment along the major inner-most (column) dimension. Importantly: ColMajor and RowMajor both have the *same* actual memory storage arrangement, with values along a row (across columns) contiguous in memory -- the only difference is in the order of the indexes used to access this memory.

func (*Shape) IsContiguous

func (sh *Shape) IsContiguous() bool

IsContiguous returns true if shape is either row or column major

func (*Shape) IsEqual

func (sh *Shape) IsEqual(oth *Shape) bool

IsEqual returns true if this shape is same as other (does not compare names)

func (*Shape) IsRowMajor

func (sh *Shape) IsRowMajor() bool

IsRowMajor returns true if shape is row-major organized: first dimension is the row or outer-most storage dimension. Values *along a row* are contiguous, as you increment along the minor, inner-most (column) dimension. Importantly: ColMajor and RowMajor both have the *same* actual memory storage arrangement, with values along a row (across columns) contiguous in memory -- the only difference is in the order of the indexes used to access this memory.

func (*Shape) Len

func (sh *Shape) Len() int

Len returns the total length of elements in the tensor (i.e., the product of the shape sizes)

func (*Shape) NumDims

func (sh *Shape) NumDims() int

NumDims returns the total number of dimensions.

func (*Shape) Offset

func (sh *Shape) Offset(index []int) int

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.

func (*Shape) RowCellSize

func (sh *Shape) RowCellSize() (rows, cells int)

RowCellSize returns the size of the outer-most Row shape dimension, and the size of all the remaining inner dimensions (the "cell" size) -- e.g., for Tensors that are columns in a data table. Only valid for RowMajor organization.

func (*Shape) SetShape

func (sh *Shape) SetShape(shape, strides []int, names []string)

SetShape sets the shape parameters. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created.

func (*Shape) SetShape64

func (sh *Shape) SetShape64(shape, strides []int64, names []string)

SetShape64 sets the shape parameters from int64 slices (e.g., arrow/tensor). If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created.

func (*Shape) Shape64

func (sh *Shape) Shape64() []int64

Shape64 returns a slice of int64 containing the dimensions sizes. This is a copy -- modifications will not change shape.

func (*Shape) Shapes

func (sh *Shape) Shapes() []int

Shapes returns the slice of dimension sizes. This is *not* a copy -- modifications will change the shape.

func (*Shape) Strides

func (sh *Shape) Strides() []int

Strides returns the slice of strides This is *not* a copy -- modifications will change the shape.

func (*Shape) Strides64

func (sh *Shape) Strides64() []int64

Strides64 returns a slice of int64 containing strides This is a copy -- modifications will not change shape.

func (*Shape) String

func (sh *Shape) String() string

String satisfies the fmt.Stringer interface

type String

type String struct {
	Shape
	Values []string
	Nulls  bitslice.Slice
	Meta   map[string]string
}

etensor.String is a tensor of strings backed by a []string slice

func NewString

func NewString(shape, strides []int, names []string) *String

NewString returns a new n-dimensional array of strings If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created.

func NewStringShape

func NewStringShape(shape *Shape) *String

NewStringShape returns a new n-dimensional array of strings from given shape

func (*String) Agg

func (tsr *String) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*String) At

func (tsr *String) At(i, j int) float64

At is the gonum/mat.Matrix interface method for returning 2D matrix element at given row, column index. Not supported for String -- do not call!

func (*String) Clone

func (tsr *String) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*String) CopyCellsFrom

func (tsr *String) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*String) CopyFrom

func (tsr *String) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*String) CopyMetaData added in v1.0.0

func (tsr *String) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*String) CopyShapeFrom added in v1.0.0

func (tsr *String) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*String) DataType

func (tsr *String) DataType() Type

func (*String) Dims

func (tsr *String) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Not supported for String -- do not call!

func (*String) Eval

func (tsr *String) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*String) FloatVal

func (tsr *String) FloatVal(i []int) float64

func (*String) FloatVal1D

func (tsr *String) FloatVal1D(off int) float64

func (*String) FloatValRowCell added in v1.0.0

func (tsr *String) FloatValRowCell(row, cell int) float64

func (*String) Floats

func (tsr *String) Floats(flt *[]float64)

func (*String) IsNull

func (tsr *String) IsNull(i []int) bool

func (*String) IsNull1D

func (tsr *String) IsNull1D(i int) bool

func (*String) Label added in v1.0.1

func (tsr *String) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*String) MetaData added in v1.0.0

func (tsr *String) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*String) MetaDataMap added in v1.0.0

func (tsr *String) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*String) Range

func (tsr *String) Range() (min, max float64, minIdx, maxIdx int)

Range is not applicable to String tensor

func (*String) Set

func (tsr *String) Set(i []int, val string)

Set sets value at given tensor index

func (*String) Set1D added in v1.0.0

func (tsr *String) Set1D(i int, val string)

Set1D sets value at given 1D (flat) tensor index

func (*String) SetFloat

func (tsr *String) SetFloat(i []int, val float64)

func (*String) SetFloat1D

func (tsr *String) SetFloat1D(off int, val float64)

func (*String) SetFloatRowCell added in v1.0.0

func (tsr *String) SetFloatRowCell(row, cell int, val float64)

func (*String) SetFloats

func (tsr *String) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*String) SetFunc

func (tsr *String) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*String) SetMetaData added in v1.0.0

func (tsr *String) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*String) SetNull

func (tsr *String) SetNull(i []int, nul bool)

func (*String) SetNull1D

func (tsr *String) SetNull1D(i int, nul bool)

func (*String) SetNumRows

func (tsr *String) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*String) SetShape

func (tsr *String) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*String) SetString

func (tsr *String) SetString(i []int, val string)

func (*String) SetString1D

func (tsr *String) SetString1D(off int, val string)

func (*String) SetStringRowCell added in v1.0.0

func (tsr *String) SetStringRowCell(row, cell int, val string)

func (*String) SetZeros

func (tsr *String) SetZeros()

SetZeros is simple convenience function initialize all values to ""

func (*String) ShapeObj

func (tsr *String) ShapeObj() *Shape

func (*String) String added in v1.0.1

func (tsr *String) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*String) StringVal

func (tsr *String) StringVal(i []int) string

func (*String) StringVal1D

func (tsr *String) StringVal1D(off int) string

func (*String) StringValRowCell added in v1.0.0

func (tsr *String) StringValRowCell(row, cell int) string

func (*String) SubSpace

func (tsr *String) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*String) SubSpaceTry

func (tsr *String) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*String) T

func (tsr *String) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. Not supported for String -- do not call!

func (*String) Value

func (tsr *String) Value(i []int) string

Value returns value at given tensor index

func (*String) Value1D

func (tsr *String) Value1D(i int) string

Value1D returns value at given 1D (flat) tensor index

type Tensor

type Tensor interface {
	mat.Matrix

	// Len returns the number of elements in the tensor (product of shape dimensions).
	Len() int

	// DataType returns the type of data, using arrow.DataType (ID() is the arrow.Type enum value)
	DataType() Type

	// ShapeObj returns a pointer to the shape object that fully parameterizes the tensor shape
	ShapeObj() *Shape

	// Shapes returns the size in each dimension of the tensor. (Shape is the full Shape struct)
	Shapes() []int

	// Strides returns the number of elements to step in each dimension when traversing the tensor.
	Strides() []int

	// Shape64 returns the size in each dimension using int64 (arrow compatbile)
	Shape64() []int64

	// Strides64 returns the strides in each dimension using int64 (arrow compatbile)
	Strides64() []int64

	// NumDims returns the number of dimensions of the tensor.
	NumDims() int

	// Dim returns the size of the given dimension
	Dim(i int) int

	// DimNames returns the string slice of dimension names
	DimNames() []string

	// DimName returns the name of the i-th dimension.
	DimName(i int) string

	IsContiguous() bool

	// IsRowMajor returns true if shape is row-major organized:
	// first dimension is the row or outer-most storage dimension.
	// Values *along a row* are contiguous, as you increment along
	// the minor, inner-most (column) dimension.
	// Importantly: ColMajor and RowMajor both have the *same*
	// actual memory storage arrangement, with values along a row
	// (across columns) contiguous in memory -- the only difference
	// is in the order of the indexes used to access this memory.
	IsRowMajor() bool

	// IsColMajor returns true if shape is column-major organized:
	// first dimension is column, i.e., inner-most storage dimension.
	// Values *along a row* are contiguous, as you increment along
	// the major inner-most (column) dimension.
	// Importantly: ColMajor and RowMajor both have the *same*
	// actual memory storage arrangement, with values along a row
	// (across columns) contiguous in memory -- the only difference
	// is in the order of the indexes used to access this memory.
	IsColMajor() bool

	// RowCellSize returns the size of the outer-most Row shape dimension,
	// and the size of all the remaining inner dimensions (the "cell" size)
	// e.g., for Tensors that are columns in a data table.
	// Only valid for RowMajor organization.
	RowCellSize() (rows, cells int)

	// Offset returns the flat 1D array / slice 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.
	Offset(i []int) int

	// IsNull returns true if the given index has been flagged as a Null
	// (undefined, not present) value
	IsNull(i []int) bool

	// IsNull1D returns true if the given 1-dimensional index has been flagged as a Null
	// (undefined, not present) value
	IsNull1D(i int) bool

	// SetNull sets whether given index has a null value or not.
	// All values are assumed valid (non-Null) until marked otherwise, and calling
	// this method creates a Null bitslice map if one has not already been set yet.
	SetNull(i []int, nul bool)

	// SetNull1D sets whether given 1-dimensional index has a null value or not.
	// All values are assumed valid (non-Null) until marked otherwise, and calling
	// this method creates a Null bitslice map if one has not already been set yet.
	SetNull1D(i int, nul bool)

	// FloatVal returns the value of given index as a float64
	FloatVal(i []int) float64

	// SetFloat sets the value of given index as a float64
	SetFloat(i []int, val float64)

	// StringVal returns the value of given index as a string
	StringVal(i []int) string

	// SetString sets the value of given index as a string
	SetString(i []int, val string)

	// FloatVal1D returns the value of given 1-dimensional index (0-Len()-1) as a float64
	FloatVal1D(i int) float64

	// SetFloat1D sets the value of given 1-dimensional index (0-Len()-1) as a float64
	SetFloat1D(i int, val float64)

	// FloatValRowCell returns the value at given row and cell, where row is outer-most dim,
	// and cell is 1D index into remaining inner dims -- for etable.Table columns
	FloatValRowCell(row, cell int) float64

	// SetFloatRowCell sets the value at given row and cell, where row is outer-most dim,
	// and cell is 1D index into remaining inner dims -- for etable.Table columns
	SetFloatRowCell(row, cell int, val float64)

	// Floats sets []float64 slice of all elements in the tensor
	// (length is ensured to be sufficient).
	// This can be used for all of the gonum/floats methods
	// for basic math, gonum/stats, etc.
	Floats(flt *[]float64)

	// SetFloats sets tensor values from a []float64 slice (copies values).
	SetFloats(vals []float64)

	// StringVal1D returns the value of given 1-dimensional index (0-Len()-1) as a string
	StringVal1D(i int) string

	// SetString1D sets the value of given 1-dimensional index (0-Len()-1) as a string
	SetString1D(i int, val string)

	// StringValRowCell returns the value at given row and cell, where row is outer-most dim,
	// and cell is 1D index into remaining inner dims -- for etable.Table columns
	StringValRowCell(row, cell int) string

	// SetStringRowCell sets the value at given row and cell, where row is outer-most dim,
	// and cell is 1D index into remaining inner dims -- for etable.Table columns
	SetStringRowCell(row, cell int, val string)

	// SubSpace returns a new tensor with innermost subspace at given
	// offset(s) in outermost dimension(s) (len(offs) < NumDims).
	// Only valid for row or column major layouts.
	// The new tensor points to the values of the this tensor (i.e., modifications
	// will affect both), as its Values slice is a view onto the original (which
	// is why only inner-most contiguous supsaces are supported).
	// Use Clone() method to separate the two.
	SubSpace(offs []int) Tensor

	// SubSpaceTry returns a new tensor with innermost subspace at given
	// offset(s) in outermost dimension(s) (len(offs) < NumDims).
	// Try version returns an error message if the offs do not fit in tensor Shape.
	// Only valid for row or column major layouts.
	// The new tensor points to the values of the this tensor (i.e., modifications
	// will affect both), as its Values slice is a view onto the original (which
	// is why only inner-most contiguous supsaces are supported).
	// Use Clone() method to separate the two.
	SubSpaceTry(offs []int) (Tensor, error)

	// 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.
	Range() (min, max float64, minIdx, maxIdx int)

	// Agg applies given aggregation function to each element in the tensor
	// (automatically skips IsNull and NaN elements), using float64 conversions of the values.
	// init is the initial value for the agg variable. returns final aggregate value
	Agg(ini float64, fun AggFunc) float64

	// Eval applies given function to each element in the tensor (automatically
	// skips IsNull and NaN elements), using float64 conversions of the values.
	// Puts the results into given float64 slice, which is ensured to be of the proper length.
	Eval(res *[]float64, fun EvalFunc)

	// SetFunc applies given function to each element in the tensor (automatically
	// skips IsNull and NaN elements), using float64 conversions of the values.
	// Writes the results back into the same tensor elements.
	SetFunc(fun EvalFunc)

	// SetZeros is simple convenience function initialize all values to 0
	SetZeros()

	// Clone clones this tensor, creating a duplicate copy of itself with its
	// own separate memory representation of all the values, and returns
	// that as a Tensor (which can be converted into the known type as needed).
	Clone() Tensor

	// CopyFrom copies all avail values from other tensor into this tensor, with an
	// optimized implementation if the other tensor is of the same type, and
	// otherwise it goes through appropriate standard type.
	CopyFrom(from Tensor)

	// CopyShapeFrom copies just the shape from given source tensor
	// calling SetShape with the shape params from source (see for more docs).
	CopyShapeFrom(from Tensor)

	// CopyCellsFrom copies given range of values from other tensor into this tensor,
	// using flat 1D indexes: to = starting index in this Tensor to start copying into,
	// start = starting index on from Tensor to start copying from, and n = number of
	// values to copy.  Uses an optimized implementation if the other tensor is
	// of the same type, and otherwise it goes through appropriate standard type.
	CopyCellsFrom(from Tensor, to, start, n int)

	// SetShape sets the shape parameters of the tensor, and resizes backing storage appropriately.
	// existing RowMajor or ColMajor stride preference will be used if strides is nil, and
	// existing names will be preserved if nil
	SetShape(shape, strides []int, names []string)

	// SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.
	// Does nothing for other stride layouts
	SetNumRows(rows int)

	// SetMetaData sets a key=value meta data (stored as a map[string]string).
	// For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-,
	// min, max set fixed min / max values, background=color
	SetMetaData(key, val string)

	// MetaData retrieves value of given key, bool = false if not set
	MetaData(key string) (string, bool)

	// MetaDataMap returns the underlying map used for meta data
	MetaDataMap() map[string]string

	// CopyMetaData copies meta data from given source tensor
	CopyMetaData(from Tensor)
}

Tensor is the general interface for n-dimensional tensors.

Tensor is automatically a gonum/mat.Matrix, implementing the Dims(), At(), T(), and Symmetric() methods which automatically operate on the inner-most two dimensions, assuming default row-major layout. Error messages will be logged if applied to a Tensor with less than 2 dimensions, and care should be taken when using with > 2 dimensions (e.g., will only affect the first 2D subspace within a higher-dimensional space -- typically you'll want to call SubSpace to get a 2D subspace of the higher-dimensional Tensor (SubSpace is not part of interface as it returns the specific type, but is defined for all Tensor types).

func New

func New(dtype Type, shape, strides []int, names []string) Tensor

New returns a new Tensor of given type, using our Type specifier which is isomorphic with arrow.Type

type Type

type Type int

Type is a logical type -- the subset supported by etable. This is copied directly from arrow.Type They can be expressed as either a primitive physical type (bytes or bits of some fixed size), a nested type consisting of other data types, or another data type (e.g. a timestamp encoded as an int64). Note that we need the unconventional CAPS names b/c regular CamelCase is taken by the tensor type itself.

const (
	// Null type having no physical storage
	NULL Type = Type(arrow.NULL)

	// Bool is a 1 bit, LSB bit-packed ordering
	BOOL Type = Type(arrow.BOOL)

	// UINT8 is an Unsigned 8-bit little-endian integer
	UINT8 Type = Type(arrow.UINT8)

	// INT8 is a Signed 8-bit little-endian integer
	INT8 Type = Type(arrow.INT8)

	// UINT16 is an Unsigned 16-bit little-endian integer
	UINT16 Type = Type(arrow.UINT16)

	// INT16 is a Signed 16-bit little-endian integer
	INT16 Type = Type(arrow.INT16)

	// UINT32 is an Unsigned 32-bit little-endian integer
	UINT32 Type = Type(arrow.UINT32)

	// INT32 is a Signed 32-bit little-endian integer
	INT32 Type = Type(arrow.INT32)

	// UINT64 is an Unsigned 64-bit little-endian integer
	UINT64 Type = Type(arrow.UINT64)

	// INT64 is a Signed 64-bit little-endian integer
	INT64 Type = Type(arrow.INT64)

	// FLOAT16 is a 2-byte floating point value
	FLOAT16 Type = Type(arrow.FLOAT16)

	// FLOAT32 is a 4-byte floating point value
	FLOAT32 Type = Type(arrow.FLOAT32)

	// FLOAT64 is an 8-byte floating point value
	FLOAT64 Type = Type(arrow.FLOAT64)

	// STRING is a UTF8 variable-length string
	STRING Type = Type(arrow.STRING)

	// INT is a Signed 64-bit little-endian integer -- should only use on 64bit machines!
	INT Type = STRING + 1

	TypeN = INT + 1
)

func (*Type) FromString

func (i *Type) FromString(s string) error

func (Type) MarshalJSON

func (ev Type) MarshalJSON() ([]byte, error)

func (Type) String

func (i Type) String() string

func (*Type) UnmarshalJSON

func (ev *Type) UnmarshalJSON(b []byte) error

type Uint16

type Uint16 struct {
	Shape
	Values []uint16
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Uint16 is an n-dim array of uint16s.

func NewUint16

func NewUint16(shape, strides []int, names []string) *Uint16

NewUint16 returns a new n-dimensional array of uint16s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewUint16Shape

func NewUint16Shape(shape *Shape, vals []uint16) *Uint16

NewUint16Shape returns a new n-dimensional array of uint16s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Uint16) Agg

func (tsr *Uint16) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Uint16) At

func (tsr *Uint16) At(i, j int) float64

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.

func (*Uint16) Clone

func (tsr *Uint16) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Uint16) CopyCellsFrom

func (tsr *Uint16) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Uint16) CopyFrom

func (tsr *Uint16) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Uint16) CopyMetaData added in v1.0.0

func (tsr *Uint16) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Uint16) CopyShapeFrom added in v1.0.0

func (tsr *Uint16) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Uint16) DataType

func (tsr *Uint16) DataType() Type

func (*Uint16) Dims

func (tsr *Uint16) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Uint16) Eval

func (tsr *Uint16) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Uint16) FloatVal

func (tsr *Uint16) FloatVal(i []int) float64

func (*Uint16) FloatVal1D

func (tsr *Uint16) FloatVal1D(off int) float64

func (*Uint16) FloatValRowCell added in v1.0.0

func (tsr *Uint16) FloatValRowCell(row, cell int) float64

func (*Uint16) Floats

func (tsr *Uint16) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Uint16) FromArrow

func (tsr *Uint16) FromArrow(arw *tensor.Uint16, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Uint16) IsNull

func (tsr *Uint16) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Uint16) IsNull1D

func (tsr *Uint16) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Uint16) Label

func (tsr *Uint16) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Uint16) MetaData added in v1.0.0

func (tsr *Uint16) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Uint16) MetaDataMap added in v1.0.0

func (tsr *Uint16) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Uint16) Range

func (tsr *Uint16) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Uint16) Set

func (tsr *Uint16) Set(i []int, val uint16)

func (*Uint16) Set1D added in v1.0.0

func (tsr *Uint16) Set1D(i int, val uint16)

func (*Uint16) SetFloat

func (tsr *Uint16) SetFloat(i []int, val float64)

func (*Uint16) SetFloat1D

func (tsr *Uint16) SetFloat1D(off int, val float64)

func (*Uint16) SetFloatRowCell added in v1.0.0

func (tsr *Uint16) SetFloatRowCell(row, cell int, val float64)

func (*Uint16) SetFloats

func (tsr *Uint16) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Uint16) SetFunc

func (tsr *Uint16) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Uint16) SetMetaData added in v1.0.0

func (tsr *Uint16) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Uint16) SetNull

func (tsr *Uint16) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint16) SetNull1D

func (tsr *Uint16) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint16) SetNumRows

func (tsr *Uint16) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Uint16) SetShape

func (tsr *Uint16) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Uint16) SetString

func (tsr *Uint16) SetString(i []int, val string)

func (*Uint16) SetString1D

func (tsr *Uint16) SetString1D(off int, val string)

func (*Uint16) SetStringRowCell added in v1.0.0

func (tsr *Uint16) SetStringRowCell(row, cell int, val string)

func (*Uint16) SetZeros

func (tsr *Uint16) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Uint16) ShapeObj

func (tsr *Uint16) ShapeObj() *Shape

func (*Uint16) String

func (tsr *Uint16) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Uint16) StringVal

func (tsr *Uint16) StringVal(i []int) string

func (*Uint16) StringVal1D

func (tsr *Uint16) StringVal1D(off int) string

func (*Uint16) StringValRowCell added in v1.0.0

func (tsr *Uint16) StringValRowCell(row, cell int) string

func (*Uint16) SubSpace

func (tsr *Uint16) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint16) SubSpaceTry

func (tsr *Uint16) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint16) Symmetric added in v1.0.0

func (tsr *Uint16) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Uint16) T

func (tsr *Uint16) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Uint16) ToArrow

func (tsr *Uint16) ToArrow() *tensor.Uint16

ToArrow returns the apache arrow equivalent of the tensor

func (*Uint16) Value

func (tsr *Uint16) Value(i []int) uint16

func (*Uint16) Value1D

func (tsr *Uint16) Value1D(i int) uint16

type Uint32

type Uint32 struct {
	Shape
	Values []uint32
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Uint32 is an n-dim array of uint32s.

func NewUint32

func NewUint32(shape, strides []int, names []string) *Uint32

NewUint32 returns a new n-dimensional array of uint32s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewUint32Shape

func NewUint32Shape(shape *Shape, vals []uint32) *Uint32

NewUint32Shape returns a new n-dimensional array of uint32s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Uint32) Agg

func (tsr *Uint32) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Uint32) At

func (tsr *Uint32) At(i, j int) float64

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.

func (*Uint32) Clone

func (tsr *Uint32) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Uint32) CopyCellsFrom

func (tsr *Uint32) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Uint32) CopyFrom

func (tsr *Uint32) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Uint32) CopyMetaData added in v1.0.0

func (tsr *Uint32) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Uint32) CopyShapeFrom added in v1.0.0

func (tsr *Uint32) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Uint32) DataType

func (tsr *Uint32) DataType() Type

func (*Uint32) Dims

func (tsr *Uint32) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Uint32) Eval

func (tsr *Uint32) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Uint32) FloatVal

func (tsr *Uint32) FloatVal(i []int) float64

func (*Uint32) FloatVal1D

func (tsr *Uint32) FloatVal1D(off int) float64

func (*Uint32) FloatValRowCell added in v1.0.0

func (tsr *Uint32) FloatValRowCell(row, cell int) float64

func (*Uint32) Floats

func (tsr *Uint32) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Uint32) FromArrow

func (tsr *Uint32) FromArrow(arw *tensor.Uint32, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Uint32) IsNull

func (tsr *Uint32) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Uint32) IsNull1D

func (tsr *Uint32) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Uint32) Label

func (tsr *Uint32) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Uint32) MetaData added in v1.0.0

func (tsr *Uint32) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Uint32) MetaDataMap added in v1.0.0

func (tsr *Uint32) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Uint32) Range

func (tsr *Uint32) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Uint32) Set

func (tsr *Uint32) Set(i []int, val uint32)

func (*Uint32) Set1D added in v1.0.0

func (tsr *Uint32) Set1D(i int, val uint32)

func (*Uint32) SetFloat

func (tsr *Uint32) SetFloat(i []int, val float64)

func (*Uint32) SetFloat1D

func (tsr *Uint32) SetFloat1D(off int, val float64)

func (*Uint32) SetFloatRowCell added in v1.0.0

func (tsr *Uint32) SetFloatRowCell(row, cell int, val float64)

func (*Uint32) SetFloats

func (tsr *Uint32) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Uint32) SetFunc

func (tsr *Uint32) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Uint32) SetMetaData added in v1.0.0

func (tsr *Uint32) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Uint32) SetNull

func (tsr *Uint32) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint32) SetNull1D

func (tsr *Uint32) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint32) SetNumRows

func (tsr *Uint32) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Uint32) SetShape

func (tsr *Uint32) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Uint32) SetString

func (tsr *Uint32) SetString(i []int, val string)

func (*Uint32) SetString1D

func (tsr *Uint32) SetString1D(off int, val string)

func (*Uint32) SetStringRowCell added in v1.0.0

func (tsr *Uint32) SetStringRowCell(row, cell int, val string)

func (*Uint32) SetZeros

func (tsr *Uint32) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Uint32) ShapeObj

func (tsr *Uint32) ShapeObj() *Shape

func (*Uint32) String

func (tsr *Uint32) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Uint32) StringVal

func (tsr *Uint32) StringVal(i []int) string

func (*Uint32) StringVal1D

func (tsr *Uint32) StringVal1D(off int) string

func (*Uint32) StringValRowCell added in v1.0.0

func (tsr *Uint32) StringValRowCell(row, cell int) string

func (*Uint32) SubSpace

func (tsr *Uint32) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint32) SubSpaceTry

func (tsr *Uint32) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint32) Symmetric added in v1.0.0

func (tsr *Uint32) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Uint32) T

func (tsr *Uint32) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Uint32) ToArrow

func (tsr *Uint32) ToArrow() *tensor.Uint32

ToArrow returns the apache arrow equivalent of the tensor

func (*Uint32) Value

func (tsr *Uint32) Value(i []int) uint32

func (*Uint32) Value1D

func (tsr *Uint32) Value1D(i int) uint32

type Uint64

type Uint64 struct {
	Shape
	Values []uint64
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Uint64 is an n-dim array of uint64s.

func NewUint64

func NewUint64(shape, strides []int, names []string) *Uint64

NewUint64 returns a new n-dimensional array of uint64s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewUint64Shape

func NewUint64Shape(shape *Shape, vals []uint64) *Uint64

NewUint64Shape returns a new n-dimensional array of uint64s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Uint64) Agg

func (tsr *Uint64) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Uint64) At

func (tsr *Uint64) At(i, j int) float64

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.

func (*Uint64) Clone

func (tsr *Uint64) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Uint64) CopyCellsFrom

func (tsr *Uint64) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Uint64) CopyFrom

func (tsr *Uint64) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Uint64) CopyMetaData added in v1.0.0

func (tsr *Uint64) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Uint64) CopyShapeFrom added in v1.0.0

func (tsr *Uint64) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Uint64) DataType

func (tsr *Uint64) DataType() Type

func (*Uint64) Dims

func (tsr *Uint64) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Uint64) Eval

func (tsr *Uint64) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Uint64) FloatVal

func (tsr *Uint64) FloatVal(i []int) float64

func (*Uint64) FloatVal1D

func (tsr *Uint64) FloatVal1D(off int) float64

func (*Uint64) FloatValRowCell added in v1.0.0

func (tsr *Uint64) FloatValRowCell(row, cell int) float64

func (*Uint64) Floats

func (tsr *Uint64) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Uint64) FromArrow

func (tsr *Uint64) FromArrow(arw *tensor.Uint64, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Uint64) IsNull

func (tsr *Uint64) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Uint64) IsNull1D

func (tsr *Uint64) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Uint64) Label

func (tsr *Uint64) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Uint64) MetaData added in v1.0.0

func (tsr *Uint64) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Uint64) MetaDataMap added in v1.0.0

func (tsr *Uint64) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Uint64) Range

func (tsr *Uint64) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Uint64) Set

func (tsr *Uint64) Set(i []int, val uint64)

func (*Uint64) Set1D added in v1.0.0

func (tsr *Uint64) Set1D(i int, val uint64)

func (*Uint64) SetFloat

func (tsr *Uint64) SetFloat(i []int, val float64)

func (*Uint64) SetFloat1D

func (tsr *Uint64) SetFloat1D(off int, val float64)

func (*Uint64) SetFloatRowCell added in v1.0.0

func (tsr *Uint64) SetFloatRowCell(row, cell int, val float64)

func (*Uint64) SetFloats

func (tsr *Uint64) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Uint64) SetFunc

func (tsr *Uint64) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Uint64) SetMetaData added in v1.0.0

func (tsr *Uint64) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Uint64) SetNull

func (tsr *Uint64) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint64) SetNull1D

func (tsr *Uint64) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint64) SetNumRows

func (tsr *Uint64) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Uint64) SetShape

func (tsr *Uint64) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Uint64) SetString

func (tsr *Uint64) SetString(i []int, val string)

func (*Uint64) SetString1D

func (tsr *Uint64) SetString1D(off int, val string)

func (*Uint64) SetStringRowCell added in v1.0.0

func (tsr *Uint64) SetStringRowCell(row, cell int, val string)

func (*Uint64) SetZeros

func (tsr *Uint64) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Uint64) ShapeObj

func (tsr *Uint64) ShapeObj() *Shape

func (*Uint64) String

func (tsr *Uint64) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Uint64) StringVal

func (tsr *Uint64) StringVal(i []int) string

func (*Uint64) StringVal1D

func (tsr *Uint64) StringVal1D(off int) string

func (*Uint64) StringValRowCell added in v1.0.0

func (tsr *Uint64) StringValRowCell(row, cell int) string

func (*Uint64) SubSpace

func (tsr *Uint64) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint64) SubSpaceTry

func (tsr *Uint64) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint64) Symmetric added in v1.0.0

func (tsr *Uint64) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Uint64) T

func (tsr *Uint64) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Uint64) ToArrow

func (tsr *Uint64) ToArrow() *tensor.Uint64

ToArrow returns the apache arrow equivalent of the tensor

func (*Uint64) Value

func (tsr *Uint64) Value(i []int) uint64

func (*Uint64) Value1D

func (tsr *Uint64) Value1D(i int) uint64

type Uint8

type Uint8 struct {
	Shape
	Values []uint8
	Nulls  bitslice.Slice
	Meta   map[string]string
}

Uint8 is an n-dim array of uint8s.

func NewUint8

func NewUint8(shape, strides []int, names []string) *Uint8

NewUint8 returns a new n-dimensional array of uint8s. If strides is nil, row-major strides will be inferred. If names is nil, a slice of empty strings will be created. Nulls are initialized to nil.

func NewUint8Shape

func NewUint8Shape(shape *Shape, vals []uint8) *Uint8

NewUint8Shape returns a new n-dimensional array of uint8s. Using shape structure instead of separate slices, and optionally existing values if vals != nil (must be of proper length) -- we directly set our internal Values = vals, thereby sharing the same underlying data. Nulls are initialized to nil.

func (*Uint8) Agg

func (tsr *Uint8) Agg(ini float64, fun AggFunc) float64

Agg applies given aggregation function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. init is the initial value for the agg variable. returns final aggregate value

func (*Uint8) At

func (tsr *Uint8) At(i, j int) float64

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.

func (*Uint8) Clone

func (tsr *Uint8) Clone() Tensor

Clone clones this tensor, creating a duplicate copy of itself with its own separate memory representation of all the values, and returns that as a Tensor (which can be converted into the known type as needed).

func (*Uint8) CopyCellsFrom

func (tsr *Uint8) CopyCellsFrom(frm Tensor, to, start, n int)

CopyCellsFrom copies given range of values from other tensor into this tensor, using flat 1D indexes: to = starting index in this Tensor to start copying into, start = starting index on from Tensor to start copying from, and n = number of values to copy. Uses an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type.

func (*Uint8) CopyFrom

func (tsr *Uint8) CopyFrom(frm Tensor)

CopyFrom copies all avail values from other tensor into this tensor, with an optimized implementation if the other tensor is of the same type, and otherwise it goes through appropriate standard type. Copies Null state as well if present.

func (*Uint8) CopyMetaData added in v1.0.0

func (tsr *Uint8) CopyMetaData(frm Tensor)

CopyMetaData copies meta data from given source tensor

func (*Uint8) CopyShapeFrom added in v1.0.0

func (tsr *Uint8) CopyShapeFrom(frm Tensor)

CopyShapeFrom copies just the shape from given source tensor calling SetShape with the shape params from source (see for more docs).

func (*Uint8) DataType

func (tsr *Uint8) DataType() Type

func (*Uint8) Dims

func (tsr *Uint8) Dims() (r, c int)

Dims is the gonum/mat.Matrix interface method for returning the dimensionality of the 2D Matrix. Assumes Row-major ordering and logs an error if NumDims < 2.

func (*Uint8) Eval

func (tsr *Uint8) Eval(res *[]float64, fun EvalFunc)

Eval applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Puts the results into given float64 slice, which is ensured to be of the proper length.

func (*Uint8) FloatVal

func (tsr *Uint8) FloatVal(i []int) float64

func (*Uint8) FloatVal1D

func (tsr *Uint8) FloatVal1D(off int) float64

func (*Uint8) FloatValRowCell added in v1.0.0

func (tsr *Uint8) FloatValRowCell(row, cell int) float64

func (*Uint8) Floats

func (tsr *Uint8) Floats(flt *[]float64)

Floats sets []float64 slice of all elements in the tensor (length is ensured to be sufficient). This can be used for all of the gonum/floats methods for basic math, gonum/stats, etc.

func (*Uint8) FromArrow

func (tsr *Uint8) FromArrow(arw *tensor.Uint8, cpy bool)

FromArrow intializes this tensor from an arrow tensor of same type cpy = true means make a copy of the arrow data, otherwise it directly refers to its values slice -- we do not Retain() on that data so it is up to the go GC and / or your own memory management policies to ensure the data remains intact!

func (*Uint8) IsNull

func (tsr *Uint8) IsNull(i []int) bool

IsNull returns true if the given index has been flagged as a Null (undefined, not present) value

func (*Uint8) IsNull1D

func (tsr *Uint8) IsNull1D(i int) bool

IsNull1D returns true if the given 1-dimensional index has been flagged as a Null (undefined, not present) value

func (*Uint8) Label

func (tsr *Uint8) Label() string

Label satisfies the gi.Labeler interface for a summary description of the tensor

func (*Uint8) MetaData added in v1.0.0

func (tsr *Uint8) MetaData(key string) (string, bool)

MetaData retrieves value of given key, bool = false if not set

func (*Uint8) MetaDataMap added in v1.0.0

func (tsr *Uint8) MetaDataMap() map[string]string

MetaDataMap returns the underlying map used for meta data

func (*Uint8) Range

func (tsr *Uint8) Range() (min, max float64, minIdx, maxIdx int)

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.

func (*Uint8) Set

func (tsr *Uint8) Set(i []int, val uint8)

func (*Uint8) Set1D added in v1.0.0

func (tsr *Uint8) Set1D(i int, val uint8)

func (*Uint8) SetFloat

func (tsr *Uint8) SetFloat(i []int, val float64)

func (*Uint8) SetFloat1D

func (tsr *Uint8) SetFloat1D(off int, val float64)

func (*Uint8) SetFloatRowCell added in v1.0.0

func (tsr *Uint8) SetFloatRowCell(row, cell int, val float64)

func (*Uint8) SetFloats

func (tsr *Uint8) SetFloats(vals []float64)

SetFloats sets tensor values from a []float64 slice (copies values).

func (*Uint8) SetFunc

func (tsr *Uint8) SetFunc(fun EvalFunc)

SetFunc applies given function to each element in the tensor (automatically skips IsNull and NaN elements), using float64 conversions of the values. Writes the results back into the same tensor elements.

func (*Uint8) SetMetaData added in v1.0.0

func (tsr *Uint8) SetMetaData(key, val string)

SetMetaData sets a key=value meta data (stored as a map[string]string). For TensorGrid display: top-zero=+/-, odd-row=+/-, image=+/-, min, max set fixed min / max values, background=color

func (*Uint8) SetNull

func (tsr *Uint8) SetNull(i []int, nul bool)

SetNull sets whether given index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint8) SetNull1D

func (tsr *Uint8) SetNull1D(i int, nul bool)

SetNull1D sets whether given 1-dimensional index has a null value or not. All values are assumed valid (non-Null) until marked otherwise, and calling this method creates a Null bitslice map if one has not already been set yet.

func (*Uint8) SetNumRows

func (tsr *Uint8) SetNumRows(rows int)

SetNumRows sets the number of rows (outer-most dimension) in a RowMajor organized tensor.

func (*Uint8) SetShape

func (tsr *Uint8) SetShape(shape, strides []int, names []string)

SetShape sets the shape params, resizing backing storage appropriately

func (*Uint8) SetString

func (tsr *Uint8) SetString(i []int, val string)

func (*Uint8) SetString1D

func (tsr *Uint8) SetString1D(off int, val string)

func (*Uint8) SetStringRowCell added in v1.0.0

func (tsr *Uint8) SetStringRowCell(row, cell int, val string)

func (*Uint8) SetZeros

func (tsr *Uint8) SetZeros()

SetZeros is simple convenience function initialize all values to 0

func (*Uint8) ShapeObj

func (tsr *Uint8) ShapeObj() *Shape

func (*Uint8) String

func (tsr *Uint8) String() string

String satisfies the fmt.Stringer interface for string of tensor data

func (*Uint8) StringVal

func (tsr *Uint8) StringVal(i []int) string

func (*Uint8) StringVal1D

func (tsr *Uint8) StringVal1D(off int) string

func (*Uint8) StringValRowCell added in v1.0.0

func (tsr *Uint8) StringValRowCell(row, cell int) string

func (*Uint8) SubSpace

func (tsr *Uint8) SubSpace(offs []int) Tensor

SubSpace returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint8) SubSpaceTry

func (tsr *Uint8) SubSpaceTry(offs []int) (Tensor, error)

SubSpaceTry returns a new tensor with innermost subspace at given offset(s) in outermost dimension(s) (len(offs) < NumDims). Try version returns an error message if the offs do not fit in tensor Shape. Only valid for row or column major layouts. The new tensor points to the values of the this tensor (i.e., modifications will affect both), as its Values slice is a view onto the original (which is why only inner-most contiguous supsaces are supported). Use Clone() method to separate the two.

func (*Uint8) Symmetric added in v1.0.0

func (tsr *Uint8) Symmetric() (r int)

Symmetric is the gonum/mat.Matrix interface method for returning the dimensionality of a symmetric 2D Matrix. Logs error if called on non-symmetric matrix.

func (*Uint8) T

func (tsr *Uint8) T() mat.Matrix

T is the gonum/mat.Matrix transpose method. It performs an implicit transpose by returning the receiver inside a Transpose.

func (*Uint8) ToArrow

func (tsr *Uint8) ToArrow() *tensor.Uint8

ToArrow returns the apache arrow equivalent of the tensor

func (*Uint8) Value

func (tsr *Uint8) Value(i []int) uint8

func (*Uint8) Value1D

func (tsr *Uint8) Value1D(i int) uint8

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL