Liking cljdoc? Tell your friends :D

org.soulspace.qclojure.domain.math.linear-algebra


lu-decompositionclj

(lu-decomposition matrix)

Perform LU decomposition with partial pivoting for matrix inversion. Returns [L U P] where P is the permutation matrix.

This function uses Gaussian elimination with partial pivoting to decompose the matrix.

Parameters:

  • matrix: A square matrix to decompose (n×n)

Returns: A vector [L U P] where:

  • L is the lower triangular matrix
  • U is the upper triangular matrix
  • P is the permutation vector (indices of rows after pivoting)

Example: (lu-decomposition [[4 3 2] [2 1 1] [1 1 1]]) ;=> [[[1.0 0.0 0.0] [0.5 1.0 0.0] [0.25 0.5 1.0]] [[4.0 3.0 2.0] [0.0 -0.5 -0.5] [0.0 0.0 0.0]] [0 1 2]] ; Permutation

Perform LU decomposition with partial pivoting for matrix inversion.
Returns [L U P] where P is the permutation matrix.
 
This function uses Gaussian elimination with partial pivoting to decompose the matrix. 

Parameters:
- matrix: A square matrix to decompose (n×n)

Returns:
A vector [L U P] where:
- L is the lower triangular matrix
- U is the upper triangular matrix
- P is the permutation vector (indices of rows after pivoting)

Example:
(lu-decomposition [[4 3 2] [2 1 1] [1 1 1]])
;=> [[[1.0 0.0 0.0] [0.5 1.0 0.0] [0.25 0.5 1.0]]
     [[4.0 3.0 2.0] [0.0 -0.5 -0.5] [0.0 0.0 0.0]]
     [0 1 2]] ; Permutation
sourceraw docstring

matrix-inverseclj

(matrix-inverse M)

Compute matrix inverse using Gauss-Jordan elimination.

This is a simple implementation suitable for small matrices (< 20x20). For larger matrices, consider using a dedicated linear algebra library.

Parameters:

  • M: Square matrix as vector of row vectors

Returns: Inverse matrix, or nil if matrix is singular

Compute matrix inverse using Gauss-Jordan elimination.

This is a simple implementation suitable for small matrices (< 20x20).
For larger matrices, consider using a dedicated linear algebra library.

Parameters:
- M: Square matrix as vector of row vectors

Returns:
Inverse matrix, or nil if matrix is singular
sourceraw docstring

matrix-multiplyclj

(matrix-multiply A B)

Multiply two matrices represented as vectors of vectors.

Parameters:

  • A: Matrix A as vector of row vectors
  • B: Matrix B as vector of row vectors

Returns: Matrix product A*B

Multiply two matrices represented as vectors of vectors.

Parameters:
- A: Matrix A as vector of row vectors
- B: Matrix B as vector of row vectors

Returns:
Matrix product A*B
sourceraw docstring

matrix-transposeclj

(matrix-transpose M)

Transpose a matrix.

Parameters:

  • M: Matrix as vector of row vectors

Returns: Transposed matrix

Transpose a matrix.

Parameters:
- M: Matrix as vector of row vectors

Returns:
Transposed matrix
sourceraw docstring

solve-linear-systemclj

(solve-linear-system matrix b)

Solve Ax = b using LU decomposition with partial pivoting.

This function solves the linear system Ax = b where A is a square matrix and b is a vector. It uses LU decomposition with partial pivoting to efficiently solve the system.

Parameters:

  • matrix: Square matrix A (n×n)
  • b: Vector b (n×1)

Returns: Vector x (n×1) that satisfies Ax = b, or nil if no solution

Example: (solve-linear-system [[4 3 2] [2 1 1] [1 1 1]] [1 2 3]) ;=> [0.0 1.0 1.0] ; Solution to the system

Solve Ax = b using LU decomposition with partial pivoting.
 
This function solves the linear system Ax = b where A is a square matrix
and b is a vector. It uses LU decomposition with partial pivoting to
efficiently solve the system.
 
Parameters:
- matrix: Square matrix A (n×n)
- b: Vector b (n×1)

Returns:
Vector x (n×1) that satisfies Ax = b, or nil if no solution

Example:
(solve-linear-system [[4 3 2] [2 1 1] [1 1 1]]
                     [1 2 3])
;=> [0.0 1.0 1.0] ; Solution to the system
sourceraw docstring

tensor-productclj

(tensor-product matrix-a matrix-b)

Compute the tensor product of two matrices.

For matrices A (m×n) and B (p×q), returns the Kronecker product A⊗B (mp×nq).

Parameters:

  • matrix-a: First matrix (m×n)
  • matrix-b: Second matrix (p×q)

Returns: A new matrix representing the tensor product (mp×nq).

Compute the tensor product of two matrices.

For matrices A (m×n) and B (p×q), returns the Kronecker product A⊗B (mp×nq).

Parameters:
- matrix-a: First matrix (m×n)
- matrix-b: Second matrix (p×q)
 
Returns:
A new matrix representing the tensor product (mp×nq).
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close