Cordic Program, troubles
Posted: Sun Dec 04, 2011 1:15 pm
Hello everyone,
I am a CLISP newbie, I am learning it in order to "learn better" my calculator's programming language (an HP50g, it uses UserRPL).
I am having trouble with my first program, a CORDIC routine used to calculate sine and cosine in computer with little calculation power. Here is the source:
When I "run" the program the compiler says: *** - >: ANG is not a real number
I cannot work out this error, can anyone help me?
Thanks in advance,
harryme
I am a CLISP newbie, I am learning it in order to "learn better" my calculator's programming language (an HP50g, it uses UserRPL).
I am having trouble with my first program, a CORDIC routine used to calculate sine and cosine in computer with little calculation power. Here is the source:
Code: Select all
(setq vec (vector 45. 26.5650511771 14.0362434679 7.1250163489 3.576334375 1.78991060825 .895173710211 .447614170861 .223810500369 .111905677066 5.59528918938E-2 .027976452617 1.39882271423E-2 6.99411367535E-3 3.4970568507E-3 1.74852842698E-3 8.74264213694E-4 4.37132106872E-4 2.18566053439E-4 1.0928302672E-4 5.46415133601E-5 2.732075668E-5 1.36603783401E-5 6.83018917003E-6))
(format t "~% ~%Inserisci l'angolo: ")
(setq ang (read))
(setq c0 0.607252935)
(setq z0 ang)
(setq d 1)
(setq s0 0)
(loop as i below 23
do (cond
((> z0 0) (setq z1 (- z0 (svref vec i))) (setq c1 (- c0 * d s0)) (setq s1 (+ s0 * d c0)))
((< z0 0) (setq z1 (+ z0 (svref vec i))) (setq c1 (+ c0 * d s0)) (setq s1 (- s0 * d c0)))
)
(setq z0 z1)
(setq c0 c1)
(setq s0 s1)
(setq d (/ d 2))
)
(format t "~%Il seno dell'angolo inserito vale ~F° ~%" s0)
(format t "Il coseno dell'angolo inserito vale ~F° ~%" c0)
(format t "~% ~% ~%")
I cannot work out this error, can anyone help me?
Thanks in advance,
harryme