Class ComputeController
In: app/controllers/compute_controller.rb
Parent: ApplicationController

Methods

acos   acosh   add   asin   asinh   atan   atanh   chkstk   cos   cosh   div   dupl   e   exp   expt   finish   init   input   log   log10   mult   neg   pi   pop   push   rcl0   rcl1   rcl2   rcl3   rcl4   rcl5   rcl6   rcl7   rcl8   rcl9   sin   sinh   sqrt   sto0   sto1   sto2   sto3   sto4   sto5   sto6   sto7   sto8   sto9   sub   swap   tan   tanh  

Public Instance methods

[Source]

     # File app/controllers/compute_controller.rb, line 126
126:   def acos
127:     init
128:     if chkstk(1) == 1 then
129:       @calculator.acos
130:     end
131:     finish
132:   end

[Source]

     # File app/controllers/compute_controller.rb, line 147
147:   def acosh
148:     init
149:     if chkstk(1) == 1 then
150:       @calculator.acosh
151:     end
152:     finish
153:   end

[Source]

    # File app/controllers/compute_controller.rb, line 33
33:   def add
34:     init
35:     if chkstk(2) == 1 then
36:       @calculator.add
37:     end
38:     finish
39:   end

[Source]

     # File app/controllers/compute_controller.rb, line 119
119:   def asin
120:     init
121:     if chkstk(1) == 1 then
122:       @calculator.asin
123:     end
124:     finish
125:   end

[Source]

     # File app/controllers/compute_controller.rb, line 140
140:   def asinh
141:     init
142:     if chkstk(1) == 1 then
143:       @calculator.asinh
144:     end
145:     finish
146:   end

[Source]

     # File app/controllers/compute_controller.rb, line 133
133:   def atan
134:     init
135:     if chkstk(1) == 1 then
136:       @calculator.atan
137:     end
138:     finish
139:   end

[Source]

     # File app/controllers/compute_controller.rb, line 154
154:   def atanh
155:     init
156:     if chkstk(1) == 1 then
157:       @calculator.atanh
158:     end
159:     finish
160:   end

[Source]

     # File app/controllers/compute_controller.rb, line 416
416:   def chkstk(sz)
417:     if @stk.size < sz then
418:       @errmsg = "Operation requires " + sz.to_s + " stack entries."
419:       return 0
420:     else
421:       @errmsg = "All is well!"
422:       return 1
423:     end
424:   end

[Source]

    # File app/controllers/compute_controller.rb, line 84
84:   def cos
85:     init
86:     if chkstk(1) == 1 then
87:       @calculator.cos
88:     end
89:     finish
90:   end

[Source]

     # File app/controllers/compute_controller.rb, line 105
105:   def cosh
106:     init
107:     if chkstk(1) == 1 then
108:       @calculator.cosh
109:     end
110:     finish
111:   end

[Source]

    # File app/controllers/compute_controller.rb, line 54
54:   def div
55:     init
56:     if chkstk(2) == 1 then
57:       if (@stk.last == @cconst.zero) then
58:         @errmsg = "Attempted division by zero."
59:       else
60:         @calculator.div
61:       end
62:     end
63:     finish
64:   end

[Source]

     # File app/controllers/compute_controller.rb, line 192
192:   def dupl
193:     init
194:     if chkstk(1) == 1 then
195:       @calculator.dupl
196:     end
197:     finish
198:   end

[Source]

     # File app/controllers/compute_controller.rb, line 357
357:   def e
358:     init
359:     @calculator.e
360:     finish
361:   end

[Source]

     # File app/controllers/compute_controller.rb, line 185
185:   def exp
186:     init
187:     if chkstk(1) == 1 then
188:       @calculator.exp
189:     end
190:     finish
191:   end

[Source]

    # File app/controllers/compute_controller.rb, line 65
65:   def expt
66:     init
67:     if chkstk(2) == 1 then
68:  #     x = @stk[@stk.size-2]
69:  #     if (x.re <= @rconst.zero && x.im == @rconst.zero) then
70:  #       @errmsg = "Attempted illegal expt."
71:  #     else
72:         @calculator.expt
73:  #     end
74:     end
75:     finish
76:   end

[Source]

     # File app/controllers/compute_controller.rb, line 408
408:   def finish
409:     session[:stk] = @stk
410:     session[:errmsg] = @errmsg
411:     session[:mem] = @mem
412:     @in_re = "0.0"
413:     @in_im = "0.0"
414:     render(:action => :input)
415:   end

[Source]

     # File app/controllers/compute_controller.rb, line 362
