diff --git a/docs/Apatite.html b/docs/Apatite.html new file mode 100644 index 0000000..abb9af7 --- /dev/null +++ b/docs/Apatite.html @@ -0,0 +1,529 @@ + + + + + + + + + + + + + + + Apatite - github.com/watzon/apatite + + + + + + +
+

+ + module Apatite + +

+ + + + + +

Overview

+ +

Apatite is a fundimental package for scientific computing in Crystal. If that +sounds like a modified version of the first line from the NumPy homepage, +that's because it is. Apatite has (ok, will have) all of the goodness +of NumPy sitting atop the blazing speed and beautiful syntax +of Crystal.

+ + + + + +

Included Modules

+ + + + +

Extended Modules

+ + + + + + + + + +

Defined in:

+ + + + apatite/linear_algebra/ndarray.cr + + +
+ + + + apatite/linear_algebra.cr + + +
+ + + + apatite.cr + + +
+ + + + apatite/version.cr + + +
+ + + + + +

Constant Summary

+ +
+ +
+ I = Vector::I +
+ +
+

Cartesian unit vector I

+
+ + +
+ J = Vector::J +
+ +
+

Cartesian unit vector J

+
+ + +
+ K = Vector::K +
+ +
+

Cartesian unit vector K

+
+ + +
+ VERSION = "0.1.0" +
+ + +
+ + + + + +

Class Method Summary

+ + + + +

Instance Method Summary

+ + + + + + +
+ + + +

Instance methods inherited from module Apatite::LinearAlgebra

+ + + + sigmoid(input : Number) + sigmoid, + + + + sigmoid_d(input : Number) + sigmoid_d + + + + + + + + + + + +
+ + + + +

Class Method Detail

+ +
+
+ + def self.approx_precision + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.approx_precision=(approx_precision) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.precision + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.precision=(precision) + + # +
+ +
+
+ + [View source] + +
+
+ + + + +

Instance Method Detail

+ +
+
+ + def as_vector(input : Indexable) + + # +
+ +

Creates a new vector from the given input. Input can be any +Indexable type.

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

Returns a standard basis-n vector of the given size and index.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def empty + + # +
+ +

Returns a new empty Vector

+ +
+
+ + [View source] + +
+
+ +
+
+ + def full(n, i) + + # +
+ +

Returns a new vector of size n filled with i

+ +
+
+ + [View source] + +
+
+ +
+
+ + def ones(n) + + # +
+ +

Returns a new vector filled with n ones.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def vector(n, &block) + + # +
+ +

Creates a new vector of size n, and invokes the block once +for each index of self, assigning the block's value in that index.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def zeros(n) + + # +
+ +

Returns a new vector filled with n zeros.

+ +
+
+ + [View source] + +
+
+ + + + + +
+ + + diff --git a/docs/Apatite/LinearAlgebra.html b/docs/Apatite/LinearAlgebra.html new file mode 100644 index 0000000..b8dfceb --- /dev/null +++ b/docs/Apatite/LinearAlgebra.html @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + Apatite::LinearAlgebra - github.com/watzon/apatite + + + + + + +
+

+ + module Apatite::LinearAlgebra + +

+ + + + + + + + + + + +

Extended Modules

+ + + + + + +

Direct including types

+ + + + + +

Defined in:

+ + + + apatite/linear_algebra/ndarray.cr + + +
+ + + + apatite/linear_algebra/vector.cr + + +
+ + + + apatite/linear_algebra/matrix.cr + + +
+ + + + apatite/linear_algebra.cr + + +
+ + + + + + + + + + +

Instance Method Summary

+ + + + + + +
+ +
+ + + + + + +

Instance Method Detail

+ +
+
+ + def sigmoid(input : Number) + + # +
+ +

Calculates the sigmoid curve for a numeric input.

+ +

f(x) = 1/(1 + e^-x)

+ +

See also: Sigmoid function [WikiWand

+ +
+
+ + [View source] + +
+
+ +
+
+ + def sigmoid_d(input : Number) + + # +
+ +

Calculates the derivative sigmoid curve for a numeric input.

+ +

f'(x) = f(x)(1 - f(x)),

+ +
+
+ + [View source] + +
+
+ + + + + +
+ + + diff --git a/docs/Apatite/LinearAlgebra/Matrix.html b/docs/Apatite/LinearAlgebra/Matrix.html new file mode 100644 index 0000000..0effd28 --- /dev/null +++ b/docs/Apatite/LinearAlgebra/Matrix.html @@ -0,0 +1,1359 @@ + + + + + + + + + + + + + + + Apatite::LinearAlgebra::Matrix - github.com/watzon/apatite + + + + + + +
+

+ + class Apatite::LinearAlgebra::Matrix + +

+ + + + + + + + + + + +

Included Modules

+ + + + + + + + + + + +

Defined in:

+ + + + apatite/linear_algebra/matrix.cr + + +
+ + + + + + +

Constructors

+ + + + +

Class Method Summary

+ + + + +

Instance Method Summary

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

Constructor Detail

+ +
+
+ + def self.new(rows, column_count : Int32 = rows[0].size) + + # +
+ +
+
+ + [View source] + +
+
+ + + + +

Class Method Detail

+ +
+
+ + def self.[](*rows) + + # +
+ +

Creates a matrix where each argument is a row.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.build(row_count, column_count = row_count, &block) + + # +
+ +

Creates a matrix of size row_count x column_count. It fills the values by calling +the given block, passing the current row and column.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.col_vector(column) + + # +
+ +

Creates a single-column matrix where the values of that column are as given in column.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.columns(columns) + + # +
+ +

Creates a matrix using .columns as an array of column vectors.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.diagonal(values) + + # +
+ +

Creates a matrix where the diagonal elements are composed of values.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.diagonal(*values) + + # +
+ +

Creates a matrix where the diagonal elements are composed of values.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.empty(row_count = 0, column_count = 0) + + # +
+ +

Creates a empty matrix of row_count x column_count. At least one of +#row_count or #column_count must be 0.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.hstack(x, *matrices) + + # +
+ +

TODO

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.identity(n) + + # +
+ +

Creates a n x n identity matrix.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.row_vector(row) + + # +
+ +

Creates a single-row matrix where the values of that row are as given in #row.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.rows(rows) + + # +
+ +

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.scalar(n, value) + + # +
+ +

Creates an n by n diagonal matrix where each diagonal element is value.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.vstack(x, y) + + # +
+ +

TODO

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.zero(row_count, column_count = row_count) + + # +
+ +

Creates a zero matrix.

+ +
+
+ + [View source] + +
+
+ + + + +

Instance Method Detail

+ +
+
+ + def *(other : Matrix) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def *(int : Int) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def *(ind : Indexable) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def **(int) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def +(other : Matrix) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def +(vec : Indexable) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def -(vec : Indexable) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def -(other : Matrix) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def /(other : Matrix) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def /(vec : Indexable) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def ==(other : Matrix) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def [](row : Int, col : Int) + + # +
+ +

Returns element (row, col) of the matrix. Throws error on index error.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def []?(row : Int, col : Int) + + # +
+ +

Returns element (row, col) of the matrix, or nil if the index is not found.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def adjugate + + # +
+ +

Returns the adjugate of the matrix.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def cofactor(row, column) + + # +
+ +

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

+ +
+
+ + [View source] + +
+
+ +
+
+ + def column(j, &block) + + # +
+ +

Iterates over the specified column in the matrix, returning the Vector's items.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def column(j) + + # +
+ +

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

+ +
+
+ + [View source] + +
+
+ +
+
+ + def column?(j) + + # +
+ +

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

+ +
+
+ + [View source] + +
+
+ +
+
+ + def column_count : Int32 + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def column_vectors + + # +
+ +

Returns an array of the column vectors of the matrix. See Vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def determinant + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def first_minor(row, column) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def inverse + + # +
+ +

Returns the inverse of the matrix.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def laplace_expansion(*, row = nil, column = nil) + + # +
+ +

Returns the Laplace expansion along given row or column.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def pretty_print(pp) : Nil + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def row(i, &block) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def row(i) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def row_count : Int32 + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def rows + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def square? + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_s(io) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def transpose + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def unsafe_fetch(index : Int) + + # +
+ +
+
+ + [View source] + +
+
+ + + + + +
+ + + diff --git a/docs/Apatite/LinearAlgebra/NDArray.html b/docs/Apatite/LinearAlgebra/NDArray.html new file mode 100644 index 0000000..0180490 --- /dev/null +++ b/docs/Apatite/LinearAlgebra/NDArray.html @@ -0,0 +1,589 @@ + + + + + + + + + + + + + + + Apatite::LinearAlgebra::NDArray - github.com/watzon/apatite + + + + + + +
+

+ + class Apatite::LinearAlgebra::NDArray + +

+ + + + + + + + + + + +

Included Modules

+ + + + + + + + + + + +

Defined in:

+ + + + apatite/linear_algebra/ndarray.cr + + +
+ + + + + + +

Constructors

+ + + + + + +

Instance Method Summary

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

Constructor Detail

+ +
+
+ + def self.new(data : Array(Number), shape : Array(Int32)? = nil) + + # +
+ +
+
+ + [View source] + +
+
+ + + + + + +

Instance Method Detail

+ +
+
+ + def [](*args, **options) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def [](*args, **options, &block) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []=(*args, **options) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []?(*args, **options) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []?(*args, **options, &block) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def abs + + # +
+ +

Returns the absolute value of every item in the array

+ +
+
+ + [View source] + +
+
+ +
+
+ + def acos + + # +
+ +

Returns the arccosine of each element in the current array.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def data : Array(Float64) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def shape : Array(Int32) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def size(*args, **options) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def size(*args, **options, &block) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_unsafe(*args, **options) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_unsafe(*args, **options, &block) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def unsafe_fetch(*args, **options) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def unsafe_fetch(*args, **options, &block) + + # +
+ +
+
+ + [View source] + +
+
+ + + + + +
+ + + diff --git a/docs/Apatite/LinearAlgebra/Vector.html b/docs/Apatite/LinearAlgebra/Vector.html new file mode 100644 index 0000000..066f08a --- /dev/null +++ b/docs/Apatite/LinearAlgebra/Vector.html @@ -0,0 +1,2198 @@ + + + + + + + + + + + + + + + Apatite::LinearAlgebra::Vector - github.com/watzon/apatite + + + + + + +
+

+ + class Apatite::LinearAlgebra::Vector + +

+ + + + + + + +

Overview

+ +

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

+ + + + + +

Included Modules

+ + + + + + + + + + + +

Defined in:

+ + + + apatite/linear_algebra/vector.cr + + +
+ + + + + +

Constant Summary

+ +
+ +
+ I = Vector.create([1.0, 0.0, 0.0]) +
+ +
+

Cartesian unit vector I

+
+ + +
+ J = Vector.create([0.0, 1.0, 0.0]) +
+ +
+

Cartesian unit vector J

+
+ + +
+ K = Vector.create([0.0, 0.0, 1.0]) +
+ +
+

Cartesian unit vector K

+
+ + +
+ + + +

Constructors

+ + + + +

Class Method Summary

+ + + + +

Instance Method Summary

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

Constructor Detail

+ +
+
+ + def self.build(capacity : Int, &block) : self + + # +
+ +

Creates a new Vector, allocating an internal buffer with the given capacity, +and yielding that buffer. The given block must return the desired size of the vector.

+ +

This method is unsafe.

+ +
Vector.build(3) do |buffer|
+  LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)
+end
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.new(size : Int, value : Float64) + + # +
+ +

Creates a new Vector of the given size filled with the same value in each position.

+ +
Vector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.new(initial_capacity : Int) + + # +
+ +

Creates a new empty Vector backed by a buffer that is initially +initial_capacity big.

+ +

The initial_capacity is useful to avoid unnecessary reallocations +of the internal buffer in case of growth. If you have an estimate +of the maximum number of elements an vector will hold, the vector should +be initialized with that capacity for improved performance.

+ +
vec = Vector.new(5)
+vec.size # => 0
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.new + + # +
+ +

Create a new empty Vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.new(size : Int, &block : Int32 -> Float64) + + # +
+ +

Creates a new Vector of the given size and invokes the given block once +for each index of self, assigning the block's value in that index.

+ +
Vector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}
+
+vec = Vector.new(3) { 5.0 }
+vec # => Vector{5.0, 5.0, 5.0}
+ +
+
+ + [View source] + +
+
+ + + + +

Class Method Detail

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

Returns a standard basis n-vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.create(elements : Indexable(Number)) + + # +
+ +

Creates a new Vector from the elements of another Indexable +collection.

+ +
Vector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.ones(n) + + # +
+ +

Create a new vector of size n filled with ones.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.random(n, range = Float64::MIN..Float64::MAX) + + # +
+ +

Generates a random vector of size n with elements +in range.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def self.zeros(n) + + # +
+ +

Create a new vector of size n filled with zeros.

+ +
+
+ + [View source] + +
+
+ + + + +

Instance Method Detail

+ +
+
+ + def *(other) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def +(other) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def -(other) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def <<(value : Float64) + + # +
+ +

Alias for #push

+ +
+
+ + [View source] + +
+
+ +
+
+ + def <=>(other) + + # +
+ +

Combined comparison operator. Returns 0 if self equals other, 1 if +self is greater than other and -1 if self is smaller than other.

+ +

It compares the elements of both vectors in the same position using the +#<=> operator. As soon as one of such comparisons returns a non-zero +value, that result is the return value of the comparison.

+ +

If all elements are equal, the comparison is based on the size of the vectors.

+ +
Vector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1
+Vector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1
+Vector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0
+ +
+
+ + [View source] + +
+
+ +
+
+ + def ==(other : Vector) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def [](start : Int, count : Int) + + # +
+ +

Returns count or less (if there aren't enough) elements starting at the +given start index.

+ +

Negative indices count backward from the end of the vector (-1 is the last +element). Additionally, an empty vector is returned when the starting index +for an element range is at the end of the vector.

+ +

Raises IndexError if the starting index is out of range.

+ +
v = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+v[1, 3]  # => Vector{2.0, 3.0, 4.0}
+v[6, 10] # raise IndexError
+ +
+
+ + [View source] + +
+
+ +
+
+ + def [](range : Range(Int, Int)) + + # +
+ +

Returns all elements that are within the given range.

+ +

Negative indices count backward from the end of the vector (-1 is the last +element). Additionally, an empty vector is returned when the starting index +for an element range is at the end of the vector.

+ +

Raises IndexError if the starting index is out of range.

+ +
v = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+v[1..3]  # => Vector{2.0, 3.0, 4.0}
+v[6..10] # raise IndexError
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []=(index : Int, count : Int, values : Vector) + + # +
+ +

Replaces a subrange with the elements of the given vector.

+ +
vec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+vec[1, 3] = Vector{6.0, 7.0, 8.0}
+vec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}
+
+vec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+vec[1, 3] = Vector{6.0, 7.0}
+vec # = Vector{1.0, 6.0, 7.0, 5.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []=(index : Int, count : Int, value) + + # +
+ +

Replaces a subrange with a single value. All elements in the range +index...index+count are removed and replaced by a single element +value.

+ +

If count is zero, value is inserted at index.

+ +

Negative values of index count from the end of the vector.

+ +
vec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+vec[1, 3] = 6.0
+vec # => Vector{1.0, 6.0, 5.0}
+
+vec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+vec[1, 0] = 6.0
+vec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []=(index : Int, value) + + # +
+ +

Sets the given value at the given index.

+ +

Negative indices can be used to start counting from the end of the array. +Raises IndexError if trying to set an element outside the array's range.

+ +
vec = Vector{1.0, 2.0, 3.0}
+vec[0] = 5.0
+p vec # => Vec{5.0, 2.0, 3.0}
+
+vec[3] = 5.0 # raises IndexError
+ +
+
+ + [View source] + +
+
+ +
+
+ + def []=(range : Range(Int, Int), value) + + # +
+ +

Replaces a subrange with a single value.

+ +
vec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+vec[1..3] = 6.0
+vec # = Vector{1.0, 6.0, 5.0}
+
+vec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}
+vec[1...1] = 6
+vec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def add(value) + + # +
+ +

When the input is a number, this returns the result of adding +it to all vector elements. When it's a vector, the vectors +will be added together.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def angle_from(vector) + + # +
+ +

Returns the angle between this vector and another in radians. +If the vectors are mirrored across their axes this will return nil.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def antiparallel_to?(vector) + + # +
+ +

Returns whether the vectors are antiparallel to each other.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def augment(elements) + + # +
+ +

Returns a new vector with the provided elements concatenated +on the end.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def chomp(n) + + # +
+ +

Returns a new vector with the first n elements removed from +the beginning.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def clear + + # +
+ +

Removes all elements from self.

+ +
vec = Vector{1.0, 2.0, 3.0}
+vec.clear # => Vector{}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def clone + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def concat(other : Vector) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def covector + + # +
+ +

Creates a single-row matrix from this vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def cross(*vs) + + # +
+ +

Returns the cross product of this vector with the others.

