File: lapack-3.10.patch

package info (click to toggle)
r-cran-gnm 1.1-2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,380 kB
  • sloc: ansic: 127; sh: 13; makefile: 5
file content (49 lines) | stat: -rw-r--r-- 2,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Description: Fix test-biplot.R with lapack 3.10
 With lapack 3.10, test-biplot.R fails, because some results have the
 opposite sign compared to the one which is expected.
 .
 This comes from the SVD of barleyMatrix in that test file, which is different
 between lapack 3.9 and 3.10. Mathematically, the SVD is not unique, and lapack
 3.10 returns a different (still valid) solution.
 .
 This patch accomodates sign differences in the columns of the test matrices,
 so that the test passes with both lapack 3.9 and lapack 3.10.
Author: Sébastien Villemot <sebastien@debian.org>
Bug-Debian: https://bugs.debian.org/994457
Forwarded: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=994457#36
Last-Update: 2021-10-11
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/tests/testthat/test-biplot.R
+++ b/tests/testthat/test-biplot.R
@@ -6,6 +6,15 @@ set.seed(1)
 
 # Gabriel, K R (1998). Generalised bilinear regression. Biometrika 85, 689–700.
 
+expect_equivalent_up_to_column_sign <- function(A, B)
+{
+  ok <- nrow(A) == nrow(B) && ncol(A) == ncol(B)
+  if (ok)
+    for (j in 1:ncol(A))
+      ok <- ok && (all(A[,j] == B[,j]) || all(A[,j] == -B[,j]))
+  expect(ok, "Matrices are not equivalent up to column sign")
+}
+
 test_that("biplot model as expected for barley data", {
     biplotModel <- gnm(y ~ -1 + instances(Mult(site, variety), 2),
                        family = wedderburn, data = barley, verbose = FALSE)
@@ -23,12 +32,12 @@ test_that("biplot model as expected for
     # compare vs matrices in Gabriel (1998): 
     # allow for sign change in gnm and in SVD on different systems
     # 3rd element in fit is 1.425 vs 1.42 in paper
-    expect_equivalent(round(abs(A), 2), 
+    expect_equivalent_up_to_column_sign(round(abs(A), 2),
                       matrix(abs(c(-4.19, -2.76, -1.43, -1.85, -1.27, 
                                    -1.16, -1.02, -0.65, 0.15, 
                                    -0.39, -0.34, -0.05, 0.33, 0.16, 
                                    0.4, 0.73, 1.46, 2.13)), nrow = 9))
-    expect_equivalent(round(abs(B), 2), 
+    expect_equivalent_up_to_column_sign(round(abs(B), 2),
                       matrix(abs(c(2.07, 3.06, 2.96, 1.81, 1.56,
                                    1.89, 1.18, 0.85, 0.97, 0.60,
                                    -0.97, -0.51, -0.33, -0.50, -0.08,