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

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

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 angle_from(a, b) #

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?(a, b) #

Returns whether the vectors are antiparallel to each other.


[View source]
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) #

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


[View source]
def diagonal(values) #

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


[View source]
def dot(x, y) #

Get the scalar (dot) product of two vectors.

[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product


[View source]
def empty #

Returns a new empty Vector


[View source]
def empty_matrix(row_count = 0, column_count = 0) #

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.


[View source]
def eye(n) #

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.


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

Returns a new vector of size n filled with i


[View source]
def identity(n) #

Creates a n x n identity matrix.


[View source]
def ones(n) #

Returns a new vector filled with n ones.


[View source]
def parallel_to?(a, b) #

Returns whether the vectors are parallel to each other.


[View source]
def perpendicular_to?(a, b) #

Returns whether the vectors are perpendicular to each other.


[View source]
def random(n, range = nil) #

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.


[View source]
def row_vector(row) #

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


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

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


[View source]
def similarity(x, y) #

Compute the cosine similarity between two vectors.


[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]