2005-10-12 01:25:25 +02:00
|
|
|
/* Returns the coefficient of the imaginary part of complex z
|
|
|
|
|
|
|
|
z imag(z)
|
|
|
|
- -------
|
|
|
|
|
|
|
|
a + i b b
|
|
|
|
|
|
|
|
exp(i a) sin(a)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
eval_imag(void)
|
|
|
|
{
|
|
|
|
push(cadr(p1));
|
|
|
|
eval();
|
|
|
|
imag();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
imag(void)
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
rect();
|
|
|
|
p1 = pop();
|
|
|
|
push(p1);
|
|
|
|
push(p1);
|
|
|
|
conjugate();
|
|
|
|
subtract();
|
|
|
|
push_integer(2);
|
|
|
|
divide();
|
|
|
|
push(imaginaryunit);
|
|
|
|
divide();
|
|
|
|
restore();
|
|
|
|
}
|
|
|
|
|
2007-05-08 16:57:30 +02:00
|
|
|
#if SELFTEST
|
|
|
|
|
2005-10-09 23:24:06 +02:00
|
|
|
static char *s[] = {
|
|
|
|
|
|
|
|
"imag(a+i*b)",
|
|
|
|
"b",
|
|
|
|
|
|
|
|
"imag(1+exp(i*pi/3))",
|
|
|
|
"1/2*3^(1/2)",
|
|
|
|
|
|
|
|
"imag(i)",
|
|
|
|
"1",
|
|
|
|
|
|
|
|
"imag((-1)^(1/3))",
|
|
|
|
"1/2*3^(1/2)",
|
|
|
|
|
|
|
|
"imag(-i)",
|
|
|
|
"-1",
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
test_imag(void)
|
|
|
|
{
|
|
|
|
test(__FILE__, s, sizeof s / sizeof (char *));
|
2005-10-12 01:25:25 +02:00
|
|
|
}
|
2007-05-08 16:57:30 +02:00
|
|
|
|
|
|
|
#endif
|