Documentation
¶
Index ¶
- type Vector
- func (v Vector) Add(w Vector) Vector
- func (v Vector) Apply(m matrix.Matrix) Vector
- func (v Vector) Clone() Vector
- func (v Vector) Complex() []complex128
- func (v Vector) Dimension() int
- func (v Vector) Dual() Vector
- func (v Vector) Equals(w Vector, eps ...float64) bool
- func (v Vector) Imag() []float64
- func (v Vector) InnerProduct(w Vector) complex128
- func (v Vector) IsOrthogonal(w Vector) bool
- func (v Vector) IsUnit() bool
- func (v Vector) Mul(z complex128) Vector
- func (v Vector) Norm() complex128
- func (v Vector) OuterProduct(w Vector) matrix.Matrix
- func (v Vector) Real() []float64
- func (v Vector) TensorProduct(w Vector) Vector
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Vector ¶
type Vector []complex128
func New ¶
func New(z ...complex128) Vector
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 0) fmt.Println(v) }
Output: [(1+0i) (0+0i)]
func TensorProduct ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 0) vv := vector.TensorProduct(v, v) fmt.Println(vv) }
Output: [(1+0i) (0+0i) (0+0i) (0+0i)]
func TensorProductN ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 0) vv := vector.TensorProductN(v, 2) fmt.Println(vv) }
Output: [(1+0i) (0+0i) (0+0i) (0+0i)]
func Zero ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.Zero(3) fmt.Println(v) }
Output: [(0+0i) (0+0i) (0+0i)]
func (Vector) Apply ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/matrix" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 2) fmt.Println(v) m := matrix.New( []complex128{1, 2}, []complex128{1, 3}, ) vv := v.Apply(m) fmt.Println(vv) }
Output: [(1+0i) (2+0i)] [(5+0i) (7+0i)]
func (Vector) Complex ¶
func (v Vector) Complex() []complex128
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1+2i, 3+4i) fmt.Println(v.Complex()) }
Output: [(1+2i) (3+4i)]
func (Vector) Dimension ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1+2i, 3+4i) fmt.Println(v.Dimension()) }
Output: 2
func (Vector) Imag ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1+2i, 3+4i) for _, r := range v.Imag() { fmt.Println(r) } }
Output: 2 4
func (Vector) InnerProduct ¶
func (v Vector) InnerProduct(w Vector) complex128
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 0) vv := v.InnerProduct(v) fmt.Println(vv) }
Output: (1+0i)
func (Vector) IsOrthogonal ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v0 := vector.New(1, 0) v1 := vector.New(0, 1) o := v0.IsOrthogonal(v1) fmt.Println(o) }
Output: true
func (Vector) Mul ¶
func (v Vector) Mul(z complex128) Vector
func (Vector) Norm ¶
func (v Vector) Norm() complex128
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 2) n := v.Norm() fmt.Printf("%.4f", n) }
Output: (2.2361+0.0000i)
func (Vector) OuterProduct ¶
Example ¶
package main import ( "fmt" "github.com/itsubaki/q/math/vector" ) func main() { v := vector.New(1, 0) vv := v.OuterProduct(v) fmt.Println(vv) }
Output: [[(1+0i) (0+0i)] [(0+0i) (0+0i)]]
Click to show internal directories.
Click to hide internal directories.