Documentation ¶
Index ¶
- func VectorContainsData(vector ReadOnlyVector, data []float64) bool
- type MutableVector
- type ReadOnlyVector
- type Vector
- func (v Vector) AsMutable() MutableVector
- func (v Vector) Clone() ReadOnlyVector
- func (v Vector) Equals(other ReadOnlyVector) bool
- func (v Vector) Length() int
- func (v Vector) Minus(other ReadOnlyVector) ReadOnlyVector
- func (v Vector) Norm() float64
- func (v Vector) Opposite() ReadOnlyVector
- func (v Vector) Plus(other ReadOnlyVector) ReadOnlyVector
- func (v Vector) Scaled(factor float64) ReadOnlyVector
- func (v *Vector) SetValue(i int, value float64)
- func (v *Vector) SetZero(i int)
- func (v Vector) Times(other ReadOnlyVector) float64
- func (v Vector) Value(i int) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VectorContainsData ¶
func VectorContainsData(vector ReadOnlyVector, data []float64) bool
VectorContainsData tests whether a given vector contains exactly the same data as the slice of float64 numbers.
Both need to be of the same size in order for this test to be true.
Types ¶
type MutableVector ¶ added in v0.2.0
type MutableVector interface { ReadOnlyVector /* Methods */ SetValue(i int, value float64) SetZero(i int) }
func Make ¶
func Make(size int) MutableVector
Make returns a vector with the given size all filled with zeroes.
func MakeWithValues ¶
func MakeWithValues(vals []float64) MutableVector
MakeWithValues returns a vector with the given values.
type ReadOnlyVector ¶ added in v0.2.0
type ReadOnlyVector interface { /* Properties */ Length() int Norm() float64 /* Methods */ Value(i int) float64 Opposite() ReadOnlyVector Scaled(factor float64) ReadOnlyVector Plus(other ReadOnlyVector) ReadOnlyVector Minus(other ReadOnlyVector) ReadOnlyVector Times(other ReadOnlyVector) float64 Clone() ReadOnlyVector Equals(other ReadOnlyVector) bool AsMutable() MutableVector }
A ReadOnlyVector is a Vector whose operations never mutate the internal state.
func MakeReadOnly ¶ added in v0.2.0
func MakeReadOnly(size int) ReadOnlyVector
MakeReadOnly returns a read-only vector with the given size all filled with zeroes.
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector is a one-dimension array of float64 values.
func (Vector) AsMutable ¶ added in v0.2.0
func (v Vector) AsMutable() MutableVector
As Mutable returns this vector typed as a mutable one.
func (Vector) Clone ¶
func (v Vector) Clone() ReadOnlyVector
Clone creates an exact copy of the vector.
func (Vector) Equals ¶
func (v Vector) Equals(other ReadOnlyVector) bool
Equals compares two vectors and returns true if they contain the same elements.
func (Vector) Minus ¶
func (v Vector) Minus(other ReadOnlyVector) ReadOnlyVector
Minus subtracts two vectors.
func (Vector) Opposite ¶
func (v Vector) Opposite() ReadOnlyVector
Opposite creates a new vector which is the opposite of this one, that is, points in the opposite direction.
func (Vector) Plus ¶
func (v Vector) Plus(other ReadOnlyVector) ReadOnlyVector
Plus adds two vectors.
func (Vector) Scaled ¶
func (v Vector) Scaled(factor float64) ReadOnlyVector
Scaled creates a new vector consisting on the scaled projections of this vector.
func (Vector) Times ¶
func (v Vector) Times(other ReadOnlyVector) float64
Times multiplies two vectors as v' · other.