Create list of factors as in a product

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)
}
#> [1] "\\frac{1}{a \\left(v_{11} v_{22} - v_{12} v_{21}\\right)}  \\left[\\begin{matrix}v_{22} & - v_{12}\\\\- v_{21} & v_{11}\\end{matrix}\\right]"