blas

package
v0.0.0-...-f96ffc0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2015 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package blas contains linear algebra routines for matrix manipulation with optional OpenCL acceleration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(imp Impl)

Init function is called at setup time to select the implementation

func Release

func Release()

Release function is called at shutdown to release any resources

func SeedRandom

func SeedRandom(seed int64) int64

SeedRandom function sets the random seed, or seeds using time if input is zero. Returns the seed which was used.

func Sync

func Sync()

Wait for any calcs to complete

Types

type Binary32

type Binary32 func(a, b float32) float32

Binary32 represents a float32 function of two variables

func (Binary32) Apply

func (fn Binary32) Apply(m1, m2, out Matrix) Matrix

Apply method applies a function to each element in a matrix

type BinaryCL

type BinaryCL struct {
	*scl.Software
}

BinaryCL type represents a user function of two variables.

func NewBinaryCL

func NewBinaryCL(text string) BinaryCL

NewUnaryCL function compiles a new function of one variable

func (BinaryCL) Apply

func (fn BinaryCL) Apply(m1, m2, out Matrix) Matrix

Apply method applies a unary function to a matrix

type BinaryFunction

type BinaryFunction interface {
	Apply(a, b, out Matrix) Matrix
}

Function2 interface applies a function elementwise to two matrices

type Filter

type Filter struct {
	*scl.Software
}

func NewFilter

func NewFilter(size int) Filter

Create a new filter with given size

func (*Filter) Apply

func (f *Filter) Apply(in Image, kernel, dx, dy Matrix)

Apply a convolution kernel to a distribution to generate a set of distorion vectors

type Image

type Image interface {
	Import(in ...Matrix)
	Export(xv, yv, out Matrix)
	SetOrigin(x0, y0 float32) Image
	Scale(xscale, yscale, dx, dy Matrix)
	Rotate(angle, dx, dy Matrix)
	Release()
}

Image interface type represents a 2 dimensional image.

func NewImage

func NewImage(width, height, nimage, channels int) Image

NewImage creates a new OpenCL image array

type Impl

type Impl int

Different implementations which can be selected

const (
	Native32 Impl
	OpenCL32
)

func Implementation

func Implementation() Impl

Implementation function returns the current implementation

type Matrix

type Matrix interface {
	Rows() int
	Cols() int
	Size() int
	Release()
	Copy(m, ix Matrix) Matrix
	Transpose(m Matrix) Matrix
	Reshape(rows, cols int, shrink bool) Matrix
	Set(val float32) Matrix
	Load(Ordering, ...float32) Matrix
	Random(min, max float32) Matrix
	Data(Ordering) []float32
	Col(col1, col2 int) Matrix
	Row(row1, row2 int) Matrix
	Scale(s float32) Matrix
	Add(a, b Matrix, sc float32) Matrix
	Cmp(a, b Matrix, epsilon float32) Matrix
	Mul(a, b Matrix, aTrans, bTrans, oTrans bool) Matrix
	MulElem(a, b Matrix) Matrix
	Sum() float32
	SumRows(a Matrix) Matrix
	MaxCol(m Matrix) Matrix
	Norm(m Matrix) Matrix
	Histogram(m Matrix, bins int, min, max float32) Matrix
	SetFormat(string)
	String() string
}

Matrix interface type represents a fix size matrix of row x cols.

func GaussianKernel

func GaussianKernel(xs, ys int, sigma float64) Matrix

Create a gaussian kernel with given size and standard deviation, xs and ys should be odd

func New

func New(rows, cols int) (m Matrix)

New function creates a new matrix of the given size

type Ordering

type Ordering bool

Switch for column major or row major data represntation

const (
	RowMajor Ordering = false
	ColMajor Ordering = true
)

type Unary32

type Unary32 func(float32) float32

Unary32 represents a float32 function of one variable

func (Unary32) Apply

func (fn Unary32) Apply(in, out Matrix) Matrix

Apply method applies a function to each element in a matrix

type UnaryCL

type UnaryCL struct {
	*scl.Software
}

UnaryCL type represents a user function of one variable.

func NewUnaryCL

func NewUnaryCL(text string) UnaryCL

NewUnaryCL function compiles a new function of one variable

func (UnaryCL) Apply

func (fn UnaryCL) Apply(in, out Matrix) Matrix

Apply method applies a unary function to a matrix element wise.

type UnaryFunction

type UnaryFunction interface {
	Apply(in, out Matrix) Matrix
}

UnaryFunction interface type represents a function which can be applied elementwise to a matrix

Jump to

Keyboard shortcuts

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