module Bottle::LinAlg

Direct including types

Defined in:

linalg/fixed_dimension.cr
linalg/reductions.cr

Instance Method Summary

Macro Summary

Instance Method Detail

def dot(a : BaseArray(U), b : BaseArray(U)) forall U #

[View source]
def dot1d(dx : BaseArray(Float64), dy : BaseArray(Float64)) #

Dot product of two Tensors. Specifically, this is the inner product of two Tensors without the complex conjugate.

t = Tensor.new [1.0, 2.0, 3.0]

dot(t, t) # => 14.0

[View source]
def dot1d(dx : BaseArray(Float32), dy : BaseArray(Float32)) #

Dot product of two Tensors. Specifically, this is the inner product of two Tensors without the complex conjugate.

t = Tensor.new [1.0, 2.0, 3.0]

dot(t, t) # => 14.0

[View source]
def inner(dx : BaseArray(Float64), dy : BaseArray(Float64)) #

Inner product of two Tensors without the complex conjugate.

t = Tensor.new [1.0, 2.0, 3.0]

inner(t, t) # => 14.0

[View source]
def inner(dx : BaseArray(Float32), dy : BaseArray(Float32)) #

Inner product of two Tensors without the complex conjugate.

t = Tensor.new [1.0, 2.0, 3.0]

inner(t, t) # => 14.0

[View source]
def inv(t : BaseArray) #

[View source]
def inv_helper(a : BaseArray(Float64)) #

Compute the (multiplicative) inverse of a `Matrix.

Given a square matrix a, return the matrix ainv satisfying dot(a, ainv) = dot(ainv, a) = eye(a.shape[0]).

m = Matrix.new [[1.0, 2.0], [3.0, 4.0]]

inv(m)

# Matrix[[    -2.0     1.0]
#        [     1.5    -0.5]]

[View source]
def inv_helper(a : BaseArray(Float32)) #

Compute the (multiplicative) inverse of a `Matrix.

Given a square matrix a, return the matrix ainv satisfying dot(a, ainv) = dot(ainv, a) = eye(a.shape[0]).

m = Matrix.new [[1.0, 2.0], [3.0, 4.0]]

inv(m)

# Matrix[[    -2.0     1.0]
#        [     1.5    -0.5]]

[View source]
def matmul(dx : BaseArray(Float64), dy : BaseArray(Float64), dest : BaseArray(Float64)) #

[View source]
def matmul(dx : BaseArray(Float32), dy : BaseArray(Float32), dest : BaseArray(Float32)) #

[View source]
def matmul(dx : BaseArray(Float64), dy : BaseArray(Float64)) #

Computes the Matrix product of two matrices.

m = Matrix.new [[1.0, 2.0], [3.0, 4.0]]
matmul(m, m)

# Matrix[[      7.0     10.0]
#        [     15.0     22.0]]

[View source]
def matmul(dx : BaseArray(Float32), dy : BaseArray(Float32)) #

Computes the Matrix product of two matrices.

m = Matrix.new [[1.0, 2.0], [3.0, 4.0]]
matmul(m, m)

# Matrix[[      7.0     10.0]
#        [     15.0     22.0]]

[View source]
def matmul_helper(dx : BaseArray(Float64), dy : BaseArray(Float64), dest : BaseArray(Float64)) #

[View source]
def matmul_helper(dx : BaseArray(Float32), dy : BaseArray(Float32), dest : BaseArray(Float32)) #

[View source]
def norm(x : Tensor(Float64)) #

Returns the euclidean norm of a vector via the function name, so that

norm(x) := sqrt( x'*x )

t = Tensor.new [1.0, 2.0, 3.0]

norm(t) # => 3.7416573867739413

[View source]
def norm(x : Tensor(Float32)) #

Returns the euclidean norm of a vector via the function name, so that

norm(x) := sqrt( x'*x )

t = Tensor.new [1.0, 2.0, 3.0]

norm(t) # => 3.7416573867739413

[View source]
def outer(dx : BaseArray(Float64), dy : BaseArray(Float64)) #

Compute the outer product of two Tensors.

Given two vectors, a = [a0, a1, ..., aM] and b = [b0, b1, ..., bN], the outer product is:

# [[a0*b0  a0*b1 ... a0*bN ]
#  [a1*b0    .
#  [ ...          .
#  [aM*b0            aM*bN ]]

[View source]
def outer(dx : BaseArray(Float32), dy : BaseArray(Float32)) #

Compute the outer product of two Tensors.

Given two vectors, a = [a0, a1, ..., aM] and b = [b0, b1, ..., bN], the outer product is:

# [[a0*b0  a0*b1 ... a0*bN ]
#  [a1*b0    .
#  [ ...          .
#  [aM*b0            aM*bN ]]

[View source]
def validate_matrix_shape(dx, dy) #

[View source]

Macro Detail

macro linalg(dtype, prefix) #

[View source]
macro matrix_reduction_retain_size(operation) #

[View source]