matrix.sqrt: Square root of a matrix

matrix.sqrtR Documentation

Square root of a matrix

Description

Computes the square root of the matrix A, where A does not have to be a square matrix, when the square root exists. See https://people.orie.cornell.edu/davidr/SDAFE2/Rscripts/SDAFE2.R

Usage

matrix.sqrt(A)

Arguments

A

A matrix, not necessarily square

Value

Returns the square root of A, if exists, otherwise gives an error message.

Author(s)

Elvan Ceyhan

Examples

A<-matrix(sample(20:40,4),ncol=2)
matrix.sqrt(A)

A<-matrix(sample(20:40,16),ncol=4)
matrix.sqrt(A)
#sqrt of inverse of A, or sqrt inverse of A
matrix.sqrt(solve(A))

#non-square matrix
A<-matrix(sample(20:40,20),ncol=4)
matrix.sqrt(A)


nnspat documentation built on Aug. 30, 2022, 9:06 a.m.