linalg

package
v0.0.0-...-0d80f57 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2012 License: LGPL-3.0 Imports: 5 Imported by: 0

README

This package (go.opt/linalg) is part of go.opt repository. It is distributed under
LGPL3 license. See file COPYING in repository root //github.com/hrautila/go.opt/

Linalg package provides thin interface for BLAS/LAPACK libraries. 
It is modelled after CVXOPT python package.  

It is still work in progress and does not implement all LAPACK functions.
And BLAS interfaces for complex valued matrices is not as complete as for float
valued matrices. However, all BLAS functionality is available for complex valued
matrices via generic matrix interface.

It uses real and complex column-major matrix implementation from go.opt/matrix 

Requirements: 
	libblas package
	liblapack package

(See the cgo_ files in blas/lapack subdirectories).


Documentation

Index

Constants

View Source
const (
	// BLAS/LAPACK parameters. Chosen values match corresponding
	// parameters in CBLAS implementation.
	RowMajor    = 101 // Atlas row-major
	ColumnMajor = 102 // Atlas column major
	PNoTrans    = 111 // 'N'
	PTrans      = 112 // 'T'
	PConjTrans  = 113 // 'C'
	PUpper      = 121 // 'U'
	PLower      = 122 // 'L'
	PNonUnit    = 131 // 'N'
	PUnit       = 132 // 'U'
	PDiag       = 133 // 'D'
	PLeft       = 141 // 'L'
	PRight      = 142 // 'R'
	// These for LAPACK only
	PJobNo      = 151 // 'N'
	PJobValue   = 152 // 'V'
	PJobAll     = 153 // 'A'
	PJobS       = 154 // 'S'
	PJobO       = 155 // 'O'
	PRangeAll   = 161 // 'A'
	PRangeValue = 162 // 'V'
	PRangeInt   = 163 // 'I'
)

BLAS/LAPACK matrix parameter constants.

Variables

View Source
var (
	// trans: No Transpose 'N'
	OptNoTrans  = &IOpt{"trans", PNoTrans}
	OptNoTransA = &IOpt{"transA", PNoTrans}
	OptNoTransB = &IOpt{"transB", PNoTrans}
	// trans: Transpose 'T'
	OptTrans  = &IOpt{"trans", PTrans}
	OptTransA = &IOpt{"transA", PTrans}
	OptTransB = &IOpt{"transB", PTrans}
	// trans: Conjugate Transpose 'C'
	OptConjTrans  = &IOpt{"trans", PConjTrans}
	OptConjTransA = &IOpt{"transA", PConjTrans}
	OptConjTransB = &IOpt{"transB", PConjTrans}
	// uplo: Upper Triangular 'U'
	OptUpper = &IOpt{"uplo", PUpper}
	// uplo: Lower Triangular 'L'
	OptLower = &IOpt{"uplo", PLower}
	// side parameter 'L', 'R'
	OptLeft  = &IOpt{"side", PLeft}
	OptRight = &IOpt{"side", PRight}
	// diag parameter 'U'
	OptUnit = &IOpt{"diag", PUnit}
	// diag parameter 'N'
	OptNonUnit = &IOpt{"diag", PNonUnit}
	OptDiag    = &IOpt{"diag", PDiag}
	// Lapack jobz  'N'
	OptJobZNo = &IOpt{"jobz", PJobNo}
	// Lapack jobz   'V'
	OptJobZValue = &IOpt{"jobz", PJobValue}
	// Lapack jobu 'N'
	OptJobuNo = &IOpt{"jobu", PJobNo}
	// Lapack jobu 'A'
	OptJobuAll = &IOpt{"jobu", PJobAll}
	// Lapack jobu 'S'
	OptJobuS = &IOpt{"jobu", PJobS}
	// Lapack jobu 'O'
	OptJobuO = &IOpt{"jobu", PJobO}
	// Lapack jobvt 'N',
	OptJobvtNo = &IOpt{"jobvt", PJobNo}
	// Lapack jobvt 'A',
	OptJobvtAll = &IOpt{"jobvt", PJobAll}
	// Lapack jobvt 'S',
	OptJobvtS = &IOpt{"jobvt", PJobS}
	// Lapack jobvt 'O',
	OptJobvtO = &IOpt{"jobvt", PJobO}
	// Lapack range 'A'
	OptRangeAll = &IOpt{"range", PRangeAll}
	// Lapack range 'V'
	OptRangeValue = &IOpt{"range", PRangeValue}
	// Lapack range 'I'
	OptRangeInt = &IOpt{"range", PRangeInt}
)

Matrix parameter option variables.

Functions

func GetBoolOpt

func GetBoolOpt(name string, defval bool, opts ...Option) (val bool)

Get boolean option value. If option not present returns defval.

func GetComplexOpt

func GetComplexOpt(name string, defval complex128, opts ...Option) (val complex128)

Get string option value. If option not present returns defval.

func GetFloatOpt

func GetFloatOpt(name string, defval float64, opts ...Option) (val float64)

Get float option value. If option not present returns defval.

func GetIntOpt

func GetIntOpt(name string, defval int, opts ...Option) (val int)

Get integer option value. If option not present returns defval.

func GetParam

func GetParam(name string, params ...Option) (val int)

func GetStringOpt

func GetStringOpt(name string, defval string, opts ...Option) (val string)

Get string option value. If option not present returns defval.

func ParamString

func ParamString(p int) string

