We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09e6161 commit 0b142cdCopy full SHA for 0b142cd
R/eigchk.R
@@ -0,0 +1,22 @@
1
+eigchk <- function(Cmat) {
2
+
3
+ # check Cmat for singularity
4
5
+ eigval <- eigen(Cmat)$values
6
+ ncoef <- length(eigval)
7
+ if (eigval[ncoef] < 0) {
8
+ neig <- min(length(eigval),10)
9
+ cat("\nSmallest eigenvalues:\n")
10
+ print(eigval[(ncoef-neig+1):ncoef])
11
+ cat("\nLargest eigenvalues:\n")
12
+ print(eigval[1:neig])
13
+ stop("Negative eigenvalue of coefficient matrix.")
14
+ }
15
+ if (eigval[ncoef] == 0) stop("Zero eigenvalue of coefficient matrix.")
16
+ logcondition <- log10(eigval[1]) - log10(eigval[ncoef])
17
+ if (logcondition > 12) {
18
+ warning("Near singularity in coefficient matrix.")
19
+ cat(paste("\nLog10 Eigenvalues range from\n",
20
+ log10(eigval[ncoef])," to ",log10(eigval[1]),"\n"))
21
22
+}
0 commit comments