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.crapatite/linear_algebra.cr
apatite.cr
apatite/version.cr
Constant Summary
-
I =
Vector::I
-
Cartesian unit vector I
Vector{1.0, 0.0, 0.0}
-
J =
Vector::J
-
Cartesian unit vector J
Vector{0.0, 1.0, 0.0}
-
K =
Vector::K
-
Cartesian unit vector K
Vector{0.0, 0.0, 1.0}
-
VERSION =
"0.1.0"
Class Method Summary
Instance Method Summary
-
#angle_from(a, b)
Returns the angle between this vector and another in radians.
-
#antiparallel_to?(a, b)
Returns whether the vectors are antiparallel to each other.
-
#as_vector(input : Indexable)
Creates a new vector from the given
input
. -
#basis(size, index)
Creates a standard basis-n vector of the given
size
andindex
. -
#diagonal(values)
Creates a matrix where the diagonal elements are composed of
values
. -
#dot(x, y)
Get the scalar (dot) product of two vectors.
-
#empty
Returns a new empty
Vector
-
#empty_matrix(row_count = 0, column_count = 0)
Creates a new empty matrix with the given
row_count
andcolumn_count
. -
#eye(n)
Creates a new diagonal matrix of size
n
with ones in the diagonal and zeros elsewhere. -
#full(n, i)
Returns a new vector of size
n
filled withi
-
#identity(n)
Creates a
n x n
identity matrix. -
#ones(n)
Returns a new vector filled with
n
ones. -
#parallel_to?(a, b)
Returns whether the vectors are parallel to each other.
-
#perpendicular_to?(a, b)
Returns whether the vectors are perpendicular to each other.
-
#random(n, range = nil)
Creates a new vector of size
n
filled with random numbers. -
#row_vector(row)
Creates a single-row matrix where the values of that row are as given in
row
. -
#scalar(n, value)
Creates an
n
byn
diagonal matrix where each diagonal element is value. -
#similarity(x, y)
Compute the cosine similarity between two vectors.
-
#vector(n, &block)
Creates a new vector of size
n
, and invokes the block once for each index ofself
, assigning the block's value in that index. -
#zeros(n)
Returns a new vector filled with
n
zeros.
Instance methods inherited from module Apatite::LinearAlgebra
sigmoid(input : Number)
sigmoid,
sigmoid_d(input : Number)
sigmoid_d
Class Method Detail
Instance Method Detail
Returns the angle between this vector and another in radians.
If the vectors are mirrored across their axes this will return nil
.
Creates a new vector from the given input
. Input can be any
Indexable
type.
Get the scalar (dot) product of two vectors.
[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product
Creates a new empty matrix with the given row_count
and
column_count
. At lease one of row_count
or
column_count
must be zero.
Creates a new vector of size n
filled with random numbers. A range
can optionally be passed in if you want to limit the random numbers
to a given range.
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.