Map parameter value to name string that can be used when calling Fortran library functions.

func PrintIndexes

func PrintIndexes(p *IndexOpts)

func PrintParameters

func PrintParameters(p *Parameters)

Print parameter structure.

Types

type BOpt

type BOpt struct {
	OptName string
	Val     bool
}

Boolean valued option.

func BoolOpt

func BoolOpt(name string, val bool) *BOpt

Return bool valued option.

func (*BOpt) Bool

func (O *BOpt) Bool() bool

func (*BOpt) Complex

func (O *BOpt) Complex() complex128

Return NaN.

func (*BOpt) Float

func (O *BOpt) Float() float64

Return NaN.

func (*BOpt) Int

func (O *BOpt) Int() int

Return zero.

func (*BOpt) Name

func (O *BOpt) Name() string

func (*BOpt) String

func (O *BOpt) String() string

type COpt

type COpt struct {
	OptName string
	Val     complex128
}

Complex valued option.

func ComplexOpt

func ComplexOpt(name string, val complex128) *COpt

Return complex valued option.

func (*COpt) Bool

func (O *COpt) Bool() bool

func (*COpt) Complex

func (O *COpt) Complex() complex128

Return NaN.

func (*COpt) Float

func (O *COpt) Float() float64

Return NaN.

func (*COpt) Int

func (O *COpt) Int() int

Return zero.

func (*COpt) Name

func (O *COpt) Name() string

func (*COpt) String

func (O *COpt) String() string

type FOpt

type FOpt struct {
	OptName string
	Val     float64
}

Float valued option.

func FloatOpt

func FloatOpt(name string, val float64) *FOpt

Return integer valued option.

func (*FOpt) Bool

func (O *FOpt) Bool() bool

Return false.

func (*FOpt) Complex

func (O *FOpt) Complex() complex128

Return NaN.

func (*FOpt) Float

func (O *FOpt) Float() float64

func (*FOpt) Int

func (O *FOpt) Int() int

Return zero.

func (*FOpt) Name

func (O *FOpt) Name() string

func (*FOpt) String

func (O *FOpt) String() string

type IOpt

type IOpt struct {
	OptName string
	Val     int
}

Integer valued option.

func IntOpt

func IntOpt(name string, val int) *IOpt

Return integer valued option.

func (*IOpt) Bool

func (O *IOpt) Bool() bool

Return false.

func (*IOpt) Complex

func (O *IOpt) Complex() complex128

Return NaN.

func (*IOpt) Float

func (O *IOpt) Float() float64

Return NaN.

func (*IOpt) Int

func (O *IOpt) Int() int

func (*IOpt) Name

func (O *IOpt) Name() string

func (*IOpt) String

func (O *IOpt) String() string

type IndexOpts

type IndexOpts struct {
	// these for BLAS and LAPACK
	N, Nx, Ny                                   int
	M, Ma, Mb                                   int
	LDa, LDb, LDc                               int
	IncX, IncY                                  int
	OffsetX, OffsetY, OffsetA, OffsetB, OffsetC int
	K                                           int
	Ku                                          int
	Kl                                          int
	// these used in LAPACK
	Nrhs                        int
	OffsetD, OffsetDL, OffsetDU int
	LDw, LDz                    int
	OffsetW, OffsetZ            int
	LDu, LDvt                   int
	OffsetS, OffsetU, OffsetVt  int
}

LinalgIndex structure holds fields for various BLAS/LAPACK indexing variables.

func GetIndexOpts

func GetIndexOpts(opts ...Option) *IndexOpts

Parse option list and return index structure with relevant fields set and other fields with default values.

type Opt

type Opt struct {
	Name string
	Val  int
}

Type Opt holds one BLAS/LAPACK index or parameter option.

type Option

type Option interface {
	// Name of option.
	Name() string
	// Integer value of option.
	Int() int
	// Float value of option or NaN.
	Float() float64
	// Float value of option or NaN.
	Complex() complex128
	// Bool value of option.
	Bool() bool
	// Option value as string.
	String() string
}

Interface for named options.

func GetOption

func GetOption(name string, opts ...Option) Option

Find named option from a list of options. Returns nil of not found.

type Parameters

type Parameters struct {
	Trans, TransA, TransB int
	Uplo                  int
	Diag                  int
	Side                  int
	Jobz                  int
	Jobu                  int
	Jobvt                 int
	Range                 int
}

Structure for BLAS/LAPACK function parameters.

func GetParameters

func GetParameters(params ...Option) (p *Parameters, err error)

Parse options and return parameter structure with option fields set to given or sensible defaults.

type SOpt

type SOpt struct {
	OptName string
	Val     string
}

String valued option.

func StringOpt

func StringOpt(name string, val string) *SOpt

Return string valued option.

func (*SOpt) Bool

func (O *SOpt) Bool() bool

Return false.

func (*SOpt) Complex

func (O *SOpt) Complex() complex128

Return NaN.

func (*SOpt) Float

func (O *SOpt) Float() float64

func (*SOpt) Int

func (O *SOpt) Int() int

Return zero.

func (*SOpt) Name

func (O *SOpt) Name() string

func (*SOpt) String

func (O *SOpt) String() string

Directories

Path Synopsis
Interface to the double-precision real and complex BLAS library.
Interface to the double-precision real and complex BLAS library.
Interface to the double-precision real and complex LAPACK library.
Interface to the double-precision real and complex LAPACK library.

Jump to

Keyboard shortcuts

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