Performs various linear algebra operations like finding the inverse, the QR decomposition, the eigenvectors and the eigenvalues.

columnspace(x, matrix = TRUE)

nullspace(x, matrix = TRUE)

rowspace(x, matrix = TRUE)

singular_values(x)

inv(x, method = c("lu", "gauss", "cf", "yac"))

inv2fl(x)

eigenval(x)

eigenvec(x)

GramSchmidt(x)

pinv(x)

rref(x)

QRdecomposition(x)

det(x, ...)

trace_(x)

Arguments

x

A matrix for which a property is requested.

matrix

When relevant should a matrix be returned.

method

The default works by $LU$ decomposition. The alternatives are Gaussian elimination (gauss), the cofactor method (cf), and Ryacas (yac).

...

Auxillary arguments.

Value

Returns the requested property of a matrix.

See also

Examples

if (has_sympy()) {
  A <- matrix(c("a", "0", "0", "1"), 2, 2) |> as_sym()
  
  QRdecomposition(A)
  eigenval(A)
  eigenvec(A)
  inv(A)
  inv2fl(A)
  det(A)
  
  ## Matrix inversion:
  d <- 3
  m <- matrix_sym(d, d)
  print(system.time(inv(m)))                  ## Gauss elimination
  print(system.time(inv(m, method="cf")))     ## Cofactor 
  print(system.time(inv(m, method="lu")))     ## LU decomposition
  if (requireNamespace("Ryacas")){
    print(system.time(inv(m, method="yac")))  ## Use Ryacas
  }

  A <- matrix(c("a", "b", "c", "d"), 2, 2) %>% as_sym()
  evec <- eigenvec(A)
  evec
  evec1 <- evec[[1]]$eigvec
  evec1
  simplify(evec1)
  
  lapply(evec, function(l) simplify(l$eigvec))

  A <- as_sym("[[1, 2, 3], [4, 5, 6]]")
  pinv(A)
}
#>    user  system elapsed 
#>   0.205   0.000   0.205 
#>    user  system elapsed 
#>   0.045   0.000   0.045 
#>    user  system elapsed 
#>   0.236   0.000   0.236 
#> Loading required namespace: Ryacas
#>    user  system elapsed 
#>   0.076   0.000   0.090 
#> c: ⎡-17       ⎤
#>    ⎢────  4/9 ⎥
#>    ⎢ 18       ⎥
#>    ⎢          ⎥
#>    ⎢-1/9  1/9 ⎥
#>    ⎢          ⎥
#>    ⎢ 13       ⎥
#>    ⎢ ──   -2/9⎥
#>    ⎣ 18       ⎦