362:   def init
363:     @data_hash = params[:calculator]
364:     if session[:rconst] then
365:       stk = session[:stk]
366: #      puts "found stk"
367:       rconst = session[:rconst]
368:       rconst.one.setrconst(rconst)
369: #      puts "found rconst"
370:       cconst = session[:cconst]
371:       cconst.one.setcconst(cconst)
372:       cconst.one.setrconst(rconst)
373: #      puts "found cconst"
374:       errmsg = session[:errmsg]
375:       mem = session[:mem]
376:     else
377:       stk = Array.new
378:       session[:stk] = stk
379: #      puts "put stk"
380:       rconst = ApfpConst.new
381:       rconst.one.setrconst(rconst)
382:       rconst.init2
383:       rconst.one.setrconst(rconst)
384:       session[:rconst] = rconst
385: #      puts "put rconst"
386:       cconst = ApcConst.new(rconst)
387:       cconst.one.setcconst(cconst)
388:       cconst.one.setrconst(rconst)
389:       session[:cconst] = cconst
390: #      puts "put cconst"
391:       errmsg = "All is well!"
392:       session[:errmsg] = errmsg
393:       mem=Array(10)
394:       i = 0
395:       while i < 10 do
396:         mem[i] = cconst.zero
397:         i += 1
398:       end
399:       session[:mem] = mem
400:     end
401:     @stk = stk
402:     @errmsg = errmsg
403:     @rconst = rconst
404:     @cconst = cconst
405:     @mem = mem
406:     @calculator = Calculator.new(stk,rconst,cconst,errmsg,mem)
407:   end

[Source]

    # File app/controllers/compute_controller.rb, line 27
27:   def input
28:     init
29:     @in_re = "0.0"
30:     @in_im = "0.0"
31:   end

[Source]

     # File app/controllers/compute_controller.rb, line 161
161:   def log
162:     init
163:     if chkstk(1) == 1 then
164:       x = @stk.last
165:       if (x == @cconst.zero)
166:         @errmsg = "Attempted illegal log."
167:       else
168:         @calculator.log
169:       end
170:     end
171:     finish
172:   end

[Source]

     # File app/controllers/compute_controller.rb, line 173
173:   def log10
174:     init
175:     x = @stk.last
176:     if chkstk(1) == 1 then
177:       if (x == @cconst.zero)
178:         @errmsg = "Attempted illegal log10."
179:       else
180:         @calculator.log10
181:       end
182:     end
183:     finish
184:   end

[Source]

    # File app/controllers/compute_controller.rb, line 47
47:   def mult
48:     init
49:     if chkstk(2) == 1 then
50:       @calculator.mult
51:     end
52:     finish
53:   end

[Source]

     # File app/controllers/compute_controller.rb, line 213
213:   def neg
214:     init
215:     if chkstk(1) == 1 then
216:       @calculator.neg
217:     end
218:     finish
219:   end

[Source]

     # File app/controllers/compute_controller.rb, line 352
352:   def pi
353:     init
354:     @calculator.pi
355:     finish
356:   end

[Source]

     # File app/controllers/compute_controller.rb, line 206
206:   def pop
207:     init
208:     if chkstk(1) == 1 then
209:       @calculator.pop
210:     end
211:     finish
212:   end

[Source]

    # File app/controllers/compute_controller.rb, line 6
 6:   def push
 7:     init
 8:     v_re = @data_hash[:in_re]
 9:     v_im = @data_hash[:in_im]
10: #    puts "v_re = " + v_re.to_s
11: #    puts "v_im = " + v_im.to_s
12:     cv_re = ap_in(v_re)
13:     cv_im = ap_in(v_im)
14:     if cv_re.to_s == "BAD" && cv_im.to_s == "BAD" then
15:       @errmsg = "Both real & imaginary components bad."
16:     elsif cv_re.to_s == "BAD" then
17:       @errmsg = "Real component bad."
18:     elsif cv_im.to_s == "BAD" then
19:       @errmsg = "Imaginary component bad."
20:     else
21:       @errmsg = "All is well!"
22:       v_c= Apc.new(cv_re,cv_im)
23:       @stk.push(v_c)
24:     end
25:     finish
26:   end

[Source]

     # File app/controllers/compute_controller.rb, line 290
290:   def rcl0
291:     init
292:     @calculator.rcl(0)
293:     finish
294:   end

[Source]

     # File app/controllers/compute_controller.rb, line 295
295:   def rcl1
296:     init
297:     @calculator.rcl(1)
298:     finish
299:   end

[Source]

     # File app/controllers/compute_controller.rb, line 300
300:   def rcl2
301:     init
302:     @calculator.rcl(2)
303:     finish
304:   end

[Source]

     # File app/controllers/compute_controller.rb, line 305
305:   def rcl3
306:     init
307:     @calculator.rcl(3)
308:     finish
309:   end

[Source]

     # File app/controllers/compute_controller.rb, line 310
310:   def rcl4
311:     init
312:     @calculator.rcl(4)
313:     finish
314:   end