+ +
v1 = Vector{1.0, 0.0, 0.0}
+v2 = Vector{0.0, 1.0, 0.0}
+v1.cross(v2) => Vector{0.0, 0.0, 1.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def distance_from(obj) + + # +
+ +

Gets this vector's distance from the argument, when considered +a point in space.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def dot(other) + + # +
+ +

Get the scalar (dot) product of this vector with vector.

+ +

https://en.wikipedia.org/wiki/Scalar_product

+ +
+
+ + [View source] + +
+
+ +
+
+ + def e(i) + + # +
+ +

Returns the ith element of the vector. Returns nil if i +is out of bounds. Indexing starts from 1.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def independent?(*vs) + + # +
+ +

Returns true if all vectors are linearly independent.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def lies_in(plane) + + # +
+ +

Returns true if the vector is a point on the given plane.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def lies_on(line) + + # +
+ +

Returns true if the vector is a point on the given line

+ +
+
+ + [View source] + +
+
+ +
+
+ + def log + + # +
+ +

Return a new Vector with the log of every item in self.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def magnitude + + # +
+ +

Returns the magnitude/euclidian norm of this vector.

+ +

https://en.wikipedia.org/wiki/Euclidean_distance

+ +
+
+ + [View source] + +
+
+ +
+
+ + def map(&block) + + # +
+ +

Invokes the given block for each element of self.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def map!(&block) + + # +
+ +

Invokes the given block for each element of self, replacing the element +with the value returned by the block. Returns self.

+ +
vec = Vector{1.0, 2.0, 3.0}
+vec.map! { |x| x * x }
+a # => Vector{1.0, 4.0, 9.0}
+ +
+
+ + [View source] + +
+
+ +
+
+ + def map_with_index(&block) + + # +
+ +

Optimized version of Enumerable#map_with_index.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def map_with_index!(&block) + + # +
+ +

Like #map_with_index, but mutates self instead of allocating a new object.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def max + + # +
+ +

Returns the (absolute) largest element in this vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def max_index + + # +
+ +

Gets the index of the largest element in this vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def multiply(value) + + # +
+ +

When the input is a number, this returns the result of multiplying +it to all vector elements. When it's a vector, the vectors +will be element-wise multiplied.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def parallel_to?(vector) + + # +
+ +

Returns whether the vectors are parallel to each other.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def perpendicular_to?(vector) + + # +
+ +

Returns whether the vectors are perpendicular to each other.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def pretty_print(pp) : Nil + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def product + + # +
+ +

Get the product of all elements in this vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def push(*values : Float64) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def push(value : Float64) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def reflection_in(object) + + # +
+ +

Returns the result of reflecting the point in the given object +(point, line, or plane).

+ +
+
+ + [View source] + +
+
+ +
+
+ + def rotate(t, object) + + # +
+ +

Rotates the vector about the given object. The object should +be a point if the vector is 2D, and a line if it is 3D. Be +careful with line directions!

+ +
+
+ + [View source] + +
+
+ +
+
+ + def round + + # +
+ +

Gets the result of rounding the elements of the vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def set_elements(elements) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def sigmoid + + # +
+ +

Sums the numbers in the vector and returns a sigmoid value +across the whole vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def size : Int32 + + # +
+ +

Returns the number of elements in the vector

+ +
+
+ + [View source] + +
+
+ +
+
+ + def snap_to(value) + + # +
+ +

Returns a copy of the vector with elements set to value if +they differ from it by less than Apetite.precision

+ +
+
+ + [View source] + +
+
+ +
+
+ + def subtract(value) + + # +
+ +

When the input is a number, this returns the result of subtracting +it to all vector elements. When it's a vector, the vectors +will be subtracted.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def sum + + # +
+ +

Returns the sum of all elements in the vector.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_3d + + # +
+ +

Utility to make sure vectors are 3D. If they are 2D, a zero +z-component is added.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_a + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_diagonal_matrix + + # +
+ +

Returns a diagonal Matrix with the vectors elements as its +diagonal elements.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_s(io) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_unit_vector + + # +
+ +

Returns a new vector created by normalizing this one +to have a magnitude of 1. If the vector is a zero +vector, it will not be modified.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_unsafe : Pointer(Float64) + + # +
+ +

Returns a pointer to the internal buffer where self's elements are stored.

+ +

This method is unsafe because it returns a pointer, and the pointed might eventually +not be that of self if the array grows and its internal buffer is reallocated.

+ +
vec = Vector{1.0, 2.0, 3.0}
+vec.to_unsafe[0] # => 1.0
+ +
+
+ + [View source] + +
+
+ +
+
+ + def top(n) + + # +
+ +

Returns a vector containing only the first n elements.

+ +
+
+ + [View source] + +
+
+ +
+
+ + def transpose + + # +
+ +

Transpose this vector into a 1xn Matrix

+ +
+
+ + [View source] + +
+
+ +
+
+ + def unsafe_fetch(index : Int) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def zero? + + # +
+ +
+
+ + [View source] + +
+
+ + + + + +
+ + + diff --git a/docs/Array.html b/docs/Array.html new file mode 100644 index 0000000..50fbd00 --- /dev/null +++ b/docs/Array.html @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + Array(T) - github.com/watzon/apatite + + + + + + +
+

+ + class Array(T) + +

+ + + + + + + +

Overview

+ +

An Array is an ordered, integer-indexed collection of objects of type T.

+ +

Array indexing starts at 0. A negative index is assumed to be +relative to the end of the array: -1 indicates the last element, +-2 is the next to last element, and so on.

+ +

An Array can be created using the usual new method (several are provided), or with an array literal:

+ +
Array(Int32).new  # => []
+[1, 2, 3]         # Array(Int32)
+[1, "hello", 'x'] # Array(Int32 | String | Char)
+ +

An Array can have mixed types, meaning T will be a union of types, but these are determined +when the array is created, either by specifying T or by using an array literal. In the latter +case, T will be set to the union of the array literal elements' types.

+ +

When creating an empty array you must always specify T:

+ +
[] of Int32 # same as Array(Int32)
+[]          # syntax error
+ +

An Array is implemented using an internal buffer of some capacity +and is reallocated when elements are pushed to it when more capacity +is needed. This is normally known as a dynamic array.

+ +

You can use a special array literal syntax with other types too, as long as they define an argless +new method and a << method. Set is one such type:

+ +
set = Set{1, 2, 3} # => Set{1, 2, 3}
+set.class          # => Set(Int32)
+ +

The above is the same as this:

+ +
set = Set(typeof(1, 2, 3)).new
+set << 1
+set << 2
+set << 3
+ + + + + +

Included Modules

+ + + + + + + + + + + +

Defined in:

+ + + + apatite/core_ext/array.cr + + +
+ + + + + + + + + + +

Instance Method Summary

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +

Instance Method Detail

+ +
+
+ + def all? + + # +
+ +

Tests whether all elements evaluate to true

+ +
+
+ + [View source] + +
+
+ +
+
+ + def any? + + # +
+ +

Tests whether any of the elements evaluate to true

+ +
+
+ + [View source] + +
+
+ +
+
+ + def shape + + # +
+ +

Get the array's dimensions

+ +
+
+ + [View source] + +
+
+ +
+
+ + def to_vec + + # +
+ +
+
+ + [View source] + +
+
+ + + + + +
+ + + diff --git a/docs/css/style.css b/docs/css/style.css new file mode 100644 index 0000000..7295c3f --- /dev/null +++ b/docs/css/style.css @@ -0,0 +1,629 @@ +html, body { + background: #FFFFFF; + position: relative; + margin: 0; + padding: 0; + width: 100%; + height: 100%; + overflow: hidden; +} + +body { + font-family: "Avenir", "Tahoma", "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + color: #333; + line-height: 1.5; +} + +a { + color: #263F6C; +} + +a:visited { + color: #112750; +} + +h1, h2, h3, h4, h5, h6 { + margin: 35px 0 25px; + color: #444444; +} + +h1.type-name { + color: #47266E; + margin: 20px 0 30px; + background-color: #F8F8F8; + padding: 10px 12px; + border: 1px solid #EBEBEB; + border-radius: 2px; +} + +h2 { + border-bottom: 1px solid #E6E6E6; + padding-bottom: 5px; +} + +body { + display: flex; +} + +.sidebar, .main-content { + overflow: auto; +} + +.sidebar { + width: 30em; + color: #F8F4FD; + background-color: #2E1052; + padding: 0 0 30px; + box-shadow: inset -3px 0 4px rgba(0,0,0,.35); + line-height: 1.2; +} + +.sidebar .search-box { + padding: 8px 9px; +} + +.sidebar input { + display: block; + box-sizing: border-box; + margin: 0; + padding: 5px; + font: inherit; + font-family: inherit; + line-height: 1.2; + width: 100%; + border: 0; + outline: 0; + border-radius: 2px; + box-shadow: 0px 3px 5px rgba(0,0,0,.25); + transition: box-shadow .12s; +} + +.sidebar input:focus { + box-shadow: 0px 5px 6px rgba(0,0,0,.5); +} + +.sidebar input::-webkit-input-placeholder { /* Chrome/Opera/Safari */ + color: #C8C8C8; + font-size: 14px; + text-indent: 2px; +} + +.sidebar input::-moz-placeholder { /* Firefox 19+ */ + color: #C8C8C8; + font-size: 14px; + text-indent: 2px; +} + +.sidebar input:-ms-input-placeholder { /* IE 10+ */ + color: #C8C8C8; + font-size: 14px; + text-indent: 2px; +} + +.sidebar input:-moz-placeholder { /* Firefox 18- */ + color: #C8C8C8; + font-size: 14px; + text-indent: 2px; +} + +.sidebar ul { + margin: 0; + padding: 0; + list-style: none outside; +} + +.sidebar li { + display: block; + position: relative; +} + +.types-list li.hide { + display: none; +} + +.sidebar a { + text-decoration: none; + color: inherit; + transition: color .14s; +} +.types-list a { + display: block; + padding: 5px 15px 5px 30px; +} + +.types-list { + display: block; +} + +.sidebar a:focus { + outline: 1px solid #D1B7F1; +} + +.types-list a { + padding: 5px 15px 5px 30px; +} + +.sidebar .current > a, +.sidebar a:hover { + color: #866BA6; +} + +.repository-links { + padding: 5px 15px 5px 30px; +} + +.types-list li ul { + overflow: hidden; + height: 0; + max-height: 0; + transition: 1s ease-in-out; +} + +.types-list li.parent { + padding-left: 30px; +} + +.types-list li.parent::before { + box-sizing: border-box; + content: "â–¼"; + display: block; + width: 30px; + height: 30px; + position: absolute; + top: 0; + left: 0; + text-align: center; + color: white; + font-size: 8px; + line-height: 30px; + transform: rotateZ(-90deg); + cursor: pointer; + transition: .2s linear; +} + + +.types-list li.parent > a { + padding-left: 0; +} + +.types-list li.parent.open::before { + transform: rotateZ(0); +} + +.types-list li.open > ul { + height: auto; + max-height: 1000em; +} + +.main-content { + padding: 0 30px 30px 30px; + width: 100%; +} + +.kind { + font-size: 60%; + color: #866BA6; +} + +.superclass-hierarchy { + margin: -15px 0 30px 0; + padding: 0; + list-style: none outside; + font-size: 80%; +} + +.superclass-hierarchy .superclass { + display: inline-block; + margin: 0 7px 0 0; + padding: 0; +} + +.superclass-hierarchy .superclass + .superclass::before { + content: "<"; + margin-right: 7px; +} + +.other-types-list li { + display: inline-block; +} + +.other-types-list, +.list-summary { + margin: 0 0 30px 0; + padding: 0; + list-style: none outside; +} + +.entry-const { + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; +} + +.entry-const code { + white-space: pre-wrap; +} + +.entry-summary { + padding-bottom: 4px; +} + +.superclass-hierarchy .superclass a, +.other-type a, +.entry-summary .signature { + padding: 4px 8px; + margin-bottom: 4px; + display: inline-block; + background-color: #f8f8f8; + color: #47266E; + border: 1px solid #f0f0f0; + text-decoration: none; + border-radius: 3px; + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; + transition: background .15s, border-color .15s; +} + +.superclass-hierarchy .superclass a:hover, +.other-type a:hover, +.entry-summary .signature:hover { + background: #D5CAE3; + border-color: #624288; +} + +.entry-summary .summary { + padding-left: 32px; +} + +.entry-summary .summary p { + margin: 12px 0 16px; +} + +.entry-summary a { + text-decoration: none; +} + +.entry-detail { + padding: 30px 0; +} + +.entry-detail .signature { + position: relative; + padding: 5px 15px; + margin-bottom: 10px; + display: block; + border-radius: 5px; + background-color: #f8f8f8; + color: #47266E; + border: 1px solid #f0f0f0; + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; + transition: .2s ease-in-out; +} + +.entry-detail:target .signature { + background-color: #D5CAE3; + border: 1px solid #624288; +} + +.entry-detail .signature .method-permalink { + position: absolute; + top: 0; + left: -35px; + padding: 5px 15px; + text-decoration: none; + font-weight: bold; + color: #624288; + opacity: .4; + transition: opacity .2s; +} + +.entry-detail .signature .method-permalink:hover { + opacity: 1; +} + +.entry-detail:target .signature .method-permalink { + opacity: 1; +} + +.methods-inherited { + padding-right: 10%; + line-height: 1.5em; +} + +.methods-inherited h3 { + margin-bottom: 4px; +} + +.methods-inherited a { + display: inline-block; + text-decoration: none; + color: #47266E; +} + +.methods-inherited a:hover { + text-decoration: underline; + color: #6C518B; +} + +.methods-inherited .tooltip>span { + background: #D5CAE3; + padding: 4px 8px; + border-radius: 3px; + margin: -4px -8px; +} + +.methods-inherited .tooltip * { + color: #47266E; +} + +pre { + padding: 10px 20px; + margin-top: 4px; + border-radius: 3px; + line-height: 1.45; + overflow: auto; + color: #333; + background: #fdfdfd; + font-size: 14px; + border: 1px solid #eee; +} + +code { + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; +} + +:not(pre) > code { + background-color: rgba(40,35,30,0.05); + padding: 0.2em 0.4em; + font-size: 85%; + border-radius: 3px; +} + +span.flag { + padding: 2px 4px 1px; + border-radius: 3px; + margin-right: 3px; + font-size: 11px; + border: 1px solid transparent; +} + +span.flag.orange { + background-color: #EE8737; + color: #FCEBDD; + border-color: #EB7317; +} + +span.flag.yellow { + background-color: #E4B91C; + color: #FCF8E8; + border-color: #B69115; +} + +span.flag.green { + background-color: #469C14; + color: #E2F9D3; + border-color: #34700E; +} + +span.flag.red { + background-color: #BF1919; + color: #F9ECEC; + border-color: #822C2C; +} + +span.flag.purple { + background-color: #2E1052; + color: #ECE1F9; + border-color: #1F0B37; +} + +.tooltip>span { + position: absolute; + opacity: 0; + display: none; + pointer-events: none; +} + +.tooltip:hover>span { + display: inline-block; + opacity: 1; +} + +.c { + color: #969896; +} + +.n { + color: #0086b3; +} + +.t { + color: #0086b3; +} + +.s { + color: #183691; +} + +.i { + color: #7f5030; +} + +.k { + color: #a71d5d; +} + +.o { + color: #a71d5d; +} + +.m { + color: #795da3; +} + +.hidden { + display: none; +} +.search-results { + font-size: 90%; + line-height: 1.3; +} + +.search-results mark { + color: inherit; + background: transparent; + font-weight: bold; +} +.search-result { + padding: 5px 8px 5px 5px; + cursor: pointer; + border-left: 5px solid transparent; + transform: translateX(-3px); + transition: all .2s, background-color 0s, border .02s; + min-height: 3.2em; +} +.search-result.current { + border-left-color: #ddd; + background-color: rgba(200,200,200,0.4); + transform: translateX(0); + transition: all .2s, background-color .5s, border 0s; +} +.search-result.current:hover, +.search-result.current:focus { + border-left-color: #866BA6; +} +.search-result:not(.current):nth-child(2n) { + background-color: rgba(255,255,255,.06); +} +.search-result__title { + font-size: 105%; + word-break: break-all; + line-height: 1.1; + padding: 3px 0; +} +.search-result__title strong { + font-weight: normal; +} +.search-results .search-result__title > a { + padding: 0; + display: block; +} +.search-result__title > a > .args { + color: #dddddd; + font-weight: 300; + transition: inherit; + font-size: 88%; + line-height: 1.2; + letter-spacing: -.02em; +} +.search-result__title > a > .args * { + color: inherit; +} + +.search-result a, +.search-result a:hover { + color: inherit; +} +.search-result:not(.current):hover .search-result__title > a, +.search-result:not(.current):focus .search-result__title > a, +.search-result__title > a:focus { + color: #866BA6; +} +.search-result:not(.current):hover .args, +.search-result:not(.current):focus .args { + color: #6a5a7d; +} + +.search-result__type { + color: #e8e8e8; + font-weight: 300; +} +.search-result__doc { + color: #bbbbbb; + font-size: 90%; +} +.search-result__doc p { + margin: 0; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; + line-height: 1.2em; + max-height: 2.4em; +} + +.js-modal-visible .modal-background { + display: flex; +} +.main-content { + position: relative; +} +.modal-background { + position: absolute; + display: none; + height: 100%; + width: 100%; + background: rgba(120,120,120,.4); + z-index: 100; + align-items: center; + justify-content: center; +} +.usage-modal { + max-width: 90%; + background: #fff; + border: 2px solid #ccc; + border-radius: 9px; + padding: 5px 15px 20px; + min-width: 50%; + color: #555; + position: relative; + transform: scale(.5); + transition: transform 200ms; +} +.js-modal-visible .usage-modal { + transform: scale(1); +} +.usage-modal > .close-button { + position: absolute; + right: 15px; + top: 8px; + color: #aaa; + font-size: 27px; + cursor: pointer; +} +.usage-modal > .close-button:hover { + text-shadow: 2px 2px 2px #ccc; + color: #999; +} +.modal-title { + margin: 0; + text-align: center; + font-weight: normal; + color: #666; + border-bottom: 2px solid #ddd; + padding: 10px; +} +.usage-list { + padding: 0; + margin: 13px; +} +.usage-list > li { + padding: 5px 2px; + overflow: auto; + padding-left: 100px; + min-width: 12em; +} +.usage-modal kbd { + background: #eee; + border: 1px solid #ccc; + border-bottom-width: 2px; + border-radius: 3px; + padding: 3px 8px; + font-family: monospace; + margin-right: 2px; + display: inline-block; +} +.usage-key { + float: left; + clear: left; + margin-left: -100px; + margin-right: 12px; +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..361f104 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + README - github.com/watzon/apatite + + + + + + +
+

Apatite

+ +

Apatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.

+ +

Installation

+ +
  1. Add the dependency to your shard.yml:
+ +

`yaml + dependencies:

+ +
 apatite:
+   github: watzon/apatite
+ +

`

+ +
  1. Run shards install
+ +

Usage

+ +
require "apatite"
+ +

TODO Write usage instructions here, but first write the library...

+ +

Roadmap

+ + + +

Contributing

+ +
  1. Fork it (<https://github.com/watzon/apatite/fork>)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
+ +

Contributors

+ + +
+ + diff --git a/docs/index.json b/docs/index.json new file mode 100644 index 0000000..4254d63 --- /dev/null +++ b/docs/index.json @@ -0,0 +1 @@ +{"repository_name":"github.com/watzon/apatite","body":"# Apatite\n\nApatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n apatite:\n github: watzon/apatite\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"apatite\"\n```\n\nTODO: Write usage instructions here, but first write the library...\n\n## Roadmap\n\n- [ ] Apetite\n\t- [ ] Vector Math\n\t\t- [ ] Matrix\n\t\t- [ ] NDArray\n\t\t- [x] Vector\n\t\t- [ ] Line\n\t\t- [ ] Plane\n\t\t- [ ] Polygon\n\t\t- [ ] LinkedList\n\t\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Chris Watson](https://github.com/watzon) - creator and maintainer","program":{"html_id":"github.com/watzon/apatite/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/watzon/apatite","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite","path":"Apatite.html","kind":"module","full_name":"Apatite","name":"Apatite","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra.cr","line_number":5,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr"},{"filename":"apatite.cr","line_number":10,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr"},{"filename":"apatite/version.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/version.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector::I","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector::J","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector::K","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"subclasses":[],"including_types":[],"namespace":null,"doc":"Apatite is a fundimental package for scientific computing in Crystal. If that\nsounds like a modified version of the first line from the NumPy homepage,\nthat's because it is. Apatite has (ok, will have) all of the goodness\nof NumPy sitting atop the blazing speed and beautiful syntax\nof Crystal.","summary":"

Apatite is a fundimental package for scientific computing in Crystal.

","class_methods":[{"id":"approx_precision-class-method","html_id":"approx_precision-class-method","name":"approx_precision","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L17","def":{"name":"approx_precision","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@approx_precision"}},{"id":"approx_precision=(approx_precision)-class-method","html_id":"approx_precision=(approx_precision)-class-method","name":"approx_precision=","doc":null,"summary":null,"abstract":false,"args":[{"name":"approx_precision","doc":null,"default_value":"","external_name":"approx_precision","restriction":""}],"args_string":"(approx_precision)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L21","def":{"name":"approx_precision=","args":[{"name":"approx_precision","doc":null,"default_value":"","external_name":"approx_precision","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@approx_precision = approx_precision"}},{"id":"precision-class-method","html_id":"precision-class-method","name":"precision","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L16","def":{"name":"precision","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@precision"}},{"id":"precision=(precision)-class-method","html_id":"precision=(precision)-class-method","name":"precision=","doc":null,"summary":null,"abstract":false,"args":[{"name":"precision","doc":null,"default_value":"","external_name":"precision","restriction":""}],"args_string":"(precision)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L20","def":{"name":"precision=","args":[{"name":"precision","doc":null,"default_value":"","external_name":"precision","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@precision = precision"}}],"constructors":[],"instance_methods":[{"id":"as_vector(input:Indexable)-instance-method","html_id":"as_vector(input:Indexable)-instance-method","name":"as_vector","doc":"Creates a new vector from the given `input`. Input can be any\n`Indexable` type.","summary":"

Creates a new vector from the given input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"args_string":"(input : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L58","def":{"name":"as_vector","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(input)"}},{"id":"basis(size,index)-instance-method","html_id":"basis(size,index)-instance-method","name":"basis","doc":"Returns a standard basis-n vector of the given `size` and `index`.","summary":"

Returns a standard basis-n vector of the given size and index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L63","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.basis(size, index)"}},{"id":"empty-instance-method","html_id":"empty-instance-method","name":"empty","doc":"Returns a new empty `Vector`","summary":"

Returns a new empty Vector

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L31","def":{"name":"empty","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new"}},{"id":"full(n,i)-instance-method","html_id":"full(n,i)-instance-method","name":"full","doc":"Returns a new vector of size `n` filled with `i`","summary":"

Returns a new vector of size n filled with i

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(n, i)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L46","def":{"name":"full","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, i)"}},{"id":"ones(n)-instance-method","html_id":"ones(n)-instance-method","name":"ones","doc":"Returns a new vector filled with `n` ones.","summary":"

Returns a new vector filled with n ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L36","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1)"}},{"id":"vector(n,&block)-instance-method","html_id":"vector(n,&block)-instance-method","name":"vector","doc":"Creates a new vector of size `n`, and invokes the block once\nfor each index of `self`, assigning the block's value in that index.","summary":"

Creates a new vector of size n, and invokes the block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L52","def":{"name":"vector","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n) do |i|\n yield i\nend"}},{"id":"zeros(n)-instance-method","html_id":"zeros(n)-instance-method","name":"zeros","doc":"Returns a new vector filled with `n` zeros.","summary":"

Returns a new vector filled with n zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L41","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0)"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","path":"Apatite/LinearAlgebra.html","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra/vector.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr"},{"filename":"apatite/linear_algebra/matrix.cr","line_number":3,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr"},{"filename":"apatite/linear_algebra.cr","line_number":6,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"subclasses":[],"including_types":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"namespace":{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"sigmoid(input:Number)-instance-method","html_id":"sigmoid(input:Number)-instance-method","name":"sigmoid","doc":"Calculates the sigmoid curve for a numeric input.\n\nf(x) = 1/(1 + e^-x)\n\nSee also: [Sigmoid function [WikiWand]](https://www.wikiwand.com/en/Sigmoid_function)","summary":"

Calculates the sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr#L14","def":{"name":"sigmoid","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\n1 / (1 + (Math.exp(-num)))\n"}},{"id":"sigmoid_d(input:Number)-instance-method","html_id":"sigmoid_d(input:Number)-instance-method","name":"sigmoid_d","doc":"Calculates the derivative sigmoid curve for a numeric input.\n\nf'(x) = f(x)(1 - f(x)),","summary":"

Calculates the derivative sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr#L22","def":{"name":"sigmoid_d","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\nnum * (1 - num)\n"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix","path":"Apatite/LinearAlgebra/Matrix.html","kind":"class","full_name":"Apatite::LinearAlgebra::Matrix","name":"Matrix","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/matrix.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[{"id":"[](*rows)-class-method","html_id":"[](*rows)-class-method","name":"[]","doc":"Creates a matrix where each argument is a row.","summary":"

Creates a matrix where each argument is a row.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(*rows)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L22","def":{"name":"[]","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows(rows)"}},{"id":"build(row_count,column_count=row_count,&block)-class-method","html_id":"build(row_count,column_count=row_count,&block)-class-method","name":"build","doc":"Creates a matrix of size `row_count x column_count`. It fills the values by calling\nthe given block, passing the current row and column.","summary":"

Creates a matrix of size row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L28","def":{"name":"build","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count < 0 || column_count < 0\n raise(ArgumentError.new)\nend\nrows = Array.new(row_count) do |i|\n Vector.new(column_count) do |j|\n yield i, j\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"col_vector(column)-class-method","html_id":"col_vector(column)-class-method","name":"col_vector","doc":"Creates a single-column matrix where the values of that column are as given in column.","summary":"

Creates a single-column matrix where the values of that column are as given in column.

","abstract":false,"args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(column)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L39","def":{"name":"col_vector","args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([column].transpose, 1)"}},{"id":"columns(columns)-class-method","html_id":"columns(columns)-class-method","name":"columns","doc":"Creates a matrix using `columns` as an array of column vectors.","summary":"

Creates a matrix using .columns as an array of column vectors.

","abstract":false,"args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"args_string":"(columns)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L44","def":{"name":"columns","args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(rows(columns)).transpose"}},{"id":"diagonal(values)-class-method","html_id":"diagonal(values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L70","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = values.size\nif size == 0\n return Matrix.empty\nend\nrows = Array.new(size) do |j|\n row = Array.new(size, 0)\n row[j] = values[j]\n row\nend\nnew(rows)\n"}},{"id":"diagonal(*values)-class-method","html_id":"diagonal(*values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(*values)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L84","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty(row_count=0,column_count=0)-class-method","html_id":"empty(row_count=0,column_count=0)-class-method","name":"empty","doc":"Creates a empty matrix of `row_count x column_count`. At least one of\n`row_count` or `column_count` must be 0.","summary":"

Creates a empty matrix of row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L90","def":{"name":"empty","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (column_count != 0) && (row_count != 0)\n raise(ArgumentError.new(\"One size must be 0\"))\nend\nif column_count < 0 || row_count < 0\n raise(ArgumentError.new(\"Negative size\"))\nend\nMatrix.new(([] of Vector) * row_count, column_count)\n"}},{"id":"hstack(x,*matrices)-class-method","html_id":"hstack(x,*matrices)-class-method","name":"hstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"args_string":"(x, *matrices)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L97","def":{"name":"hstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"identity(n)-class-method","html_id":"identity(n)-class-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L101","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"scalar(n, 1)"}},{"id":"row_vector(row)-class-method","html_id":"row_vector(row)-class-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in #row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L106","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([row], 0)"}},{"id":"rows(rows)-class-method","html_id":"rows(rows)-class-method","name":"rows","doc":"Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.","summary":"

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(rows)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L111","def":{"name":"rows","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = rows[0]? ? rows[0].size : 0\nrows.each do |row|\n if row.size == size\n else\n raise(\"Dimension mismatch: row size differs (#{row.size} should be #{size})\")\n end\nend\nMatrix.new(rows, size)\n"}},{"id":"scalar(n,value)-class-method","html_id":"scalar(n,value)-class-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L120","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(Array.new(n, value))"}},{"id":"vstack(x,y)-class-method","html_id":"vstack(x,y)-class-method","name":"vstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"args_string":"(x, y)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L125","def":{"name":"vstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"zero(row_count,column_count=row_count)-class-method","html_id":"zero(row_count,column_count=row_count)-class-method","name":"zero","doc":"Creates a zero matrix.","summary":"

Creates a zero matrix.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L129","def":{"name":"zero","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = Array.new(row_count) do\n Vector.new(column_count)\nend\nMatrix.new(rows, column_count)\n"}}],"constructors":[{"id":"new(rows,column_count:Int32=rows[0].size)-class-method","html_id":"new(rows,column_count:Int32=rows[0].size)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"rows[0].size","external_name":"column_count","restriction":"Int32"}],"args_string":"(rows, column_count : Int32 = rows[0].size)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L15","def":{"name":"new","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"rows[0].size","external_name":"column_count","restriction":"Int32"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows, column_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"*(other:Matrix)-instance-method","html_id":"*(other:Matrix)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L134","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n (0...column_count).reduce(0.0) do |vij, k|\n vij + (self[i, k] * other[k, j])\n end\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"*(int:Int)-instance-method","html_id":"*(int:Int)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"args_string":"(int : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L148","def":{"name":"*","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e * int\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"*(ind:Indexable)-instance-method","html_id":"*(ind:Indexable)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"args_string":"(ind : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L155","def":{"name":"*","args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"m = column_vector\nr = self * m\nr.column(0)\n"}},{"id":"**(int)-instance-method","html_id":"**(int)-instance-method","name":"**","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"args_string":"(int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L161","def":{"name":"**","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if int >= 1\nelse\n raise(\"Number can not the less than 1\")\nend\nmat = self\n(int - 1).times do\n mat = mat * self\nend\nmat\n"}},{"id":"+(other:Matrix)-instance-method","html_id":"+(other:Matrix)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L170","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] + other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"+(vec:Indexable)-instance-method","html_id":"+(vec:Indexable)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L182","def":{"name":"+","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(vec:Indexable)-instance-method","html_id":"-(vec:Indexable)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L199","def":{"name":"-","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(other:Matrix)-instance-method","html_id":"-(other:Matrix)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L187","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] - other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"/(other:Matrix)-instance-method","html_id":"/(other:Matrix)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L204","def":{"name":"/","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self * other.inverse"}},{"id":"/(vec:Indexable)-instance-method","html_id":"/(vec:Indexable)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L208","def":{"name":"/","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e / other\n end\nend\nreturn new_matrix(rows, column_count)\n"}},{"id":"==(other:Matrix)-instance-method","html_id":"==(other:Matrix)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L215","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (Matrix === other) && (column_count == other.column_count)\nelse\n return false\nend\nrows == other.rows\n"}},{"id":"[](row:Int,col:Int)-instance-method","html_id":"[](row:Int,col:Int)-instance-method","name":"[]","doc":"Returns element `(row, col)` of the matrix. Throws error on index error.","summary":"

Returns element (row, col) of the matrix.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L222","def":{"name":"[]","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[row][col]"}},{"id":"[]?(row:Int,col:Int)-instance-method","html_id":"[]?(row:Int,col:Int)-instance-method","name":"[]?","doc":"Returns element `(row, col)` of the matrix, or nil if the index is not found.","summary":"

Returns element (row, col) of the matrix, or nil if the index is not found.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L227","def":{"name":"[]?","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = fetch(row) do\n nil\nend\nif v.nil?\nelse\n v[col]?\nend\n"}},{"id":"adjugate-instance-method","html_id":"adjugate-instance-method","name":"adjugate","doc":"Returns the adjugate of the matrix.","summary":"

Returns the adjugate of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L233","def":{"name":"adjugate","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#adjugate` requires a square matrix.\")\nend\nMatrix.build(row_count, column_count) do |row, column|\n cofactor(column, row)\nend\n"}},{"id":"cofactor(row,column)-instance-method","html_id":"cofactor(row,column)-instance-method","name":"cofactor","doc":"Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)","summary":"

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L241","def":{"name":"cofactor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"cofactor of empty matrix is not defined\")\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#cofactor` requires a square matrix.\")\nend\ndet_of_minor = (first_minor(row, column)).determinant\ndet_of_minor * ((-1.0) ** (row + column))\n"}},{"id":"column(j,&block)-instance-method","html_id":"column(j,&block)-instance-method","name":"column","doc":"Iterates over the specified column in the matrix, returning the Vector's items.","summary":"

Iterates over the specified column in the matrix, returning the Vector's items.

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L268","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return self\nend\nrow_count.times do |i|\n yield rows[i][j]\nend\nself\n"}},{"id":"column(j)-instance-method","html_id":"column(j)-instance-method","name":"column","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L259","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n raise(\"Index out of range\")\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column?(j)-instance-method","html_id":"column?(j)-instance-method","name":"column?","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L250","def":{"name":"column?","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return nil\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L11","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@column_count"}},{"id":"column_vectors-instance-method","html_id":"column_vectors-instance-method","name":"column_vectors","doc":"Returns an array of the column vectors of the matrix. See `Vector`.","summary":"

Returns an array of the column vectors of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L277","def":{"name":"column_vectors","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Vector).new(column_count) do |i|\n column(i)\nend"}},{"id":"determinant-instance-method","html_id":"determinant-instance-method","name":"determinant","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L348","def":{"name":"determinant","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nm = rows\ncase row_count\nwhen 0\n +1\nwhen 1\n +m[0][0]\nwhen 2\n ((+m[0][0]) * m[1][1]) - (m[0][1] * m[1][0])\nwhen 3\n m0, m1, m2 = m\n (((((((+m0[0]) * m1[1]) * m2[2]) - ((m0[0] * m1[2]) * m2[1])) - ((m0[1] * m1[0]) * m2[2])) + ((m0[1] * m1[2]) * m2[0])) + ((m0[2] * m1[0]) * m2[1])) - ((m0[2] * m1[1]) * m2[0])\nwhen 4\n m0, m1, m2, m3 = m\n ((((((((((((((((((((((((((+m0[0]) * m1[1]) * m2[2]) * m3[3]) - (((m0[0] * m1[1]) * m2[3]) * m3[2])) - (((m0[0] * m1[2]) * m2[1]) * m3[3])) + (((m0[0] * m1[2]) * m2[3]) * m3[1])) + (((m0[0] * m1[3]) * m2[1]) * m3[2])) - (((m0[0] * m1[3]) * m2[2]) * m3[1])) - (((m0[1] * m1[0]) * m2[2]) * m3[3])) + (((m0[1] * m1[0]) * m2[3]) * m3[2])) + (((m0[1] * m1[2]) * m2[0]) * m3[3])) - (((m0[1] * m1[2]) * m2[3]) * m3[0])) - (((m0[1] * m1[3]) * m2[0]) * m3[2])) + (((m0[1] * m1[3]) * m2[2]) * m3[0])) + (((m0[2] * m1[0]) * m2[1]) * m3[3])) - (((m0[2] * m1[0]) * m2[3]) * m3[1])) - (((m0[2] * m1[1]) * m2[0]) * m3[3])) + (((m0[2] * m1[1]) * m2[3]) * m3[0])) + (((m0[2] * m1[3]) * m2[0]) * m3[1])) - (((m0[2] * m1[3]) * m2[1]) * m3[0])) - (((m0[3] * m1[0]) * m2[1]) * m3[2])) + (((m0[3] * m1[0]) * m2[2]) * m3[1])) + (((m0[3] * m1[1]) * m2[0]) * m3[2])) - (((m0[3] * m1[1]) * m2[2]) * m3[0])) - (((m0[3] * m1[2]) * m2[0]) * m3[1])) + (((m0[3] * m1[2]) * m2[1]) * m3[0])\nelse\n determinant_bareiss\nend\n"}},{"id":"first_minor(row,column)-instance-method","html_id":"first_minor(row,column)-instance-method","name":"first_minor","doc":null,"summary":null,"abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L423","def":{"name":"first_minor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"first_minor of empty matrix is not defined\")\nend\nif 0 <= row && row < row_count\nelse\n raise(ArgumentError.new(\"invalid row (#{row.inspect} for 0..#{row_count - 1})\"))\nend\nif 0 <= column && column < column_count\nelse\n raise(ArgumentError.new(\"invalid column (#{column.inspect} for 0..#{column_count - 1})\"))\nend\narrays = to_a.map(&.to_a)\narrays.delete_at(row)\narrays.each do |array|\n array.delete_at(column)\nend\nMatrix.new(arrays, column_count - 1)\n"}},{"id":"inverse-instance-method","html_id":"inverse-instance-method","name":"inverse","doc":"Returns the inverse of the matrix.","summary":"

Returns the inverse of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L298","def":{"name":"inverse","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n if square?\n else\n raise(\"Dimention mismatch: `Matrix#inverse` requires a square matrix.\")\n end\nend\n(Matrix.identity(row_count)).inverse_from(self)\n"}},{"id":"laplace_expansion(*,row=nil,column=nil)-instance-method","html_id":"laplace_expansion(*,row=nil,column=nil)-instance-method","name":"laplace_expansion","doc":"Returns the Laplace expansion along given row or column.","summary":"

Returns the Laplace expansion along given row or column.

","abstract":false,"args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"args_string":"(*, row = nil, column = nil)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L444","def":{"name":"laplace_expansion","args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = row || column\nif (!num) || (row && column)\n raise(ArgumentError.new(\"exactly one the row or column arguments must be specified\"))\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nif empty?\n raise(\"laplace_expansion of empty matrix is not defined\")\nend\nif 0 <= num && num < row_count\nelse\n raise(ArgumentError.new(\"invalid num (#{num.inspect} for 0..#{row_count - 1})\"))\nend\nif row\n (row(num)).map_with_index do |e, k|\n e * (cofactor(num, k))\n end.reduce(&.+)\nelse\n (column(num)).map_with_index do |e, k|\n e * (cofactor(k, num))\n end.reduce(&.+)\nend\n"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L510","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"[\", self, \"]\") do |vec|\n pp.group do\n vec.to_a.pretty_print(pp)\n end\nend"}},{"id":"row(i,&block)-instance-method","html_id":"row(i,&block)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L469","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":""},"return_type":"","visibility":"Public","body":"(@rows.fetch(i) do\n return self\nend).each(&block)\nself\n"}},{"id":"row(i)-instance-method","html_id":"row(i)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L474","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(rows.fetch(i) do\n [] of Float64\nend)"}},{"id":"row_count:Int32-instance-method","html_id":"row_count:Int32-instance-method","name":"row_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L13","def":{"name":"row_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@row_count"}},{"id":"rows-instance-method","html_id":"rows-instance-method","name":"rows","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L478","def":{"name":"rows","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = [] of Vector\nrow_count.times do |i|\n rows << self[i - 1]\nend\nrows\n"}},{"id":"square?-instance-method","html_id":"square?-instance-method","name":"square?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L486","def":{"name":"square?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"row_count == column_count"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L496","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n \"Matrix.empty(#{row_count}, #{column_count})\"\nelse\n io << \"Matrix[\"\n io << (map do |row|\n (\"{\" + (row.to_a.map do |e|\n e.to_s\n end.join(\", \"))) + \"}\"\n end.join(\", \"))\n io << \"]\"\nend"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L490","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count.zero?\n return Matrix.empty(column_count, 0)\nend\ntransposed = rows.map do |v|\n v.to_a\nend.transpose\nMatrix.new(transposed, row_count)\n"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L519","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray","path":"Apatite/LinearAlgebra/NDArray.html","kind":"class","full_name":"Apatite::LinearAlgebra::NDArray","name":"NDArray","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":2,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","html_id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"args_string":"(data : Array(Number), shape : Array(Int32)? = nil)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L18","def":{"name":"new","args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(data, shape)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"[](*args,**options)-instance-method","html_id":"[](*args,**options)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]"}},{"id":"[](*args,**options,&block)-instance-method","html_id":"[](*args,**options,&block)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options] do |*yield_args|\n yield *yield_args\nend"}},{"id":"[]=(*args,**options)-instance-method","html_id":"[]=(*args,**options)-instance-method","name":"[]=","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L13","def":{"name":"[]=","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args] = **options"}},{"id":"[]?(*args,**options)-instance-method","html_id":"[]?(*args,**options)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]?"}},{"id":"[]?(*args,**options,&block)-instance-method","html_id":"[]?(*args,**options,&block)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]? do |*yield_args|\n yield *yield_args\nend"}},{"id":"abs-instance-method","html_id":"abs-instance-method","name":"abs","doc":"Returns the absolute value of every item in the array","summary":"

