Ticket #481: PCA-patch-003.patch
File PCA-patch-003.patch, 7.5 KB (added by Paul C. Anagnostopoulos, 11 years ago) |
---|
-
src/ops/set.ops
40 40 41 41 =item B<set>(out INT, in NUM) 42 42 43 A floating-point number is truncated (rounded toward zero) when assigned 44 to an integer register. 45 43 46 =item B<set>(out INT, invar PMC) 44 47 45 48 =item B<set>(out INT, invar PMC) -
src/dynoplibs/trans.ops
105 105 106 106 ######################################## 107 107 108 =item B<cot>(out NUM, in NUM) 109 110 Set $1 to the cotangent of $2 (given in radians). 111 112 =cut 113 114 inline op cot(out NUM, in NUM) :base_math { 115 $1 = ((FLOATVAL)1) / tan((FLOATVAL)$2); 116 } 117 118 ######################################## 119 120 =item B<csc>(out NUM, in NUM) 121 122 Set $1 to the cosecant of $2 (given in radians). 123 124 =cut 125 126 inline op csc(out NUM, in NUM) :base_math { 127 $1 = ((FLOATVAL)1) / sin((FLOATVAL)$2); 128 } 129 130 ######################################## 131 108 132 =item B<exp>(out NUM, in NUM) 109 133 110 134 Set $1 to I<e> raised to the power $2. I<e> is the base of the natural -
src/pmc/float.pmc
77 77 78 78 =item C<INTVAL get_integer()> 79 79 80 Returns an integer representation of the number (by casting). 80 Returns an integer representation of the number by truncating 81 (rounding toward zero). 81 82 82 83 =cut 83 84 … … 391 392 392 393 =item C<METHOD PMC *cosh()> 393 394 395 =item C<METHOD PMC *cot()> 396 397 =item C<METHOD PMC *csc()> 398 394 399 =item C<METHOD PMC *exp()> 395 400 396 401 =item C<METHOD PMC *ln()> … … 425 430 RETURN(PMC *d); 426 431 } 427 432 428 METHOD cos() {429 PMC * const d = Parrot_pmc_new(INTERP,430 Parrot_get_ctx_HLL_type(INTERP, enum_class_Float));431 SET_ATTR_fv(INTERP, d, cos(SELF.get_number()));432 RETURN(PMC *d);433 }434 435 433 METHOD asec() { 436 434 PMC * const d = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF)); 437 435 SET_ATTR_fv(INTERP, d, acos(1.0 / SELF.get_number())); … … 456 454 RETURN(PMC *d); 457 455 } 458 456 457 METHOD cos() { 458 PMC * const d = Parrot_pmc_new(INTERP, 459 Parrot_get_ctx_HLL_type(INTERP, enum_class_Float)); 460 SET_ATTR_fv(INTERP, d, cos(SELF.get_number())); 461 RETURN(PMC *d); 462 } 463 459 464 METHOD cosh() { 460 465 PMC * const d = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF)); 461 466 SET_ATTR_fv(INTERP, d, cosh(SELF.get_number())); 462 467 RETURN(PMC *d); 463 468 } 464 469 470 METHOD cot() { 471 PMC * const d = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF)); 472 SET_ATTR_fv(INTERP, d, 1.0 / tan(SELF.get_number())); 473 RETURN(PMC *d); 474 } 475 476 METHOD csc() { 477 PMC * const d = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF)); 478 SET_ATTR_fv(INTERP, d, 1.0 / sin(SELF.get_number())); 479 RETURN(PMC *d); 480 } 481 465 482 METHOD exp() { 466 483 PMC * const d = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF)); 467 484 SET_ATTR_fv(INTERP, d, exp(SELF.get_number())); -
t/pmc/float.t
16 16 17 17 =cut 18 18 19 .const int TESTS = 16 219 .const int TESTS = 166 20 20 .const num PRECISION = 0.000001 21 21 22 22 .sub 'test' :main … … 78 78 log10_method() 79 79 log2_method() 80 80 sec_method() 81 csc_method() 81 82 sech_method() 82 83 sin_method() 83 84 sinh_method() 84 85 tan_method() 86 cot_method() 85 87 tanh_method() 86 88 sqrt_method() 87 89 .end … … 998 1000 test_method('sec', 0.5, 1.139493927) 999 1001 .end 1000 1002 1003 .sub 'csc_method' 1004 test_method('csc', 0.5, 2.0858296) 1005 test_method('csc', 1.0, 1.1883951) 1006 .end 1007 1001 1008 .sub 'sech_method' 1002 1009 test_method('sech', 0.0, 1.0) 1003 1010 test_method('sech', 0.5, 0.886818884) … … 1018 1025 test_method('tan', 0.5, 0.546302490) 1019 1026 .end 1020 1027 1028 .sub 'cot_method' 1029 test_method('cot', 0.5, 1.8304877) 1030 test_method('cot', 1.0, 0.64209262) 1031 .end 1032 1021 1033 .sub 'tanh_method' 1022 1034 test_method('tanh', 0.0, 0.0) 1023 1035 test_method('tanh', 0.5, 0.462117157) -
t/dynoplibs/trans.t
23 23 .local num epsilon 24 24 epsilon = _epsilon() 25 25 26 plan( 69)26 plan(77) 27 27 28 28 test_sin_n(epsilon) 29 29 test_sin_i(epsilon) … … 31 31 test_cos_i(epsilon) 32 32 test_tan_n(epsilon) 33 33 test_tan_i(epsilon) 34 test_cot_n(epsilon) 35 test_cot_i(epsilon) 34 36 test_sec_n(epsilon) 35 37 test_sec_i(epsilon) 38 test_csc_n(epsilon) 39 test_csc_i(epsilon) 36 40 test_atan_n(epsilon) 37 41 test_atan_i(epsilon) 38 42 test_asin_n(epsilon) … … 137 141 is($N0, 1.557408, "tan(1)", epsilon) 138 142 .end 139 143 144 .sub test_cot_n 145 .param num epsilon 146 147 $N0 = cot 0.5 148 is($N0, 1.8305, "cot(0.5)", epsilon) 149 150 $N0 = cot 1.0 151 is($N0, 0.64209, "cot(1.0)", epsilon) 152 .end 153 154 .sub test_cot_i 155 .param num epsilon 156 157 $N0 = cot 1 158 is($N0, 0.64209, "cot(1)", epsilon) 159 160 $N0 = cot 2 161 is($N0, -0.45766, "cot(2)", epsilon) 162 .end 163 140 164 .sub test_sec_n 141 165 .param num epsilon 142 166 … … 153 177 is($N1, 1.850816, "sec(1)", epsilon) 154 178 .end 155 179 180 .sub test_csc_n 181 .param num epsilon 182 183 $N0 = csc 0.5 184 is($N0, 2.0858, "csc(0.5)", epsilon) 185 186 $N0 = csc 1.0 187 is($N0, 1.1884, "csc(1.0)", epsilon) 188 .end 189 190 .sub test_csc_i 191 .param num epsilon 192 193 $N0 = csc 1 194 is($N0, 1.1884, "csc(1)", epsilon) 195 196 $N0 = csc 2 197 is($N0, 1.0998, "csc(2)", epsilon) 198 .end 199 156 200 .sub test_atan_n 157 201 .param num epsilon 158 202 -
t/dynoplibs/trans-infnan.t
20 20 21 21 .sub main :main 22 22 .include 'test_more.pir' 23 plan( 67)23 plan(70) 24 24 25 25 test_exp() 26 26 test_sin() … … 36 36 test_coth() 37 37 test_acot() 38 38 test_sec() 39 test_csc() 39 40 test_sech() 40 41 test_asec() 41 42 test_ln() … … 232 233 is($N1, 'NaN', '... sec NaN') 233 234 .end 234 235 236 .sub test_csc 237 $N0 = 'Inf' 238 $N1 = csc $N0 239 is($N1, 'NaN', 'csc: csc Inf') 240 $N0 = '-Inf' 241 $N1 = csc $N0 242 is($N1, 'NaN', '... csc -Inf') 243 $N0 = 'NaN' 244 $N1 = csc $N0 245 is($N1, 'NaN', '... csc NaN') 246 .end 247 235 248 .sub test_sech 236 249 $N0 = 'Inf' 237 250 $N1 = sech $N0 … … 295 308 is($N1, 'NaN', '... log2 -Inf') 296 309 .end 297 310 298 299 311 .sub test_cot 300 312 $N0 = 'Inf' 301 #$N1 = cot $N0 302 #is($N1, 'NaN', 'cot: cot Inf') 303 todo(0, 'cot Inf', 'cot/coth/acot not implemented for real numbers') 313 $N1 = cot $N0 314 is($N1, 'NaN', 'cot: cot Inf') 304 315 $N0 = '-Inf' 305 #$N1 = cot $N0 306 #is($N1, 'NaN', '... cot -Inf') 307 todo(0, 'cot -Inf', 'cot/coth/acot not implemented for real numbers') 316 $N1 = cot $N0 317 is($N1, 'NaN', '... cot -Inf') 308 318 $N0 = 'NaN' 309 #$N1 = cot $N0 310 #is($N1, 'NaN', '... cot NaN') 311 todo(0, 'cot NaN', 'cot/coth/acot not implemented for real numbers') 319 $N1 = cot $N0 320 is($N1, 'NaN', '... cot NaN') 312 321 .end 313 322 314 323 .sub test_pow