tensor

package
v0.0.0-...-beb861e Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package tensor ... very simplified tensor with interface compatible with gorgonia.org/tensor

Index

Constants

This section is empty.

Variables

View Source
var ErrEndReached = errors.New("at end")

ErrEndReached is returned by iterator when at ane

View Source
var ErrIndexOutOfBounds = errors.New("index out of bounds")

ErrIndexOutOfBounds is returned by At when out of bounds

View Source
var Float64 = reflect.Float64

Float64 is element type

Functions

This section is empty.

Types

type Dense

type Dense struct {
	// contains filtered or unexported fields
}

Dense is a dense tensor

func NewDense

func NewDense(ty Dtype, s Shape, args ...Option) *Dense

NewDense ...

func (*Dense) At

func (t *Dense) At(args ...int) (v interface{}, e error)

At returns one element

func (*Dense) Data

func (t *Dense) Data() interface{}

Data returns underlying data

func (*Dense) Dtype

func (t *Dense) Dtype() Dtype

Dtype returns element type

func (*Dense) Iterator

func (t *Dense) Iterator() Iterator

Iterator returns a flat iterator

func (*Dense) Shape

func (t *Dense) Shape() Shape

Shape returns dimensions extend

func (*Dense) Strides

func (t *Dense) Strides() []int

Strides returns position-shift per dimension

type DenseIterator

type DenseIterator struct {
	// contains filtered or unexported fields
}

DenseIterator is returned by Dense.Iterator

func (*DenseIterator) Next

func (it *DenseIterator) Next() (i int, e error)

Next return current index and advance

func (*DenseIterator) Start

func (it *DenseIterator) Start() (i int, e error)

Start returns 0

type Dtype

type Dtype = reflect.Kind

Dtype is tensor element type

type Iterator

type Iterator interface {
	Start() (int, error)
	Next() (int, error)
}

Iterator is the interface for tensor iterator

type Option

type Option func(t *Dense)

Option can be passed to NewDense ex: WithBacking

func WithBacking

func WithBacking(data []float64) Option

WithBacking binds an existing storage to tensor

type Shape

type Shape []int

Shape ...

type Tensor

type Tensor interface {
	Shape() Shape
	At(args ...int) (interface{}, error)
}

Tensor is the minimal interface for tensor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL