Documentation ¶
Overview ¶
Package v3 implements a Matrix type representing a row-major 3D matrix (i.e. a Nx3 matrix). The v3.Matrix is used to represent the cartesian coordinates of sets of atoms in goChem. It is based int gonum's (github.com/gonum) Dense type, with some additional restrictions because of the fixed number of columns and with some additional functions that were found useful for the purposes of goChem.
Index ¶
- Constants
- func KronekerDelta(a, b, epsilon float64) float64
- func Matrix2Dense(A *Matrix) *mat.Dense
- type Error
- type Matrix
- func (F *Matrix) Add(A, B *Matrix)
- func (F *Matrix) AddFloat(A *Matrix, B float64)
- func (F *Matrix) AddRow(A, row *Matrix)
- func (F *Matrix) AddVec(A, vec *Matrix)
- func (F *Matrix) Col(dst []float64, i int) []float64
- func (F *Matrix) ColSlice(i int) *Matrix
- func (F *Matrix) ColView(i int) *Matrix
- func (F *Matrix) Cross(a, b *Matrix)
- func (F *Matrix) DelRow(A *Matrix, i int)
- func (F *Matrix) DelVec(A *Matrix, i int)
- func (F *Matrix) Dot(A *Matrix) float64
- func (F *Matrix) Mul(A, B mat.Matrix)
- func (F *Matrix) NVecs() int
- func (F *Matrix) Norm(i float64) float64
- func (F *Matrix) RawSlice() []float64
- func (F *Matrix) Row(dst []float64, i int) []float64
- func (F *Matrix) RowView(i int) *Matrix
- func (F *Matrix) Scale(v float64, A *Matrix)
- func (F *Matrix) ScaleByCol(A, Col mat.Matrix)
- func (F *Matrix) ScaleByRow(A, Row *Matrix)
- func (F *Matrix) ScaleByVec(A, coord *Matrix)
- func (F *Matrix) SetMatrix(i, j int, A *Matrix)
- func (F *Matrix) SetVecs(A *Matrix, clist []int)
- func (F *Matrix) Slice(i, r, j, c int) *Matrix
- func (F *Matrix) SomeVecs(A *Matrix, clist []int)
- func (F *Matrix) SomeVecsSafe(A *Matrix, clist []int) error
- func (F *Matrix) Stack(A, B *Matrix)
- func (F *Matrix) StackVec(A, B *Matrix)
- func (F *Matrix) String() string
- func (F *Matrix) Sub(A, B *Matrix)
- func (F *Matrix) SubRow(A, row *Matrix)
- func (F *Matrix) SubVec(A, vec *Matrix)
- func (F *Matrix) SwapVecs(i, j int)
- func (F *Matrix) Tr()
- func (F *Matrix) Unit(A *Matrix)
- func (F *Matrix) VecSlice(i int) *Matrix
- func (F *Matrix) VecView(i int) *Matrix
- func (F *Matrix) View(i, j, r, c int) *Matrix
- type PanicMsg
Constants ¶
const ( ErrNotXx3Matrix = PanicMsg("goChem/v3: A VecMatrix should have 3 columns") ErrNoCrossProduct = PanicMsg("goChem/v3: Invalid matrix for cross product") ErrNotOrthogonal = PanicMsg("goChem/v3: Vectors nor orthogonal") ErrNotEnoughElements = PanicMsg("goChem/v3: not enough elements in Matrix") ErrGonum = PanicMsg("goChem/v3: Error in gonum function") ErrEigen = PanicMsg("goChem/v3: Can't obtain eigenvectors/eigenvalues of given matrix") ErrDeterminant = PanicMsg("goChem/v3: Determinants are only available for 3x3 matrices") ErrShape = PanicMsg("goChem/v3: Dimension mismatch") ErrIndexOutOfRange = PanicMsg("mat64: index out of range") )
Variables ¶
This section is empty.
Functions ¶
func KronekerDelta ¶
KronekerDelta is a naive implementation of the kroneker delta function.
func Matrix2Dense ¶
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
type Matrix ¶
The main container, must be able to implement any gonum interface. Matrix is a set of vectors in 3D space. The underlying implementation varies. Within the package it is understood that a "vector" is a row vector, i.e. the cartesian coordinates of a point in 3D space. The name of some funcitions in the library reflect this.
func Dense2Matrix ¶
func EigenWrap ¶
EigenWrap wraps the mat.Eigen structure in order to guarantee That the eigenvectors and eigenvalues are sorted according to the eigenvalues It also guarantees orthonormality and handness. I don't know how many of these are already guaranteed by Eig(). Will delete the unneeded parts And even this whole function when sure. The main reason for this function Is the compatibiliy with go.matrix. This function should dissapear when we have a pure Go blas.
func (*Matrix) AddFloat ¶
AddFloat puts in the receiver a matrix which elements are those of matrix A plus the float B.
func (*Matrix) AddRow ¶
AddRow adds the row vector row to each row of the matrix A, putting the result on the receiver. Panics if matrices are mismatched. It will not work if A and row reference to the same Matrix.
func (*Matrix) AddVec ¶
Adds a vector to the coordmatrix A putting the result on the received. depending on whether the underlying matrix to coordmatrix is col or row major, it could add a col or a row vector.
func (*Matrix) Col ¶
Col fills the dst slice of float64 with the ith col of matrix F and returns it. The slice must have the correct size or be nil, in which case a new slice will be created. This method is merely a frontend for the mat64.Col function of gonum.
func (*Matrix) ColView ¶
Puts a view of the given col of the matrix on the receiver. This function is for compatibility with the gonum v1 API The older one might be deleted in the future, but, if at all, it will take time.
func (*Matrix) Cross ¶
Cross puts the cross product of the first vecs of a and b in the first vec of F. Panics if error.
func (*Matrix) Dot ¶
Dot gets the dot product between the first row of F and the first row of A. It's a vector dot product, to be used with 1-row matrices.
func (*Matrix) Mul ¶
Mul Wrapps mat.Mul to take care of the case when one of the arguments is also the received. Since the received is a Matrix, the mat64 function could check A (mat64.Dense) vs F (Matrix) and it would not know that internally F.Dense==A, hence the need for this function.
func (*Matrix) RawSlice ¶ added in v0.6.0
RawSlice returns the underlying []float64 slice for the receiver. Changes on either the []float64 or the receiver are expected to reflect on the other.
func (*Matrix) Row ¶
Row fills the dst slice of float64 with the ith row of matrix F and returns it. The slice must have the correct size or be nil, in which case a new slice will be created. This method is merely a frontend for the mat64.Row function of gonum.
func (*Matrix) ScaleByCol ¶
ScaleByCol scales each column of matrix A by Col, putting the result in the received.
func (*Matrix) ScaleByRow ¶
ScaleByRow scales each column of matrix A by row, putting the result in the received.
func (*Matrix) ScaleByVec ¶
Scale each coordinates in A by the coordinate in coord. The result is put in F.
func (*Matrix) SetMatrix ¶
Puts the matrix A in the received starting from the ith row and jth col of the receiver.
func (*Matrix) SetVecs ¶
Set the vectors whith index n = each value on clist, in the received to the n vector of A.
func (*Matrix) Slice ¶
Slice returns a view of F starting from i,j and spanning r rows and c columns. Changes in the view are reflected in F and vice-versa This function is to keep compatibility with the gonum v1 API.
func (*Matrix) SomeVecs ¶
SomeVecs Returns a matrix contaning all the ith rows of matrix A, where i are the numbers in clist. The rows are in the same order than the clist.
func (*Matrix) SomeVecsSafe ¶
SomeVecsSafe returns a matrix contaning all the ith vectors of matrix A, where i are the numbers in clist. The vectors are in the same order than the clist. It will try to recover so it returns an error instead of panicking.
func (*Matrix) SubRow ¶
SubRow subtracts the row vector row to each row of the matrix A, putting the result on the receiver. Panics if matrices are mismatched. It will not work if A and row reference to the same Matrix.
func (*Matrix) SubVec ¶
SubVec subtracts the vector to each vector of the matrix A, putting the result on the receiver. Panics if matrices are mismatched. It will not work if A and row reference to the same Matrix.
func (*Matrix) Tr ¶
func (F *Matrix) Tr()
Tr() performs an explicit, in-place tranpose of the receiver. it relies in the fact that v3 matrix are all 3D. If the receiver has more than 3 rows, the square submatrix of the first 3 rows will be transposed (i.e. no panic or returned error). it panics if the receiver has less than 3 rows.
func (*Matrix) VecSlice ¶
VecSlice slice of the given vector of the matrix in the receiver This function is to keep compatibility with the new gonum v1 API
func (*Matrix) View ¶
View returns a view of F starting from i,j and spanning r rows and c columns. Changes in the view are reflected in F and vice-versa This view has the wrong signature for the interface mat64.Viewer, But the right signatur was not possible to implement. Notice that very little memory allocation happens, only a couple of ints and pointers.