struct

Geode::Vector1(T)

Inherits Geode::VectorBase < Geode::CommonVector < Geode::VectorOperations < Geode::VectorMatrices < Geode::VectorGeometry < Geode::VectorComparison < Indexable < Enumerable < Iterable < Struct < Value < Object

Vector containing one component.

Using this type generally doesn't make sense, but it is included to complete some rules and combinations.

T is the scalar type.

Constructors

new(components : Tuple(T))

Creates a vector from its components.

Source
new(array : StaticArray(T, 1))

Constructs the vector with pre-existing values.

Source
new(other : CommonVector(T, 1))

Copies the contents of another vector.

Source
new(x : T)

Creates a vector from its components.

Source
new

Constructs the vector by yielding for each component.

The value of each component should be returned from the block. The block will be given the index of each component as an argument.

Vector1(Int32).new { |i| i + 5 } # => (5)
Source

Class methods

[](x : T)

Constructs a vector with existing components.

The type of the components is derived from the type of each argument.

Vector1[1] # => (1)
Source
[](x)

Constructs a vector with existing components.

The type of the components is specified by the type parameter. Each value is cast to the type T.

Vector1F[1] # => (1.0)
Source

Instance methods

to_column

Converts this vector to a column vector, in other words a matrix with one column.

vector = Vector1[5]
vector.to_column # => [[5]]
Source
to_row

Converts this vector to a row vector, in other words a matrix with one row.

vector = Vector1[5]
vector.to_row # => [[5]]
Source
tuple

Retrieves the components as a tuple.

Source
x

Retrieves the x component.

Source