Skip to content
Snippets Groups Projects
is_positive_definite.Rd 1015 B
Newer Older
Arnaud Duvermy's avatar
Arnaud Duvermy committed
% Generated by roxygen2: do not edit by hand
Arnaud Duvermy's avatar
Arnaud Duvermy committed
% Please edit documentation in R/utils.R
Arnaud Duvermy's avatar
Arnaud Duvermy committed
\name{is_positive_definite}
\alias{is_positive_definite}
\title{Check if a matrix is positive definite
This function checks whether a given matrix is positive definite, i.e., all of its eigenvalues are positive.}
\usage{
is_positive_definite(mat)
}
\arguments{
\item{mat}{The matrix to be checked.}
}
\value{
A logical value indicating whether the matrix is positive definite.
}
\description{
Check if a matrix is positive definite
This function checks whether a given matrix is positive definite, i.e., all of its eigenvalues are positive.
}
\examples{
# Create a positive definite matrix
mat1 <- matrix(c(4, 2, 2, 3), nrow = 2)
is_positive_definite(mat1)
# Expected output: TRUE

# Create a non-positive definite matrix
mat2 <- matrix(c(4, 2, 2, -3), nrow = 2)
is_positive_definite(mat2)
# Expected output: FALSE

# Check an empty matrix
mat3 <- matrix(nrow = 0, ncol = 0)
is_positive_definite(mat3)
# Expected output: TRUE

}