class Apatite::LinearAlgebra::Vector(T)

Overview

Represents a mathematical vector, and also constitutes a row or column of a Matrix

Included Modules

Defined in:

apatite/linear_algebra/vector.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.[](*array) #

Creates a new vector from a list of elements.


[View source]
def self.basis(size, index) #

Returns a standard basis n-vector.


[View source]
def self.elements(array, copy = true) #

Creates a vector from an Array. The optional second argument specifies whether the array itself or a copy is used internally.


[View source]
def self.zero(size) #

Return a zero vector.


[View source]

Instance Method Detail

def *(x) #

Multiplies the vector by x, where x is a number or a matrix.


[View source]
def +(x) #

Vector addition.


[View source]
def -(x) #

Vector subtraction.


[View source]
def /(x) #

Vector division.


[View source]
def <=> #

Take me to your leader


[View source]
def ==(other) #

Equality operator


[View source]
def angle_with(v) #

Returns an angle with another vector. Result is within the [0…Math::PI].


[View source]
def clone #

Returns a copy of the vector.


[View source]
def coerce(klass, *args) #

The coerce method allows you to attempt to coerce the elements in the matrix to another type. The type


[View source]
def cross(v) #

Returns the cross product of this vector with the others.


[View source]
def cross_product(*vs) #

Returns the cross product of this vector with the others.


[View source]
def dot(v) #

Returns the inner product of this vector with the other.


[View source]
def each(*args, **options) #

[View source]
def each(*args, **options, &block) #

[View source]
def each2(v, &block) #

Iterate over the elements of this vector and v in conjunction.


[View source]
def inner_product(v) #

Returns the inner product of this vector with the other.


[View source]
def inspect #

[View source]
def magnitude #

Returns the modulus (Pythagorean distance) of the vector.


[View source]
def map(&block : T -> UNDERSCORE) #

[View source]
def map2(v, &block : T, T -> UNDERSCORE) #

[View source]
def norm #

Returns the modulus (Pythagorean distance) of the vector.


[View source]
def normalize #

Returns a new vector with the same direction but with norm 1


[View source]
def r #

Returns a new vector with the same direction but with norm 1


[View source]
def round(ndigits = 0) #

Returns a vector with entries rounded to the given precision.


[View source]
def to_a #

Returns the elements of the vector in an array.


[View source]
def to_matrix #

Return a single-column matrix from this vector.


[View source]
def to_s #

[View source]
def unsafe_fetch(i) #

[View source]
def zero? #

Returns true if all elements are zero.


[View source]