Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git] / circexp.cpp
blob6861e0e2f1a5149d8e8a0d3cf825582178b5c473
1 // Change circular functions to exponentials
3 #include "stdafx.h"
4 #include "defs.h"
6 void
7 eval_circexp(void)
9 push(cadr(p1));
10 eval();
12 circexp();
14 // normalize
16 eval();
19 void
20 circexp(void)
22 int i, h;
23 save();
24 p1 = pop();
26 if (car(p1) == symbol(COS)) {
27 push(cadr(p1));
28 expcos();
29 restore();
30 return;
33 if (car(p1) == symbol(SIN)) {
34 push(cadr(p1));
35 expsin();
36 restore();
37 return;
40 if (car(p1) == symbol(TAN)) {
41 p1 = cadr(p1);
42 push(imaginaryunit);
43 push(p1);
44 multiply();
45 exponential();
46 p2 = pop();
47 push(imaginaryunit);
48 push(p1);
49 multiply();
50 negate();
51 exponential();
52 p3 = pop();
53 push(p3);
54 push(p2);
55 subtract();
56 push(imaginaryunit);
57 multiply();
58 push(p2);
59 push(p3);
60 add();
61 divide();
62 restore();
63 return;
66 if (car(p1) == symbol(COSH)) {
67 p1 = cadr(p1);
68 push(p1);
69 exponential();
70 push(p1);
71 negate();
72 exponential();
73 add();
74 push_rational(1, 2);
75 multiply();
76 restore();
77 return;
80 if (car(p1) == symbol(SINH)) {
81 p1 = cadr(p1);
82 push(p1);
83 exponential();
84 push(p1);
85 negate();
86 exponential();
87 subtract();
88 push_rational(1, 2);
89 multiply();
90 restore();
91 return;
94 if (car(p1) == symbol(TANH)) {
95 p1 = cadr(p1);
96 push(p1);
97 push_integer(2);
98 multiply();
99 exponential();
100 p1 = pop();
101 push(p1);
102 push_integer(1);
103 subtract();
104 push(p1);
105 push_integer(1);
106 add();
107 divide();
108 restore();
109 return;
112 if (iscons(p1)) {
113 h = tos;
114 while (iscons(p1)) {
115 push(car(p1));
116 circexp();
117 p1 = cdr(p1);
119 list(tos - h);
120 restore();
121 return;
124 if (p1->k == TENSOR) {
125 push(p1);
126 copy_tensor();
127 p1 = pop();
128 for (i = 0; i < p1->u.tensor->nelem; i++) {
129 push(p1->u.tensor->elem[i]);
130 circexp();
131 p1->u.tensor->elem[i] = pop();
133 push(p1);
134 restore();
135 return;
138 push(p1);
139 restore();