Skip to content

Commit b9b8f10

Browse files
author
maechler
committed
update + even less platform dependent chol() ex.
git-svn-id: https://svn.r-project.org/R/trunk@89120 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 24b3668 commit b9b8f10

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

tests/lapack.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,17 @@ rbind(re = Re(A_b[,2]), im = Im(A_b[,2])) # often was "all NA", now typically "r
185185

186186
## PR#18541 by Mikael Jagan -- chol() error & warning message:
187187
x <- diag(-1, 5L)
188-
(chF <- tryCmsg(chol(x, pivot = FALSE))) # dpotrf
189-
(chT <- withCallingHandlers(warning = function(w) ..W <<- conditionMessage(w),
190-
chol(x, pivot = TRUE ))) # dpstrf
188+
(chF <- tryCmsg(chol(x, pivot = FALSE))) # dpotrf - warning
189+
chT <- withCallingHandlers(warning = function(w) ..W <<- conditionMessage(w),
190+
chol(x, pivot = TRUE )) # dpstrf - warning
191+
## IGNORE_RDIFF_BEGIN
192+
chT # matrix typically == x + pivot and rank (checked below)
193+
## IGNORE_RDIFF_END
191194
stopifnot(exprs = {
192195
grepl(" minor .* not positive$", chF) # was "not positive *definite*
193196
grepl("rank-deficient or not positive definite$", ..W) # was "indefinite*
194197
## platform dependent, Mac has several NaN's chT == -diag(5)
198+
identical(
199+
attr(chT, "pivot"), 1:5)
195200
attr(chT, "rank") %in% 0:1
196201
})

tests/lapack.Rout.save

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
R Under development (unstable) (2023-10-11 r85316) -- "Unsuffered Consequences"
3-
Copyright (C) 2023 The R Foundation for Statistical Computing
2+
R Under development (unstable) (2025-12-07 r89119) -- "Unsuffered Consequences"
3+
Copyright (C) 2025 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

66
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -434,23 +434,28 @@ NaN NaN NaN
434434
> stopifnot(is.na(A_b))
435435
> ## IGNORE_RDIFF_BEGIN
436436
> A_b
437-
11 12
438-
a NaN+NaNi NA
439-
b NaN+NaNi NA
440-
c NaN+NaNi NA
437+
11 12
438+
a NaN+NaNi NaN+NaNi
439+
b NaN+NaNi NaN+NaNi
440+
c NaN+NaNi NaN+NaNi
441441
> rbind(re = Re(A_b[,2]), im = Im(A_b[,2])) # often was "all NA", now typically "re=NA, im=NaN"
442442
a b c
443-
re NA NA NA
443+
re NaN NaN NaN
444444
im NaN NaN NaN
445445
> ## IGNORE_RDIFF_END
446446
>
447447
>
448448
> ## PR#18541 by Mikael Jagan -- chol() error & warning message:
449449
> x <- diag(-1, 5L)
450-
> (chF <- tryCmsg(chol(x, pivot = FALSE))) # dpotrf
450+
> (chF <- tryCmsg(chol(x, pivot = FALSE))) # dpotrf - warning
451451
[1] "the leading minor of order 1 is not positive"
452-
> (chT <- withCallingHandlers(warning = function(w) ..W <<- conditionMessage(w),
453-
+ chol(x, pivot = TRUE ))) # dpstrf
452+
> chT <- withCallingHandlers(warning = function(w) ..W <<- conditionMessage(w),
453+
+ chol(x, pivot = TRUE )) # dpstrf - warning
454+
Warning message:
455+
In chol.default(x, pivot = TRUE) :
456+
the matrix is either rank-deficient or not positive definite
457+
> ## IGNORE_RDIFF_BEGIN
458+
> chT # matrix typically == x + pivot and rank (checked below)
454459
[,1] [,2] [,3] [,4] [,5]
455460
[1,] -1 0 0 0 0
456461
[2,] 0 -1 0 0 0
@@ -461,13 +466,13 @@ attr(,"pivot")
461466
[1] 1 2 3 4 5
462467
attr(,"rank")
463468
[1] 0
464-
Warning message:
465-
In chol.default(x, pivot = TRUE) :
466-
the matrix is either rank-deficient or not positive definite
469+
> ## IGNORE_RDIFF_END
467470
> stopifnot(exprs = {
468471
+ grepl(" minor .* not positive$", chF) # was "not positive *definite*
469472
+ grepl("rank-deficient or not positive definite$", ..W) # was "indefinite*
470473
+ ## platform dependent, Mac has several NaN's chT == -diag(5)
474+
+ identical(
475+
+ attr(chT, "pivot"), 1:5)
471476
+ attr(chT, "rank") %in% 0:1
472477
+ })
473478
>

0 commit comments

Comments
 (0)