repo.or.cz
/
eigenmath-fx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git]
/
imag.cpp
blob
d3ebce236709a6c9f9bfa89f4ecdf87bd2cfb1c6
1
/* Returns the coefficient of the imaginary part of complex z
2
3
z imag(z)
4
- -------
5
6
a + i b b
7
8
exp(i a) sin(a)
9
*/
10
11
#include
"stdafx.h"
12
#include
"defs.h"
13
14
void
15
eval_imag
(
void
)
16
{
17
push
(
cadr
(
p1
));
18
eval
();
19
imag
();
20
}
21
22
void
23
imag
(
void
)
24
{
25
save
();
26
rect
();
27
p1
=
pop
();
28
push
(
p1
);
29
push
(
p1
);
30
conjugate
();
31
subtract
();
32
push_integer
(
2
);
33
divide
();
34
push
(
imaginaryunit
);
35
divide
();
36
restore
();
37
}
38
39
#if SELFTEST
40
41
static char
*
s
[] = {
42
43
"imag(a+i*b)"
,
44
"b"
,
45
46
"imag(1+exp(i*pi/3))"
,
47
"1/2*3^(1/2)"
,
48
49
"imag(i)"
,
50
"1"
,
51
52
"imag((-1)^(1/3))"
,
53
"1/2*3^(1/2)"
,
54
55
"imag(-i)"
,
56
"-1"
,
57
};
58
59
void
60
test_imag
(
void
)
61
{
62
test
(
__FILE__
,
s
,
sizeof
s
/
sizeof
(
char
*));
63
}
64
65
#endif