Returns the absolute value of every item in the array

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L24","def":{"name":"abs","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |e|\n e.abs\nend"}},{"id":"acos-instance-method","html_id":"acos-instance-method","name":"acos","doc":"Returns the arccosine of each element in the current array.","summary":"

Returns the arccosine of each element in the current array.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L29","def":{"name":"acos","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"data:Array(Float64)-instance-method","html_id":"data:Array(Float64)-instance-method","name":"data","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L9","def":{"name":"data","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Float64)","visibility":"Public","body":"@data"}},{"id":"shape:Array(Int32)-instance-method","html_id":"shape:Array(Int32)-instance-method","name":"shape","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Int32)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Int32)","visibility":"Public","body":"@shape"}},{"id":"size(*args,**options)-instance-method","html_id":"size(*args,**options)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options)"}},{"id":"size(*args,**options,&block)-instance-method","html_id":"size(*args,**options,&block)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"to_unsafe(*args,**options)-instance-method","html_id":"to_unsafe(*args,**options)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options)"}},{"id":"to_unsafe(*args,**options,&block)-instance-method","html_id":"to_unsafe(*args,**options,&block)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"unsafe_fetch(*args,**options)-instance-method","html_id":"unsafe_fetch(*args,**options)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options)"}},{"id":"unsafe_fetch(*args,**options,&block)-instance-method","html_id":"unsafe_fetch(*args,**options,&block)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Vector","path":"Apatite/LinearAlgebra/Vector.html","kind":"class","full_name":"Apatite::LinearAlgebra::Vector","name":"Vector","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/vector.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector.create([1.0, 0.0, 0.0])","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector.create([0.0, 1.0, 0.0])","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector.create([0.0, 0.0, 1.0])","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"}],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":"Represents a mathematical vector, and also constitutes a row or column\nof a `Matrix`","summary":"

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

","class_methods":[{"id":"[](*array)-class-method","html_id":"[](*array)-class-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"args_string":"(*array)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L156","def":{"name":"[]","args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(array)"}},{"id":"basis(size,index)-class-method","html_id":"basis(size,index)-class-method","name":"basis","doc":"Returns a standard basis n-vector.","summary":"

Returns a standard basis n-vector.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L138","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size < 1\n raise(ArgumentError.new(\"invalid size (#{size} for 1..)\"))\nend\nif 0 <= index && index < size\nelse\n raise(ArgumentError.new(\"invalid index (#{index} for 0...#{size})\"))\nend\nvec = Vector.new(size, 0.0)\nvec[index] = 1.0\nvec\n"}},{"id":"create(elements:Indexable(Number))-class-method","html_id":"create(elements:Indexable(Number))-class-method","name":"create","doc":"Creates a new `Vector` from the elements of another `Indexable`\ncollection.\n\n```\nVector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}\n```","summary":"

Creates a new Vector from the elements of another Indexable collection.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"args_string":"(elements : Indexable(Number))","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L118","def":{"name":"create","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new\nelements.each do |el|\n vec.push(el.to_f64)\nend\nvec\n"}},{"id":"ones(n)-class-method","html_id":"ones(n)-class-method","name":"ones","doc":"Create a new vector of size `n` filled with ones.","summary":"

Create a new vector of size n filled with ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L152","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1.0)"}},{"id":"random(n,range=Float64::MIN..Float64::MAX)-class-method","html_id":"random(n,range=Float64::MIN..Float64::MAX)-class-method","name":"random","doc":"Generates a random vector of size `n` with elements\nin `range`.","summary":"

Generates a random vector of size n with elements in range.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"Float64::MIN..Float64::MAX","external_name":"range","restriction":""}],"args_string":"(n, range = Float64::MIN..Float64::MAX)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L128","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"Float64::MIN..Float64::MAX","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"random = Random.new\nvec = Vector.new(n)\nn.times do\n vec.push(random.rand(range))\nend\nvec\n"}},{"id":"zeros(n)-class-method","html_id":"zeros(n)-class-method","name":"zeros","doc":"Create a new vector of size `n` filled with zeros.","summary":"

Create a new vector of size n filled with zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L147","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0.0)"}}],"constructors":[{"id":"build(capacity:Int,&block):self-class-method","html_id":"build(capacity:Int,&block):self-class-method","name":"build","doc":"Creates a new `Vector`, allocating an internal buffer with the given *capacity*,\nand yielding that buffer. The given block must return the desired size of the vector.\n\nThis method is **unsafe**.\n\n```\nVector.build(3) do |buffer|\n LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)\nend\n```","summary":"

Creates a new Vector, allocating an internal buffer with the given capacity, and yielding that buffer.

