[t] Convert an exception test to PIR
[parrot.git] / t / pmc / complex.t
blobaf42d1588b7b74b131499fe4b84e7d4aa186b303
1 #! parrot
2 # Copyright (C) 2001-2009, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/pmc/complex.t - Complex Numbers
9 =head1 SYNOPSIS
11     % prove t/pmc/complex.t
13 =head1 DESCRIPTION
15 Tests the Complex PMC.
17 =cut
19 .sub main :main
20     .include 'test_more.pir'
21     .include 'fp_equality.pasm'
22     .include "iglobals.pasm"
24     plan(467)
26     string_parsing()
27     exception_malformed_string__real_part()
28     exception_malformed_string__imaginary_part()
29     exception_malformed_string__missing_plus_or_minus()
30     test_complex_add()
31     test_complex_subtract()
32     test_complex_multiply()
33     test_complex_divide()
34     complex_divide_by_zero_Complex()
35     complex_divide_by_zero_Float()
36     complex_divide_by_zero_Integer()
37     get_int_or_num_or_bool()
38     test_get_keyed()
39     exception_get_keyed__invalid_string_key()
40     exception_get_keyed__invalid_numeric_key()
41     set_int_or_num()
42     set_keyed()
43     exception_set_keyed__invalid_key()
44     test_is_equal()
45     test_complex_abs()
46     check_whether_interface_is_done()
47     instantiate__pasm__i()
48     instantiate__pir__n()
49     instantiate__pir__p()
50     instantiate__pir__s()
51     test_complex_neg()
52     test_clone()
53     test_sub()
54     test_i_sub()
55     sprintf_with_a_complex()
56     pow_with_complex_numbers()
57     e_raised_pi_time_i__plus_1_equal_0()
58     ln_of_complex_numbers()
59     exp_of_complex_numbers()
60     sqrt_of_complex_numbers()
61     sin_of_complex_numbers()
62     cos_of_complex_numbers()
63     tan_of_complex_numbers()
64     cot_of_complex_numbers()
65     sec_of_complex_numbers()
66     csc_of_complex_numbers()
67     asin_of_complex_numbers()
68     acos_of_complex_numbers()
69     atan_of_complex_numbers()
70     acot_of_complex_numbers()
71     asec_of_complex_numbers()
72     acsc_of_complex_numbers()
73     sinh_of_complex_numbers()
74     cosh_of_complex_numbers()
75     tanh_of_complex_numbers()
76     coth_of_complex_numbers()
77     sech_of_complex_numbers()
78     csch_of_complex_numbers()
79     add_using_subclass_of_complex_bug_59630()
81     # END_OF_TESTS
83 .end
85 .macro exception_is( M )
86     .local pmc exception
87     .local string message
88     .get_results (exception)
90     message = exception['message']
91     is( message, .M, .M )
92 .endm
94 .sub string_parsing
95     $P0 = new ['Complex']
96     $P1 = new ['String']
98     set $P0, "4"
99     is( $P0, "4+0i", '"4" parsed as 4+0i' )
101     set $P0, "3.14"
102     is( $P0, "3.14+0i", '"3.14" parsed as 3.14+0i' )
104     set $P0, ".5"
105     is( $P0, "0.5+0i", '".5" parsed as 0.5+0i' )
107     set $P0, "-13"
108     is( $P0, "-13+0i", '"-13" parsed as -13+0i' )
110     set $P0, "-.3"
111     is( $P0, "-0.3+0i", '"-.3" parsed as -0.3+0i' )
113     set $P0, "i"
114     is( $P0, "0+1i", '"i" parsed as 0+1i' )
116     set $P0, "-i"
117     is( $P0, "0-1i", '"-i" parsed as 0-1i' )
119     set $P0, ".3i"
120     is( $P0, "0+0.3i", '".3i" parsed as 0+0.3i' )
122     set $P0, "2 + 3i"
123     is( $P0, "2+3i", '"2 + 3i" parsed as 2+3i' )
125     set $P0, "4 + 3.5i"
126     is( $P0, "4+3.5i", '"4 + 3.5i" parsed as 4+3.5i' )
128     set $P0, "2 + .1 i"
129     is( $P0, "2+0.1i", '"2 + .1 i" parsed as 2+0.1i' )
131     set $P0, "10 - i"
132     is( $P0, "10-1i", '"10 - i" parsed as 10-1i' )
134     set $P0, "5 - .3i"
135     is( $P0, "5-0.3i", '"5 - .3i" parsed as 5-0.3i' )
137     set $P1, "-4-i"
138     assign $P0, $P1
139     is( $P0, "-4-1i", '"-4-i" parsed as -4-1i' )
141     set $P1, "- 20 - .5 i"
142     assign $P0, $P1
143     is( $P0, "-20-0.5i", '"- 20 - .5 i" parsed as -20-0.5i' )
145     set $P1, "-13 +2i"
146     assign $P0, $P1
147     is( $P0, "-13+2i", '"-13 +2i" parsed as -13+2i' )
148 .end
150 .sub exception_malformed_string__real_part
151     $P0 = new ['Complex']
152     push_eh handler
153         set $P0, "q + 3i"
154     pop_eh
155 handler:
156     .exception_is( "Complex: malformed string" )
157 .end
159 .sub exception_malformed_string__imaginary_part
160     $P0 = new ['Complex']
161     push_eh handler
162         set $P0, "1 + ij"
163     pop_eh
164 handler:
165     .exception_is( "Complex: malformed string" )
166 .end
168 .sub exception_malformed_string__missing_plus_or_minus
169     $P0 = new ['Complex']
170     push_eh handler
171         set $P0, "1 * i"
172     pop_eh
173 handler:
174     .exception_is( "Complex: malformed string" )
175 .end
177 .sub test_complex_add
178     $P0 = new ['Complex']
179     $P1 = new ['Complex']
180     $P2 = new ['Float']
181     $P3 = new ['Integer']
183     set $P0, "1 + i"
184     add $P0, $P0, $P0
185     is( $P0, "2+2i", '1+i plus 1+i' )
187     set $P0, "1 - i"
188     set $P1, "1 + i"
189     add $P0, $P0, $P1
190     is( $P0, "2+0i", '1-i plus 1+i' )
191     is( $P1, "1+1i", '1+i as text is 1+1i' )
193     set $P0, "-i"
194     set $P1, "1"
195     add $P1, $P0, $P1
196     is( $P0, "0-1i", '-i as text is 0-1i' )
197     is( $P1, "1-1i", '-i plus 1 is 1-1i' )
199     set $P0, "2 + i"
200     set $P2, 3.3
201     add $P1, $P0, $P2
202     is( $P1, "5.3+1i", '2+i plus 3.3 is 5.3+1i' )
204     set $P0, "3 + 5i"
205     add $P1, $P0, 2
206     is( $P1, "5+5i", '3+5i plus literal 2 is 5+5i' )
208     set $P0, "2 + 2i"
209     add $P1, $P0, -2.0
210     is( $P1, "0+2i", '2+2i plus literal -2.0 is 0+2i' )
212     set $P0, "3 + 3i"
213     set $P3, -3
214     add $P1, $P0, $P3
215     is( $P1, "0+3i", '3+3i plus -3 is 0+3i' )
216     add $P1, $P3, $P0
217     is( $P1, "0+3i", '-2 plus 3+3i is 0+3i' )
218 .end
220 .sub test_complex_subtract
221     $P0 = new ['Complex']
222     $P1 = new ['Complex']
223     $P2 = new ['Float']
224     $P3 = new ['Integer']
226     set $P0, "1 + i"
227     sub $P0, $P0, $P0
228     is( $P0, "0+0i", '1+i minus 1+i is 0+0i' )
230     set $P0, "1 - i"
231     set $P1, "1 + i"
232     sub $P0, $P0, $P1
233     is( $P0, "0-2i", '1-i minus 1+i is 0-2i' )
234     is( $P1, "1+1i", '... original $3 is  unchanged' )
236     set $P0, "-i"
237     set $P1, "1"
238     sub $P1, $P0, $P1
239     is( $P0, "0-1i", '-i minus 1 is 0-1i' )
240     is( $P1, "-1-1i", '... original $3 is unchanged' )
242     set $P0, "1 - 4i"
243     set $P2, -1.0
244     sub $P1, $P0, $P2
245     is( $P1, "2-4i", '1-4i minus -1.0 is 2-4i' )
247     set $P0, "- 2 - 2i"
248     sub $P1, $P0, -4
249     is( $P1, "2-2i", '-2-2i minus -4 is 2-2i' )
251     set $P0, "3 + i"
252     sub $P1, $P0, 1.2
253     is( $P1, "1.8+1i", '3+i - literal 1.2 is 1.8+1i' )
255     set $P0, "1024 - 3i"
256     set $P3, 2048
257     sub $P1, $P0, $P3
258     is( $P1, "-1024-3i", '1024-3i minus 2048 is -1024-3i' )
259     sub $P1, $P3, $P0
260     is( $P1, "1024+3i", '2048 minus 1024-3i is 1024+3i' )
261 .end
263 .sub test_complex_multiply
264     $P0 = new ['Complex']
265     $P1 = new ['Complex']
266     $P2 = new ['Float']
267     $P3 = new ['Integer']
269     set $P0, "2 + 3i"
270     mul $P0, $P0, $P0
271     is( $P0, "-5+12i", '2+3i x 2+3i = -5+12i' )
273     set $P0, "5 - 2i"
274     set $P1, "5 + 2i"
275     mul $P0, $P0, $P1
276     is( $P0, "29+0i", '5-2i x 5+2i = 29+0i' )
277     is( $P1, "5+2i", '... original $3 is unchanged' )
279     set $P0, "3i"
280     set $P1, "2 - i"
281     mul $P1, $P0, $P1
282     is( $P0, "0+3i", '3i x 2-i = 0+3i' )
283     is( $P1, "3+6i", '... original $3 is unchanged' )
285     set $P0, "2 - 2i"
286     set $P2, 0.5
287     mul $P1, $P0, $P2
288     is( $P1, "1-1i", '2-2i x 0.5 = 1-1i' )
290     set $P0, "1 - i"
291     mul $P1, $P0, 2
292     is( $P1, "2-2i", '1-i x literal 2 = 2-2i' )
294     set $P0, "-1 + i"
295     mul $P1, $P0, -1.0
296     is( $P1, "1-1i", '-1+i x literal -1.0 = 1-1i' )
298     set $P0, "1 + i"
299     set $P3, 10
300     mul $P1, $P0, $P3
301     is( $P1, "10+10i", '1+i x literal 10 = 10+10i' )
303     mul $P1, $P3, $P0
304     is( $P1, "10+10i", '10 x 1+i is 10+10i' )
305  .end
307 .sub test_complex_divide
308     $P0 = new ['Complex']
309     $P1 = new ['Complex']
310     $P2 = new ['Float']
312     set $P0, "2 + 3i"
313     div $P0, $P0, $P0
314     is( $P0, "1+0i", '2+3i / 2+3i = 1+0i' )
316     set $P0, "3 + 5i"
317     set $P1, "5 - 3i"
318     div $P0, $P0, $P1
319     is( $P0, "0+1i", '3+5i / 5-3i = 0+1i' )
320     is( $P1, "5-3i", '... original $3 is unchanged' )
322     set $P0, "25"
323     set $P1, "3 + 4i"
324     div $P1, $P0, $P1
325     is( $P1, "3-4i", '25 / 3+4i = 3-4i' )
326     is( $P0, "25+0i", '... original $2 is unchanged' )
328     set $P0, "-3 + 6i"
329     set $P2, 3.0
330     div $P1, $P0, $P2
331     is( $P1, "-1+2i", '-3+6i / 3.0 = -1+2i' )
333     set $P0, "-2 + 3i"
334     div $P1, $P0, 2
335     is( $P1, "-1+1.5i", '-2+3i / 2 = -1+1.5i' )
337     set $P0, "2 - 3i"
338     div $P1, $P0, 0.5
339     is( $P1, "4-6i", '2-3i / 0.5 = 4-6i' )
340 .end
342 .sub complex_divide_by_zero_Complex
343     skip( 1, 'div by zero not caught' )
344     .return()
346     $P0 = new ['Complex']
347     set $P0, "4+3.5i"
348     $P1 = new ['Complex']
349     ## divide by a zero Complex
350     $P2 = new ['Complex']
351     set $P2, 0
352     push_eh handler
353         $P1 = $P0 / $P2
354     pop_eh
355 handler:
356     .exception_is( 'Divide by zero' )
357 .end
359 .sub complex_divide_by_zero_Float
360     skip( 1, 'div by zero not caught' )
361     .return()
363     $P0 = new ['Complex']
364     set $P0, "4+3.5i"
365     $P1 = new ['Complex']
366     ## divide by a zero Float
367     $P2 = new ['Float']
368     set $P2, 0
369     push_eh handler
370         $P1 = $P0 / $P2
371 handler:
372     .exception_is( 'Divide by zero' )
373 .end
375 .sub complex_divide_by_zero_Integer
376     skip( 1, 'div by zero not caught' )
377     .return()
379     $P0 = new ['Complex']
380     set $P0, "4+3.5i"
381     $P1 = new ['Complex']
382     ## divide by a zero Integer
383     $P2 = new ['Integer']
384     set $P2, 0
385     push_eh handler
386         $P1 = $P0 / $P2
387 handler:
388     .exception_is( 'Divide by zero' )
389 .end
391 .sub get_int_or_num_or_bool
392         $P0 = new ['Complex']
393         set $P0, "2 - 1.5i"
394         is( $P0, "2-1.5i", 'Complex "2 - 1.5i" returned ok' )
396         set $I0, $P0
397         is( $I0, "2", 'Complex -> Int = 2' )
399         set $N0, $P0
400         .fp_eq_ok( $N0, 2.5, 'Complex -> Num = 2.5')
402         ok( $P0, 'Complex(2-1.5i) -> bool = true' )
404         set $P0, "0"
405         nok( $P0, 'Complex(0) -> bool = true' )
406 .end
408 .sub test_get_keyed
409         $P0 = new ['Complex']
410         $P1 = new ['String']
411         set $P0, "- 3.3 + 1.2i"
412         set $P1, "imag"
414         set $N0, $P0["real"]
415         set $N1, $P0["imag"]
416         set $N2, $P0[$P1]
417         .fp_eq_ok( $N0, -3.3, 'got real part')
418         .fp_eq_ok( $N1, 1.2, 'got imag part')
419         .fp_eq_ok( $N2, 1.2, 'got imag part using variable' )
421         set $P2, $P0["real"]
422         set $P3, $P0[$P1]
423         is( $P2, "-3.3", 'get real portion of -3.3i1.2i' )
424         is( $P3, "1.2", 'get imag portion of -3.3+1.2i' )
426         set $I0, $P0["real"]
427         set $I1, $P0[$P1]
428         is( $I0, "-3", 'get real portion -> Int' )
429         is( $I1, "1", 'get imag portion -> Int' )
430 .end
432 .sub exception_get_keyed__invalid_string_key
433     $P0 = new ['Complex']
434     set $P0, "5 + 3.5i"
435     push_eh handler
436         set $N0, $P0["Foo55"]
437 handler:
438     .exception_is( "Complex: key is neither 'real' or 'imag'" )
439 .end
441 .sub exception_get_keyed__invalid_numeric_key
442     $P0 = new ['Complex']
443     set $P0, "5 + 3.5i"
444     push_eh handler
445         set $N0, $P0[2]
446 handler:
447     .exception_is( "Complex: key must be 0 or 1" )
448 .end
450 .sub set_int_or_num
451     $P0 = new ['Complex']
453     set $P0, "3 + 4i"
454     set $P0, -2
455     is( $P0, "-2+0i", '-2 -> Complex = -2+0i' )
457     set $P0, "2 + 5i"
458     set $P0, .4
459     is( $P0, "0.4+0i", '.4 -> Complex = 0.4+0i' )
460 .end
462 .sub set_keyed
463     $P0 = new ['Complex']
464     $P1 = new ['String']
465     $P2 = new ['String']
466     set $P1, "real"
468     set $P0[$P1], 1
469     set $P0["imag"], 4
470     is( $P0, "1+4i", 'set imag and real portion separately' )
472     set $P0[$P1], 3.2
473     set $P0["imag"], -2.3
474     is( $P0, "3.2-2.3i", '... again' )
476     set $P2, ".5"
477     set $P0[$P1], $P2
478     set $P2, 6
479     set $P0["imag"], $P2
480     is( $P0, "0.5+6i", '... now using String PMCs' )
481 .end
483 .sub exception_set_keyed__invalid_key
484     $P0 = new ['Complex']
485     push_eh handler
486         set $P0[2], 12.5
487 handler:
488     .exception_is( "Complex: key must be 0 or 1" )
489 .end
491 .sub test_is_equal
492     $P0 = new ['Complex']
493     $P1 = new ['Complex']
495     set $P0, "2 + 3j"
496     set $P1["real"], 2
497     set $P1["imag"], 3
499     is( $P0, $P1, 'create new Complex from real/imag and test eq' )
500     set $P1, 0
501     isnt( $P0, $P1, '... now make sure it ne to 0' )
502 .end
504 .sub test_complex_abs
505     $P0 = new ['Complex']
506     set $P0, "4 + 3i"
507     $P1 = new ['Undef']
508     abs $P1, $P0
509     is( $P1, "5", 'abs 4+3j -> 5' )
510 .end
512 .sub check_whether_interface_is_done
513     .local pmc pmc1
514     pmc1 = new ['Complex']
515     .local int bool1
517     does bool1, pmc1, "scalar"
518     ok( bool1, 'Comples does scalar' )
520     does bool1, pmc1, "no_interface"
521     nok( bool1, 'Comples !does no_interface' )
522 .end
524 .sub instantiate__pasm__i
525     skip( 1, 'instantiate n/y' )
526     .return()
528     set $I0, 1
529     set $I1, 2
530     set $I2, 0
531     set $I3, 0
532     set $I4, 0
533     set $I5, 10
534     set $I6, 20
535     get_class $P2, "Complex"
536     # instantiate $P1
537     is( $P1, "10+20i", 'instantiate pasm i' )
538 .end
540 .sub instantiate__pir__n
541     skip( 1, 'instantiate n/y' )
542     .return()
544     $P0 = get_class "Complex"
545     # $P1 = $P0."instantiate"(2.0, 3.0)
546     is( $P1, "2+3i", 'instantiate pir n' )
547 .end
549 .sub instantiate__pir__p
550     skip( 1, 'instantiate n/y' )
551     .return()
553     $P0 = get_class "Complex"
554     $P1 = new ['Float']
555     $P1 = 2.0
556     $P2 = new ['Float']
557     $P2 = 3.0
558     # $P1 = $P0."instantiate"($P1, $P2)
559     is( $P1, "2+3i", 'instantiate pir p' )
560 .end
562 .sub instantiate__pir__s
563     skip( 1, 'instantiate n/y' )
564     .return()
566     $P0 = get_class "Complex"
567     # $P1 = $P0."instantiate"("2 + 3i")
568     is( $P1, "2+3i", 'instantiate pir s' )
569 .end
571 .sub test_complex_neg
572      $P0 = new ['Complex']
573      set $P0, "1.3 + 1.7i"
574      $P1 = new ['Integer']
575      neg $P1, $P0
576      set $N0, $P1[0]
577      set $N1, $P1[1]
578      .fp_eq_ok($N0, -1.3, 'test complex negative')
579      .fp_eq_ok($N1, -1.7, '... and the imag port')
580 .end
582 .sub test_clone
583      $P0 = new ['Complex']
584      set $P0, "1 - 3i"
585      clone $P1, $P0
586      is( $P0, $P1, 'clone Complex PMC')
588      set $P0, "0 + 0i"
589      set $N0, $P1[0]
590      set $N1, $P1[1]
591      .fp_eq_ok($N0, 1.0, 'no change to cloned after setting orig')
592      .fp_eq_ok($N1, -3.0, '... nor to imag portion')
593 .end
595 .sub test_sub
596     .local pmc d, f, c
597     d = new ['Undef']
598     f = new ['Float']
599     c = new ['Complex']
600     f = 2.2
601     c = "5+2j"
602     d = c - f
603     is( d, "2.8+2i", '5+2j - 2.2 = 2.8+i (using d=c-f)' )
605     typeof $S0, d
606     is( $S0, "Complex", 'd is typeof Complex' )
608     d = f - c
609     is( d, "-2.8-2i", '2.2 - 5+2j = -2.8-2i' )
611     typeof $S0, d
612     is( $S0, "Complex", 'typeof still Complex' )
613 .end
615 .sub test_i_sub
616     .local pmc f, c
617     f = new ['Float']
618     f = 2.2
619     c = new ['Complex']
620     c = "5+2j"
621     c -= f
622     is( c, '2.8+2i', 'Complex -= test' )
623     c = new ['Complex']
624     c = "5+2j"
625     f -= c
626     is( f, '-2.8-2i', '... and reverse it' )
627 .end
629 .macro sprintf_is(fmt, number, message)
630     c = .number
631     $S0 = sprintf .fmt, c
632     $S1 = .message
633     is( $S0, $S1, $S1 )
634 .endm
636 .sub sprintf_with_a_complex
637     .local pmc c, c2
638     c = new ['Complex']
639     .sprintf_is( "%d%+di", "1.35+35.1i", "1+35i" )
640     .sprintf_is( "%.3f%+.3fi", "0+3.141592653589793i", "0.000+3.142i" )
641     .sprintf_is( "%.3f%+.3fi", "0+i", "0.000+1.000i" )
642 .end
644 .macro pow_test_is(base, power, message)
645     c = .base
646     c2 = .power
647     c3 = pow c, c2
648     $S0 = sprintf "%.6f%+.6fi", c3
649     $S1 = .message
650     is( $S0, $S1, $S1 )
651 .endm
653 .sub pow_with_complex_numbers
654     .local pmc c, c2, c3
655     c  = new ['Complex']
656     c2 = new ['Complex']
657     c3 = new ['Complex']
658     .pow_test_is( "i", "i", "0.207880+0.000000i" )
659     .pow_test_is( "i", "2", "-1.000000+0.000000i" )
660     .pow_test_is( "2i", "2", "-4.000000+0.000000i" )
661     .pow_test_is( "2+2i", "2+2i", "-1.452505-0.809890i" )
662     .pow_test_is( "i", "0.5i", "0.455938+0.000000i" )
663     .pow_test_is( 2, "2i", "0.183457+0.983028i" )
664     c2 = new ['Integer']
665     .pow_test_is( "2i", 2, "-4.000000+0.000000i" )
666     .pow_test_is( "2", 4, "16.000000+0.000000i" )
667     c2 = new ['Float']
668     .pow_test_is( "2i", 0.5, "1.000000+1.000000i" )
669 .end
671 .sub e_raised_pi_time_i__plus_1_equal_0
672     .local pmc c, c2, c3
673     c  = new ['Complex']
674     c2 = new ['Complex']
675     c3 = new ['Complex']
676     # e^(pi * i) + 1 = 0
677     $N0 = atan 1
678     $N0 *= 4
679     c[0] = 0.0
680     c[1] = $N0
681     c2 = c.'exp'()
682     c2 += 1.0
683     .sprintf_is( "%.3f%+.3fi", c2, "0.000+0.000i" )
684 .end
686 # # The inverse hyperbolic functions are broken wrt -0.0
687 # # Need to find some formal spec for when to return -0.0.
689 .macro complex_op_is( val, res, op )
690     $P1 = new ['Complex']
691     $P2 = new ['Complex']
692     set $P1, .val
694     set $S0, .val
695     set $S1, .res
696     set $S2, .op
698     #XXX: can't do $P1.'$S2'()
699     $P2 = $P1. $S2()
700     $S3 = sprintf "%f%+fi", $P2
702     concat $S4, $S2, " of "
703     concat $S4, $S4, $S0
705     is( $S3, $S1, $S4 )
706 .endm
708 .macro complex_op_todo( val, res, op, todo )
709     $P1 = new ['Complex']
710     $P2 = new ['Complex']
711     set $P1, .val
713     set $S0, .val
714     set $S1, .res
715     set $S2, .op
716     set $S3, .todo
718     #XXX: can't do $P1.'$S2'()
719     $P2 = $P1. $S2()
720     $S3 = sprintf "%f%+fi", $P2
722     concat $S5, $S2, " of "
723     concat $S5, $S5, $S4
725     $I0 = cmp_str $S1, $S3
726     $I0 = not $I0
728     todo( $I0, $S4 )
729 .endm
731 .sub ln_of_complex_numbers
732     .complex_op_is("-2+0i", "0.693147+3.141593i", 'ln' )
733     .complex_op_is("-1+0i", "0.000000+3.141593i", 'ln' )
734     .complex_op_is("-0.5+0i", "-0.693147+3.141593i", 'ln' )
735     .complex_op_is("0.5+0i", "-0.693147+0.000000i", 'ln' )
736     .complex_op_is("1+0i", "0.000000+0.000000i", 'ln' )
737     .complex_op_is("2+0i", "0.693147+0.000000i", 'ln' )
738     .complex_op_is("0-2i", "0.693147-1.570796i", 'ln' )
739     .complex_op_is("0-1i", "0.000000-1.570796i", 'ln' )
740     .complex_op_is("0-0.5i", "-0.693147-1.570796i", 'ln' )
741     .complex_op_is("0+0.5i", "-0.693147+1.570796i", 'ln' )
742     .complex_op_is("0+1i", "0.000000+1.570796i", 'ln' )
743     .complex_op_is("0+2i", "0.693147+1.570796i", 'ln' )
744   t_inf:
745     skip(1, 'inf is not platform-independent' )
746     goto end_inf
747     .complex_op_is("0+0i", "-inf+0.000000i", 'ln' )
748   end_inf:
749     .complex_op_is("2+3i", "1.282475+0.982794i", 'ln' )
750     .complex_op_is("2-3i", "1.282475-0.982794i", 'ln' )
751     .complex_op_is("-2+3i", "1.282475+2.158799i", 'ln' )
752     .complex_op_is("-2-3i", "1.282475-2.158799i", 'ln' )
753 .end
755 .sub exp_of_complex_numbers
756     .complex_op_is( "-2+0i", "0.135335+0.000000i", 'exp' )
757     .complex_op_is( "-1+0i", "0.367879+0.000000i", 'exp' )
758     .complex_op_is( "-0.5+0i", "0.606531+0.000000i", 'exp' )
759     .complex_op_is( "0.5+0i", "1.648721+0.000000i", 'exp' )
760     .complex_op_is( "1+0i", "2.718282+0.000000i", 'exp' )
761     .complex_op_is( "2+0i", "7.389056+0.000000i", 'exp' )
762     .complex_op_is( "0-2i", "-0.416147-0.909297i", 'exp' )
763     .complex_op_is( "0-1i", "0.540302-0.841471i", 'exp' )
764     .complex_op_is( "0-0.5i", "0.877583-0.479426i", 'exp' )
765     .complex_op_is( "0+0.5i", "0.877583+0.479426i", 'exp' )
766     .complex_op_is( "0+1i", "0.540302+0.841471i", 'exp' )
767     .complex_op_is( "0+2i", "-0.416147+0.909297i", 'exp' )
768     .complex_op_is( "0+0i", "1.000000+0.000000i", 'exp' )
769     .complex_op_is( "2+3i", "-7.315110+1.042744i", 'exp' )
770     .complex_op_is( "2-3i", "-7.315110-1.042744i", 'exp' )
771     .complex_op_is( "-2+3i", "-0.133981+0.019099i", 'exp' )
772     .complex_op_is( "-2-3i", "-0.133981-0.019099i", 'exp' )
773 .end
775 .sub sqrt_of_complex_numbers
776     .complex_op_is( "4", "2.000000+0.000000i", 'sqrt' )
777     .complex_op_is( "i", "0.707107+0.707107i", 'sqrt' )
778     .complex_op_is( "2i","1.000000+1.000000i", 'sqrt' )
779     .complex_op_is( "2+2i", "1.553774+0.643594i", 'sqrt' )
780     .complex_op_is( "1+i", "1.098684+0.455090i", 'sqrt' )
781     .complex_op_is( "-2+0i", "0.000000+1.414214i", 'sqrt' )
782     .complex_op_is( "-1+0i", "0.000000+1.000000i", 'sqrt' )
783     .complex_op_is( "-0.5+0i", "0.000000+0.707107i", 'sqrt' )
784     .complex_op_is( "0.5+0i", "0.707107+0.000000i", 'sqrt' )
785     .complex_op_is( "1+0i", "1.000000+0.000000i", 'sqrt' )
786     .complex_op_is( "2+0i", "1.414214+0.000000i", 'sqrt' )
787     .complex_op_is( "0-2i", "1.000000-1.000000i", 'sqrt' )
788     .complex_op_is( "0-1i", "0.707107-0.707107i", 'sqrt' )
789     .complex_op_is( "0-0.5i", "0.500000-0.500000i", 'sqrt' )
790     .complex_op_is( "0+0.5i", "0.500000+0.500000i", 'sqrt' )
791     .complex_op_is( "0+1i", "0.707107+0.707107i", 'sqrt' )
792     .complex_op_is( "0+2i", "1.000000+1.000000i", 'sqrt' )
793     .complex_op_is( "0+0i", "0.000000+0.000000i", 'sqrt' )
794     .complex_op_is( "2+3i", "1.674149+0.895977i", 'sqrt' )
795     .complex_op_is( "2-3i", "1.674149-0.895977i", 'sqrt' )
796     .complex_op_is( "-2+3i", "0.895977+1.674149i", 'sqrt' )
797     .complex_op_is( "-2-3i", "0.895977-1.674149i", 'sqrt' )
798 .end
800 .sub sin_of_complex_numbers
801     .complex_op_is("-2+0i", "-0.909297+0.000000i", 'sin' )
802     .complex_op_is("-1+0i", "-0.841471+0.000000i", 'sin' )
803     .complex_op_is("-0.5+0i", "-0.479426+0.000000i", 'sin' )
804     .complex_op_is("0.5+0i", "0.479426+0.000000i", 'sin' )
805     .complex_op_is("1+0i", "0.841471+0.000000i", 'sin' )
806     .complex_op_is("2+0i", "0.909297+0.000000i", 'sin' )
807     .complex_op_is("0-2i", "0.000000-3.626860i", 'sin' )
808     .complex_op_is("0-1i", "0.000000-1.175201i", 'sin' )
809     .complex_op_is("0-0.5i", "0.000000-0.521095i", 'sin' )
810     .complex_op_is("0+0.5i", "0.000000+0.521095i", 'sin' )
811     .complex_op_is("0+1i", "0.000000+1.175201i", 'sin' )
812     .complex_op_is("0+2i", "0.000000+3.626860i", 'sin' )
813     .complex_op_is("0+0i", "0.000000+0.000000i", 'sin' )
814     .complex_op_is("2+3i", "9.154499-4.168907i", 'sin' )
815     .complex_op_is("2-3i", "9.154499+4.168907i", 'sin' )
816     .complex_op_is("-2+3i", "-9.154499-4.168907i", 'sin' )
817     .complex_op_is("-2-3i", "-9.154499+4.168907i", 'sin' )
818 .end
820 .sub cos_of_complex_numbers
821     .complex_op_is("-2+0i", "-0.416147+0.000000i", 'cos' )
822     .complex_op_is("-1+0i", "0.540302+0.000000i", 'cos' )
823     .complex_op_is("-0.5+0i", "0.877583+0.000000i", 'cos' )
824     .complex_op_is("0.5+0i", "0.877583+0.000000i", 'cos' )
825     .complex_op_is("1+0i", "0.540302+0.000000i", 'cos' )
826     .complex_op_is("2+0i", "-0.416147+0.000000i", 'cos' )
827     .complex_op_is("0-2i", "3.762196+0.000000i", 'cos' )
828     .complex_op_is("0-1i", "1.543081+0.000000i", 'cos' )
829     .complex_op_is("0-0.5i", "1.127626+0.000000i", 'cos' )
830     .complex_op_is("0+0.5i", "1.127626+0.000000i", 'cos' )
831     .complex_op_is("0+1i", "1.543081+0.000000i", 'cos' )
832     .complex_op_is("0+2i", "3.762196+0.000000i", 'cos' )
833     .complex_op_is("0+0i", "1.000000+0.000000i", 'cos' )
834     .complex_op_is("2+3i", "-4.189626-9.109228i", 'cos' )
835     .complex_op_is("2-3i", "-4.189626+9.109228i", 'cos' )
836     .complex_op_is("-2+3i", "-4.189626+9.109228i", 'cos' )
837     .complex_op_is("-2-3i", "-4.189626-9.109228i", 'cos' )
838 .end
840 .sub tan_of_complex_numbers
841     .complex_op_is("-2+0i", "2.185040+0.000000i", 'tan' )
842     .complex_op_is("-1+0i", "-1.557408+0.000000i", 'tan' )
843     .complex_op_is("-0.5+0i", "-0.546302+0.000000i", 'tan' )
844     .complex_op_is("0.5+0i", "0.546302+0.000000i", 'tan' )
845     .complex_op_is("1+0i", "1.557408+0.000000i", 'tan' )
846     .complex_op_is("2+0i", "-2.185040+0.000000i", 'tan' )
847     .complex_op_is("0-2i", "0.000000-0.964028i", 'tan' )
848     .complex_op_is("0-1i", "0.000000-0.761594i", 'tan' )
849     .complex_op_is("0-0.5i", "0.000000-0.462117i", 'tan' )
850     .complex_op_is("0+0.5i", "0.000000+0.462117i", 'tan' )
851     .complex_op_is("0+1i", "0.000000+0.761594i", 'tan' )
852     .complex_op_is("0+2i", "0.000000+0.964028i", 'tan' )
853     .complex_op_is("0+0i", "0.000000+0.000000i", 'tan' )
854     .complex_op_is("2+3i", "-0.003764+1.003239i", 'tan' )
855     .complex_op_is("2-3i", "-0.003764-1.003239i", 'tan' )
856     .complex_op_is("-2+3i", "0.003764+1.003239i", 'tan' )
857     .complex_op_is("-2-3i", "0.003764-1.003239i", 'tan' )
858 .end
860 .sub cot_of_complex_numbers
861     .complex_op_is("-2+0i", "0.457658+0.000000i", 'cot' )
862     .complex_op_is("-1+0i", "-0.642093+0.000000i", 'cot' )
863     .complex_op_is("-0.5+0i", "-1.830488+0.000000i", 'cot' )
864     .complex_op_is("0.5+0i", "1.830488+0.000000i", 'cot' )
865     .complex_op_is("1+0i", "0.642093+0.000000i", 'cot' )
866     .complex_op_is("2+0i", "-0.457658+0.000000i", 'cot' )
867     .complex_op_is("0-2i", "0.000000+1.037315i", 'cot' )
868     .complex_op_is("0-1i", "0.000000+1.313035i", 'cot' )
869     .complex_op_is("0-0.5i", "0.000000+2.163953i", 'cot' )
870     .complex_op_is("0+0.5i", "0.000000-2.163953i", 'cot' )
871     .complex_op_is("0+1i", "0.000000-1.313035i", 'cot' )
872     .complex_op_is("0+2i", "0.000000-1.037315i", 'cot' )
873     .complex_op_is("2+3i", "-0.003740-0.996758i", 'cot' )
874     .complex_op_is("2-3i", "-0.003740+0.996758i", 'cot' )
875     .complex_op_is("-2+3i", "0.003740-0.996758i", 'cot' )
876     .complex_op_is("-2-3i", "0.003740+0.996758i", 'cot' )
877 .end
879 .sub sec_of_complex_numbers
880     .complex_op_is("-2+0i", "-2.402998+0.000000i", 'sec' )
881     .complex_op_is("-1+0i", "1.850816+0.000000i", 'sec' )
882     .complex_op_is("-0.5+0i", "1.139494+0.000000i", 'sec' )
883     .complex_op_is("0.5+0i", "1.139494+0.000000i", 'sec' )
884     .complex_op_is("1+0i", "1.850816+0.000000i", 'sec' )
885     .complex_op_is("2+0i", "-2.402998+0.000000i", 'sec' )
886     .complex_op_is("0-2i", "0.265802+0.000000i", 'sec' )
887     .complex_op_is("0-1i", "0.648054+0.000000i", 'sec' )
888     .complex_op_is("0-0.5i", "0.886819+0.000000i", 'sec' )
889     .complex_op_is("0+0.5i", "0.886819+0.000000i", 'sec' )
890     .complex_op_is("0+1i", "0.648054+0.000000i", 'sec' )
891     .complex_op_is("0+2i", "0.265802+0.000000i", 'sec' )
892     .complex_op_is("0+0i", "1.000000+0.000000i", 'sec' )
893     .complex_op_is("2+3i", "-0.041675+0.090611i", 'sec' )
894     .complex_op_is("2-3i", "-0.041675-0.090611i", 'sec' )
895     .complex_op_is("-2+3i", "-0.041675-0.090611i", 'sec' )
896     .complex_op_is("-2-3i", "-0.041675+0.090611i", 'sec' )
897 .end
899 .sub csc_of_complex_numbers
900     .complex_op_is("-2+0i", "-1.099750+0.000000i", 'csc' )
901     .complex_op_is("-1+0i", "-1.188395+0.000000i", 'csc' )
902     .complex_op_is("-0.5+0i", "-2.085830+0.000000i", 'csc' )
903     .complex_op_is("0.5+0i", "2.085830+0.000000i", 'csc' )
904     .complex_op_is("1+0i", "1.188395+0.000000i", 'csc' )
905     .complex_op_is("2+0i", "1.099750+0.000000i", 'csc' )
906     .complex_op_is("0-2i", "0.000000+0.275721i", 'csc' )
907     .complex_op_is("0-1i", "0.000000+0.850918i", 'csc' )
908     .complex_op_is("0-0.5i", "0.000000+1.919035i", 'csc' )
909     .complex_op_is("0+0.5i", "0.000000-1.919035i", 'csc' )
910     .complex_op_is("0+1i", "0.000000-0.850918i", 'csc' )
911     .complex_op_is("0+2i", "0.000000-0.275721i", 'csc' )
912     .complex_op_is("2+3i", "0.090473+0.041201i", 'csc' )
913     .complex_op_is("2-3i", "0.090473-0.041201i", 'csc' )
914     .complex_op_is("-2+3i", "-0.090473+0.041201i", 'csc' )
915     .complex_op_is("-2-3i", "-0.090473-0.041201i", 'csc' )
916 .end
918 .sub asin_of_complex_numbers
919     .complex_op_is("-2+0i", "-1.570796+1.316958i", 'asin' )
920     .complex_op_is("-1+0i", "-1.570796+0.000000i", 'asin' )
921     .complex_op_is("-0.5+0i", "-0.523599+0.000000i", 'asin' )
922     .complex_op_is("0.5+0i", "0.523599+0.000000i", 'asin' )
923     .complex_op_is("1+0i", "1.570796+0.000000i", 'asin' )
924     .complex_op_is("2+0i", "1.570796-1.316958i", 'asin' )
925     .complex_op_is("0-2i", "0.000000-1.443635i", 'asin' )
926     .complex_op_is("0-1i", "0.000000-0.881374i", 'asin' )
927     .complex_op_is("0-0.5i", "0.000000-0.481212i", 'asin' )
928     .complex_op_is("0+0.5i", "0.000000+0.481212i", 'asin' )
929     .complex_op_is("0+1i", "0.000000+0.881374i", 'asin' )
930     .complex_op_is("0+2i", "0.000000+1.443635i", 'asin' )
931     .complex_op_is("0+0i", "0.000000+0.000000i", 'asin' )
932     .complex_op_is("2+3i", "0.570653+1.983387i", 'asin' )
933     .complex_op_is("2-3i", "0.570653-1.983387i", 'asin' )
934     .complex_op_is("-2+3i", "-0.570653+1.983387i", 'asin' )
935     .complex_op_is("-2-3i", "-0.570653-1.983387i", 'asin' )
936 .end
938 .sub acos_of_complex_numbers
939     .complex_op_is("-2+0i", "3.141593-1.316958i", 'acos' )
940     .complex_op_is("-1+0i", "3.141593+0.000000i", 'acos' )
941     .complex_op_is("-0.5+0i", "2.094395+0.000000i", 'acos' )
942     .complex_op_is("0.5+0i", "1.047198+0.000000i", 'acos' )
943     .complex_op_is("1+0i", "0.000000+0.000000i", 'acos' )
944     .complex_op_is("2+0i", "0.000000+1.316958i", 'acos' )
945     .complex_op_is("0-2i", "1.570796+1.443635i", 'acos' )
946     .complex_op_is("0-1i", "1.570796+0.881374i", 'acos' )
947     .complex_op_is("0-0.5i", "1.570796+0.481212i", 'acos' )
948     .complex_op_is("0+0.5i", "1.570796-0.481212i", 'acos' )
949     .complex_op_is("0+1i", "1.570796-0.881374i", 'acos' )
950     .complex_op_is("0+2i", "1.570796-1.443635i", 'acos' )
951     .complex_op_is("0+0i", "1.570796+0.000000i", 'acos' )
952     .complex_op_is("2+3i", "1.000144-1.983387i", 'acos' )
953     .complex_op_is("2-3i", "1.000144+1.983387i", 'acos' )
954     .complex_op_is("-2+3i", "2.141449-1.983387i", 'acos' )
955     .complex_op_is("-2-3i", "2.141449+1.983387i", 'acos' )
956 .end
958 .sub atan_of_complex_numbers
959     .complex_op_is("-2+0i", "-1.107149+0.000000i", 'atan' )
960     .complex_op_is("-1+0i", "-0.785398+0.000000i", 'atan' )
961     .complex_op_is("-0.5+0i", "-0.463648+0.000000i", 'atan' )
962     .complex_op_is("0.5+0i", "0.463648+0.000000i", 'atan' )
963     .complex_op_is("1+0i", "0.785398+0.000000i", 'atan' )
964     .complex_op_is("2+0i", "1.107149+0.000000i", 'atan' )
965     .complex_op_is("0-2i", "-1.570796-0.549306i", 'atan' )
966     .complex_op_is("0-0.5i", "0.000000-0.549306i", 'atan' )
967     .complex_op_is("0+0.5i", "0.000000+0.549306i", 'atan' )
968     .complex_op_is("0+2i", "-1.570796+0.549306i", 'atan' )
969     .complex_op_is("0+0i", "0.000000+0.000000i", 'atan' )
970     .complex_op_is("2+3i", "1.409921+0.229073i", 'atan' )
971     .complex_op_is("2-3i", "1.409921-0.229073i", 'atan' )
972     .complex_op_is("-2+3i", "-1.409921+0.229073i", 'atan' )
973     .complex_op_is("-2-3i", "-1.409921-0.229073i", 'atan' )
974 .end
976 .sub acot_of_complex_numbers
977     .complex_op_is("-2+0i", "-0.463648+0.000000i", 'acot' )
978     .complex_op_is("-1+0i", "-0.785398+0.000000i", 'acot' )
979     .complex_op_is("-0.5+0i", "-1.107149+0.000000i", 'acot' )
980     .complex_op_is("0.5+0i", "1.107149+0.000000i", 'acot' )
981     .complex_op_is("1+0i", "0.785398+0.000000i", 'acot' )
982     .complex_op_is("2+0i", "0.463648+0.000000i", 'acot' )
983     .complex_op_is("0-2i", "0.000000+0.549306i", 'acot' )
984     .complex_op_is("0-0.5i", "-1.570796+0.549306i", 'acot' )
985     .complex_op_is("0+0.5i", "-1.570796-0.549306i", 'acot' )
986     .complex_op_is("0+2i", "0.000000-0.549306i", 'acot' )
987     .complex_op_is("2+3i", "0.160875-0.229073i", 'acot' )
988     .complex_op_is("2-3i", "0.160875+0.229073i", 'acot' )
989     .complex_op_is("-2+3i", "-0.160875-0.229073i", 'acot' )
990     .complex_op_is("-2-3i", "-0.160875+0.229073i", 'acot' )
991 .end
993 .sub asec_of_complex_numbers
994     .complex_op_is("-2+0i", "2.094395+0.000000i", 'asec' )
995     .complex_op_is("-1+0i", "3.141593+0.000000i", 'asec' )
996     .complex_op_is("-0.5+0i", "3.141593-1.316958i", 'asec' )
997     .complex_op_is("0.5+0i", "0.000000+1.316958i", 'asec' )
998     .complex_op_is("1+0i", "0.000000+0.000000i", 'asec' )
999     .complex_op_is("2+0i", "1.047198+0.000000i", 'asec' )
1000     .complex_op_is("0-2i", "1.570796-0.481212i", 'asec' )
1001     .complex_op_is("0-1i", "1.570796-0.881374i", 'asec' )
1002     .complex_op_is("0-0.5i", "1.570796-1.443635i", 'asec' )
1003     .complex_op_is("0+0.5i", "1.570796+1.443635i", 'asec' )
1004     .complex_op_is("0+1i", "1.570796+0.881374i", 'asec' )
1005     .complex_op_is("0+2i", "1.570796+0.481212i", 'asec' )
1006     .complex_op_is("2+3i", "1.420411+0.231335i", 'asec' )
1007     .complex_op_is("2-3i", "1.420411-0.231335i", 'asec' )
1008     .complex_op_is("-2+3i", "1.721182+0.231335i", 'asec' )
1009     .complex_op_is("-2-3i", "1.721182-0.231335i", 'asec' )
1010 .end
1012 .sub acsc_of_complex_numbers
1013     .complex_op_is("-2+0i", "-0.523599+0.000000i", 'acsc' )
1014     .complex_op_is("-1+0i", "-1.570796+0.000000i", 'acsc' )
1015     .complex_op_is("-0.5+0i", "-1.570796+1.316958i", 'acsc' )
1016     .complex_op_is("0.5+0i", "1.570796-1.316958i", 'acsc' )
1017     .complex_op_is("1+0i", "1.570796+0.000000i", 'acsc' )
1018     .complex_op_is("2+0i", "0.523599+0.000000i", 'acsc' )
1019     .complex_op_is("0-2i", "0.000000+0.481212i", 'acsc' )
1020     .complex_op_is("0-1i", "0.000000+0.881374i", 'acsc' )
1021     .complex_op_is("0-0.5i", "0.000000+1.443635i", 'acsc' )
1022     .complex_op_is("0+0.5i", "0.000000-1.443635i", 'acsc' )
1023     .complex_op_is("0+1i", "0.000000-0.881374i", 'acsc' )
1024     .complex_op_is("0+2i", "0.000000-0.481212i", 'acsc' )
1025     .complex_op_is("2+3i", "0.150386-0.231335i", 'acsc' )
1026     .complex_op_is("2-3i", "0.150386+0.231335i", 'acsc' )
1027     .complex_op_is("-2+3i", "-0.150386-0.231335i", 'acsc' )
1028     .complex_op_is("-2-3i", "-0.150386+0.231335i", 'acsc' )
1029 .end
1031 .sub sinh_of_complex_numbers
1032     .local pmc config_hash, interp
1033     .local string has_negative_zero
1034     interp = getinterp
1035     config_hash = interp[.IGLOBALS_CONFIG_HASH]
1036     has_negative_zero = config_hash["has_negative_zero"]
1038     .complex_op_is("-2+0i", "-3.626860+0.000000i", 'sinh' )
1039     .complex_op_is("-1+0i", "-1.175201+0.000000i", 'sinh' )
1040     .complex_op_is("-0.5+0i", "-0.521095+0.000000i", 'sinh' )
1041     .complex_op_is("0.5+0i", "0.521095+0.000000i", 'sinh' )
1042     .complex_op_is("1+0i", "1.175201+0.000000i", 'sinh' )
1043     .complex_op_is("2+0i", "3.626860+0.000000i", 'sinh' )
1044     .complex_op_is("0-1i", "0.000000-0.841471i", 'sinh' )
1045     .complex_op_is("0-0.5i", "0.000000-0.479426i", 'sinh' )
1046     .complex_op_is("0+0.5i", "0.000000+0.479426i", 'sinh' )
1047     .complex_op_is("0+1i", "0.000000+0.841471i", 'sinh' )
1048     .complex_op_is("0+0i", "0.000000+0.000000i", 'sinh' )
1049     .complex_op_is("2+3i", "-3.590565+0.530921i", 'sinh' )
1050     .complex_op_is("2-3i", "-3.590565-0.530921i", 'sinh' )
1051     .complex_op_is("-2+3i", "3.590565+0.530921i", 'sinh' )
1052     .complex_op_is("-2-3i", "3.590565-0.530921i", 'sinh' )
1054     unless has_negative_zero goto todo
1055     .complex_op_is("0-2i", "-0.000000-0.909297i", 'sinh' )
1056     .complex_op_is("0+2i", "-0.000000+0.909297i", 'sinh' )
1057     .return()
1059 todo:
1060     .complex_op_todo("0-2i", "-0.000000-0.909297i", 'sinh', 'TT #313' )
1061     .complex_op_todo("0+2i", "-0.000000+0.909297i", 'sinh', 'TT #313' )
1062     .return()
1063 .end
1065 .sub cosh_of_complex_numbers
1066     .complex_op_is("-2+0i", "3.762196+0.000000i", 'cosh' )
1067     .complex_op_is("-1+0i", "1.543081+0.000000i", 'cosh' )
1068     .complex_op_is("-0.5+0i", "1.127626+0.000000i", 'cosh' )
1069     .complex_op_is("0.5+0i", "1.127626+0.000000i", 'cosh' )
1070     .complex_op_is("1+0i", "1.543081+0.000000i", 'cosh' )
1071     .complex_op_is("2+0i", "3.762196+0.000000i", 'cosh' )
1072     .complex_op_is("0-2i", "-0.416147+0.000000i", 'cosh' )
1073     .complex_op_is("0-1i", "0.540302+0.000000i", 'cosh' )
1074     .complex_op_is("0-0.5i", "0.877583+0.000000i", 'cosh' )
1075     .complex_op_is("0+0.5i", "0.877583+0.000000i", 'cosh' )
1076     .complex_op_is("0+1i", "0.540302+0.000000i", 'cosh' )
1077     .complex_op_is("0+2i", "-0.416147+0.000000i", 'cosh' )
1078     .complex_op_is("0+0i", "1.000000+0.000000i", 'cosh' )
1079     .complex_op_is("2+3i", "-3.724546+0.511823i", 'cosh' )
1080     .complex_op_is("2-3i", "-3.724546-0.511823i", 'cosh' )
1081     .complex_op_is("-2+3i", "-3.724546-0.511823i", 'cosh' )
1082     .complex_op_is("-2-3i", "-3.724546+0.511823i", 'cosh' )
1083 .end
1085 .sub tanh_of_complex_numbers
1086     .complex_op_is("-2+0i", "-0.964028+0.000000i", 'tanh' )
1087     .complex_op_is("-1+0i", "-0.761594+0.000000i", 'tanh' )
1088     .complex_op_is("-0.5+0i", "-0.462117+0.000000i", 'tanh' )
1089     .complex_op_is("0.5+0i", "0.462117+0.000000i", 'tanh' )
1090     .complex_op_is("1+0i", "0.761594+0.000000i", 'tanh' )
1091     .complex_op_is("2+0i", "0.964028+0.000000i", 'tanh' )
1092     .complex_op_is("0-2i", "0.000000+2.185040i", 'tanh' )
1093     .complex_op_is("0-1i", "0.000000-1.557408i", 'tanh' )
1094     .complex_op_is("0-0.5i", "0.000000-0.546302i", 'tanh' )
1095     .complex_op_is("0+0.5i", "0.000000+0.546302i", 'tanh' )
1096     .complex_op_is("0+1i", "0.000000+1.557408i", 'tanh' )
1097     .complex_op_is("0+2i", "0.000000-2.185040i", 'tanh' )
1098     .complex_op_is("0+0i", "0.000000+0.000000i", 'tanh' )
1099     .complex_op_is("2+3i", "0.965386-0.009884i", 'tanh' )
1100     .complex_op_is("2-3i", "0.965386+0.009884i", 'tanh' )
1101     .complex_op_is("-2+3i", "-0.965386-0.009884i", 'tanh' )
1102     .complex_op_is("-2-3i", "-0.965386+0.009884i", 'tanh' )
1103 .end
1105 .sub coth_of_complex_numbers
1106     .complex_op_is("-2+0i", "-1.037315+0.000000i", 'coth' )
1107     .complex_op_is("-1+0i", "-1.313035+0.000000i", 'coth' )
1108     .complex_op_is("-0.5+0i", "-2.163953+0.000000i", 'coth' )
1109     .complex_op_is("0.5+0i", "2.163953+0.000000i", 'coth' )
1110     .complex_op_is("1+0i", "1.313035+0.000000i", 'coth' )
1111     .complex_op_is("2+0i", "1.037315+0.000000i", 'coth' )
1112     .complex_op_is("0-2i", "0.000000-0.457658i", 'coth' )
1113     .complex_op_is("0-1i", "0.000000+0.642093i", 'coth' )
1114     .complex_op_is("0-0.5i", "0.000000+1.830488i", 'coth' )
1115     .complex_op_is("0+0.5i", "0.000000-1.830488i", 'coth' )
1116     .complex_op_is("0+1i", "0.000000-0.642093i", 'coth' )
1117     .complex_op_is("0+2i", "0.000000+0.457658i", 'coth' )
1118     .complex_op_is("2+3i", "1.035747+0.010605i", 'coth' )
1119     .complex_op_is("2-3i", "1.035747-0.010605i", 'coth' )
1120     .complex_op_is("-2+3i", "-1.035747+0.010605i", 'coth' )
1121     .complex_op_is("-2-3i", "-1.035747-0.010605i", 'coth' )
1122 .end
1124 .sub sech_of_complex_numbers
1125     .complex_op_is("-2+0i", "0.265802+0.000000i", 'sech' )
1126     .complex_op_is("-1+0i", "0.648054+0.000000i", 'sech' )
1127     .complex_op_is("-0.5+0i", "0.886819+0.000000i", 'sech' )
1128     .complex_op_is("0.5+0i", "0.886819+0.000000i", 'sech' )
1129     .complex_op_is("1+0i", "0.648054+0.000000i", 'sech' )
1130     .complex_op_is("2+0i", "0.265802+0.000000i", 'sech' )
1131     .complex_op_is("0-2i", "-2.402998+0.000000i", 'sech' )
1132     .complex_op_is("0-1i", "1.850816+0.000000i", 'sech' )
1133     .complex_op_is("0-0.5i", "1.139494+0.000000i", 'sech' )
1134     .complex_op_is("0+0.5i", "1.139494+0.000000i", 'sech' )
1135     .complex_op_is("0+1i", "1.850816+0.000000i", 'sech' )
1136     .complex_op_is("0+2i", "-2.402998+0.000000i", 'sech' )
1137     .complex_op_is("0+0i", "1.000000+0.000000i", 'sech' )
1138     .complex_op_is("2+3i", "-0.263513-0.036212i", 'sech' )
1139     .complex_op_is("2-3i", "-0.263513+0.036212i", 'sech' )
1140     .complex_op_is("-2+3i", "-0.263513+0.036212i", 'sech' )
1141     .complex_op_is("-2-3i", "-0.263513-0.036212i", 'sech' )
1142 .end
1144 .sub csch_of_complex_numbers
1145     .complex_op_is("-2+0i", "-0.275721+0.000000i", 'csch' )
1146     .complex_op_is("-1+0i", "-0.850918+0.000000i", 'csch' )
1147     .complex_op_is("-0.5+0i", "-1.919035+0.000000i", 'csch' )
1148     .complex_op_is("0.5+0i", "1.919035+0.000000i", 'csch' )
1149     .complex_op_is("1+0i", "0.850918+0.000000i", 'csch' )
1150     .complex_op_is("2+0i", "0.275721+0.000000i", 'csch' )
1151     .complex_op_is("0-2i", "0.000000+1.099750i", 'csch' )
1152     .complex_op_is("0-1i", "0.000000+1.188395i", 'csch' )
1153     .complex_op_is("0-0.5i", "0.000000+2.085830i", 'csch' )
1154     .complex_op_is("0+0.5i", "0.000000-2.085830i", 'csch' )
1155     .complex_op_is("0+1i", "0.000000-1.188395i", 'csch' )
1156     .complex_op_is("0+2i", "0.000000-1.099750i", 'csch' )
1157     .complex_op_is("2+3i", "-0.272549-0.040301i", 'csch' )
1158     .complex_op_is("2-3i", "-0.272549+0.040301i", 'csch' )
1159     .complex_op_is("-2+3i", "0.272549-0.040301i", 'csch' )
1160     .complex_op_is("-2-3i", "0.272549+0.040301i", 'csch' )
1161 .end
1163 .sub add_using_subclass_of_complex_bug_59630
1164     skip( 3, 'add using subclass of Complex - RT #59630' )
1165     .return()
1167     $P0 = subclass 'Complex', 'MyComplex'
1168     addattribute $P0, "re"
1169     addattribute $P0, "im"
1171     .local pmc a, b, c
1172     ##   a = 1 + 2i
1173     a = new ['MyComplex']
1174     a['real'] = 1
1175     a['imag'] = 2
1176     is( a, "1+2i", '' )
1178     ##   b = 3 + 4i
1179     b = new ['MyComplex']
1180     b['real'] = 3
1181     b['imag'] = 4
1182     is( b, "3+4i" , '' )
1184     ##   c = a + b
1185     c = add a, b
1186     is( c, "4+6i", '' )
1187 .end
1189 .namespace ['MyComplex']
1191 .sub 'init' :vtable
1192     $P1 = new ['Float']
1193     setattribute self, "re", $P1
1194     $P2 = new ['Float']
1195     setattribute self, "im", $P2
1196 .end
1198 .namespace []   # revert to root for next test
1201 # Local Variables:
1202 #   mode: cperl
1203 #   cperl-indent-level: 4
1204 #   fill-column: 100
1205 # End:
1206 # vim: expandtab shiftwidth=4 filetype=pir: