The R Project SVN R

Rev

Rev 81944 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 81944 Rev 89335
Line 1... Line 1...
1
 
1
 
2
R Under development (unstable) (2022-03-19 r81942) -- "Unsuffered Consequences"
2
R Under development (unstable) (2026-01-26 r89332) -- "Unsuffered Consequences"
3
Copyright (C) 2022 The R Foundation for Statistical Computing
3
Copyright (C) 2026 The R Foundation for Statistical Computing
4
Platform: x86_64-pc-linux-gnu (64-bit)
4
Platform: x86_64-pc-linux-gnu
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
8
Type 'license()' or 'licence()' for distribution details.
8
Type 'license()' or 'licence()' for distribution details.
9
 
9
 
Line 135... Line 135...
135
> ## Real Trig.:
135
> ## Real Trig.:
136
> cos(0) == 1
136
> cos(0) == 1
137
[1] TRUE
137
[1] TRUE
138
> sin(3*pi/2) == cos(pi)
138
> sin(3*pi/2) == cos(pi)
139
[1] TRUE
139
[1] TRUE
140
> x <- rnorm(99)
-
 
141
> all( sin(-x) == - sin(x))
-
 
142
[1] TRUE
-
 
143
> all( cos(-x) == cos(x))
-
 
144
[1] TRUE
-
 
145
> 
140
> 
146
> x <- 1:99/100
141
> x <- 1:99/100
-
 
142
> ## IGNORE_RDIFF_BEGIN
147
> all(abs(1 - x / asin(sin(x))) <= 2*Meps)# "== 2*" for HP-UX
143
> table(Isin <- abs(1 - x / asin(sin(x)))/Meps)# mostly 0, often <= 1
-
 
144
 
-
 
145
  0 0.5   1 
-
 
146
 88   2   9 
-
 
147
> table(Itan <- abs(1 - x / atan(tan(x)))/Meps)#  (ditto)
-
 
148
 
-
 
149
  0 0.5   1 
-
 
150
 97   1   1 
-
 
151
> ## IGNORE_RDIFF_END
-
 
152
> all(Isin <= 4) # typically <= 1, 3 needed for [mingw-w64 v12 on Win]
148
[1] TRUE
153
[1] TRUE
149
> all(abs(1 - x / atan(tan(x))) <  2*Meps)
154
> all(Itan <= 4)
150
[1] TRUE
155
[1] TRUE
151
> 
156
> 
152
> ## Sun has asin(.) = acos(.) = 0 for these:
157
> ## Sun has asin(.) = acos(.) = 0 for these:
153
> ##	is.nan(acos(1.1)) && is.nan(asin(-2)) [!]
158
> ##	is.nan(acos(1.1)) && is.nan(asin(-2)) [!]
154
> 
159
> 
Line 213... Line 218...
213
> stopifnot(all.equal( digamma(x), psigamma(x,0), tolerance = 2*Meps),
218
> stopifnot(all.equal( digamma(x), psigamma(x,0), tolerance = 2*Meps),
214
+           all.equal(trigamma(x), psigamma(x,1), tolerance = 2*Meps))# TRUE (+ NaN warnings)
219
+           all.equal(trigamma(x), psigamma(x,1), tolerance = 2*Meps))# TRUE (+ NaN warnings)
215
Warning messages:
220
Warning messages:
216
1: In digamma(x) : NaNs produced
221
1: In digamma(x) : NaNs produced
217
2: In psigamma(x, 0) : NaNs produced
222
2: In psigamma(x, 0) : NaNs produced
218
> ## very large x:
223
> ## very large x,  compare with asymptotic approximation:
219
> x <- 1e30 ^ (1:10)
224
> x <- 1e30 ^ (1:10)
220
> a.relE <- function(appr, true) abs(1 - appr/true)
225
> arelEps <- function(appr, true) abs(1 - appr/true) / Meps
-
 
226
> ## IGNORE_RDIFF_BEGIN
221
> stopifnot(a.relE(digamma(x),   log(x)) < 1e-13,
227
> sort( digamE <- arelEps( digamma(x), log(x))) # all 0 for glibc
-
 
228
 [1] 0 0 0 0 0 0 0 0 0 0
222
+           a.relE(trigamma(x),     1/x) < 1e-13)
229
> sort(trigamE <- arelEps(trigamma(x),  1/x  )) # 11 22 ... 108 159 for glibc
-
 
230
 [1]  11  22  32  43  54  65  75  86 108 159
223
> x <- sqrt(x[2:6]); stopifnot(a.relE(psigamma(x,2), - 1/x^2) < 1e-13)
231
> x <- sqrt(x[2:6]); sort(psiga2E <- arelEps(psigamma(x,2), - 1/x^2)) # 22 33 43 55 65
-
 
232
[1] 22 33 43 55 65
224
> x <- 10^(10*(2:6));stopifnot(a.relE(psigamma(x,5), +24/x^5) < 1e-13)
233
> x <- 10^(10*(2:6));sort(psiga5E <- arelEps(psigamma(x,5), +24/x^5)) #  5 50.5 .. 106
-
 
234
[1]   5.0  50.5  54.0  98.5 106.0
-
 
235
> ## IGNORE_RDIFF_END
-
 
236
> stopifnot(digamE  <   64, # seen '0'
-
 
237
+           trigamE < 1300, # mfuzz: upto 671
-
 
238
+           psiga2E <  430, # mfuzz: upto 212
-
 
239
+           psiga5E < 1010) # mfuzz: upto 505.5
225
> 
240
> 
226
> ## fft():
241
> ## fft():
227
> ok <- TRUE
242
> ok <- TRUE
228
> ##test EXTENSIVELY:	for(N in 1:100) {
243
> ##test EXTENSIVELY:	for(N in 1:100) {
229
>     cat(".")
244
>     cat(".")
Line 242... Line 257...
242
[1] TRUE
257
[1] TRUE
243
> 
258
> 
244
> ## var():
259
> ## var():
245
> for(n in 2:10)
260
> for(n in 2:10)
246
+     print(all.equal(n*(n-1)*var(diag(n)),
261
+     print(all.equal(n*(n-1)*var(diag(n)),
247
+ 		    matrix(c(rep(c(n-1,rep(-1,n)),n-1), n-1), nr=n, nc=n),
262
+ 		    matrix(c(rep(c(n-1,rep(-1,n)),n-1), n-1), nrow=n, ncol=n),
-
 
263
+                                 ##----- use 0*Meps to see non-0 rel.error ==> all TRUE for glibc
248
+ 		    tolerance = 20*Meps)) # use tolerance = 0 to see rel.error
264
+ 		    tolerance = 20*Meps))
249
[1] TRUE
265
[1] TRUE
250
[1] TRUE
266
[1] TRUE
251
[1] TRUE
267
[1] TRUE
252
[1] TRUE
268
[1] TRUE
253
[1] TRUE
269
[1] TRUE
Line 321... Line 337...
321
> is.na(z)
337
> is.na(z)
322
[1] TRUE
338
[1] TRUE
323
> 
339
> 
324
> ## Last Line:
340
> ## Last Line:
325
> cat('Time elapsed: ', proc.time() - .proctime00,'\n')
341
> cat('Time elapsed: ', proc.time() - .proctime00,'\n')
326
Time elapsed:  0.677 0.028 0.714 0 0 
342
Time elapsed:  0.188 0.047 0.237 0 0 
327
> 
343
>