","abstract":false,"args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"args_string":"(capacity : Int, &block) : self","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L106","def":{"name":"build","args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"self","visibility":"Public","body":"vec = Vector.new(capacity)\nvec.size = (yield vec.to_unsafe).to_i\nvec\n"}},{"id":"new(size:Int,value:Float64)-class-method","html_id":"new(size:Int,value:Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* filled with the same *value* in each position.\n\n```\nVector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}\n```","summary":"

Creates a new Vector of the given size filled with the same value in each position.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(size : Int, value : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L63","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(size, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(initial_capacity:Int)-class-method","html_id":"new(initial_capacity:Int)-class-method","name":"new","doc":"Creates a new empty `Vector` backed by a buffer that is initially\n`initial_capacity` big.\n\nThe *initial_capacity* is useful to avoid unnecessary reallocations\nof the internal buffer in case of growth. If you have an estimate\nof the maximum number of elements an vector will hold, the vector should\nbe initialized with that capacity for improved performance.\n\n```\nvec = Vector.new(5)\nvec.size # => 0\n```","summary":"

Creates a new empty Vector backed by a buffer that is initially initial_capacity big.

","abstract":false,"args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"args_string":"(initial_capacity : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L43","def":{"name":"new","args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(initial_capacity)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new-class-method","html_id":"new-class-method","name":"new","doc":"Create a new empty `Vector`.","summary":"

Create a new empty Vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L25","def":{"name":"new","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(size:Int,&block:Int32->Float64)-class-method","html_id":"new(size:Int,&block:Int32->Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* and invokes the given block once\nfor each index of `self`, assigning the block's value in that index.\n\n```\nVector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}\n\nvec = Vector.new(3) { 5.0 }\nvec # => Vector{5.0, 5.0, 5.0}\n```","summary":"

Creates a new Vector of the given size and invokes the given block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"args_string":"(size : Int, &block : Int32 -> Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L87","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(Int32 -> Float64)"},"return_type":"","visibility":"Public","body":"Vector.build(size) do |buffer|\n size.to_i.times do |i|\n buffer[i] = yield i\n end\n size\nend"}}],"instance_methods":[{"id":"*(other)-instance-method","html_id":"*(other)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L370","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"multiply(other)"}},{"id":"+(other)-instance-method","html_id":"+(other)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L362","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"add(other)"}},{"id":"-(other)-instance-method","html_id":"-(other)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L366","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"subtract(other)"}},{"id":"<<(value:Float64)-instance-method","html_id":"<<(value:Float64)-instance-method","name":"<<","doc":"Alias for `#push`","summary":"

Alias for #push

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L349","def":{"name":"<<","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(value)"}},{"id":"(other)-instance-method","html_id":"(other)-instance-method","name":"<=>","doc":"Combined comparison operator. Returns *0* if `self` equals *other*, *1* if\n`self` is greater than *other* and *-1* if `self` is smaller than *other*.\n\nIt compares the elements of both vectors in the same position using the\n`<=>` operator. As soon as one of such comparisons returns a non-zero\nvalue, that result is the return value of the comparison.\n\nIf all elements are equal, the comparison is based on the size of the vectors.\n\n```\nVector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1\nVector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1\nVector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0\n```","summary":"

Combined comparison operator.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L339","def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"min_size = Math.min(size, other.size)\n0.upto(min_size - 1) do |i|\n n = @buffer[i] <=> other.to_unsafe[i]\n if n != 0\n return n\n end\nend\nsize <=> other.size\n"}},{"id":"==(other:Vector)-instance-method","html_id":"==(other:Vector)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L353","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"equals?(other) do |x, y|\n x == y\nend"}},{"id":"[](start:Int,count:Int)-instance-method","html_id":"[](start:Int,count:Int)-instance-method","name":"[]","doc":"Returns count or less (if there aren't enough) elements starting at the\ngiven start index.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1, 3] # => Vector{2.0, 3.0, 4.0}\nv[6, 10] # raise IndexError\n```","summary":"

Returns count or less (if there aren't enough) elements starting at the given start index.

","abstract":false,"args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"args_string":"(start : Int, count : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L191","def":{"name":"[]","args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nif start == size\n return Vector.new\nend\nif start < 0\n start = start + size\nend\nif 0 <= start && start <= size\nelse\n raise(IndexError.new)\nend\nif count == 0\n return Vector.new\nend\ncount = Math.min(count, size - start)\nVector.build(count) do |buffer|\n buffer.copy_from(@buffer + start, count)\n count\nend\n"}},{"id":"[](range:Range(Int,Int))-instance-method","html_id":"[](range:Range(Int,Int))-instance-method","name":"[]","doc":"Returns all elements that are within the given range.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1..3] # => Vector{2.0, 3.0, 4.0}\nv[6..10] # raise IndexError\n```","summary":"

Returns all elements that are within the given range.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"args_string":"(range : Range(Int, Int))","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L173","def":{"name":"[]","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)]"}},{"id":"[]=(index:Int,count:Int,values:Vector)-instance-method","html_id":"[]=(index:Int,count:Int,values:Vector)-instance-method","name":"[]=","doc":"Replaces a subrange with the elements of the given vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0, 8.0}\nvec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0}\nvec # = Vector{1.0, 6.0, 7.0, 5.0}\n```","summary":"

Replaces a subrange with the elements of the given vector.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"args_string":"(index : Int, count : Int, values : Vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L297","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ndiff = values.size - count\nif diff == 0\n (@buffer + index).copy_from(values.to_unsafe, values.size)\nelse\n if diff < 0\n diff = -diff\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @size = @size - diff\n else\n resize_to_capacity(Math.pw2ceil(@size + diff))\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n @size = @size + diff\n end\nend\nvalues\n"}},{"id":"[]=(index:Int,count:Int,value)-instance-method","html_id":"[]=(index:Int,count:Int,value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value. All elements in the range\n`index...index+count` are removed and replaced by a single element\n*value*.\n\nIf *count* is zero, *value* is inserted at *index*.\n\nNegative values of *index* count from the end of the vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = 6.0\nvec # => Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 0] = 6.0\nvec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, count : Int, value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L248","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nvalue = value.to_f64\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ncase count\nwhen 0\n insert(index, value)\nwhen 1\n @buffer[index] = value\nelse\n diff = count - 1\n ((@buffer + index) + 1).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @buffer[index] = value\n @size = @size - diff\nend\nvalue\n"}},{"id":"[]=(index:Int,value)-instance-method","html_id":"[]=(index:Int,value)-instance-method","name":"[]=","doc":"Sets the given value at the given index.\n\nNegative indices can be used to start counting from the end of the array.\nRaises `IndexError` if trying to set an element outside the array's range.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec[0] = 5.0\np vec # => Vec{5.0, 2.0, 3.0}\n\nvec[3] = 5.0 # raises IndexError\n```","summary":"

Sets the given value at the given index.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L226","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"index = check_index_out_of_bounds(index)\n@buffer[index] = value.to_f64\n"}},{"id":"[]=(range:Range(Int,Int),value)-instance-method","html_id":"[]=(range:Range(Int,Int),value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1..3] = 6.0\nvec # = Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1...1] = 6\nvec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(range : Range(Int, Int), value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L282","def":{"name":"[]=","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)] = value.to_f64"}},{"id":"add(value)-instance-method","html_id":"add(value)-instance-method","name":"add","doc":"When the input is a number, this returns the result of adding\nit to all vector elements. When it's a vector, the vectors\nwill be added together.","summary":"

When the input is a number, this returns the result of adding it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L488","def":{"name":"add","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a + b\nend"}},{"id":"angle_from(vector)-instance-method","html_id":"angle_from(vector)-instance-method","name":"angle_from","doc":"Returns the angle between this vector and another in radians.\nIf the vectors are mirrored across their axes this will return `nil`.","summary":"

Returns the angle between this vector and another in radians.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L440","def":{"name":"angle_from","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = vector.is_a?(Vector) ? vector : Vector.create(vector)\nif size == v.size\nelse\n raise(\"Cannot compute the angle between vectors with different dimensionality\")\nend\ndot = 0_f64\nmod1 = 0_f64\nmod2 = 0_f64\n(zip(vector)).each do |x, v|\n dot = dot + (x * v)\n mod1 = mod1 + (x * x)\n mod2 = mod2 + (v * v)\nend\nmod1 = Math.sqrt(mod1)\nmod2 = Math.sqrt(mod2)\nif (mod2 * mod2) == 0\n return 0.0\nend\ntheta = (dot / (mod1 * mod2)).clamp(-1, 1)\nMath.acos(theta)\n"}},{"id":"antiparallel_to?(vector)-instance-method","html_id":"antiparallel_to?(vector)-instance-method","name":"antiparallel_to?","doc":"Returns whether the vectors are antiparallel to each other.","summary":"

Returns whether the vectors are antiparallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L475","def":{"name":"antiparallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\n(angle - Math::PI).abs <= Apatite.precision\n"}},{"id":"augment(elements)-instance-method","html_id":"augment(elements)-instance-method","name":"augment","doc":"Returns a new vector with the provided `elements` concatenated\non the end.","summary":"

Returns a new vector with the provided elements concatenated on the end.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L556","def":{"name":"augment","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = elements.is_a?(Vector) ? elements : Vector.create(elements)\nconcat(elements)\n"}},{"id":"chomp(n)-instance-method","html_id":"chomp(n)-instance-method","name":"chomp","doc":"Returns a new vector with the first `n` elements removed from\nthe beginning.","summary":"

Returns a new vector with the first n elements removed from the beginning.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L541","def":{"name":"chomp","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i >= n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Removes all elements from self.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.clear # => Vector{}\n```","summary":"

Removes all elements from self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L782","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.clear(@size)\n@size = 0\nself\n"}},{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L374","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(@elements.clone)"}},{"id":"concat(other:Vector)-instance-method","html_id":"concat(other:Vector)-instance-method","name":"concat","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L731","def":{"name":"concat","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other_size = other.size\nnew_size = size + other_size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\n(@buffer + @size).copy_from(other.to_unsafe, other_size)\n@size = new_size\nself\n"}},{"id":"covector-instance-method","html_id":"covector-instance-method","name":"covector","doc":"Creates a single-row matrix from this vector.","summary":"

Creates a single-row matrix from this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L601","def":{"name":"covector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(self)"}},{"id":"cross(*vs)-instance-method","html_id":"cross(*vs)-instance-method","name":"cross","doc":"Returns the cross product of this vector with the others.\n\n```\nv1 = Vector{1.0, 0.0, 0.0}\nv2 = Vector{0.0, 1.0, 0.0}\nv1.cross(v2) => Vector{0.0, 0.0, 1.0}\n```","summary":"

Returns the cross product of this vector with the others.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L518","def":{"name":"cross","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size >= 2\nelse\n raise(\"cross product is not defined on vectors of dimension #{size}\")\nend\nif vs.size == (size - 2)\nelse\n raise(ArgumentError.new(\"wrong number of arguments (#{vs.size} for #{size - 2})\"))\nend\nvs.each do |v|\n if v.size == size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\ncase size\nwhen 2\n Vector[-@buffer[1], @buffer[0]]\nwhen 3\n v = vs[0]\n Vector[(v[2] * @buffer[1]) - (v[1] * @buffer[2]), (v[0] * @buffer[2]) - (v[2] * @buffer[0]), (v[1] * @buffer[0]) - (v[0] * @buffer[1])]\nelse\nend\n"}},{"id":"distance_from(obj)-instance-method","html_id":"distance_from(obj)-instance-method","name":"distance_from","doc":"Gets this vector's distance from the argument, when considered\na point in space.","summary":"

Gets this vector's distance from the argument, when considered a point in space.

","abstract":false,"args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"args_string":"(obj)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L629","def":{"name":"distance_from","args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n return object.distance_from(self)\nend\nv = elements.is_a?(Vector) ? elements.elements : elements\nif v.size == @elements.size\nelse\n return nil\nend\nsum = 0\npart = 0\neach_with_index do |x, i|\n part = x - v[i - 1]\n sum = sum + (part * part)\nend\nMath.sqrt(sum)\n"}},{"id":"dot(other)-instance-method","html_id":"dot(other)-instance-method","name":"dot","doc":"Get the scalar (dot) product of this vector with `vector`.\n\n[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product)","summary":"

Get the scalar (dot) product of this vector with vector.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L574","def":{"name":"dot","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other = other.is_a?(Vector) ? other : Vector.create(other)\nif size == other.size\nelse\n raise(\"Cannot compute the dot product of vectors with different dimensionality\")\nend\nproduct = 0\n(0...size).each do |i|\n product = product + (self[i] * other[i])\nend\nproduct\n"}},{"id":"e(i)-instance-method","html_id":"e(i)-instance-method","name":"e","doc":"Returns the `ith` element of the vector. Returns `nil` if `i`\nis out of bounds. Indexing starts from 1.","summary":"

Returns the ith element of the vector.

","abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L426","def":{"name":"e","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(i < 1 || i > @size) ? nil : self[i - 1]"}},{"id":"independent?(*vs)-instance-method","html_id":"independent?(*vs)-instance-method","name":"independent?","doc":"Returns true if all vectors are linearly independent.","summary":"

Returns true if all vectors are linearly independent.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L384","def":{"name":"independent?","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vs.each do |v|\n if v.size == vs.first.size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\nif vs.size > sv.first.size\n return false\nend\nMatrix[*vs].rank.equal?(vs.count)\n"}},{"id":"lies_in(plane)-instance-method","html_id":"lies_in(plane)-instance-method","name":"lies_in","doc":"Returns true if the vector is a point on the given plane.","summary":"

Returns true if the vector is a point on the given plane.

","abstract":false,"args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"args_string":"(plane)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L654","def":{"name":"lies_in","args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"plane.contains(self)"}},{"id":"lies_on(line)-instance-method","html_id":"lies_on(line)-instance-method","name":"lies_on","doc":"Returns true if the vector is a point on the given line","summary":"

Returns true if the vector is a point on the given line

","abstract":false,"args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"args_string":"(line)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L649","def":{"name":"lies_on","args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"line.contains(self)"}},{"id":"log-instance-method","html_id":"log-instance-method","name":"log","doc":"Return a new `Vector` with the log of every item in `self`.","summary":"

Return a new Vector with the log of every item in self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L562","def":{"name":"log","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n Math.log(x)\nend"}},{"id":"magnitude-instance-method","html_id":"magnitude-instance-method","name":"magnitude","doc":"Returns the magnitude/euclidian norm of this vector.\n\n[https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance)","summary":"

Returns the magnitude/euclidian norm of this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L419","def":{"name":"magnitude","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"sum = reduce(0.0) do |acc, e|\n acc = acc + (e * e)\nend\nMath.sqrt(sum)\n"}},{"id":"map(&block)-instance-method","html_id":"map(&block)-instance-method","name":"map","doc":"Invokes the given block for each element of `self`.","summary":"

Invokes the given block for each element of self.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L379","def":{"name":"map","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i]\nend"}},{"id":"map!(&block)-instance-method","html_id":"map!(&block)-instance-method","name":"map!","doc":"Invokes the given block for each element of `self`, replacing the element\nwith the value returned by the block. Returns `self`.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.map! { |x| x * x }\na # => Vector{1.0, 4.0, 9.0}\n```","summary":"

Invokes the given block for each element of self, replacing the element with the value returned by the block.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L400","def":{"name":"map!","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.map!(size) do |e|\n yield e\nend\nself\n"}},{"id":"map_with_index(&block)-instance-method","html_id":"map_with_index(&block)-instance-method","name":"map_with_index","doc":"Optimized version of `Enumerable#map_with_index`.","summary":"

Optimized version of Enumerable#map_with_index.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L406","def":{"name":"map_with_index","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i], i\nend"}},{"id":"map_with_index!(&block)-instance-method","html_id":"map_with_index!(&block)-instance-method","name":"map_with_index!","doc":"Like `map_with_index`, but mutates `self` instead of allocating a new object.","summary":"

Like #map_with_index, but mutates self instead of allocating a new object.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L411","def":{"name":"map_with_index!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"to_unsafe.map_with_index!(size) do |e, i|\n yield e, i\nend\nself\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the (absolute) largest element in this vector.","summary":"

Returns the (absolute) largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L589","def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, i|\n i.abs > acc.abs ? i : acc\nend"}},{"id":"max_index-instance-method","html_id":"max_index-instance-method","name":"max_index","doc":"Gets the index of the largest element in this vector.","summary":"

Gets the index of the largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L594","def":{"name":"max_index","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"idx = 0\neach_with_index do |e, i|\n idx = e.abs > self[idx].abs ? i : idx\nend\nidx\n"}},{"id":"multiply(value)-instance-method","html_id":"multiply(value)-instance-method","name":"multiply","doc":"When the input is a number, this returns the result of multiplying\nit to all vector elements. When it's a vector, the vectors\nwill be element-wise multiplied.","summary":"

When the input is a number, this returns the result of multiplying it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L502","def":{"name":"multiply","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a * b\nend"}},{"id":"parallel_to?(vector)-instance-method","html_id":"parallel_to?(vector)-instance-method","name":"parallel_to?","doc":"Returns whether the vectors are parallel to each other.","summary":"

Returns whether the vectors are parallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L469","def":{"name":"parallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\nangle <= Apatite.precision\n"}},{"id":"perpendicular_to?(vector)-instance-method","html_id":"perpendicular_to?(vector)-instance-method","name":"perpendicular_to?","doc":"Returns whether the vectors are perpendicular to each other.","summary":"

Returns whether the vectors are perpendicular to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L481","def":{"name":"perpendicular_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(dot(vector)).abs <= Apatite.precision"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L754","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"Vector{\", self, \"}\")"}},{"id":"product-instance-method","html_id":"product-instance-method","name":"product","doc":"Get the product of all elements in this vector.","summary":"

Get the product of all elements in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L567","def":{"name":"product","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, v|\n acc = acc * v\nend"}},{"id":"push(*values:Float64)-instance-method","html_id":"push(*values:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"args_string":"(*values : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L665","def":{"name":"push","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new_size = @size + values.size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\nvalues.each_with_index do |value, i|\n @buffer[@size + i] = value\nend\n@size = new_size\nself\n"}},{"id":"push(value:Float64)-instance-method","html_id":"push(value:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L658","def":{"name":"push","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"check_needs_resize\n@buffer[@size] = value\n@size = @size + 1\nself\n"}},{"id":"reflection_in(object)-instance-method","html_id":"reflection_in(object)-instance-method","name":"reflection_in","doc":"Returns the result of reflecting the point in the given `object`\n(point, line, or plane).","summary":"

Returns the result of reflecting the point in the given object (point, line, or plane).

","abstract":false,"args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(object)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L684","def":{"name":"reflection_in","args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n p = @elements.dup\n c = (object.point_closest_to(p)).elements\n return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))])\nend\nq = object.is_a?(Vector) ? object.elements : object\nif @elements.size == q.size\nelse\n return nil\nend\nmap_with_index do |x, i|\n q[i - 1] + (q[i - 1] - x)\nend\n"}},{"id":"rotate(t,object)-instance-method","html_id":"rotate(t,object)-instance-method","name":"rotate","doc":"Rotates the vector about the given `object`. The object should\nbe a point if the vector is 2D, and a line if it is 3D. Be\ncareful with line directions!","summary":"

Rotates the vector about the given object.

","abstract":false,"args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(t, object)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L678","def":{"name":"rotate","args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"round-instance-method","html_id":"round-instance-method","name":"round","doc":"Gets the result of rounding the elements of the vector.","summary":"

Gets the result of rounding the elements of the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L612","def":{"name":"round","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n x.round\nend"}},{"id":"set_elements(elements)-instance-method","html_id":"set_elements(elements)-instance-method","name":"set_elements","doc":null,"summary":null,"abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L726","def":{"name":"set_elements","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@elements = elements.is_a?(Vector) ? elements.elements : elements\nself\n"}},{"id":"sigmoid-instance-method","html_id":"sigmoid-instance-method","name":"sigmoid","doc":"Sums the numbers in the vector and returns a sigmoid value\nacross the whole vector.","summary":"

