Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: math
See also: cdiv cmul csub cadd

Quantlet: cabs
Description: computes absolute value of a complex array

Usage: y = cabs(x)
Input:
x n x p x d1 x ... x dn complex array
Output:
y n x p x d1 x ... x dn array

Example:
library("math")
z = complex(3, 4)
cabs(z)
z = complex(4*matrix(2,2,2), 3*matrix(2,2,2))
cabs(z)

Result:
Contents of y		;; Pythagoras in complex plane
[1,]   5
Contents of y
[,,1,1,1,1,1,1]
[1,]        5        5
[2,]        5        5
[,,2,1,1,1,1,1]
[1,]        5        5
[2,]        5        5
Example:
library("math")
library("plot")
n = 100
t =(0:n)/n
phi = t*2*pi
xr = sqrt(t).*sin(phi)
xi = t^2.*cos(phi)
z = complex(xr, xi)
dat =  setmask(sin(phi)~cabs(z), "line", "blue")
gc = setmask( #(0.2,  0.7)' + grcircle(0.3), "line", "red")
leye = setmask( #(0.1,  0.75)' + grcircle(0.05), "line", "green")
reye = setmask( #(0.3,  0.75)' + grcircle(0.05), "line", "green")
nose = setmask( #(0.2,  0.65)' + grcircle(0.02), "line", "magenta")
plot(dat, gc, leye, reye, nose)

Result:
a curly graph with a "ghost face"



Author: MD*Tech, 20021125 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006