Documentation ¶
Index ¶
- func Eps(eps ...float64) float64
- type Matrix
- func (m0 Matrix) Add(m1 Matrix) Matrix
- func (m0 Matrix) Apply(m1 Matrix) Matrix
- func (m0 Matrix) Clone() Matrix
- func (m0 Matrix) Conjugate() Matrix
- func (m0 Matrix) Dagger() Matrix
- func (m0 Matrix) Dimension() (int, int)
- func (m0 Matrix) Equals(m1 Matrix, eps ...float64) bool
- func (m0 Matrix) Inverse() Matrix
- func (m0 Matrix) IsHermite(eps ...float64) bool
- func (m0 Matrix) IsUnitary(eps ...float64) bool
- func (m0 Matrix) Mul(z complex128) Matrix
- func (m0 Matrix) Sub(m1 Matrix) Matrix
- func (m0 Matrix) TensorProduct(m1 Matrix) Matrix
- func (m0 Matrix) Trace() complex128
- func (m0 Matrix) Transpose() Matrix
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Matrix ¶
type Matrix [][]complex128
Matrix type manages complex numbers in matrices.
func AntiCommutator ¶
func Commutator ¶
func TensorProduct ¶
TensorProduct implements the product for any number of matrices.
Example ¶
Output: [(0+2i) (0+4i) (0+4i) (0+8i)] [(0+6i) (0+0i) (0+12i) (0+0i)] [(0+6i) (0+12i) (0+0i) (0+0i)] [(0+18i) (0+0i) (0+0i) (0+0i)]
func TensorProductN ¶
TensorProductN returns a matrix whose elements are the product of the elements by themselves N times.
func (Matrix) Apply ¶
Apply returns a matrix that is the result of aplying the two matrices together.
func (Matrix) Conjugate ¶
Conjugate returns the matrix conjugated.
Example ¶
Output: [(1+0i) (2+0i) (3+0i) (4+0i)] [(0+0i) (1+0i) (1+1i) (2+2i)] [(0+0i) (0+0i) (1+0i) (1+0i)] [(0+0i) (0+0i) (0+0i) (1+0i)] [(1-0i) (2-0i) (3-0i) (4-0i)] [(0-0i) (1-0i) (1-1i) (2-2i)] [(0-0i) (0-0i) (1-0i) (1-0i)] [(0-0i) (0-0i) (0-0i) (1-0i)]
func (Matrix) Dagger ¶
Dagger returns the matrix transposed and conjugated.
Example ¶
Output: [(1+0i) (2+0i) (3+0i) (4+0i)] [(0+0i) (1+0i) (1+1i) (2+2i)] [(0+0i) (0+0i) (1+0i) (1+0i)] [(0+0i) (0+0i) (0+0i) (1+0i)] [(1-0i) (0-0i) (0-0i) (0-0i)] [(2-0i) (1-0i) (0-0i) (0-0i)] [(3-0i) (1-1i) (1-0i) (0-0i)] [(4-0i) (2-2i) (1-0i) (1-0i)]
func (Matrix) IsHermite ¶
IsHermite returns true if the matrix is equal to its conjugated transposed.
func (Matrix) IsUnitary ¶
IsUnitary returns true if the conjugate transpose of the matrix is equal to its inverse.
func (Matrix) Mul ¶
func (m0 Matrix) Mul(z complex128) Matrix
Mul returns a matrix whose elements are the product of the argument by the original elements.
Example ¶
Output: [(2+1i) (4+2i) (6+3i) (8+4i)] [(0+0i) (2+1i) (1+3i) (2+6i)] [(0+0i) (0+0i) (2+1i) (2+1i)] [(0+0i) (0+0i) (0+0i) (2+1i)]
func (Matrix) Sub ¶
Sub returns a matrix whose elements are the difference between the first matrix elements and the second matrix elements.
func (Matrix) TensorProduct ¶
TensorProduct returns a matrix whose elements are the tensor product of the two matrices.
Example ¶
Output: [(0+2i) (0+4i) (0+4i) (0+8i)] [(0+6i) (0+0i) (0+12i) (0+0i)] [(0+6i) (0+12i) (0+0i) (0+0i)] [(0+18i) (0+0i) (0+0i) (0+0i)]
func (Matrix) Trace ¶
func (m0 Matrix) Trace() complex128
Trace returns the sum of matrix diagonal components.
func (Matrix) Transpose ¶
Transpose returns the matrix transposed.
Example ¶
Output: [(1+0i) (2+0i) (3+0i) (4+0i)] [(0+0i) (1+0i) (1+1i) (2+2i)] [(0+0i) (0+0i) (1+0i) (1+0i)] [(0+0i) (0+0i) (0+0i) (1+0i)] [(1+0i) (0+0i) (0+0i) (0+0i)] [(2+0i) (1+0i) (0+0i) (0+0i)] [(3+0i) (1+1i) (1+0i) (0+0i)] [(4+0i) (2+2i) (1+0i) (1+0i)]