class Apatite::LinearAlgebra::Vector(T)
- Apatite::LinearAlgebra::Vector(T)
- Reference
- Object
Overview
Represents a mathematical vector, and also constitutes a row or column
of a Matrix
Included Modules
- Comparable(Apatite::LinearAlgebra::Vector(T))
- Enumerable(T)
- Indexable(T)
Defined in:
apatite/linear_algebra/vector.crClass Method Summary
-
.[](*array)
Creates a new vector from a list of elements.
-
.basis(size, index)
Returns a standard basis
n
-vector. -
.elements(array, copy = true)
Creates a vector from an Array.
-
.zero(size)
Return a zero vector.
Instance Method Summary
-
#*(x)
Multiplies the vector by x, where x is a number or a matrix.
-
#+(x)
Vector addition.
-
#-(x)
Vector subtraction.
-
#/(x)
Vector division.
-
#<=>
Take me to your leader
-
#==(other)
Equality operator
-
#angle_with(v)
Returns an angle with another vector.
-
#clone
Returns a copy of the vector.
-
#coerce(klass)
Attempt to coerce the elements in the vector to another type.
-
#cross(v)
Returns the cross product of this vector with the others.
-
#cross_product(*vs)
Returns the cross product of this vector with the others.
-
#dot(v)
Returns the inner product of this vector with the other.
- #each(*args, **options)
- #each(*args, **options, &block)
-
#each2(v, &block)
Iterate over the elements of this vector and
v
in conjunction. -
#inner_product(v)
Returns the inner product of this vector with the other.
- #inspect
-
#magnitude
Returns the modulus (Pythagorean distance) of the vector.
- #map(&block : T -> UNDERSCORE)
- #map2(v, &block : T, T -> UNDERSCORE)
-
#norm
Returns the modulus (Pythagorean distance) of the vector.
-
#normalize
Returns a new vector with the same direction but with norm 1
-
#r
Returns a new vector with the same direction but with norm 1
-
#round(ndigits = 0)
Returns a vector with entries rounded to the given precision.
-
#to_a
Returns the elements of the vector in an array.
-
#to_matrix
Return a single-column matrix from this vector.
- #to_s
- #unsafe_fetch(i)
-
#zero?
Returns
true
if all elements are zero.
Class Method Detail
Creates a vector from an Array. The optional second argument specifies whether the array itself or a copy is used internally.