sparse

package
v0.0.0-...-7b6cf24 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2012 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Sparse matrix operations

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxProcs int     // Number of goroutines to run concurrently when multiplyin matrices
	Margin   int = 3 // Number of columns/rows visible returned by String

	BufferLen int = 100
)
View Source
var GrowFraction int = 10

Functions

func Init

func Init()

Initialise goroutine and memory handling

Types

type Sparse

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

Sparse matrix type

func Elements

func Elements(mats ...*Sparse) (e *Sparse)

Return of the non-zero elements of a set of matrices in column major order as a column vector.

func Identity

func Identity(s int) (m *Sparse)

Return the I matrix

func Matrix

func Matrix(a [][]float64) (m *Sparse)

Return a sparse matrix based on a slice of float64 slices

func Random

func Random(r, c int, density float64) (m *Sparse)

func Zero

func Zero(r, c int) (m *Sparse)

Return the O matrix

func (*Sparse) Add

func (self *Sparse) Add(b *Sparse) (m *Sparse)

Add one matrix to another

func (*Sparse) Apply

func (self *Sparse) Apply(f matrix.ApplyFunc) (m *Sparse)

Apply a function to non-zero elements of the matrix

func (*Sparse) ApplyAll

func (self *Sparse) ApplyAll(f matrix.ApplyFunc) (m *Sparse)

Apply a function to all elements of the matrix

func (*Sparse) At

func (self *Sparse) At(r, c int) (v float64)

Return the value at (r, c)

func (*Sparse) Augment

func (self *Sparse) Augment(b *Sparse) (m *Sparse)

Join a matrix to the right of self returning the new matrix

func (*Sparse) Clean

func (self *Sparse) Clean() (m *Sparse)

Clean zero elements from a matrix

func (*Sparse) CleanError

func (self *Sparse) CleanError(error float64) (m *Sparse)

Clean elements within error of zero from a matrix

func (*Sparse) Copy

func (self *Sparse) Copy() (m *Sparse)

Return a copy of a matrix

func (*Sparse) Det

func (self *Sparse) Det() (d float64)

Calculate the determinant of a matrix

func (*Sparse) Dims

func (self *Sparse) Dims() (r, c int)

Return the dimensions of a matrix

func (*Sparse) Dot

func (self *Sparse) Dot(b *Sparse) (p *Sparse)

Multiply two matrices returning the product - columns calculated concurrently

func (*Sparse) Elements

func (self *Sparse) Elements() (a []float64)

Return of the non-zero elements of the matrix in column major order as an array.

func (*Sparse) Equals

func (self *Sparse) Equals(b *Sparse) bool

Test for equality of two matrices

func (*Sparse) EqualsApprox

func (self *Sparse) EqualsApprox(b *Sparse, error float64) bool

Test for approximate equality of two matrices, tolerance for equality given by error

func (*Sparse) Filter

func (self *Sparse) Filter(f matrix.FilterFunc) (m *Sparse)

Return a matrix with all elements at (r, c) set to zero where FilterFunc(r, c) returns false

func (*Sparse) Inner

func (self *Sparse) Inner(b *Sparse) (p float64)

Calculate the inner product of two matrices

func (*Sparse) Max

func (self *Sparse) Max() (m float64)

Return the maximum non-zero of a matrix

func (*Sparse) MaxAxis

func (self *Sparse) MaxAxis(cols bool) (m *Sparse)

Return a column or row vector holding the max of rows or columns

func (*Sparse) Min

func (self *Sparse) Min() (m float64)

Return the minimum non-zero of a matrix

func (*Sparse) MinAxis

func (self *Sparse) MinAxis(cols bool) (m *Sparse)

Return a column or row vector holding the min of rows or columns

func (*Sparse) MulElem

func (self *Sparse) MulElem(b *Sparse) (m *Sparse)

Multiply two matrices element by element

func (*Sparse) Norm

func (self *Sparse) Norm(ord int) (n float64)

Determin a variety of norms

func (*Sparse) Scalar

func (self *Sparse) Scalar(f float64) (m *Sparse)

Scale a matrix by a factor

func (*Sparse) Set

func (self *Sparse) Set(r, c int, v float64)

Set the value at (r, c) to v

func (*Sparse) Stack

func (self *Sparse) Stack(b *Sparse) (m *Sparse)

Join a matrix below self returning the new matrix

func (*Sparse) String

func (self *Sparse) String() (s string)

func (*Sparse) Sub

func (self *Sparse) Sub(b *Sparse) (m *Sparse)

Subtract one matrix from another

func (*Sparse) Sum

func (self *Sparse) Sum() (s float64)

Calculate the sum of a matrix

func (*Sparse) SumAxis

func (self *Sparse) SumAxis(cols bool) (m *Sparse)

Return a column or row vector holding the sums of rows or columns

func (*Sparse) T

func (self *Sparse) T() (m *Sparse)

Return the transpose of a matrix

Jump to

Keyboard shortcuts

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