Documentation ¶
Index ¶
- Constants
- type FlagBits
- type Float2Function
- type FloatConstSource
- type FloatDiagonalSource
- type FloatEvaluator
- type FloatFunction
- type FloatMapping
- type FloatMatrix
- func MakeMatrix(rows, cols int, ebuf []float64) *FloatMatrix
- func NewCopy(A *FloatMatrix) *FloatMatrix
- func NewJoin(how JoinType, mlist ...*FloatMatrix) *FloatMatrix
- func NewMatrix(r, s int) *FloatMatrix
- func TriL(A *FloatMatrix, bits int) *FloatMatrix
- func TriU(A *FloatMatrix, bits int) *FloatMatrix
- func (A *FloatMatrix) Add(val float64)
- func (A *FloatMatrix) AllClose(B *FloatMatrix, tols ...float64) bool
- func (C *FloatMatrix) Column(A *FloatMatrix, col int, sizes ...int) *FloatMatrix
- func (A *FloatMatrix) Copy(B *FloatMatrix) *FloatMatrix
- func (A *FloatMatrix) Data() []float64
- func (D *FloatMatrix) Diag(A *FloatMatrix, n ...int) *FloatMatrix
- func (A *FloatMatrix) Get(i, j int) float64
- func (A *FloatMatrix) GetAt(i int) float64
- func (A *FloatMatrix) GetAtUnsafe(i int) float64
- func (A *FloatMatrix) GetUnsafe(i, j int) float64
- func (A *FloatMatrix) GobDecode(buf []byte) (err error)
- func (A *FloatMatrix) GobEncode() ([]byte, error)
- func (A *FloatMatrix) IsVector() bool
- func (A *FloatMatrix) Len() int
- func (A *FloatMatrix) Log()
- func (A *FloatMatrix) Map(t FloatMapping, bits ...int)
- func (A *FloatMatrix) MarshalJSON() ([]byte, error)
- func (R *FloatMatrix) Row(A *FloatMatrix, row int, sizes ...int) *FloatMatrix
- func (A *FloatMatrix) Scale(val float64)
- func (A *FloatMatrix) Set(i, j int, v float64)
- func (A *FloatMatrix) SetAt(i int, v float64)
- func (A *FloatMatrix) SetAtUnsafe(i int, v float64)
- func (A *FloatMatrix) SetBuf(rows, cols, stride int, ebuf []float64) *FloatMatrix
- func (m *FloatMatrix) SetFrom(source FloatSource, bits ...int)
- func (A *FloatMatrix) SetUnsafe(i, j int, v float64)
- func (A *FloatMatrix) Size() (int, int)
- func (A *FloatMatrix) Stride() int
- func (A *FloatMatrix) String() string
- func (A *FloatMatrix) SubMatrix(B *FloatMatrix, row, col int, sizes ...int) *FloatMatrix
- func (X *FloatMatrix) SubVector(Y *FloatMatrix, offset, nlen int) *FloatMatrix
- func (A *FloatMatrix) ToString(format string) string
- func (A *FloatMatrix) ToStringPartial(format string, rowpart, colpart int) string
- func (A *FloatMatrix) Transpose(B *FloatMatrix) *FloatMatrix
- func (A *FloatMatrix) UnmarshalJSON(buf []byte) (err error)
- type FloatNormSource
- type FloatSink
- type FloatSource
- type FloatTableSource
- type FloatUniformSource
- type JoinType
Constants ¶
const ( STACK = iota AUGMENT )
const ( LOWER = 0x1 UPPER = 0x2 SYMM = 0x4 HERM = 0x8 UNIT = 0x10 NONE = 0 STRICT = UNIT )
align values with bit values in gomas-package
const ABSTOL = 1e-8
Absolute tolerance. Values v1, v2 are equal within tolerance if ABS(v1-v2) < ABSTOL + RELTOL*ABS(v2)
const RELTOL = 1.0000000000000001e-05
Relative tolerance
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Float2Function ¶
type Float2Function struct { // float valued callable function Callable func(float64, float64) float64 // value of second argument for callable Constant float64 }
Two parameter mapping from float value to new ie. newval = fn(oldval, const)
type FloatConstSource ¶
type FloatConstSource struct {
Const float64
}
Source that produces const values.
func NewFloatConstSource ¶
func NewFloatConstSource(val float64) *FloatConstSource
type FloatDiagonalSource ¶
type FloatDiagonalSource struct {
Const float64
}
Source that provides constant for diagonal, zero otherwise
func NewFloatDiagonalSource ¶
func NewFloatDiagonalSource(val float64) *FloatDiagonalSource
func (*FloatDiagonalSource) Get ¶
func (s *FloatDiagonalSource) Get(i, j int) float64
type FloatEvaluator ¶
Simple wrapper for element location dependent mapping.
type FloatFunction ¶
Single parameter mapping from float value to another float value.
type FloatMapping ¶
Interface for mapping element values to new values.
type FloatMatrix ¶
type FloatMatrix struct {
// contains filtered or unexported fields
}
Column majoe double precision matrix.
func MakeMatrix ¶
func MakeMatrix(rows, cols int, ebuf []float64) *FloatMatrix
Make a new matrix and use ebuf as element storage. cap(ebuf) must not be less than rows*cols.
func NewJoin ¶
func NewJoin(how JoinType, mlist ...*FloatMatrix) *FloatMatrix
Create a new matrix by joining argument matrices. If join type is AUGMENT then matrices are joined on increasing column numbers ie. horizontally. Result matrix size is rowmax(mlist) by sum(m in mlist; cols(m)) If join type is STACK then matrices are joined on increasing row numbers ie. vertically and result matrix size is sum(m in mlist: rows(m) by colmax(mlist).
func TriL ¶
func TriL(A *FloatMatrix, bits int) *FloatMatrix
Make matrix LOWER triangular matrix ie. set strictly upper part to zero.
func TriU ¶
func TriU(A *FloatMatrix, bits int) *FloatMatrix
Make matrix UPPER triangular matrix ie. set strictly lower part to zero.
func (*FloatMatrix) AllClose ¶
func (A *FloatMatrix) AllClose(B *FloatMatrix, tols ...float64) bool
Test if matrix A is equal to B within given tolenrances. Tolerances are given as tuple (abstol, reltol). If no tolerances are given default constants ABSTOL and RELTOL are used.
func (*FloatMatrix) Column ¶
func (C *FloatMatrix) Column(A *FloatMatrix, col int, sizes ...int) *FloatMatrix
Make C column of A. C = A[:,col]. Parameter sizes is singleton (row) and column vector starts at `row` and extends to the last element of the column. Alternatively sizes can be tuple of (row, numelems) and column vector starts at `row` and extends `numelems` elements. Function returns C.
func (*FloatMatrix) Copy ¶
func (A *FloatMatrix) Copy(B *FloatMatrix) *FloatMatrix
Make A copy of B.
func (*FloatMatrix) Diag ¶
func (D *FloatMatrix) Diag(A *FloatMatrix, n ...int) *FloatMatrix
Return matrix diagonal as row vector. If optional parameter n < 0 returns n'th sub-diagonal. If n > 0 returns n'th super-diagonal and if n == 0 returns main diagonal
func (*FloatMatrix) Get ¶
func (A *FloatMatrix) Get(i, j int) float64
Get element at [i, j]. Returns NaN if indexes are invalid. Negative indexes counted from end.
func (*FloatMatrix) GetAt ¶
func (A *FloatMatrix) GetAt(i int) float64
Get element at index i. Returns NaN if index is invalid.
func (*FloatMatrix) GetAtUnsafe ¶
func (A *FloatMatrix) GetAtUnsafe(i int) float64
Get element at index i. Unsafe vesrsion
func (*FloatMatrix) GetUnsafe ¶
func (A *FloatMatrix) GetUnsafe(i, j int) float64
Get element at [i, j]. Unsafe version without checks and negative indexes
func (*FloatMatrix) GobDecode ¶
func (A *FloatMatrix) GobDecode(buf []byte) (err error)
Decode a matrix.
func (*FloatMatrix) GobEncode ¶
func (A *FloatMatrix) GobEncode() ([]byte, error)
GobEncode matrix. If A is a submatrix elements outside submatrix are not included.
func (*FloatMatrix) IsVector ¶
func (A *FloatMatrix) IsVector() bool
func (*FloatMatrix) Map ¶
func (A *FloatMatrix) Map(t FloatMapping, bits ...int)
Change matrix elements with a Mapping. If flag bit UPPER is set then strictly lower part of the matrix is not touched. If flag bit LOWER is set then strictly upper part of the matrix is not touched. If bit SYMM is set then transformer is evaluated only for upper part indexes and strictly lower part is set symmetrically.
func (*FloatMatrix) MarshalJSON ¶
func (A *FloatMatrix) MarshalJSON() ([]byte, error)
func (*FloatMatrix) Row ¶
func (R *FloatMatrix) Row(A *FloatMatrix, row int, sizes ...int) *FloatMatrix
Make R a row vector of A i.e. R = A[row,:]
func (*FloatMatrix) SetAtUnsafe ¶
func (A *FloatMatrix) SetAtUnsafe(i int, v float64)
Set element at index i.
func (*FloatMatrix) SetBuf ¶
func (A *FloatMatrix) SetBuf(rows, cols, stride int, ebuf []float64) *FloatMatrix
Set matrix size and storage. Minimum size for ebuf is stride*cols. If stride zero or negative then rows is used as row stride. Returns nil if buffer capasity too small. Otherwise returns A.
func (*FloatMatrix) SetFrom ¶
func (m *FloatMatrix) SetFrom(source FloatSource, bits ...int)
Set matrix elements from source. Optional bits define which part of the matrix is accessed. Default is to set all entries.
Bits
UPPER set upper triangular/trapezoidal part UPPER|UNIT set strictly upper triangular/trapezoidal part LOWER set lower triangular/trapezoidal part LOWER|UNIT set strictly lower triangular/trapezoidal part SYMM set lower part symmetrically to upper part
To set strictly lower part of a matrix: A.SetFrom(src, LOWER|UNIT)
func (*FloatMatrix) SetUnsafe ¶
func (A *FloatMatrix) SetUnsafe(i, j int, v float64)
Set element at [i, j]
func (*FloatMatrix) Size ¶
func (A *FloatMatrix) Size() (int, int)
Get size of the matrix as tuple (rows, cols).
func (*FloatMatrix) String ¶
func (A *FloatMatrix) String() string
func (*FloatMatrix) SubMatrix ¶
func (A *FloatMatrix) SubMatrix(B *FloatMatrix, row, col int, sizes ...int) *FloatMatrix
Make A submatrix of B. Returns A.
func (*FloatMatrix) SubVector ¶
func (X *FloatMatrix) SubVector(Y *FloatMatrix, offset, nlen int) *FloatMatrix
Make X subvector of Y, X = Y[offset:offset+nlen]
func (*FloatMatrix) ToString ¶
func (A *FloatMatrix) ToString(format string) string
func (*FloatMatrix) ToStringPartial ¶
func (A *FloatMatrix) ToStringPartial(format string, rowpart, colpart int) string
Convert matrix to string with spesific element format.
func (*FloatMatrix) Transpose ¶
func (A *FloatMatrix) Transpose(B *FloatMatrix) *FloatMatrix
Transpose matrix, A = B.T
func (*FloatMatrix) UnmarshalJSON ¶
func (A *FloatMatrix) UnmarshalJSON(buf []byte) (err error)
type FloatNormSource ¶
type FloatNormSource struct { // mean of the distribution Mean float64 // required standard deviation StdDev float64 Rnd *rand.Rand }
Float value source for normally distributed values with mean `Mean` and standard deviation `StdDev`.
func NewFloatNormSource ¶
func NewFloatNormSource(params ...float64) *FloatNormSource
Create a new source of Normally distributed float values. Optional parameters is either StdDev or tuple of (StdDev, Mean). Initial random number is multiplied with StdDev and Mean is added to the result. Default values for (StdDev,Mean) is (1.0, 0.0)
func (*FloatNormSource) Get ¶
func (s *FloatNormSource) Get(i, j int) float64
Fetch a new value from distribution.
type FloatSource ¶
Interface for providing float values.
type FloatTableSource ¶
Source for retrieving matrix elements from a table. Default is returned if element index outside table.
func NewFloatTableSource ¶
func NewFloatTableSource(data [][]float64, defval float64) *FloatTableSource
Create a new table source.
func (*FloatTableSource) Get ¶
func (ts *FloatTableSource) Get(i, j int) float64
func (*FloatTableSource) Size ¶
func (ts *FloatTableSource) Size() (int, int)
Return source table dimensions.
type FloatUniformSource ¶
type FloatUniformSource struct { // shifting factor Shift float64 // scaling factor Scale float64 Rnd *rand.Rand }
Float value source for uniformly distributed in range [0.0,1.0) shifted and scaled and returning value Scale*(Uniform()-Shift)
func NewFloatUniformSource ¶
func NewFloatUniformSource(params ...float64) *FloatUniformSource
Create a new source of uniformly distributed float values. Optional parameters is either shift or tuple of (shift, scale). Value of shift is added to initial value which is then multiplied with the scaling factor. Default values for shift and scale are (0.0, 1.0) that creates source for random numbers from [0.0, 1.0)
func (*FloatUniformSource) Get ¶
func (s *FloatUniformSource) Get(i, j int) float64
Fetch a new value from distribution.