libraryextensions/linalg/lib/Linalg.xtl

Linalg.xtl -- the facade of the linalg extension: numerical linear algebra through nalgebra. Matrices are Float arrays (row by column); a right-hand side may be a vector or a matrix of columns. Import: "la:" u_se< "Linalg" Run with xetal-x (xetal-x --ext DIR puts this directory on XETAL_PATH). Each signature line is written out by the binding macro (lib/Ffi.xtlm).

source · imports ffi: lib/Ffi.xtlm

ˡs̲olve : (Num a, Num b) => a -> b -> Float

function · line 11

a la:s_olve b: x with a x = b (a square and not singular).

"s_olve : float float -> floats"    ᶠᶠⁱb̲ind< "linalg/solve"
ᶠᶠⁱb̲ind< expands to
ˡs̲olve ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/solve?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:linalg/solve?float=" c̲at f̲ormat s̲hape b
  v ← n̲umbers ⎕N̲GET "ext:linalg/solve"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/solve?shape") r̲eshape v
}

ˡi̲nverse : Num a => a -> Float

function · line 13

la:i_nverse a: the inverse of a square matrix.

"i_nverse : float -> floats"        ᶠᶠⁱb̲ind< "linalg/inverse"
ᶠᶠⁱb̲ind< expands to
ˡi̲nverse ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/inverse?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:linalg/inverse"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/inverse?shape") r̲eshape v
}

ˡd̲et : Num a => a -> Float

function · line 15

la:d_et a: the determinant.

"d_et : float -> float"             ᶠᶠⁱb̲ind< "linalg/det"
ᶠᶠⁱb̲ind< expands to
ˡd̲et ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/det?float=" c̲at f̲ormat s̲hape a
  f̲irst n̲umbers ⎕N̲GET "ext:linalg/det"
}

ˡl̲stsq : (Num a, Num b) => a -> b -> Float

function · line 17

a la:l_stsq b: the x minimizing |a x - b| (least squares, by the SVD).

"l_stsq : float float -> floats"    ᶠᶠⁱb̲ind< "linalg/lstsq"
ᶠᶠⁱb̲ind< expands to
ˡl̲stsq ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/lstsq?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:linalg/lstsq?float=" c̲at f̲ormat s̲hape b
  v ← n̲umbers ⎕N̲GET "ext:linalg/lstsq"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/lstsq?shape") r̲eshape v
}

Eigenvalues

ˡe̲ig : Num a => a -> Float

function · line 21

la:e_ig a: a symmetric matrix's eigenvalues, ascending.

"e_ig : float -> floats"            ᶠᶠⁱb̲ind< "linalg/eigsym"
ᶠᶠⁱb̲ind< expands to
ˡe̲ig ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/eigsym?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:linalg/eigsym"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/eigsym?shape") r̲eshape v
}

ˡe̲igVecs : Num a => a -> Float

function · line 24

la:e_igVecs a: a symmetric matrix's eigenvectors, one column each, in the order of ˡᵃe̲ig.

"e_igVecs : float -> floats"        ᶠᶠⁱb̲ind< "linalg/eigvecs"
ᶠᶠⁱb̲ind< expands to
ˡe̲igVecs ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/eigvecs?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:linalg/eigvecs"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/eigvecs?shape") r̲eshape v
}

The singular value decomposition

ˡs̲vdS : Num a => a -> Float

function · line 32

la:s_vdS a: the singular values s, descending.

"s_vdS : float -> floats"           ᶠᶠⁱb̲ind< "linalg/svd_s"
ᶠᶠⁱb̲ind< expands to
ˡs̲vdS ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/svd_s?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:linalg/svd_s"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/svd_s?shape") r̲eshape v
}
Used in: s

ˡs̲vdU : Num a => a -> Float

function · line 34

la:s_vdU a: the left singular vectors U, m by r, one column each.

"s_vdU : float -> floats"           ᶠᶠⁱb̲ind< "linalg/svd_u"
ᶠᶠⁱb̲ind< expands to
ˡs̲vdU ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/svd_u?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:linalg/svd_u"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/svd_u?shape") r̲eshape v
}
Used in: u

ˡs̲vdV : Num a => a -> Float

function · line 36

la:s_vdV a: the right singular vectors V, n by r, one column each.

"s_vdV : float -> floats"           ᶠᶠⁱb̲ind< "linalg/svd_v"
ᶠᶠⁱb̲ind< expands to
ˡs̲vdV ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:linalg/svd_v?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:linalg/svd_v"
  (f̲loor n̲umbers ⎕N̲GET "ext:linalg/svd_v?shape") r̲eshape v
}
Used in: v

ˡpackage : Char

value · line 39

The native package behind these functions.

ˡpackage ← "linalg"