scale_matrix: Create list of factors as in a product

View source: R/matrix_scaled.R

scale_matrixR Documentation

Create list of factors as in a product

Description

Create list of factors as in a product

Usage

scale_matrix(X, k = NULL, divide = TRUE)

Arguments

X

matrix

k

scalar to be factored out

divide

Should X be divided with k before constructing scaled matrix?

Examples

if (has_sympy()) {
  V <- matrix_sym(2, 2, "v")
  a <- symbol("a")
  
  K <- a*V
  scale_matrix(K, a)
  scale_matrix(V, a, divide = FALSE)

  Ks <- scale_matrix(V, a, divide = FALSE)
  Ks
  W <- matrix_sym(2, 2, "w")
  unscale_matrix(Ks) %*% W
  unscale_matrix(Ks) %*% W |> scale_matrix(a)
  Ksi <- unscale_matrix(Ks) |> inv() |> scale_matrix(a/det(unscale_matrix(Ks)))
  (Ksi |> unscale_matrix()) %*% (Ks |> unscale_matrix()) |> simplify()
  tex(Ksi)
}


caracas documentation built on June 22, 2024, 10:59 a.m.