Documentation ¶
Overview ¶
Package vector implements mathematical vectors over float64 values, with common operations defined on them, like addition, the scalar product or normalization.
Operations that result in a new vector (like addition or the cross product) have both an in-place and a non-destructive version, with the first being a method on the Vector type and the latter being a function.
In-place operations on vectors return the vector to make it possible to chain ("pipe") operations. This is purely convenience.
Index ¶
- func Angle(a, b *Vector) (Θ float64, err error)
- func DotProduct(a, b *Vector) (dot float64, err error)
- func Equal(a, b *Vector) (equal bool)
- type CrossError
- type DimError
- type IndexError
- type Vector
- func (v *Vector) Add(other *Vector) (ret *Vector, err error)
- func (v *Vector) Copy() *Vector
- func (v *Vector) Cross2D(other *Vector) float64
- func (v *Vector) CrossProduct(other *Vector) (*Vector, error)
- func (v Vector) Dim() uint
- func (v *Vector) From(dims []float64)
- func (v Vector) Get(n uint) (val float64)
- func (v Vector) Len() (result float64)
- func (v *Vector) Normalize() *Vector
- func (v *Vector) Scale(x float64) *Vector
- func (v Vector) Set(n uint, x float64) (err error)
- func (v *Vector) String() string
- func (v *Vector) Substract(other *Vector) (ret *Vector, err error)
- func (v *Vector) To() []float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DotProduct ¶
Dot-product of two Vectors.
Types ¶
type CrossError ¶
type CrossError DimError
For cross products where either ndim != 3.
func (CrossError) Error ¶
func (e CrossError) Error() string
type IndexError ¶
type IndexError uint
For out-of-range indexes.
func (IndexError) Error ¶
func (e IndexError) Error() string
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
NodeAddr vector over float64 values
func CrossProduct ¶
Cross product of two vectors. Returns error when ndim of either vector != 3.
func (*Vector) CrossProduct ¶
Cross product with another vector, in-place. Returns error when ndim of either vector != 3.