The R Project SVN R

Rev

Rev 72142 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 72142 Rev 72294
Line 15... Line 15...
15
## had z[1,3] == 0 and log(0) %*% 0 as as.matrix(0).
15
## had z[1,3] == 0 and log(0) %*% 0 as as.matrix(0).
16
 
16
 
17
## matrix products
17
## matrix products
18
for(mopt in c("default","internal","default.simd")) {
18
for(mopt in c("default","internal","default.simd")) {
19
 
19
 
20
  # matprod="blas" is excluded because some tests fails due to issues
20
  # matprod="blas" is excluded because some tests fail due to issues
21
  # in NaN/Inf propagation even in Rblas
21
  # in NaN/Inf propagation even in Rblas
22
  options(matprod=mopt)
22
  options(matprod=mopt)
23
 
23
 
24
  m <- matrix(c(1,2,3,4), ncol=2)
24
  m <- matrix(c(1,2,3,4), ncol=2)
25
  v <- c(11,12)
25
  v <- c(11,12)
Line 111... Line 111...
111
  stopifnot(identical(m1 %*% m2, matrix(c(18i,24i,30i,38i,52i,66i), 3, 2) ))
111
  stopifnot(identical(m1 %*% m2, matrix(c(18i,24i,30i,38i,52i,66i), 3, 2) ))
112
  stopifnot(identical(crossprod(m1, m1), t(m1) %*% m1))
112
  stopifnot(identical(crossprod(m1, m1), t(m1) %*% m1))
113
  stopifnot(identical(tcrossprod(m1, m1), m1 %*% t(m1)))
113
  stopifnot(identical(tcrossprod(m1, m1), m1 %*% t(m1)))
114
}
114
}
115
 
115
 
-
 
116
## check that propagation of NaN/Inf values in multiplication of complex
-
 
117
## numbers is the same as in multiplication of complex matrices
-
 
118
 
-
 
119
for(mopt in c("default","internal","default.simd")) {
-
 
120
  # matprod="blas" is excluded because some tests fail due to issues
-
 
121
  # in NaN/Inf propagation even in Rblas
-
 
122
  options(matprod=mopt)
-
 
123
 
-
 
124
  vals <- c(0, 1, NaN, Inf)
-
 
125
  for(ar in vals)
-
 
126
  for(ai in vals)
-
 
127
  for(br in vals)
-
 
128
  for(bi in vals) {
-
 
129
    a = ar + 1i * ai
-
 
130
    b = br + 1i * bi
-
 
131
    stopifnot(identical(a * b, as.complex(a %*% b)))
-
 
132
    stopifnot(identical(a * b, as.complex(crossprod(a,b))))
-
 
133
    stopifnot(identical(a * b, as.complex(tcrossprod(a,b))))
-
 
134
  }
-
 
135
}