sqrtmat: Computes square root of a matrix.

Description Usage Arguments Value Examples

View source: R/sqrtmat.R

Description

A function for computing the square roots of a quadratic matrix using the Denman-Beavers algorithm. note that convergence is not guaranteed, even for matrices that do have square roots.

Usage

1
sqrtmat(mat, maxit = 50, tolerance = NA, verbose = FALSE)

Arguments

mat

A numeric matrix where numbers need to be rescaled.

maxit

Number of iterations of the algorithm, by deafult set to 50.

tolerance

Tolerance for the convergence, by deafult set to NA.

verbose

Logical, set to TRUE if you used tolerance criterion and you wish to see the messages about convergence, by deafult set to FALSE.

Value

A list with square root and inverse square root of mat.

Examples

1
2
3
4
5
# create a matrix
mat <- matrix(runif(9), 3, 3)

# taking a square root
sqrtmat(mat)

hstojic/hclass documentation built on May 17, 2019, 6:16 p.m.