3
# Copyright (C) 2013 Baptiste Auguie and Dirk Eddelbuettel
5
# This file is part of RcppArmadillo.
7
# RcppArmadillo is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 2 of the License, or
10
# (at your option) any later version.
12
# RcppArmadillo is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with RcppArmadillo. If not, see <http://www.gnu.org/licenses/>.
20
.setUp <- RcppArmadillo:::unit_test_setup("complex.cpp")
22
test.complex <- function() {
28
A <- matrix(rnorm(9), 3)
29
B <- matrix(rnorm(9), 3)
32
V <- rnorm(3) + 1i * rnorm(3)
33
S <- matrix(rnorm(5*3), nrow=3)
37
rl <- complexCppTests(A, B, V, S) # returns results list from C++
39
checkEquals(rl[["C"]], C, msg="complex matrix")
40
checkEquals(rl[["Cst"]], t(C), msg="complex matrix transpose")
41
checkEquals(rl[["Ct"]], Conj(t(C)), msg="complex matrix transpose conjugated")
42
checkEquals(rl[["conjC"]], Conj(C), msg="complex matrix conjugated")
43
checkEquals(rl[["absC"]], Mod(C), msg="complex matrix mod")
44
checkEquals(rl[["CV"]], C %*% V, msg="complex matrix product")
45
checkEquals(rl[["CS"]], C %*% S, msg="complex matrix times vector")
46
checkEquals(rl[["CC"]], C * C, msg="complex matrix ops mult")
47
checkEquals(rl[["CdC"]], C / C, msg="complex matrix ops div")
48
checkEquals(rl[["CpC"]], C + C, msg="complex matrix ops plus")
49
checkEquals(rl[["CmC"]], C - C, msg="complex matrix ops minus")