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]
/
real.cpp
blob
21d07885eb210cd8ec6fee1a7dab5b9ce5f4b09b
1
/* Returns the real part of complex z
2
3
z real(z)
4
- -------
5
6
a + i b a
7
8
exp(i a) cos(a)
9
*/
10
11
#include
"stdafx.h"
12
#include
"defs.h"
13
14
void
15
eval_real
(
void
)
16
{
17
push
(
cadr
(
p1
));
18
eval
();
19
real
();
20
}
21
22
void
23
real
(
void
)
24
{
25
save
();
26
rect
();
27
p1
=
pop
();
28
push
(
p1
);
29
push
(
p1
);
30
conjugate
();
31
add
();
32
push_integer
(
2
);
33
divide
();
34
restore
();
35
}
36
37
#if SELFTEST
38
39
static char
*
s
[] = {
40
41
"real(a+i*b)"
,
42
"a"
,
43
44
"real(1+exp(i*pi/3))"
,
45
"3/2"
,
46
47
"real(i)"
,
48
"0"
,
49
50
"real((-1)^(1/3))"
,
51
"1/2"
,
52
};
53
54
void
55
test_real
(
void
)
56
{
57
test
(
__FILE__
,
s
,
sizeof
s
/
sizeof
(
char
*));
58
}
59
60
#endif