1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | DEBUG_RECT = false
|
11 |
|
12 | Eval_rect = ->
|
13 | push(cadr(p1))
|
14 | Eval()
|
15 | rect()
|
16 |
|
17 | rect = ->
|
18 | save()
|
19 | p1 = pop()
|
20 | input = p1
|
21 |
|
22 | if DEBUG_RECT then console.log "RECT of " + input
|
23 |
|
24 | if DEBUG_RECT then console.log "any clock forms in : " + input + " ? " + findPossibleClockForm(input)
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | if issymbol(p1)
|
32 | if DEBUG_RECT then console.log " rect: simple symbol: " + input
|
33 | if !iszero(get_binding(symbol(ASSUME_REAL_VARIABLES)))
|
34 | push(p1)
|
35 | else
|
36 | push_symbol(YYRECT)
|
37 | push(p1)
|
38 | list(2)
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | else if !iszero(get_binding(symbol(ASSUME_REAL_VARIABLES))) and
|
51 | !findPossibleExponentialForm(p1) and
|
52 | !findPossibleClockForm(p1) and
|
53 | !(Find(p1, symbol(SIN)) and Find(p1, symbol(COS)) and Find(p1, imaginaryunit))
|
54 | if DEBUG_RECT then console.log " rect: simple symbol: " + input
|
55 | push(p1)
|
56 |
|
57 |
|
58 | else if (car(p1) == symbol(MULTIPLY) and isimaginaryunit(cadr(p1)) and !iszero(get_binding(symbol(ASSUME_REAL_VARIABLES))))
|
59 | push(p1)
|
60 |
|
61 |
|
62 | else if (car(p1) == symbol(ADD))
|
63 | if DEBUG_RECT then console.log " rect - " + input + " is a sum "
|
64 | push_integer(0)
|
65 | p1 = cdr(p1)
|
66 | while (iscons(p1))
|
67 | push(car(p1))
|
68 | rect()
|
69 | add()
|
70 | p1 = cdr(p1)
|
71 |
|
72 | else
|
73 |
|
74 |
|
75 |
|
76 | if DEBUG_RECT then console.log " rect - " + input + " is NOT a sum "
|
77 |
|
78 | push(p1);
|
79 | abs()
|
80 |
|
81 | if DEBUG_RECT then console.log " rect - " + input + " abs: " + stack[tos-1].toString()
|
82 | push(p1)
|
83 | arg()
|
84 | if DEBUG_RECT then console.log " rect - " + input + " arg of " + p1 + " : " + stack[tos-1].toString()
|
85 | p1 = pop()
|
86 | push(p1)
|
87 | cosine()
|
88 | if DEBUG_RECT then console.log " rect - " + input + " cosine: " + stack[tos-1].toString()
|
89 | push(imaginaryunit)
|
90 | push(p1)
|
91 | sine()
|
92 | if DEBUG_RECT then console.log " rect - " + input + " sine: " + stack[tos-1].toString()
|
93 | multiply()
|
94 | if DEBUG_RECT then console.log " rect - " + input + " i * sine: " + stack[tos-1].toString()
|
95 | add()
|
96 | if DEBUG_RECT then console.log " rect - " + input + " cos + i * sine: " + stack[tos-1].toString()
|
97 | multiply()
|
98 | restore()
|
99 | if DEBUG_RECT then console.log "rect of " + input + " : " + stack[tos-1]
|
100 |
|