Sums the numbers in the vector and returns a sigmoid value across the whole vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L707","def":{"name":"sigmoid","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"LinearAlgebra.sigmoid(sum)"}},{"id":"size:Int32-instance-method","html_id":"size:Int32-instance-method","name":"size","doc":"Returns the number of elements in the vector","summary":"

Returns the number of elements in the vector

","abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L24","def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@size"}},{"id":"snap_to(value)-instance-method","html_id":"snap_to(value)-instance-method","name":"snap_to","doc":"Returns a copy of the vector with elements set to `value` if\nthey differ from it by less than `Apetite.precision`","summary":"

Returns a copy of the vector with elements set to value if they differ from it by less than Apetite.precision

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L623","def":{"name":"snap_to","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |y|\n (y - x).abs <= Apetite.precision ? value : y\nend"}},{"id":"subtract(value)-instance-method","html_id":"subtract(value)-instance-method","name":"subtract","doc":"When the input is a number, this returns the result of subtracting\nit to all vector elements. When it's a vector, the vectors\nwill be subtracted.","summary":"

When the input is a number, this returns the result of subtracting it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L495","def":{"name":"subtract","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a - b\nend"}},{"id":"sum-instance-method","html_id":"sum-instance-method","name":"sum","doc":"Returns the sum of all elements in the vector.","summary":"

Returns the sum of all elements in the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L507","def":{"name":"sum","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce(0) do |acc, i|\n acc + i\nend"}},{"id":"to_3d-instance-method","html_id":"to_3d-instance-method","name":"to_3d","doc":"Utility to make sure vectors are 3D. If they are 2D, a zero\nz-component is added.","summary":"

Utility to make sure vectors are 3D.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L713","def":{"name":"to_3d","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = dup\ncase v.elements.size\nwhen 3\n break\nwhen 2\n v.elements.push(0)\nelse\n return nil\nend\nreturn v\n"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L744","def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Float64).new(size) do |i|\n self[i]\nend"}},{"id":"to_diagonal_matrix-instance-method","html_id":"to_diagonal_matrix-instance-method","name":"to_diagonal_matrix","doc":"Returns a diagonal `Matrix` with the vectors elements as its\ndiagonal elements.","summary":"

Returns a diagonal Matrix with the vectors elements as its diagonal elements.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L607","def":{"name":"to_diagonal_matrix","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix::Diagonal.new(elements)"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L748","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"io << \"{\"\njoin(\", \", io, &.inspect(io))\nio << \"}\"\n"}},{"id":"to_unit_vector-instance-method","html_id":"to_unit_vector-instance-method","name":"to_unit_vector","doc":"Returns a new vector created by normalizing this one\nto have a magnitude of `1`. If the vector is a zero\nvector, it will not be modified.","summary":"

Returns a new vector created by normalizing this one to have a magnitude of 1.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L433","def":{"name":"to_unit_vector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"r = magnitude\nr == 0 ? dup : map do |x|\n x.to_f64 / r\nend\n"}},{"id":"to_unsafe:Pointer(Float64)-instance-method","html_id":"to_unsafe:Pointer(Float64)-instance-method","name":"to_unsafe","doc":"Returns a pointer to the internal buffer where `self`'s elements are stored.\n\nThis method is **unsafe** because it returns a pointer, and the pointed might eventually\nnot be that of `self` if the array grows and its internal buffer is reallocated.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.to_unsafe[0] # => 1.0\n```","summary":"

Returns a pointer to the internal buffer where self's elements are stored.

","abstract":false,"args":[],"args_string":" : Pointer(Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L772","def":{"name":"to_unsafe","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Pointer(Float64)","visibility":"Public","body":"@buffer"}},{"id":"top(n)-instance-method","html_id":"top(n)-instance-method","name":"top","doc":"Returns a vector containing only the first `n` elements.","summary":"

Returns a vector containing only the first n elements.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L548","def":{"name":"top","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i < n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":"Transpose this vector into a 1xn `Matrix`","summary":"

Transpose this vector into a 1xn Matrix

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L617","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.col_vector(self)"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L759","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}},{"id":"zero?-instance-method","html_id":"zero?-instance-method","name":"zero?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L788","def":{"name":"zero?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"all?(&.zero?)"}}],"macros":[],"types":[]}]}]},{"html_id":"github.com/watzon/apatite/Array","path":"Array.html","kind":"class","full_name":"Array(T)","name":"Array","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/core_ext/array.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"An `Array` is an ordered, integer-indexed collection of objects of type T.\n\nArray indexing starts at 0. A negative index is assumed to be\nrelative to the end of the array: -1 indicates the last element,\n-2 is the next to last element, and so on.\n\nAn `Array` can be created using the usual `new` method (several are provided), or with an array literal:\n\n```\nArray(Int32).new # => []\n[1, 2, 3] # Array(Int32)\n[1, \"hello\", 'x'] # Array(Int32 | String | Char)\n```\n\nAn `Array` can have mixed types, meaning T will be a union of types, but these are determined\nwhen the array is created, either by specifying T or by using an array literal. In the latter\ncase, T will be set to the union of the array literal elements' types.\n\nWhen creating an empty array you must always specify T:\n\n```\n[] of Int32 # same as Array(Int32)\n[] # syntax error\n```\n\nAn `Array` is implemented using an internal buffer of some capacity\nand is reallocated when elements are pushed to it when more capacity\nis needed. This is normally known as a [dynamic array](http://en.wikipedia.org/wiki/Dynamic_array).\n\nYou can use a special array literal syntax with other types too, as long as they define an argless\n`new` method and a `<<` method. `Set` is one such type:\n\n```\nset = Set{1, 2, 3} # => Set{1, 2, 3}\nset.class # => Set(Int32)\n```\n\nThe above is the same as this:\n\n```\nset = Set(typeof(1, 2, 3)).new\nset << 1\nset << 2\nset << 3\n```","summary":"

An Array is an ordered, integer-indexed collection of objects of type T.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"all?-instance-method","html_id":"all?-instance-method","name":"all?","doc":"Tests whether all elements evaluate to true","summary":"

Tests whether all elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L3","def":{"name":"all?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == false\n return false\n end\nend\ntrue\n"}},{"id":"any?-instance-method","html_id":"any?-instance-method","name":"any?","doc":"Tests whether any of the elements evaluate to true","summary":"

Tests whether any of the elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L11","def":{"name":"any?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == true\n return true\n end\nend\nfalse\n"}},{"id":"shape-instance-method","html_id":"shape-instance-method","name":"shape","doc":"Get the array's dimensions","summary":"

Get the array's dimensions

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L19","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"max = max_by do |i|\n i.is_a?(Array) ? i.size : i\nend\nmax.is_a?(Array) ? [size, max.size] : [max]\n"}},{"id":"to_vec-instance-method","html_id":"to_vec-instance-method","name":"to_vec","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L24","def":{"name":"to_vec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Apatite::Vector.create(self)"}}],"macros":[],"types":[]}]}} \ No newline at end of file diff --git a/docs/js/doc.js b/docs/js/doc.js new file mode 100644 index 0000000..8796e74 --- /dev/null +++ b/docs/js/doc.js @@ -0,0 +1,1019 @@ +window.CrystalDoc = (window.CrystalDoc || {}); + +CrystalDoc.base_path = (CrystalDoc.base_path || ""); + +CrystalDoc.searchIndex = (CrystalDoc.searchIndex || false); +CrystalDoc.MAX_RESULTS_DISPLAY = 140; + +CrystalDoc.runQuery = function(query) { + function searchType(type, query, results) { + var matches = []; + var matchedFields = []; + var name = type.full_name; + var i = name.lastIndexOf("::"); + if (i > 0) { + name = name.substring(i + 2); + } + var nameMatches = query.matches(name); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + + var namespaceMatches = query.matchesNamespace(type.full_name); + if(namespaceMatches){ + matches = matches.concat(namespaceMatches); + matchedFields.push("name"); + } + + var docMatches = query.matches(type.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + if (matches.length > 0) { + results.push({ + id: type.id, + result_type: "type", + kind: type.kind, + name: name, + full_name: type.full_name, + href: type.path, + summary: type.summary, + matched_fields: matchedFields, + matched_terms: matches + }); + } + + type.instance_methods.forEach(function(method) { + searchMethod(method, type, "instance_method", query, results); + }) + type.class_methods.forEach(function(method) { + searchMethod(method, type, "class_method", query, results); + }) + type.constructors.forEach(function(constructor) { + searchMethod(constructor, type, "constructor", query, results); + }) + type.macros.forEach(function(macro) { + searchMethod(macro, type, "macro", query, results); + }) + type.constants.forEach(function(constant){ + searchConstant(constant, type, query, results); + }); + + type.types.forEach(function(subtype){ + searchType(subtype, query, results); + }); + }; + + function searchMethod(method, type, kind, query, results) { + var matches = []; + var matchedFields = []; + var nameMatches = query.matchesMethod(method.name, kind, type); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + + method.args.forEach(function(arg){ + var argMatches = query.matches(arg.external_name); + if (argMatches) { + matches = matches.concat(argMatches); + matchedFields.push("args"); + } + }); + + var docMatches = query.matches(type.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + + if (matches.length > 0) { + var typeMatches = query.matches(type.full_name); + if (typeMatches) { + matchedFields.push("type"); + matches = matches.concat(typeMatches); + } + results.push({ + id: method.id, + type: type.full_name, + result_type: kind, + name: method.name, + full_name: type.full_name + "#" + method.name, + args_string: method.args_string, + summary: method.summary, + href: type.path + "#" + method.id, + matched_fields: matchedFields, + matched_terms: matches + }); + } + } + + function searchConstant(constant, type, query, results) { + var matches = []; + var matchedFields = []; + var nameMatches = query.matches(constant.name); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + var docMatches = query.matches(constant.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + if (matches.length > 0) { + var typeMatches = query.matches(type.full_name); + if (typeMatches) { + matchedFields.push("type"); + matches = matches.concat(typeMatches); + } + results.push({ + id: constant.id, + type: type.full_name, + result_type: "constant", + name: constant.name, + full_name: type.full_name + "#" + constant.name, + value: constant.value, + summary: constant.summary, + href: type.path + "#" + constant.id, + matched_fields: matchedFields, + matched_terms: matches + }); + } + } + + var results = []; + searchType(CrystalDoc.searchIndex.program, query, results); + return results; +}; + +CrystalDoc.rankResults = function(results, query) { + function uniqueArray(ar) { + var j = {}; + + ar.forEach(function(v) { + j[v + "::" + typeof v] = v; + }); + + return Object.keys(j).map(function(v) { + return j[v]; + }); + } + + results = results.sort(function(a, b) { + var matchedTermsDiff = uniqueArray(b.matched_terms).length - uniqueArray(a.matched_terms).length; + var aHasDocs = b.matched_fields.includes("doc"); + var bHasDocs = b.matched_fields.includes("doc"); + + var aOnlyDocs = aHasDocs && a.matched_fields.length == 1; + var bOnlyDocs = bHasDocs && b.matched_fields.length == 1; + + if (a.result_type == "type" && b.result_type != "type" && !aOnlyDocs) { + if(CrystalDoc.DEBUG) { console.log("a is type b not"); } + return -1; + } else if (b.result_type == "type" && a.result_type != "type" && !bOnlyDocs) { + if(CrystalDoc.DEBUG) { console.log("b is type, a not"); } + return 1; + } + if (a.matched_fields.includes("name")) { + if (b.matched_fields.includes("name")) { + var a_name = (CrystalDoc.prefixForType(a.result_type) || "") + ((a.result_type == "type") ? a.full_name : a.name); + var b_name = (CrystalDoc.prefixForType(b.result_type) || "") + ((b.result_type == "type") ? b.full_name : b.name); + a_name = a_name.toLowerCase(); + b_name = b_name.toLowerCase(); + for(var i = 0; i < query.normalizedTerms.length; i++) { + var term = query.terms[i].replace(/^::?|::?$/, ""); + var a_orig_index = a_name.indexOf(term); + var b_orig_index = b_name.indexOf(term); + if(CrystalDoc.DEBUG) { console.log("term: " + term + " a: " + a_name + " b: " + b_name); } + if(CrystalDoc.DEBUG) { console.log(a_orig_index, b_orig_index, a_orig_index - b_orig_index); } + if (a_orig_index >= 0) { + if (b_orig_index >= 0) { + if(CrystalDoc.DEBUG) { console.log("both have exact match", a_orig_index > b_orig_index ? -1 : 1); } + if(a_orig_index != b_orig_index) { + if(CrystalDoc.DEBUG) { console.log("both have exact match at different positions", a_orig_index > b_orig_index ? 1 : -1); } + return a_orig_index > b_orig_index ? 1 : -1; + } + } else { + if(CrystalDoc.DEBUG) { console.log("a has exact match, b not"); } + return -1; + } + } else if (b_orig_index >= 0) { + if(CrystalDoc.DEBUG) { console.log("b has exact match, a not"); } + return 1; + } + } + } else { + if(CrystalDoc.DEBUG) { console.log("a has match in name, b not"); } + return -1; + } + } else if ( + !a.matched_fields.includes("name") && + b.matched_fields.includes("name") + ) { + return 1; + } + + if (matchedTermsDiff != 0 || (aHasDocs != bHasDocs)) { + if(CrystalDoc.DEBUG) { console.log("matchedTermsDiff: " + matchedTermsDiff, aHasDocs, bHasDocs); } + return matchedTermsDiff; + } + + var matchedFieldsDiff = b.matched_fields.length - a.matched_fields.length; + if (matchedFieldsDiff != 0) { + if(CrystalDoc.DEBUG) { console.log("matched to different number of fields: " + matchedFieldsDiff); } + return matchedFieldsDiff > 0 ? 1 : -1; + } + + var nameCompare = a.name.localeCompare(b.name); + if(nameCompare != 0){ + if(CrystalDoc.DEBUG) { console.log("nameCompare resulted in: " + a.name + "<=>" + b.name + ": " + nameCompare); } + return nameCompare > 0 ? 1 : -1; + } + + if(a.matched_fields.includes("args") && b.matched_fields.includes("args")) { + for(var i = 0; i < query.terms.length; i++) { + var term = query.terms[i]; + var aIndex = a.args_string.indexOf(term); + var bIndex = b.args_string.indexOf(term); + if(CrystalDoc.DEBUG) { console.log("index of " + term + " in args_string: " + aIndex + " - " + bIndex); } + if(aIndex >= 0){ + if(bIndex >= 0){ + if(aIndex != bIndex){ + return aIndex > bIndex ? 1 : -1; + } + }else{ + return -1; + } + }else if(bIndex >= 0) { + return 1; + } + } + } + + return 0; + }); + + if (results.length > 1) { + // if we have more than two search terms, only include results with the most matches + var bestMatchedTerms = uniqueArray(results[0].matched_terms).length; + + results = results.filter(function(result) { + return uniqueArray(result.matched_terms).length + 1 >= bestMatchedTerms; + }); + } + return results; +}; + +CrystalDoc.prefixForType = function(type) { + switch (type) { + case "instance_method": + return "#"; + + case "class_method": + case "macro": + case "constructor": + return "."; + + default: + return false; + } +}; + +CrystalDoc.displaySearchResults = function(results, query) { + function sanitize(html){ + return html.replace(/<(?!\/?code)[^>]+>/g, ""); + } + + // limit results + if (results.length > CrystalDoc.MAX_RESULTS_DISPLAY) { + results = results.slice(0, CrystalDoc.MAX_RESULTS_DISPLAY); + } + + var $frag = document.createDocumentFragment(); + var $resultsElem = document.querySelector(".search-list"); + $resultsElem.innerHTML = ""; + + results.forEach(function(result, i) { + var url = CrystalDoc.base_path + result.href; + var type = false; + + var title = query.highlight(result.result_type == "type" ? result.full_name : result.name); + + var prefix = CrystalDoc.prefixForType(result.result_type); + if (prefix) { + title = "" + prefix + "" + title; + } + + title = "" + title + ""; + + if (result.args_string) { + title += + "" + query.highlight(result.args_string) + ""; + } + + $elem = document.createElement("li"); + $elem.className = "search-result search-result--" + result.result_type; + $elem.dataset.href = url; + $elem.setAttribute("title", result.full_name + " docs page"); + + var $title = document.createElement("div"); + $title.setAttribute("class", "search-result__title"); + var $titleLink = document.createElement("a"); + $titleLink.setAttribute("href", url); + + $titleLink.innerHTML = title; + $title.appendChild($titleLink); + $elem.appendChild($title); + $elem.addEventListener("click", function() { + $titleLink.click(); + }); + + if (result.result_type !== "type") { + var $type = document.createElement("div"); + $type.setAttribute("class", "search-result__type"); + $type.innerHTML = query.highlight(result.type); + $elem.appendChild($type); + } + + if(result.summary){ + var $doc = document.createElement("div"); + $doc.setAttribute("class", "search-result__doc"); + $doc.innerHTML = query.highlight(sanitize(result.summary)); + $elem.appendChild($doc); + } + + $elem.appendChild(document.createComment(JSON.stringify(result))); + $frag.appendChild($elem); + }); + + $resultsElem.appendChild($frag); + + CrystalDoc.toggleResultsList(true); +}; + +CrystalDoc.toggleResultsList = function(visible) { + if (visible) { + document.querySelector(".types-list").classList.add("hidden"); + document.querySelector(".search-results").classList.remove("hidden"); + } else { + document.querySelector(".types-list").classList.remove("hidden"); + document.querySelector(".search-results").classList.add("hidden"); + } +}; + +CrystalDoc.Query = function(string) { + this.original = string; + this.terms = string.split(/\s+/).filter(function(word) { + return CrystalDoc.Query.stripModifiers(word).length > 0; + }); + + var normalized = this.terms.map(CrystalDoc.Query.normalizeTerm); + this.normalizedTerms = normalized; + + function runMatcher(field, matcher) { + if (!field) { + return false; + } + var normalizedValue = CrystalDoc.Query.normalizeTerm(field); + + var matches = []; + normalized.forEach(function(term) { + if (matcher(normalizedValue, term)) { + matches.push(term); + } + }); + return matches.length > 0 ? matches : false; + } + + this.matches = function(field) { + return runMatcher(field, function(normalized, term) { + if (term[0] == "#" || term[0] == ".") { + return false; + } + return normalized.indexOf(term) >= 0; + }); + }; + + function namespaceMatcher(normalized, term){ + var i = term.indexOf(":"); + if(i >= 0){ + term = term.replace(/^::?|::?$/, ""); + var index = normalized.indexOf(term); + if((index == 0) || (index > 0 && normalized[index-1] == ":")){ + return true; + } + } + return false; + } + this.matchesMethod = function(name, kind, type) { + return runMatcher(name, function(normalized, term) { + var i = term.indexOf("#"); + if(i >= 0){ + if (kind != "instance_method") { + return false; + } + }else{ + i = term.indexOf("."); + if(i >= 0){ + if (kind != "class_method" && kind != "macro" && kind != "constructor") { + return false; + } + }else{ + //neither # nor . + if(term.indexOf(":") && namespaceMatcher(normalized, term)){ + return true; + } + } + } + + var methodName = term; + if(i >= 0){ + var termType = term.substring(0, i); + methodName = term.substring(i+1); + + if(termType != "") { + if(CrystalDoc.Query.normalizeTerm(type.full_name).indexOf(termType) < 0){ + return false; + } + } + } + return normalized.indexOf(methodName) >= 0; + }); + }; + + this.matchesNamespace = function(namespace){ + return runMatcher(namespace, namespaceMatcher); + }; + + this.highlight = function(string) { + if (typeof string == "undefined") { + return ""; + } + function escapeRegExp(s) { + return s.replace(/[.*+?\^${}()|\[\]\\]/g, "\\$&").replace(/^[#\.:]+/, ""); + } + return string.replace( + new RegExp("(" + this.normalizedTerms.map(escapeRegExp).join("|") + ")", "gi"), + "$1" + ); + }; +}; +CrystalDoc.Query.normalizeTerm = function(term) { + return term.toLowerCase(); +}; +CrystalDoc.Query.stripModifiers = function(term) { + switch (term[0]) { + case "#": + case ".": + case ":": + return term.substr(1); + + default: + return term; + } +} + +CrystalDoc.search = function(string) { + if(!CrystalDoc.searchIndex) { + console.log("CrystalDoc search index not initialized, delaying search"); + + document.addEventListener("CrystalDoc:loaded", function listener(){ + document.removeEventListener("CrystalDoc:loaded", listener); + CrystalDoc.search(string); + }); + return; + } + + document.dispatchEvent(new Event("CrystalDoc:searchStarted")); + + var query = new CrystalDoc.Query(string); + var results = CrystalDoc.runQuery(query); + results = CrystalDoc.rankResults(results, query); + CrystalDoc.displaySearchResults(results, query); + + document.dispatchEvent(new Event("CrystalDoc:searchPerformed")); +}; + +CrystalDoc.initializeIndex = function(data) { + CrystalDoc.searchIndex = data; + + document.dispatchEvent(new Event("CrystalDoc:loaded")); +}; + +CrystalDoc.loadIndex = function() { + function loadJSON(file, callback) { + var xobj = new XMLHttpRequest(); + xobj.overrideMimeType("application/json"); + xobj.open("GET", file, true); + xobj.onreadystatechange = function() { + if (xobj.readyState == 4 && xobj.status == "200") { + callback(xobj.responseText); + } + }; + xobj.send(null); + } + + function loadScript(file) { + script = document.createElement("script"); + script.src = file; + document.body.appendChild(script); + } + + function parseJSON(json) { + CrystalDoc.initializeIndex(JSON.parse(json)); + } + + for(var i = 0; i < document.scripts.length; i++){ + var script = document.scripts[i]; + if (script.src && script.src.indexOf("js/doc.js") >= 0) { + if (script.src.indexOf("file://") == 0) { + // We need to support JSONP files for the search to work on local file system. + var jsonPath = script.src.replace("js/doc.js", "search-index.js"); + loadScript(jsonPath); + return; + } else { + var jsonPath = script.src.replace("js/doc.js", "index.json"); + loadJSON(jsonPath, parseJSON); + return; + } + } + } + console.error("Could not find location of js/doc.js"); +}; + +// Callback for jsonp +function crystal_doc_search_index_callback(data) { + CrystalDoc.initializeIndex(data); +} + +Navigator = function(sidebar, searchInput, list, leaveSearchScope){ + this.list = list; + var self = this; + + var performingSearch = false; + + document.addEventListener('CrystalDoc:searchStarted', function(){ + performingSearch = true; + }); + document.addEventListener('CrystalDoc:searchDebounceStarted', function(){ + performingSearch = true; + }); + document.addEventListener('CrystalDoc:searchPerformed', function(){ + performingSearch = false; + }); + document.addEventListener('CrystalDoc:searchDebounceStopped', function(event){ + performingSearch = false; + }); + + function delayWhileSearching(callback) { + if(performingSearch){ + document.addEventListener('CrystalDoc:searchPerformed', function listener(){ + document.removeEventListener('CrystalDoc:searchPerformed', listener); + + // add some delay to let search results display kick in + setTimeout(callback, 100); + }); + }else{ + callback(); + } + } + + function clearMoveTimeout() { + clearTimeout(self.moveTimeout); + self.moveTimeout = null; + } + + function startMoveTimeout(upwards){ + /*if(self.moveTimeout) { + clearMoveTimeout(); + } + + var go = function() { + if (!self.moveTimeout) return; + self.move(upwards); + self.moveTimout = setTimeout(go, 600); + }; + self.moveTimeout = setTimeout(go, 800);*/ + } + + function scrollCenter(element) { + var rect = element.getBoundingClientRect(); + var middle = sidebar.clientHeight / 2; + sidebar.scrollTop += rect.top + rect.height / 2 - middle; + } + + var move = this.move = function(upwards){ + if(!this.current){ + this.highlightFirst(); + return true; + } + var next = upwards ? this.current.previousElementSibling : this.current.nextElementSibling; + if(next && next.classList) { + this.highlight(next); + scrollCenter(next); + return true; + } + return false; + }; + + this.moveRight = function(){ + }; + this.moveLeft = function(){ + }; + + this.highlight = function(elem) { + if(!elem){ + return; + } + this.removeHighlight(); + + this.current = elem; + this.current.classList.add("current"); + }; + + this.highlightFirst = function(){ + this.highlight(this.list.querySelector('li:first-child')); + }; + + this.removeHighlight = function() { + if(this.current){ + this.current.classList.remove("current"); + } + this.current = null; + } + + this.openSelectedResult = function() { + if(this.current) { + this.current.click(); + } + } + + this.focus = function() { + searchInput.focus(); + searchInput.select(); + this.highlightFirst(); + } + + function handleKeyUp(event) { + switch(event.key) { + case "ArrowUp": + case "ArrowDown": + case "i": + case "j": + case "k": + case "l": + case "c": + case "h": + case "t": + case "n": + event.stopPropagation(); + clearMoveTimeout(); + } + } + + function handleKeyDown(event) { + switch(event.key) { + case "Enter": + event.stopPropagation(); + event.preventDefault(); + leaveSearchScope(); + self.openSelectedResult(); + break; + case "Escape": + event.stopPropagation(); + event.preventDefault(); + leaveSearchScope(); + break; + case "j": + case "c": + case "ArrowUp": + if(event.ctrlKey || event.key == "ArrowUp") { + event.stopPropagation(); + self.move(true); + startMoveTimeout(true); + } + break; + case "k": + case "h": + case "ArrowDown": + if(event.ctrlKey || event.key == "ArrowDown") { + event.stopPropagation(); + self.move(false); + startMoveTimeout(false); + } + break; + case "k": + case "t": + case "ArrowLeft": + if(event.ctrlKey || event.key == "ArrowLeft") { + event.stopPropagation(); + self.moveLeft(); + } + break; + case "l": + case "n": + case "ArrowRight": + if(event.ctrlKey || event.key == "ArrowRight") { + event.stopPropagation(); + self.moveRight(); + } + break; + } + } + + function handleInputKeyUp(event) { + switch(event.key) { + case "ArrowUp": + case "ArrowDown": + event.stopPropagation(); + event.preventDefault(); + clearMoveTimeout(); + } + } + + function handleInputKeyDown(event) { + switch(event.key) { + case "Enter": + event.stopPropagation(); + event.preventDefault(); + delayWhileSearching(function(){ + self.openSelectedResult(); + leaveSearchScope(); + }); + break; + case "Escape": + event.stopPropagation(); + event.preventDefault(); + // remove focus from search input + leaveSearchScope(); + sidebar.focus(); + break; + case "ArrowUp": + event.stopPropagation(); + event.preventDefault(); + self.move(true); + startMoveTimeout(true); + break; + + case "ArrowDown": + event.stopPropagation(); + event.preventDefault(); + self.move(false); + startMoveTimeout(false); + break; + } + } + + sidebar.tabIndex = 100; // set tabIndex to enable keylistener + sidebar.addEventListener('keyup', function(event) { + handleKeyUp(event); + }); + sidebar.addEventListener('keydown', function(event) { + handleKeyDown(event); + }); + searchInput.addEventListener('keydown', function(event) { + handleInputKeyDown(event); + }); + searchInput.addEventListener('keyup', function(event) { + handleInputKeyUp(event); + }); + this.move(); +}; + +var UsageModal = function(title, content) { + var $body = document.body; + var self = this; + var $modalBackground = document.createElement("div"); + $modalBackground.classList.add("modal-background"); + var $usageModal = document.createElement("div"); + $usageModal.classList.add("usage-modal"); + $modalBackground.appendChild($usageModal); + var $title = document.createElement("h3"); + $title.classList.add("modal-title"); + $title.innerHTML = title + $usageModal.appendChild($title); + var $closeButton = document.createElement("span"); + $closeButton.classList.add("close-button"); + $closeButton.setAttribute("title", "Close modal"); + $closeButton.innerText = '×'; + $usageModal.appendChild($closeButton); + $usageModal.insertAdjacentHTML("beforeend", content); + + $modalBackground.addEventListener('click', function(event) { + var element = event.target || event.srcElement; + + if(element == $modalBackground) { + self.hide(); + } + }); + $closeButton.addEventListener('click', function(event) { + self.hide(); + }); + + $body.insertAdjacentElement('beforeend', $modalBackground); + + this.show = function(){ + $body.classList.add("js-modal-visible"); + }; + this.hide = function(){ + $body.classList.remove("js-modal-visible"); + }; + this.isVisible = function(){ + return $body.classList.contains("js-modal-visible"); + } +} + + +document.addEventListener('DOMContentLoaded', function() { + var sessionStorage; + try { + sessionStorage = window.sessionStorage; + } catch (e) { } + if(!sessionStorage) { + sessionStorage = { + setItem: function() {}, + getItem: function() {}, + removeItem: function() {} + }; + } + + var repositoryName = document.querySelector('#repository-name').getAttribute('content'); + var typesList = document.querySelector('.types-list'); + var searchInput = document.querySelector('.search-input'); + var parents = document.querySelectorAll('.types-list li.parent'); + + var scrollSidebarToOpenType = function(){ + var openTypes = typesList.querySelectorAll('.current'); + if (openTypes.length > 0) { + var lastOpenType = openTypes[openTypes.length - 1]; + lastOpenType.scrollIntoView(); + } + } + + scrollSidebarToOpenType(); + + var setPersistentSearchQuery = function(value){ + sessionStorage.setItem(repositoryName + '::search-input:value', value); + } + + for(var i = 0; i < parents.length; i++) { + var _parent = parents[i]; + _parent.addEventListener('click', function(e) { + e.stopPropagation(); + + if(e.target.tagName.toLowerCase() == 'li') { + if(e.target.className.match(/open/)) { + sessionStorage.removeItem(e.target.getAttribute('data-id')); + e.target.className = e.target.className.replace(/ +open/g, ''); + } else { + sessionStorage.setItem(e.target.getAttribute('data-id'), '1'); + if(e.target.className.indexOf('open') == -1) { + e.target.className += ' open'; + } + } + } + }); + + if(sessionStorage.getItem(_parent.getAttribute('data-id')) == '1') { + _parent.className += ' open'; + } + } + + var leaveSearchScope = function(){ + CrystalDoc.toggleResultsList(false); + window.focus(); + } + + var navigator = new Navigator(document.querySelector('.types-list'), searchInput, document.querySelector(".search-results"), leaveSearchScope); + + CrystalDoc.loadIndex(); + var searchTimeout; + var lastSearchText = false; + var performSearch = function() { + document.dispatchEvent(new Event("CrystalDoc:searchDebounceStarted")); + + clearTimeout(searchTimeout); + searchTimeout = setTimeout(function() { + var text = searchInput.value; + + if(text == "") { + CrystalDoc.toggleResultsList(false); + }else if(text == lastSearchText){ + document.dispatchEvent(new Event("CrystalDoc:searchDebounceStopped")); + }else{ + CrystalDoc.search(text); + navigator.highlightFirst(); + searchInput.focus(); + } + lastSearchText = text; + setPersistentSearchQuery(text); + }, 200); + }; + + if(location.hash.length > 3 && location.hash.substring(0,3) == "#q="){ + // allows directly linking a search query which is then executed on the client + // this comes handy for establishing a custom browser search engine with https://crystal-lang.org/api/#q=%s as a search URL + // TODO: Add OpenSearch description + var searchQuery = location.hash.substring(3); + history.pushState({searchQuery: searchQuery}, "Search for " + searchQuery, location.href.replace(/#q=.*/, "")); + searchInput.value = searchQuery; + document.addEventListener('CrystalDoc:loaded', performSearch); + } + + if (searchInput.value.length == 0) { + var searchText = sessionStorage.getItem(repositoryName + '::search-input:value'); + if(searchText){ + searchInput.value = searchText; + } + } + searchInput.addEventListener('keyup', performSearch); + searchInput.addEventListener('input', performSearch); + + var usageModal = new UsageModal('Keyboard Shortcuts', '' + + '' + ); + + function handleShortkeys(event) { + var element = event.target || event.srcElement; + + if(element.tagName == "INPUT" || element.tagName == "TEXTAREA" || element.parentElement.tagName == "TEXTAREA"){ + return; + } + + switch(event.key) { + case "?": + usageModal.show(); + break; + + case "Escape": + usageModal.hide(); + break; + + case "s": + case "/": + if(usageModal.isVisible()) { + return; + } + event.stopPropagation(); + navigator.focus(); + performSearch(); + break; + } + } + + document.addEventListener('keyup', handleShortkeys); + + var scrollToEntryFromLocationHash = function() { + var hash = window.location.hash; + if (hash) { + var targetAnchor = unescape(hash.substr(1)); + var targetEl = document.querySelectorAll('.entry-detail[id="' + targetAnchor + '"]'); + + if (targetEl && targetEl.length > 0) { + targetEl[0].offsetParent.scrollTop = targetEl[0].offsetTop; + } + } + }; + window.addEventListener("hashchange", scrollToEntryFromLocationHash, false); + scrollToEntryFromLocationHash(); +}); diff --git a/docs/search-index.js b/docs/search-index.js new file mode 100644 index 0000000..0bc4c10 --- /dev/null +++ b/docs/search-index.js @@ -0,0 +1 @@ +crystal_doc_search_index_callback({"repository_name":"github.com/watzon/apatite","body":"# Apatite\n\nApatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n apatite:\n github: watzon/apatite\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"apatite\"\n```\n\nTODO: Write usage instructions here, but first write the library...\n\n## Roadmap\n\n- [ ] Apetite\n\t- [ ] Vector Math\n\t\t- [ ] Matrix\n\t\t- [ ] NDArray\n\t\t- [x] Vector\n\t\t- [ ] Line\n\t\t- [ ] Plane\n\t\t- [ ] Polygon\n\t\t- [ ] LinkedList\n\t\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Chris Watson](https://github.com/watzon) - creator and maintainer","program":{"html_id":"github.com/watzon/apatite/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/watzon/apatite","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite","path":"Apatite.html","kind":"module","full_name":"Apatite","name":"Apatite","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra.cr","line_number":5,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr"},{"filename":"apatite.cr","line_number":10,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr"},{"filename":"apatite/version.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/version.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector::I","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector::J","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector::K","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"subclasses":[],"including_types":[],"namespace":null,"doc":"Apatite is a fundimental package for scientific computing in Crystal. If that\nsounds like a modified version of the first line from the NumPy homepage,\nthat's because it is. Apatite has (ok, will have) all of the goodness\nof NumPy sitting atop the blazing speed and beautiful syntax\nof Crystal.","summary":"

Apatite is a fundimental package for scientific computing in Crystal.

","class_methods":[{"id":"approx_precision-class-method","html_id":"approx_precision-class-method","name":"approx_precision","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L17","def":{"name":"approx_precision","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@approx_precision"}},{"id":"approx_precision=(approx_precision)-class-method","html_id":"approx_precision=(approx_precision)-class-method","name":"approx_precision=","doc":null,"summary":null,"abstract":false,"args":[{"name":"approx_precision","doc":null,"default_value":"","external_name":"approx_precision","restriction":""}],"args_string":"(approx_precision)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L21","def":{"name":"approx_precision=","args":[{"name":"approx_precision","doc":null,"default_value":"","external_name":"approx_precision","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@approx_precision = approx_precision"}},{"id":"precision-class-method","html_id":"precision-class-method","name":"precision","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L16","def":{"name":"precision","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@precision"}},{"id":"precision=(precision)-class-method","html_id":"precision=(precision)-class-method","name":"precision=","doc":null,"summary":null,"abstract":false,"args":[{"name":"precision","doc":null,"default_value":"","external_name":"precision","restriction":""}],"args_string":"(precision)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L20","def":{"name":"precision=","args":[{"name":"precision","doc":null,"default_value":"","external_name":"precision","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@@precision = precision"}}],"constructors":[],"instance_methods":[{"id":"as_vector(input:Indexable)-instance-method","html_id":"as_vector(input:Indexable)-instance-method","name":"as_vector","doc":"Creates a new vector from the given `input`. Input can be any\n`Indexable` type.","summary":"

Creates a new vector from the given input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"args_string":"(input : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L58","def":{"name":"as_vector","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(input)"}},{"id":"basis(size,index)-instance-method","html_id":"basis(size,index)-instance-method","name":"basis","doc":"Returns a standard basis-n vector of the given `size` and `index`.","summary":"

Returns a standard basis-n vector of the given size and index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L63","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.basis(size, index)"}},{"id":"empty-instance-method","html_id":"empty-instance-method","name":"empty","doc":"Returns a new empty `Vector`","summary":"

Returns a new empty Vector

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L31","def":{"name":"empty","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new"}},{"id":"full(n,i)-instance-method","html_id":"full(n,i)-instance-method","name":"full","doc":"Returns a new vector of size `n` filled with `i`","summary":"

Returns a new vector of size n filled with i

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(n, i)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L46","def":{"name":"full","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, i)"}},{"id":"ones(n)-instance-method","html_id":"ones(n)-instance-method","name":"ones","doc":"Returns a new vector filled with `n` ones.","summary":"

Returns a new vector filled with n ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L36","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1)"}},{"id":"vector(n,&block)-instance-method","html_id":"vector(n,&block)-instance-method","name":"vector","doc":"Creates a new vector of size `n`, and invokes the block once\nfor each index of `self`, assigning the block's value in that index.","summary":"

Creates a new vector of size n, and invokes the block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L52","def":{"name":"vector","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n) do |i|\n yield i\nend"}},{"id":"zeros(n)-instance-method","html_id":"zeros(n)-instance-method","name":"zeros","doc":"Returns a new vector filled with `n` zeros.","summary":"

Returns a new vector filled with n zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite.cr#L41","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0)"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","path":"Apatite/LinearAlgebra.html","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra/vector.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr"},{"filename":"apatite/linear_algebra/matrix.cr","line_number":3,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr"},{"filename":"apatite/linear_algebra.cr","line_number":6,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"subclasses":[],"including_types":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"namespace":{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"sigmoid(input:Number)-instance-method","html_id":"sigmoid(input:Number)-instance-method","name":"sigmoid","doc":"Calculates the sigmoid curve for a numeric input.\n\nf(x) = 1/(1 + e^-x)\n\nSee also: [Sigmoid function [WikiWand]](https://www.wikiwand.com/en/Sigmoid_function)","summary":"

Calculates the sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr#L14","def":{"name":"sigmoid","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\n1 / (1 + (Math.exp(-num)))\n"}},{"id":"sigmoid_d(input:Number)-instance-method","html_id":"sigmoid_d(input:Number)-instance-method","name":"sigmoid_d","doc":"Calculates the derivative sigmoid curve for a numeric input.\n\nf'(x) = f(x)(1 - f(x)),","summary":"

Calculates the derivative sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra.cr#L22","def":{"name":"sigmoid_d","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\nnum * (1 - num)\n"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix","path":"Apatite/LinearAlgebra/Matrix.html","kind":"class","full_name":"Apatite::LinearAlgebra::Matrix","name":"Matrix","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/matrix.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[{"id":"[](*rows)-class-method","html_id":"[](*rows)-class-method","name":"[]","doc":"Creates a matrix where each argument is a row.","summary":"

Creates a matrix where each argument is a row.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(*rows)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L22","def":{"name":"[]","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows(rows)"}},{"id":"build(row_count,column_count=row_count,&block)-class-method","html_id":"build(row_count,column_count=row_count,&block)-class-method","name":"build","doc":"Creates a matrix of size `row_count x column_count`. It fills the values by calling\nthe given block, passing the current row and column.","summary":"

Creates a matrix of size row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L28","def":{"name":"build","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count < 0 || column_count < 0\n raise(ArgumentError.new)\nend\nrows = Array.new(row_count) do |i|\n Vector.new(column_count) do |j|\n yield i, j\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"col_vector(column)-class-method","html_id":"col_vector(column)-class-method","name":"col_vector","doc":"Creates a single-column matrix where the values of that column are as given in column.","summary":"

Creates a single-column matrix where the values of that column are as given in column.

","abstract":false,"args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(column)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L39","def":{"name":"col_vector","args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([column].transpose, 1)"}},{"id":"columns(columns)-class-method","html_id":"columns(columns)-class-method","name":"columns","doc":"Creates a matrix using `columns` as an array of column vectors.","summary":"

Creates a matrix using .columns as an array of column vectors.

","abstract":false,"args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"args_string":"(columns)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L44","def":{"name":"columns","args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(rows(columns)).transpose"}},{"id":"diagonal(values)-class-method","html_id":"diagonal(values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L70","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = values.size\nif size == 0\n return Matrix.empty\nend\nrows = Array.new(size) do |j|\n row = Array.new(size, 0)\n row[j] = values[j]\n row\nend\nnew(rows)\n"}},{"id":"diagonal(*values)-class-method","html_id":"diagonal(*values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(*values)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L84","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty(row_count=0,column_count=0)-class-method","html_id":"empty(row_count=0,column_count=0)-class-method","name":"empty","doc":"Creates a empty matrix of `row_count x column_count`. At least one of\n`row_count` or `column_count` must be 0.","summary":"

Creates a empty matrix of row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L90","def":{"name":"empty","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (column_count != 0) && (row_count != 0)\n raise(ArgumentError.new(\"One size must be 0\"))\nend\nif column_count < 0 || row_count < 0\n raise(ArgumentError.new(\"Negative size\"))\nend\nMatrix.new(([] of Vector) * row_count, column_count)\n"}},{"id":"hstack(x,*matrices)-class-method","html_id":"hstack(x,*matrices)-class-method","name":"hstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"args_string":"(x, *matrices)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L97","def":{"name":"hstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"identity(n)-class-method","html_id":"identity(n)-class-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L101","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"scalar(n, 1)"}},{"id":"row_vector(row)-class-method","html_id":"row_vector(row)-class-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in #row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L106","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([row], 0)"}},{"id":"rows(rows)-class-method","html_id":"rows(rows)-class-method","name":"rows","doc":"Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.","summary":"

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(rows)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L111","def":{"name":"rows","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = rows[0]? ? rows[0].size : 0\nrows.each do |row|\n if row.size == size\n else\n raise(\"Dimension mismatch: row size differs (#{row.size} should be #{size})\")\n end\nend\nMatrix.new(rows, size)\n"}},{"id":"scalar(n,value)-class-method","html_id":"scalar(n,value)-class-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L120","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(Array.new(n, value))"}},{"id":"vstack(x,y)-class-method","html_id":"vstack(x,y)-class-method","name":"vstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"args_string":"(x, y)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L125","def":{"name":"vstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"zero(row_count,column_count=row_count)-class-method","html_id":"zero(row_count,column_count=row_count)-class-method","name":"zero","doc":"Creates a zero matrix.","summary":"

Creates a zero matrix.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L129","def":{"name":"zero","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = Array.new(row_count) do\n Vector.new(column_count)\nend\nMatrix.new(rows, column_count)\n"}}],"constructors":[{"id":"new(rows,column_count:Int32=rows[0].size)-class-method","html_id":"new(rows,column_count:Int32=rows[0].size)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"rows[0].size","external_name":"column_count","restriction":"Int32"}],"args_string":"(rows, column_count : Int32 = rows[0].size)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L15","def":{"name":"new","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"rows[0].size","external_name":"column_count","restriction":"Int32"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows, column_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"*(other:Matrix)-instance-method","html_id":"*(other:Matrix)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L134","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n (0...column_count).reduce(0.0) do |vij, k|\n vij + (self[i, k] * other[k, j])\n end\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"*(int:Int)-instance-method","html_id":"*(int:Int)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"args_string":"(int : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L148","def":{"name":"*","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e * int\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"*(ind:Indexable)-instance-method","html_id":"*(ind:Indexable)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"args_string":"(ind : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L155","def":{"name":"*","args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"m = column_vector\nr = self * m\nr.column(0)\n"}},{"id":"**(int)-instance-method","html_id":"**(int)-instance-method","name":"**","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"args_string":"(int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L161","def":{"name":"**","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if int >= 1\nelse\n raise(\"Number can not the less than 1\")\nend\nmat = self\n(int - 1).times do\n mat = mat * self\nend\nmat\n"}},{"id":"+(other:Matrix)-instance-method","html_id":"+(other:Matrix)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L170","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] + other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"+(vec:Indexable)-instance-method","html_id":"+(vec:Indexable)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L182","def":{"name":"+","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(vec:Indexable)-instance-method","html_id":"-(vec:Indexable)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L199","def":{"name":"-","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(other:Matrix)-instance-method","html_id":"-(other:Matrix)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L187","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] - other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"/(other:Matrix)-instance-method","html_id":"/(other:Matrix)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L204","def":{"name":"/","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self * other.inverse"}},{"id":"/(vec:Indexable)-instance-method","html_id":"/(vec:Indexable)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L208","def":{"name":"/","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e / other\n end\nend\nreturn new_matrix(rows, column_count)\n"}},{"id":"==(other:Matrix)-instance-method","html_id":"==(other:Matrix)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L215","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (Matrix === other) && (column_count == other.column_count)\nelse\n return false\nend\nrows == other.rows\n"}},{"id":"[](row:Int,col:Int)-instance-method","html_id":"[](row:Int,col:Int)-instance-method","name":"[]","doc":"Returns element `(row, col)` of the matrix. Throws error on index error.","summary":"

Returns element (row, col) of the matrix.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L222","def":{"name":"[]","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[row][col]"}},{"id":"[]?(row:Int,col:Int)-instance-method","html_id":"[]?(row:Int,col:Int)-instance-method","name":"[]?","doc":"Returns element `(row, col)` of the matrix, or nil if the index is not found.","summary":"

Returns element (row, col) of the matrix, or nil if the index is not found.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L227","def":{"name":"[]?","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = fetch(row) do\n nil\nend\nif v.nil?\nelse\n v[col]?\nend\n"}},{"id":"adjugate-instance-method","html_id":"adjugate-instance-method","name":"adjugate","doc":"Returns the adjugate of the matrix.","summary":"

Returns the adjugate of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L233","def":{"name":"adjugate","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#adjugate` requires a square matrix.\")\nend\nMatrix.build(row_count, column_count) do |row, column|\n cofactor(column, row)\nend\n"}},{"id":"cofactor(row,column)-instance-method","html_id":"cofactor(row,column)-instance-method","name":"cofactor","doc":"Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)","summary":"

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L241","def":{"name":"cofactor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"cofactor of empty matrix is not defined\")\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#cofactor` requires a square matrix.\")\nend\ndet_of_minor = (first_minor(row, column)).determinant\ndet_of_minor * ((-1.0) ** (row + column))\n"}},{"id":"column(j,&block)-instance-method","html_id":"column(j,&block)-instance-method","name":"column","doc":"Iterates over the specified column in the matrix, returning the Vector's items.","summary":"

Iterates over the specified column in the matrix, returning the Vector's items.

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L268","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return self\nend\nrow_count.times do |i|\n yield rows[i][j]\nend\nself\n"}},{"id":"column(j)-instance-method","html_id":"column(j)-instance-method","name":"column","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L259","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n raise(\"Index out of range\")\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column?(j)-instance-method","html_id":"column?(j)-instance-method","name":"column?","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L250","def":{"name":"column?","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return nil\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L11","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@column_count"}},{"id":"column_vectors-instance-method","html_id":"column_vectors-instance-method","name":"column_vectors","doc":"Returns an array of the column vectors of the matrix. See `Vector`.","summary":"

Returns an array of the column vectors of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L277","def":{"name":"column_vectors","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Vector).new(column_count) do |i|\n column(i)\nend"}},{"id":"determinant-instance-method","html_id":"determinant-instance-method","name":"determinant","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L348","def":{"name":"determinant","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nm = rows\ncase row_count\nwhen 0\n +1\nwhen 1\n +m[0][0]\nwhen 2\n ((+m[0][0]) * m[1][1]) - (m[0][1] * m[1][0])\nwhen 3\n m0, m1, m2 = m\n (((((((+m0[0]) * m1[1]) * m2[2]) - ((m0[0] * m1[2]) * m2[1])) - ((m0[1] * m1[0]) * m2[2])) + ((m0[1] * m1[2]) * m2[0])) + ((m0[2] * m1[0]) * m2[1])) - ((m0[2] * m1[1]) * m2[0])\nwhen 4\n m0, m1, m2, m3 = m\n ((((((((((((((((((((((((((+m0[0]) * m1[1]) * m2[2]) * m3[3]) - (((m0[0] * m1[1]) * m2[3]) * m3[2])) - (((m0[0] * m1[2]) * m2[1]) * m3[3])) + (((m0[0] * m1[2]) * m2[3]) * m3[1])) + (((m0[0] * m1[3]) * m2[1]) * m3[2])) - (((m0[0] * m1[3]) * m2[2]) * m3[1])) - (((m0[1] * m1[0]) * m2[2]) * m3[3])) + (((m0[1] * m1[0]) * m2[3]) * m3[2])) + (((m0[1] * m1[2]) * m2[0]) * m3[3])) - (((m0[1] * m1[2]) * m2[3]) * m3[0])) - (((m0[1] * m1[3]) * m2[0]) * m3[2])) + (((m0[1] * m1[3]) * m2[2]) * m3[0])) + (((m0[2] * m1[0]) * m2[1]) * m3[3])) - (((m0[2] * m1[0]) * m2[3]) * m3[1])) - (((m0[2] * m1[1]) * m2[0]) * m3[3])) + (((m0[2] * m1[1]) * m2[3]) * m3[0])) + (((m0[2] * m1[3]) * m2[0]) * m3[1])) - (((m0[2] * m1[3]) * m2[1]) * m3[0])) - (((m0[3] * m1[0]) * m2[1]) * m3[2])) + (((m0[3] * m1[0]) * m2[2]) * m3[1])) + (((m0[3] * m1[1]) * m2[0]) * m3[2])) - (((m0[3] * m1[1]) * m2[2]) * m3[0])) - (((m0[3] * m1[2]) * m2[0]) * m3[1])) + (((m0[3] * m1[2]) * m2[1]) * m3[0])\nelse\n determinant_bareiss\nend\n"}},{"id":"first_minor(row,column)-instance-method","html_id":"first_minor(row,column)-instance-method","name":"first_minor","doc":null,"summary":null,"abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L423","def":{"name":"first_minor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"first_minor of empty matrix is not defined\")\nend\nif 0 <= row && row < row_count\nelse\n raise(ArgumentError.new(\"invalid row (#{row.inspect} for 0..#{row_count - 1})\"))\nend\nif 0 <= column && column < column_count\nelse\n raise(ArgumentError.new(\"invalid column (#{column.inspect} for 0..#{column_count - 1})\"))\nend\narrays = to_a.map(&.to_a)\narrays.delete_at(row)\narrays.each do |array|\n array.delete_at(column)\nend\nMatrix.new(arrays, column_count - 1)\n"}},{"id":"inverse-instance-method","html_id":"inverse-instance-method","name":"inverse","doc":"Returns the inverse of the matrix.","summary":"

Returns the inverse of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L298","def":{"name":"inverse","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n if square?\n else\n raise(\"Dimention mismatch: `Matrix#inverse` requires a square matrix.\")\n end\nend\n(Matrix.identity(row_count)).inverse_from(self)\n"}},{"id":"laplace_expansion(*,row=nil,column=nil)-instance-method","html_id":"laplace_expansion(*,row=nil,column=nil)-instance-method","name":"laplace_expansion","doc":"Returns the Laplace expansion along given row or column.","summary":"

Returns the Laplace expansion along given row or column.

","abstract":false,"args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"args_string":"(*, row = nil, column = nil)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L444","def":{"name":"laplace_expansion","args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = row || column\nif (!num) || (row && column)\n raise(ArgumentError.new(\"exactly one the row or column arguments must be specified\"))\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nif empty?\n raise(\"laplace_expansion of empty matrix is not defined\")\nend\nif 0 <= num && num < row_count\nelse\n raise(ArgumentError.new(\"invalid num (#{num.inspect} for 0..#{row_count - 1})\"))\nend\nif row\n (row(num)).map_with_index do |e, k|\n e * (cofactor(num, k))\n end.reduce(&.+)\nelse\n (column(num)).map_with_index do |e, k|\n e * (cofactor(k, num))\n end.reduce(&.+)\nend\n"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L510","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"[\", self, \"]\") do |vec|\n pp.group do\n vec.to_a.pretty_print(pp)\n end\nend"}},{"id":"row(i,&block)-instance-method","html_id":"row(i,&block)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L469","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":""},"return_type":"","visibility":"Public","body":"(@rows.fetch(i) do\n return self\nend).each(&block)\nself\n"}},{"id":"row(i)-instance-method","html_id":"row(i)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L474","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(rows.fetch(i) do\n [] of Float64\nend)"}},{"id":"row_count:Int32-instance-method","html_id":"row_count:Int32-instance-method","name":"row_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L13","def":{"name":"row_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@row_count"}},{"id":"rows-instance-method","html_id":"rows-instance-method","name":"rows","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L478","def":{"name":"rows","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = [] of Vector\nrow_count.times do |i|\n rows << self[i - 1]\nend\nrows\n"}},{"id":"square?-instance-method","html_id":"square?-instance-method","name":"square?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L486","def":{"name":"square?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"row_count == column_count"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L496","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n \"Matrix.empty(#{row_count}, #{column_count})\"\nelse\n io << \"Matrix[\"\n io << (map do |row|\n (\"{\" + (row.to_a.map do |e|\n e.to_s\n end.join(\", \"))) + \"}\"\n end.join(\", \"))\n io << \"]\"\nend"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L490","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count.zero?\n return Matrix.empty(column_count, 0)\nend\ntransposed = rows.map do |v|\n v.to_a\nend.transpose\nMatrix.new(transposed, row_count)\n"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/matrix.cr#L519","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray","path":"Apatite/LinearAlgebra/NDArray.html","kind":"class","full_name":"Apatite::LinearAlgebra::NDArray","name":"NDArray","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":2,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","html_id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"args_string":"(data : Array(Number), shape : Array(Int32)? = nil)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L18","def":{"name":"new","args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(data, shape)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"[](*args,**options)-instance-method","html_id":"[](*args,**options)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]"}},{"id":"[](*args,**options,&block)-instance-method","html_id":"[](*args,**options,&block)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options] do |*yield_args|\n yield *yield_args\nend"}},{"id":"[]=(*args,**options)-instance-method","html_id":"[]=(*args,**options)-instance-method","name":"[]=","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L13","def":{"name":"[]=","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args] = **options"}},{"id":"[]?(*args,**options)-instance-method","html_id":"[]?(*args,**options)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]?"}},{"id":"[]?(*args,**options,&block)-instance-method","html_id":"[]?(*args,**options,&block)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]? do |*yield_args|\n yield *yield_args\nend"}},{"id":"abs-instance-method","html_id":"abs-instance-method","name":"abs","doc":"Returns the absolute value of every item in the array","summary":"

