The R Project SVN R

Rev

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

Rev 59039 Rev 61150
Line 91... Line 91...
91
\examples{
91
\examples{
92
require(graphics)
92
require(graphics)
93
 
93
 
94
0i ^ (-3:3)
94
0i ^ (-3:3)
95
 
95
 
96
matrix(1i^ (-6:5), nrow=4) #- all columns are the same
96
matrix(1i^ (-6:5), nrow = 4) #- all columns are the same
97
0 ^ 1i # a complex NaN
97
0 ^ 1i # a complex NaN
98
 
98
 
99
## create a complex normal vector
99
## create a complex normal vector
100
z <- complex(real = stats::rnorm(100), imaginary = stats::rnorm(100))
100
z <- complex(real = stats::rnorm(100), imaginary = stats::rnorm(100))
101
## or also (less efficiently):
101
## or also (less efficiently):
102
z2 <- 1:2 + 1i*(8:9)
102
z2 <- 1:2 + 1i*(8:9)
103
 
103
 
104
## The Arg(.) is an angle:
104
## The Arg(.) is an angle:
105
zz <- (rep(1:4,len=9) + 1i*(9:1))/10
105
zz <- (rep(1:4, len = 9) + 1i*(9:1))/10
106
zz.shift <- complex(modulus = Mod(zz), argument= Arg(zz) + pi)
106
zz.shift <- complex(modulus = Mod(zz), argument = Arg(zz) + pi)
107
plot(zz, xlim=c(-1,1), ylim=c(-1,1), col="red", asp = 1,
107
plot(zz, xlim = c(-1,1), ylim = c(-1,1), col = "red", asp = 1,
108
     main = expression(paste("Rotation by "," ", pi == 180^o)))
108
     main = expression(paste("Rotation by "," ", pi == 180^o)))
109
abline(h=0,v=0, col="blue", lty=3)
109
abline(h = 0, v = 0, col = "blue", lty = 3)
110
points(zz.shift, col="orange")
110
points(zz.shift, col = "orange")
111
}
111
}
112
\keyword{complex}
112
\keyword{complex}