sparse: github.com/ctessum/sparse Index | Files

package sparse

import "github.com/ctessum/sparse"

Index

Package Files

sparse.go

Variables

var BoundsCheck = true

BoundsCheck specifies whether to check array bounds every time

type Array Uses

type Array interface {
    Set(val float64, index ...int)
    Get(index ...int) float64
    Scale(val float64)
    Sum() float64
    GetShape() []int
}

Array is a general float64 array type.

type DenseArray Uses

type DenseArray struct {
    Elements []float64

    Shape []int
    // contains filtered or unexported fields
}

DenseArray is a dense array with an arbitrary number of dimensions

func ZerosDense Uses

func ZerosDense(dims ...int) *DenseArray

ZerosDense initializes a new dense array.

func (*DenseArray) AbsMax Uses

func (A *DenseArray) AbsMax() float64

AbsMax returns the maximum absolute value of the array

func (*DenseArray) AddDense Uses

func (A *DenseArray) AddDense(B *DenseArray)

AddDense adds array B to array A in place.

func (*DenseArray) AddSparse Uses

func (A *DenseArray) AddSparse(B *SparseArray)

Add array B to array A in place.

func (*DenseArray) AddVal Uses

func (A *DenseArray) AddVal(val float64, index ...int)

AddVal adds value val at array index index.

func (*DenseArray) CheckIndex Uses

func (A *DenseArray) CheckIndex(index []int) error

CheckIndex checks whether index is within array dimensions.

func (*DenseArray) Copy Uses

func (A *DenseArray) Copy() *DenseArray

Copy an array

func (*DenseArray) Fix Uses

func (A *DenseArray) Fix()

Fix re-initializes the unexported fields, for example after transmitting via rpc.

func (*DenseArray) Get Uses

func (A *DenseArray) Get(index ...int) float64

Get array value at index

func (*DenseArray) Get1d Uses

func (A *DenseArray) Get1d(index1d int) float64

Get array value at one-dimensional index

func (*DenseArray) GetShape Uses

func (A *DenseArray) GetShape() []int

GetShape returns the array shape.

func (*DenseArray) Index1d Uses

func (A *DenseArray) Index1d(index ...int) (index1d int)

Convert n-dimensional index to one-dimensional index

func (*DenseArray) IndexNd Uses

func (A *DenseArray) IndexNd(index1d int) (indexNd []int)

IndexNd converts a 1-dimensional index to an n-dimensional index

func (*DenseArray) Max Uses

func (A *DenseArray) Max() float64

returns either zero of the maximum value of the array; whichever is greater.

func (*DenseArray) Scale Uses

func (A *DenseArray) Scale(val float64)

Scale Multiplies entire array by val

func (*DenseArray) ScaleCopy Uses

func (A *DenseArray) ScaleCopy(val float64) *DenseArray

ScaleCopy returns a copy of the array multiplied by val

func (*DenseArray) Set Uses

func (A *DenseArray) Set(val float64, index ...int)

Set index to val.

func (*DenseArray) Subset Uses

func (A *DenseArray) Subset(start []int, end []int) (B *DenseArray)

Subset extracts a subset of the array.

func (*DenseArray) Sum Uses

func (A *DenseArray) Sum() float64

Sum calculates the array sum.

type DenseArrayInt Uses

type DenseArrayInt struct {
    Elements []int

    Shape []int
    // contains filtered or unexported fields
}

DenseArrayInt is a dense array of integers with an arbitrary number of dimensions

func ZerosDenseInt Uses

func ZerosDenseInt(dims ...int) *DenseArrayInt

ZerosDenseInt initializes a new dense integer array.

func (*DenseArrayInt) CheckIndex Uses

func (A *DenseArrayInt) CheckIndex(index []int) error

CheckIndex checks whether index is within array dimensions.

func (*DenseArrayInt) Get Uses

func (A *DenseArrayInt) Get(index ...int) int

Get array value at index

func (*DenseArrayInt) Index1d Uses

func (A *DenseArrayInt) Index1d(index ...int) (index1d int)

Convert n-dimensional index to one-dimensional index

func (*DenseArrayInt) Set Uses

func (A *DenseArrayInt) Set(val int, index ...int)

Set index to val.

type SparseArray Uses

type SparseArray struct {
    Elements map[int]float64

    Shape []int
    // contains filtered or unexported fields
}

SparseArray is a sparse array with an arbitrary number of dimensions

func ArrayMultiply Uses

func ArrayMultiply(A, B *SparseArray) *SparseArray

func ZerosSparse Uses

func ZerosSparse(dims ...int) *SparseArray

ZerosSparse initializes a new sparse array.

func (*SparseArray) AddSparse Uses

func (A *SparseArray) AddSparse(B *SparseArray)

AddSparse adds array B to array A in place.

func (*SparseArray) AddVal Uses

func (A *SparseArray) AddVal(val float64, index ...int)

Add val at array index

func (*SparseArray) CheckIndex Uses

func (A *SparseArray) CheckIndex(index []int) error

CheckIndex checks whether index is within array dimensions.

func (*SparseArray) Copy Uses

func (A *SparseArray) Copy() *SparseArray

Copy copies the array.

func (*SparseArray) Fix Uses

func (A *SparseArray) Fix()

Fix re-initializes the unexported fields, for example after transmitting via rpc.

func (*SparseArray) Get Uses

func (A *SparseArray) Get(index ...int) float64

Get array value at index

func (*SparseArray) Get1d Uses

func (A *SparseArray) Get1d(index1d int) float64

Get array value at one-dimensional index

func (*SparseArray) GetShape Uses

func (A *SparseArray) GetShape() []int

GetShape returns the array shape.

func (*SparseArray) Index1d Uses

func (A *SparseArray) Index1d(index ...int) (index1d int)

Index1d converts an n-dimensional index to a one-dimensional index.

func (*SparseArray) IndexNd Uses

func (A *SparseArray) IndexNd(index1d int) (indexNd []int)

Convert a 1-dimensional index to an n-dimensional index

func (*SparseArray) IsNil Uses

func (A *SparseArray) IsNil() bool

IsNil returns whether the array has been allocated or not

func (*SparseArray) Nonzero Uses

func (A *SparseArray) Nonzero() []int

Nonzero returns (one dimensional) indicies of nonzero array Elements

func (*SparseArray) Scale Uses

func (A *SparseArray) Scale(val float64)

Scale Multiplies entire array by val

func (*SparseArray) ScaleCopy Uses

func (A *SparseArray) ScaleCopy(val float64) *SparseArray

ScaleCopy returns a copy of the array multiplied by val

func (*SparseArray) Set Uses

func (A *SparseArray) Set(val float64, index ...int)

Set index to val.

func (*SparseArray) SubtractSparse Uses

func (A *SparseArray) SubtractSparse(B *SparseArray)

Subtract array B from array A in place.

func (*SparseArray) SubtractVal Uses

func (A *SparseArray) SubtractVal(val float64, index ...int)

Subtract val at array index

func (*SparseArray) Sum Uses

func (A *SparseArray) Sum() float64

Sum calculates the array sum.

func (*SparseArray) ToDense Uses

func (A *SparseArray) ToDense() []float64

func (*SparseArray) ToDense32 Uses

func (A *SparseArray) ToDense32() []float32

func (*SparseArray) ToDenseArray Uses

func (A *SparseArray) ToDenseArray() *DenseArray

Package sparse imports 1 packages (graph) and is imported by 5 packages. Updated 2018-12-01. Refresh now. Tools for package owners.