Returns the absolute value of every item in the array

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L24","def":{"name":"abs","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |e|\n e.abs\nend"}},{"id":"acos-instance-method","html_id":"acos-instance-method","name":"acos","doc":"Returns the arccosine of each element in the current array.","summary":"

Returns the arccosine of each element in the current array.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L29","def":{"name":"acos","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"data:Array(Float64)-instance-method","html_id":"data:Array(Float64)-instance-method","name":"data","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L9","def":{"name":"data","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Float64)","visibility":"Public","body":"@data"}},{"id":"shape:Array(Int32)-instance-method","html_id":"shape:Array(Int32)-instance-method","name":"shape","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Int32)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Int32)","visibility":"Public","body":"@shape"}},{"id":"size(*args,**options)-instance-method","html_id":"size(*args,**options)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options)"}},{"id":"size(*args,**options,&block)-instance-method","html_id":"size(*args,**options,&block)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"to_unsafe(*args,**options)-instance-method","html_id":"to_unsafe(*args,**options)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options)"}},{"id":"to_unsafe(*args,**options,&block)-instance-method","html_id":"to_unsafe(*args,**options,&block)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"unsafe_fetch(*args,**options)-instance-method","html_id":"unsafe_fetch(*args,**options)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options)"}},{"id":"unsafe_fetch(*args,**options,&block)-instance-method","html_id":"unsafe_fetch(*args,**options,&block)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Vector","path":"Apatite/LinearAlgebra/Vector.html","kind":"class","full_name":"Apatite::LinearAlgebra::Vector","name":"Vector","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/vector.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector.create([1.0, 0.0, 0.0])","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector.create([0.0, 1.0, 0.0])","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector.create([0.0, 0.0, 1.0])","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"}],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":"Represents a mathematical vector, and also constitutes a row or column\nof a `Matrix`","summary":"

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

