UNPKG

628 Btext/coffeescriptView Raw
1###
2 Returns the coefficient of the imaginary part of complex z
3
4 z imag(z)
5 - -------
6
7 a + i b b
8
9 exp(i a) sin(a)
10###
11
12DEBUG_IMAG = false
13
14Eval_imag = ->
15 push(cadr(p1))
16 Eval()
17 imag()
18
19imag = ->
20 save()
21 rect()
22 p1 = pop()
23
24 if DEBUG_IMAG then console.log "IMAGE of " + p1
25
26 push(p1)
27 push(p1)
28 conjugate()
29 if DEBUG_IMAG then console.log " image: conjugate result: " + stack[tos-1]
30
31 subtract()
32 push_integer(2)
33 divide()
34 if DEBUG_IMAG then console.log " image: 1st divide result: " + stack[tos-1]
35 push(imaginaryunit)
36 divide()
37 if DEBUG_IMAG then console.log " image: 2nd divide result: " + stack[tos-1]
38 restore()
39