[Source]

     # File app/controllers/compute_controller.rb, line 315
315:   def rcl5
316:     init
317:     @calculator.rcl(5)
318:     finish
319:   end

[Source]

     # File app/controllers/compute_controller.rb, line 320
320:   def rcl6
321:     init
322:     @calculator.rcl(6)
323:     finish
324:   end

[Source]

     # File app/controllers/compute_controller.rb, line 325
325:   def rcl7
326:     init
327:     @calculator.rcl(7)
328:     finish
329:   end

[Source]

     # File app/controllers/compute_controller.rb, line 330
330:   def rcl8
331:     init
332:     @calculator.rcl(8)
333:      finish
334:   end

[Source]

     # File app/controllers/compute_controller.rb, line 335
335:   def rcl9
336:     init
337:     @calculator.rcl(9)
338:     finish
339:   end

[Source]

    # File app/controllers/compute_controller.rb, line 77
77:   def sin
78:     init
79:     if chkstk(1) == 1 then
80:       @calculator.sin
81:     end
82:     finish
83:   end

[Source]

     # File app/controllers/compute_controller.rb, line 98
 98:   def sinh
 99:     init
100:     if chkstk(1) == 1 then
101:       @calculator.sinh
102:     end
103:     finish
104:   end

[Source]

     # File app/controllers/compute_controller.rb, line 340
340:   def sqrt
341:     init
342:     if chkstk(1) == 1 then
343: #      x = @stk.last
344: #      if (x.re <= @rconst.zero && x.im == @rconst.zero) then
345: #        @errmsg = "Attempted illegal sqrt."
346: #      else
347:         @calculator.sqrt
348: #      end
349:     end
350:     finish
351:   end

[Source]

     # File app/controllers/compute_controller.rb, line 220
220:   def sto0
221:     init
222:     if chkstk(1) == 1 then
223:       @calculator.sto(0)
224:     end
225:     finish
226:   end

[Source]

     # File app/controllers/compute_controller.rb, line 227
227:   def sto1
228:     init
229:     if chkstk(1) == 1 then
230:       @calculator.sto(1)
231:     end
232:     finish
233:   end

[Source]

     # File app/controllers/compute_controller.rb, line 234
234:   def sto2
235:     init
236:     if chkstk(1) == 1 then
237:       @calculator.sto(2)
238:     end
239:     finish
240:   end

[Source]

     # File app/controllers/compute_controller.rb, line 241
241:   def sto3
242:     init
243:     if chkstk(1) == 1 then
244:       @calculator.sto(3)
245:     end
246:     finish
247:   end

[Source]

     # File app/controllers/compute_controller.rb, line 248
248:   def sto4
249:     init
250:     if chkstk(1) == 1 then
251:       @calculator.sto(4)
252:     end
253:     finish
254:   end

[Source]

     # File app/controllers/compute_controller.rb, line 255
255:   def sto5
256:     init
257:     if chkstk(1) == 1 then
258:       @calculator.sto(5)
259:     end
260:     finish
261:   end

[Source]

     # File app/controllers/compute_controller.rb, line 262
262:   def sto6
263:     init
264:     if chkstk(1) == 1 then
265:       @calculator.sto(6)
266:     end
267:     finish
268:   end

[Source]

     # File app/controllers/compute_controller.rb, line 269
269:   def sto7
270:     init
271:     if chkstk(1) == 1 then
272:       @calculator.sto(7)
273:     end
274:     finish
275:   end

[Source]

     # File app/controllers/compute_controller.rb, line 276
276:   def sto8
277:     init
278:     if chkstk(1) == 1 then
279:       @calculator.sto(8)
280:     end
281:     finish
282:   end

[Source]

     # File app/controllers/compute_controller.rb, line 283
283:   def sto9
284:     init
285:     if chkstk(1) == 1 then
286:       @calculator.sto(9)
287:     end
288:     finish
289:   end

[Source]

    # File app/controllers/compute_controller.rb, line 40
40:   def sub
41:     init
42:     if chkstk(2) == 1 then
43:       @calculator.sub
44:     end
45:     finish
46:   end

[Source]

     # File app/controllers/compute_controller.rb, line 199
199:   def swap
200:     init
201:     if chkstk(2) == 1 then
202:       @calculator.swap
203:     end
204:     finish
205:   end

[Source]

    # File app/controllers/compute_controller.rb, line 91
91:   def tan
92:     init
93:     if chkstk(1) == 1 then
94:       @calculator.tan
95:     end
96:     finish
97:   end

[Source]

     # File app/controllers/compute_controller.rb, line 112
112:   def tanh
113:     init
114:     if chkstk(1) == 1 then
115:       @calculator.tanh
116:     end
117:     finish
118:   end

[Validate]