","class_methods":[{"id":"[](*array)-class-method","html_id":"[](*array)-class-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"args_string":"(*array)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L156","def":{"name":"[]","args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(array)"}},{"id":"basis(size,index)-class-method","html_id":"basis(size,index)-class-method","name":"basis","doc":"Returns a standard basis n-vector.","summary":"

Returns a standard basis n-vector.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L138","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size < 1\n raise(ArgumentError.new(\"invalid size (#{size} for 1..)\"))\nend\nif 0 <= index && index < size\nelse\n raise(ArgumentError.new(\"invalid index (#{index} for 0...#{size})\"))\nend\nvec = Vector.new(size, 0.0)\nvec[index] = 1.0\nvec\n"}},{"id":"create(elements:Indexable(Number))-class-method","html_id":"create(elements:Indexable(Number))-class-method","name":"create","doc":"Creates a new `Vector` from the elements of another `Indexable`\ncollection.\n\n```\nVector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}\n```","summary":"

Creates a new Vector from the elements of another Indexable collection.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"args_string":"(elements : Indexable(Number))","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L118","def":{"name":"create","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new\nelements.each do |el|\n vec.push(el.to_f64)\nend\nvec\n"}},{"id":"ones(n)-class-method","html_id":"ones(n)-class-method","name":"ones","doc":"Create a new vector of size `n` filled with ones.","summary":"

Create a new vector of size n filled with ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L152","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1.0)"}},{"id":"random(n,range=Float64::MIN..Float64::MAX)-class-method","html_id":"random(n,range=Float64::MIN..Float64::MAX)-class-method","name":"random","doc":"Generates a random vector of size `n` with elements\nin `range`.","summary":"

Generates a random vector of size n with elements in range.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"Float64::MIN..Float64::MAX","external_name":"range","restriction":""}],"args_string":"(n, range = Float64::MIN..Float64::MAX)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L128","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"Float64::MIN..Float64::MAX","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"random = Random.new\nvec = Vector.new(n)\nn.times do\n vec.push(random.rand(range))\nend\nvec\n"}},{"id":"zeros(n)-class-method","html_id":"zeros(n)-class-method","name":"zeros","doc":"Create a new vector of size `n` filled with zeros.","summary":"

Create a new vector of size n filled with zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L147","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0.0)"}}],"constructors":[{"id":"build(capacity:Int,&block):self-class-method","html_id":"build(capacity:Int,&block):self-class-method","name":"build","doc":"Creates a new `Vector`, allocating an internal buffer with the given *capacity*,\nand yielding that buffer. The given block must return the desired size of the vector.\n\nThis method is **unsafe**.\n\n```\nVector.build(3) do |buffer|\n LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)\nend\n```","summary":"

Creates a new Vector, allocating an internal buffer with the given capacity, and yielding that buffer.

","abstract":false,"args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"args_string":"(capacity : Int, &block) : self","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L106","def":{"name":"build","args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"self","visibility":"Public","body":"vec = Vector.new(capacity)\nvec.size = (yield vec.to_unsafe).to_i\nvec\n"}},{"id":"new(size:Int,value:Float64)-class-method","html_id":"new(size:Int,value:Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* filled with the same *value* in each position.\n\n```\nVector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}\n```","summary":"

Creates a new Vector of the given size filled with the same value in each position.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(size : Int, value : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L63","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(size, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(initial_capacity:Int)-class-method","html_id":"new(initial_capacity:Int)-class-method","name":"new","doc":"Creates a new empty `Vector` backed by a buffer that is initially\n`initial_capacity` big.\n\nThe *initial_capacity* is useful to avoid unnecessary reallocations\nof the internal buffer in case of growth. If you have an estimate\nof the maximum number of elements an vector will hold, the vector should\nbe initialized with that capacity for improved performance.\n\n```\nvec = Vector.new(5)\nvec.size # => 0\n```","summary":"

Creates a new empty Vector backed by a buffer that is initially initial_capacity big.

","abstract":false,"args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"args_string":"(initial_capacity : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L43","def":{"name":"new","args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(initial_capacity)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new-class-method","html_id":"new-class-method","name":"new","doc":"Create a new empty `Vector`.","summary":"

Create a new empty Vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L25","def":{"name":"new","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(size:Int,&block:Int32->Float64)-class-method","html_id":"new(size:Int,&block:Int32->Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* and invokes the given block once\nfor each index of `self`, assigning the block's value in that index.\n\n```\nVector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}\n\nvec = Vector.new(3) { 5.0 }\nvec # => Vector{5.0, 5.0, 5.0}\n```","summary":"

Creates a new Vector of the given size and invokes the given block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"args_string":"(size : Int, &block : Int32 -> Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L87","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(Int32 -> Float64)"},"return_type":"","visibility":"Public","body":"Vector.build(size) do |buffer|\n size.to_i.times do |i|\n buffer[i] = yield i\n end\n size\nend"}}],"instance_methods":[{"id":"*(other)-instance-method","html_id":"*(other)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L370","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"multiply(other)"}},{"id":"+(other)-instance-method","html_id":"+(other)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L362","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"add(other)"}},{"id":"-(other)-instance-method","html_id":"-(other)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L366","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"subtract(other)"}},{"id":"<<(value:Float64)-instance-method","html_id":"<<(value:Float64)-instance-method","name":"<<","doc":"Alias for `#push`","summary":"

Alias for #push

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L349","def":{"name":"<<","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(value)"}},{"id":"(other)-instance-method","html_id":"(other)-instance-method","name":"<=>","doc":"Combined comparison operator. Returns *0* if `self` equals *other*, *1* if\n`self` is greater than *other* and *-1* if `self` is smaller than *other*.\n\nIt compares the elements of both vectors in the same position using the\n`<=>` operator. As soon as one of such comparisons returns a non-zero\nvalue, that result is the return value of the comparison.\n\nIf all elements are equal, the comparison is based on the size of the vectors.\n\n```\nVector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1\nVector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1\nVector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0\n```","summary":"

Combined comparison operator.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L339","def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"min_size = Math.min(size, other.size)\n0.upto(min_size - 1) do |i|\n n = @buffer[i] <=> other.to_unsafe[i]\n if n != 0\n return n\n end\nend\nsize <=> other.size\n"}},{"id":"==(other:Vector)-instance-method","html_id":"==(other:Vector)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L353","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"equals?(other) do |x, y|\n x == y\nend"}},{"id":"[](start:Int,count:Int)-instance-method","html_id":"[](start:Int,count:Int)-instance-method","name":"[]","doc":"Returns count or less (if there aren't enough) elements starting at the\ngiven start index.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1, 3] # => Vector{2.0, 3.0, 4.0}\nv[6, 10] # raise IndexError\n```","summary":"

Returns count or less (if there aren't enough) elements starting at the given start index.

","abstract":false,"args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"args_string":"(start : Int, count : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L191","def":{"name":"[]","args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nif start == size\n return Vector.new\nend\nif start < 0\n start = start + size\nend\nif 0 <= start && start <= size\nelse\n raise(IndexError.new)\nend\nif count == 0\n return Vector.new\nend\ncount = Math.min(count, size - start)\nVector.build(count) do |buffer|\n buffer.copy_from(@buffer + start, count)\n count\nend\n"}},{"id":"[](range:Range(Int,Int))-instance-method","html_id":"[](range:Range(Int,Int))-instance-method","name":"[]","doc":"Returns all elements that are within the given range.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1..3] # => Vector{2.0, 3.0, 4.0}\nv[6..10] # raise IndexError\n```","summary":"

Returns all elements that are within the given range.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"args_string":"(range : Range(Int, Int))","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L173","def":{"name":"[]","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)]"}},{"id":"[]=(index:Int,count:Int,values:Vector)-instance-method","html_id":"[]=(index:Int,count:Int,values:Vector)-instance-method","name":"[]=","doc":"Replaces a subrange with the elements of the given vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0, 8.0}\nvec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0}\nvec # = Vector{1.0, 6.0, 7.0, 5.0}\n```","summary":"

Replaces a subrange with the elements of the given vector.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"args_string":"(index : Int, count : Int, values : Vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L297","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ndiff = values.size - count\nif diff == 0\n (@buffer + index).copy_from(values.to_unsafe, values.size)\nelse\n if diff < 0\n diff = -diff\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @size = @size - diff\n else\n resize_to_capacity(Math.pw2ceil(@size + diff))\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n @size = @size + diff\n end\nend\nvalues\n"}},{"id":"[]=(index:Int,count:Int,value)-instance-method","html_id":"[]=(index:Int,count:Int,value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value. All elements in the range\n`index...index+count` are removed and replaced by a single element\n*value*.\n\nIf *count* is zero, *value* is inserted at *index*.\n\nNegative values of *index* count from the end of the vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = 6.0\nvec # => Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 0] = 6.0\nvec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, count : Int, value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L248","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nvalue = value.to_f64\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ncase count\nwhen 0\n insert(index, value)\nwhen 1\n @buffer[index] = value\nelse\n diff = count - 1\n ((@buffer + index) + 1).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @buffer[index] = value\n @size = @size - diff\nend\nvalue\n"}},{"id":"[]=(index:Int,value)-instance-method","html_id":"[]=(index:Int,value)-instance-method","name":"[]=","doc":"Sets the given value at the given index.\n\nNegative indices can be used to start counting from the end of the array.\nRaises `IndexError` if trying to set an element outside the array's range.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec[0] = 5.0\np vec # => Vec{5.0, 2.0, 3.0}\n\nvec[3] = 5.0 # raises IndexError\n```","summary":"

Sets the given value at the given index.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L226","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"index = check_index_out_of_bounds(index)\n@buffer[index] = value.to_f64\n"}},{"id":"[]=(range:Range(Int,Int),value)-instance-method","html_id":"[]=(range:Range(Int,Int),value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1..3] = 6.0\nvec # = Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1...1] = 6\nvec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(range : Range(Int, Int), value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L282","def":{"name":"[]=","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)] = value.to_f64"}},{"id":"add(value)-instance-method","html_id":"add(value)-instance-method","name":"add","doc":"When the input is a number, this returns the result of adding\nit to all vector elements. When it's a vector, the vectors\nwill be added together.","summary":"

When the input is a number, this returns the result of adding it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L488","def":{"name":"add","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a + b\nend"}},{"id":"angle_from(vector)-instance-method","html_id":"angle_from(vector)-instance-method","name":"angle_from","doc":"Returns the angle between this vector and another in radians.\nIf the vectors are mirrored across their axes this will return `nil`.","summary":"

Returns the angle between this vector and another in radians.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L440","def":{"name":"angle_from","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = vector.is_a?(Vector) ? vector : Vector.create(vector)\nif size == v.size\nelse\n raise(\"Cannot compute the angle between vectors with different dimensionality\")\nend\ndot = 0_f64\nmod1 = 0_f64\nmod2 = 0_f64\n(zip(vector)).each do |x, v|\n dot = dot + (x * v)\n mod1 = mod1 + (x * x)\n mod2 = mod2 + (v * v)\nend\nmod1 = Math.sqrt(mod1)\nmod2 = Math.sqrt(mod2)\nif (mod2 * mod2) == 0\n return 0.0\nend\ntheta = (dot / (mod1 * mod2)).clamp(-1, 1)\nMath.acos(theta)\n"}},{"id":"antiparallel_to?(vector)-instance-method","html_id":"antiparallel_to?(vector)-instance-method","name":"antiparallel_to?","doc":"Returns whether the vectors are antiparallel to each other.","summary":"

Returns whether the vectors are antiparallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L475","def":{"name":"antiparallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\n(angle - Math::PI).abs <= Apatite.precision\n"}},{"id":"augment(elements)-instance-method","html_id":"augment(elements)-instance-method","name":"augment","doc":"Returns a new vector with the provided `elements` concatenated\non the end.","summary":"

Returns a new vector with the provided elements concatenated on the end.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L556","def":{"name":"augment","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = elements.is_a?(Vector) ? elements : Vector.create(elements)\nconcat(elements)\n"}},{"id":"chomp(n)-instance-method","html_id":"chomp(n)-instance-method","name":"chomp","doc":"Returns a new vector with the first `n` elements removed from\nthe beginning.","summary":"

Returns a new vector with the first n elements removed from the beginning.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L541","def":{"name":"chomp","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i >= n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Removes all elements from self.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.clear # => Vector{}\n```","summary":"

Removes all elements from self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L782","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.clear(@size)\n@size = 0\nself\n"}},{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L374","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(@elements.clone)"}},{"id":"concat(other:Vector)-instance-method","html_id":"concat(other:Vector)-instance-method","name":"concat","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L731","def":{"name":"concat","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other_size = other.size\nnew_size = size + other_size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\n(@buffer + @size).copy_from(other.to_unsafe, other_size)\n@size = new_size\nself\n"}},{"id":"covector-instance-method","html_id":"covector-instance-method","name":"covector","doc":"Creates a single-row matrix from this vector.","summary":"

Creates a single-row matrix from this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L601","def":{"name":"covector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(self)"}},{"id":"cross(*vs)-instance-method","html_id":"cross(*vs)-instance-method","name":"cross","doc":"Returns the cross product of this vector with the others.\n\n```\nv1 = Vector{1.0, 0.0, 0.0}\nv2 = Vector{0.0, 1.0, 0.0}\nv1.cross(v2) => Vector{0.0, 0.0, 1.0}\n```","summary":"

Returns the cross product of this vector with the others.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L518","def":{"name":"cross","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size >= 2\nelse\n raise(\"cross product is not defined on vectors of dimension #{size}\")\nend\nif vs.size == (size - 2)\nelse\n raise(ArgumentError.new(\"wrong number of arguments (#{vs.size} for #{size - 2})\"))\nend\nvs.each do |v|\n if v.size == size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\ncase size\nwhen 2\n Vector[-@buffer[1], @buffer[0]]\nwhen 3\n v = vs[0]\n Vector[(v[2] * @buffer[1]) - (v[1] * @buffer[2]), (v[0] * @buffer[2]) - (v[2] * @buffer[0]), (v[1] * @buffer[0]) - (v[0] * @buffer[1])]\nelse\nend\n"}},{"id":"distance_from(obj)-instance-method","html_id":"distance_from(obj)-instance-method","name":"distance_from","doc":"Gets this vector's distance from the argument, when considered\na point in space.","summary":"

Gets this vector's distance from the argument, when considered a point in space.

","abstract":false,"args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"args_string":"(obj)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L629","def":{"name":"distance_from","args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n return object.distance_from(self)\nend\nv = elements.is_a?(Vector) ? elements.elements : elements\nif v.size == @elements.size\nelse\n return nil\nend\nsum = 0\npart = 0\neach_with_index do |x, i|\n part = x - v[i - 1]\n sum = sum + (part * part)\nend\nMath.sqrt(sum)\n"}},{"id":"dot(other)-instance-method","html_id":"dot(other)-instance-method","name":"dot","doc":"Get the scalar (dot) product of this vector with `vector`.\n\n[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product)","summary":"

Get the scalar (dot) product of this vector with vector.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L574","def":{"name":"dot","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other = other.is_a?(Vector) ? other : Vector.create(other)\nif size == other.size\nelse\n raise(\"Cannot compute the dot product of vectors with different dimensionality\")\nend\nproduct = 0\n(0...size).each do |i|\n product = product + (self[i] * other[i])\nend\nproduct\n"}},{"id":"e(i)-instance-method","html_id":"e(i)-instance-method","name":"e","doc":"Returns the `ith` element of the vector. Returns `nil` if `i`\nis out of bounds. Indexing starts from 1.","summary":"

Returns the ith element of the vector.

","abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L426","def":{"name":"e","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(i < 1 || i > @size) ? nil : self[i - 1]"}},{"id":"independent?(*vs)-instance-method","html_id":"independent?(*vs)-instance-method","name":"independent?","doc":"Returns true if all vectors are linearly independent.","summary":"

Returns true if all vectors are linearly independent.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L384","def":{"name":"independent?","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vs.each do |v|\n if v.size == vs.first.size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\nif vs.size > sv.first.size\n return false\nend\nMatrix[*vs].rank.equal?(vs.count)\n"}},{"id":"lies_in(plane)-instance-method","html_id":"lies_in(plane)-instance-method","name":"lies_in","doc":"Returns true if the vector is a point on the given plane.","summary":"

Returns true if the vector is a point on the given plane.

","abstract":false,"args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"args_string":"(plane)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L654","def":{"name":"lies_in","args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"plane.contains(self)"}},{"id":"lies_on(line)-instance-method","html_id":"lies_on(line)-instance-method","name":"lies_on","doc":"Returns true if the vector is a point on the given line","summary":"

Returns true if the vector is a point on the given line

","abstract":false,"args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"args_string":"(line)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L649","def":{"name":"lies_on","args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"line.contains(self)"}},{"id":"log-instance-method","html_id":"log-instance-method","name":"log","doc":"Return a new `Vector` with the log of every item in `self`.","summary":"

Return a new Vector with the log of every item in self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L562","def":{"name":"log","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n Math.log(x)\nend"}},{"id":"magnitude-instance-method","html_id":"magnitude-instance-method","name":"magnitude","doc":"Returns the magnitude/euclidian norm of this vector.\n\n[https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance)","summary":"

Returns the magnitude/euclidian norm of this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L419","def":{"name":"magnitude","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"sum = reduce(0.0) do |acc, e|\n acc = acc + (e * e)\nend\nMath.sqrt(sum)\n"}},{"id":"map(&block)-instance-method","html_id":"map(&block)-instance-method","name":"map","doc":"Invokes the given block for each element of `self`.","summary":"

Invokes the given block for each element of self.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L379","def":{"name":"map","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i]\nend"}},{"id":"map!(&block)-instance-method","html_id":"map!(&block)-instance-method","name":"map!","doc":"Invokes the given block for each element of `self`, replacing the element\nwith the value returned by the block. Returns `self`.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.map! { |x| x * x }\na # => Vector{1.0, 4.0, 9.0}\n```","summary":"

Invokes the given block for each element of self, replacing the element with the value returned by the block.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L400","def":{"name":"map!","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.map!(size) do |e|\n yield e\nend\nself\n"}},{"id":"map_with_index(&block)-instance-method","html_id":"map_with_index(&block)-instance-method","name":"map_with_index","doc":"Optimized version of `Enumerable#map_with_index`.","summary":"

Optimized version of Enumerable#map_with_index.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L406","def":{"name":"map_with_index","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i], i\nend"}},{"id":"map_with_index!(&block)-instance-method","html_id":"map_with_index!(&block)-instance-method","name":"map_with_index!","doc":"Like `map_with_index`, but mutates `self` instead of allocating a new object.","summary":"

Like #map_with_index, but mutates self instead of allocating a new object.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L411","def":{"name":"map_with_index!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"to_unsafe.map_with_index!(size) do |e, i|\n yield e, i\nend\nself\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the (absolute) largest element in this vector.","summary":"

Returns the (absolute) largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L589","def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, i|\n i.abs > acc.abs ? i : acc\nend"}},{"id":"max_index-instance-method","html_id":"max_index-instance-method","name":"max_index","doc":"Gets the index of the largest element in this vector.","summary":"

Gets the index of the largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L594","def":{"name":"max_index","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"idx = 0\neach_with_index do |e, i|\n idx = e.abs > self[idx].abs ? i : idx\nend\nidx\n"}},{"id":"multiply(value)-instance-method","html_id":"multiply(value)-instance-method","name":"multiply","doc":"When the input is a number, this returns the result of multiplying\nit to all vector elements. When it's a vector, the vectors\nwill be element-wise multiplied.","summary":"

When the input is a number, this returns the result of multiplying it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L502","def":{"name":"multiply","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a * b\nend"}},{"id":"parallel_to?(vector)-instance-method","html_id":"parallel_to?(vector)-instance-method","name":"parallel_to?","doc":"Returns whether the vectors are parallel to each other.","summary":"

Returns whether the vectors are parallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L469","def":{"name":"parallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\nangle <= Apatite.precision\n"}},{"id":"perpendicular_to?(vector)-instance-method","html_id":"perpendicular_to?(vector)-instance-method","name":"perpendicular_to?","doc":"Returns whether the vectors are perpendicular to each other.","summary":"

Returns whether the vectors are perpendicular to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L481","def":{"name":"perpendicular_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(dot(vector)).abs <= Apatite.precision"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L754","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"Vector{\", self, \"}\")"}},{"id":"product-instance-method","html_id":"product-instance-method","name":"product","doc":"Get the product of all elements in this vector.","summary":"

Get the product of all elements in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L567","def":{"name":"product","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, v|\n acc = acc * v\nend"}},{"id":"push(*values:Float64)-instance-method","html_id":"push(*values:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"args_string":"(*values : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L665","def":{"name":"push","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new_size = @size + values.size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\nvalues.each_with_index do |value, i|\n @buffer[@size + i] = value\nend\n@size = new_size\nself\n"}},{"id":"push(value:Float64)-instance-method","html_id":"push(value:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L658","def":{"name":"push","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"check_needs_resize\n@buffer[@size] = value\n@size = @size + 1\nself\n"}},{"id":"reflection_in(object)-instance-method","html_id":"reflection_in(object)-instance-method","name":"reflection_in","doc":"Returns the result of reflecting the point in the given `object`\n(point, line, or plane).","summary":"

Returns the result of reflecting the point in the given object (point, line, or plane).

","abstract":false,"args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(object)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L684","def":{"name":"reflection_in","args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n p = @elements.dup\n c = (object.point_closest_to(p)).elements\n return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))])\nend\nq = object.is_a?(Vector) ? object.elements : object\nif @elements.size == q.size\nelse\n return nil\nend\nmap_with_index do |x, i|\n q[i - 1] + (q[i - 1] - x)\nend\n"}},{"id":"rotate(t,object)-instance-method","html_id":"rotate(t,object)-instance-method","name":"rotate","doc":"Rotates the vector about the given `object`. The object should\nbe a point if the vector is 2D, and a line if it is 3D. Be\ncareful with line directions!","summary":"

Rotates the vector about the given object.

","abstract":false,"args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(t, object)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L678","def":{"name":"rotate","args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"round-instance-method","html_id":"round-instance-method","name":"round","doc":"Gets the result of rounding the elements of the vector.","summary":"

Gets the result of rounding the elements of the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L612","def":{"name":"round","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n x.round\nend"}},{"id":"set_elements(elements)-instance-method","html_id":"set_elements(elements)-instance-method","name":"set_elements","doc":null,"summary":null,"abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L726","def":{"name":"set_elements","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@elements = elements.is_a?(Vector) ? elements.elements : elements\nself\n"}},{"id":"sigmoid-instance-method","html_id":"sigmoid-instance-method","name":"sigmoid","doc":"Sums the numbers in the vector and returns a sigmoid value\nacross the whole vector.","summary":"

Sums the numbers in the vector and returns a sigmoid value across the whole vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L707","def":{"name":"sigmoid","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"LinearAlgebra.sigmoid(sum)"}},{"id":"size:Int32-instance-method","html_id":"size:Int32-instance-method","name":"size","doc":"Returns the number of elements in the vector","summary":"

Returns the number of elements in the vector

","abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L24","def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@size"}},{"id":"snap_to(value)-instance-method","html_id":"snap_to(value)-instance-method","name":"snap_to","doc":"Returns a copy of the vector with elements set to `value` if\nthey differ from it by less than `Apetite.precision`","summary":"

Returns a copy of the vector with elements set to value if they differ from it by less than Apetite.precision

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L623","def":{"name":"snap_to","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |y|\n (y - x).abs <= Apetite.precision ? value : y\nend"}},{"id":"subtract(value)-instance-method","html_id":"subtract(value)-instance-method","name":"subtract","doc":"When the input is a number, this returns the result of subtracting\nit to all vector elements. When it's a vector, the vectors\nwill be subtracted.","summary":"

When the input is a number, this returns the result of subtracting it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L495","def":{"name":"subtract","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a - b\nend"}},{"id":"sum-instance-method","html_id":"sum-instance-method","name":"sum","doc":"Returns the sum of all elements in the vector.","summary":"

Returns the sum of all elements in the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L507","def":{"name":"sum","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce(0) do |acc, i|\n acc + i\nend"}},{"id":"to_3d-instance-method","html_id":"to_3d-instance-method","name":"to_3d","doc":"Utility to make sure vectors are 3D. If they are 2D, a zero\nz-component is added.","summary":"

Utility to make sure vectors are 3D.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L713","def":{"name":"to_3d","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = dup\ncase v.elements.size\nwhen 3\n break\nwhen 2\n v.elements.push(0)\nelse\n return nil\nend\nreturn v\n"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L744","def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Float64).new(size) do |i|\n self[i]\nend"}},{"id":"to_diagonal_matrix-instance-method","html_id":"to_diagonal_matrix-instance-method","name":"to_diagonal_matrix","doc":"Returns a diagonal `Matrix` with the vectors elements as its\ndiagonal elements.","summary":"

Returns a diagonal Matrix with the vectors elements as its diagonal elements.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L607","def":{"name":"to_diagonal_matrix","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix::Diagonal.new(elements)"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L748","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"io << \"{\"\njoin(\", \", io, &.inspect(io))\nio << \"}\"\n"}},{"id":"to_unit_vector-instance-method","html_id":"to_unit_vector-instance-method","name":"to_unit_vector","doc":"Returns a new vector created by normalizing this one\nto have a magnitude of `1`. If the vector is a zero\nvector, it will not be modified.","summary":"

Returns a new vector created by normalizing this one to have a magnitude of 1.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L433","def":{"name":"to_unit_vector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"r = magnitude\nr == 0 ? dup : map do |x|\n x.to_f64 / r\nend\n"}},{"id":"to_unsafe:Pointer(Float64)-instance-method","html_id":"to_unsafe:Pointer(Float64)-instance-method","name":"to_unsafe","doc":"Returns a pointer to the internal buffer where `self`'s elements are stored.\n\nThis method is **unsafe** because it returns a pointer, and the pointed might eventually\nnot be that of `self` if the array grows and its internal buffer is reallocated.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.to_unsafe[0] # => 1.0\n```","summary":"

Returns a pointer to the internal buffer where self's elements are stored.

","abstract":false,"args":[],"args_string":" : Pointer(Float64)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L772","def":{"name":"to_unsafe","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Pointer(Float64)","visibility":"Public","body":"@buffer"}},{"id":"top(n)-instance-method","html_id":"top(n)-instance-method","name":"top","doc":"Returns a vector containing only the first `n` elements.","summary":"

Returns a vector containing only the first n elements.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L548","def":{"name":"top","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i < n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":"Transpose this vector into a 1xn `Matrix`","summary":"

Transpose this vector into a 1xn Matrix

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L617","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.col_vector(self)"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L759","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}},{"id":"zero?-instance-method","html_id":"zero?-instance-method","name":"zero?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/linear_algebra/vector.cr#L788","def":{"name":"zero?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"all?(&.zero?)"}}],"macros":[],"types":[]}]}]},{"html_id":"github.com/watzon/apatite/Array","path":"Array.html","kind":"class","full_name":"Array(T)","name":"Array","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/core_ext/array.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"An `Array` is an ordered, integer-indexed collection of objects of type T.\n\nArray indexing starts at 0. A negative index is assumed to be\nrelative to the end of the array: -1 indicates the last element,\n-2 is the next to last element, and so on.\n\nAn `Array` can be created using the usual `new` method (several are provided), or with an array literal:\n\n```\nArray(Int32).new # => []\n[1, 2, 3] # Array(Int32)\n[1, \"hello\", 'x'] # Array(Int32 | String | Char)\n```\n\nAn `Array` can have mixed types, meaning T will be a union of types, but these are determined\nwhen the array is created, either by specifying T or by using an array literal. In the latter\ncase, T will be set to the union of the array literal elements' types.\n\nWhen creating an empty array you must always specify T:\n\n```\n[] of Int32 # same as Array(Int32)\n[] # syntax error\n```\n\nAn `Array` is implemented using an internal buffer of some capacity\nand is reallocated when elements are pushed to it when more capacity\nis needed. This is normally known as a [dynamic array](http://en.wikipedia.org/wiki/Dynamic_array).\n\nYou can use a special array literal syntax with other types too, as long as they define an argless\n`new` method and a `<<` method. `Set` is one such type:\n\n```\nset = Set{1, 2, 3} # => Set{1, 2, 3}\nset.class # => Set(Int32)\n```\n\nThe above is the same as this:\n\n```\nset = Set(typeof(1, 2, 3)).new\nset << 1\nset << 2\nset << 3\n```","summary":"

An Array is an ordered, integer-indexed collection of objects of type T.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"all?-instance-method","html_id":"all?-instance-method","name":"all?","doc":"Tests whether all elements evaluate to true","summary":"

Tests whether all elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L3","def":{"name":"all?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == false\n return false\n end\nend\ntrue\n"}},{"id":"any?-instance-method","html_id":"any?-instance-method","name":"any?","doc":"Tests whether any of the elements evaluate to true","summary":"

Tests whether any of the elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L11","def":{"name":"any?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == true\n return true\n end\nend\nfalse\n"}},{"id":"shape-instance-method","html_id":"shape-instance-method","name":"shape","doc":"Get the array's dimensions","summary":"

Get the array's dimensions

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L19","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"max = max_by do |i|\n i.is_a?(Array) ? i.size : i\nend\nmax.is_a?(Array) ? [size, max.size] : [max]\n"}},{"id":"to_vec-instance-method","html_id":"to_vec-instance-method","name":"to_vec","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/6c8ee1fded2782d2cc9fcd30ca82bd149f6eb9a3/src/apatite/core_ext/array.cr#L24","def":{"name":"to_vec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Apatite::Vector.create(self)"}}],"macros":[],"types":[]}]}}) \ No newline at end of file