| 1 | package Acme::MITHALDU::XSGrabBag; | ||
| 2 | 2 | ▶ | use strictures; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use Acme::MITHALDU::XSGrabBag::Inline (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use Inline::C 0.74 (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | our $VERSION = '1.161310'; # VERSION | |
| 8 | |||
| 9 | # ABSTRACT: a bunch of XS math functions i'm not sure where to shove yet | ||
| 10 | |||
| 11 | # | ||
| 12 | # This file is part of Acme-MITHALDU-XSGrabBag | ||
| 13 | # | ||
| 14 | # | ||
| 15 | # Christian Walde has dedicated the work to the Commons by waiving all of his | ||
| 16 | # or her rights to the work worldwide under copyright law and all related or | ||
| 17 | # neighboring legal rights he or she had in the work, to the extent allowable by | ||
| 18 | # law. | ||
| 19 | # | ||
| 20 | # Works under CC0 do not require attribution. When citing the work, you should | ||
| 21 | # not imply endorsement by the author. | ||
| 22 | # | ||
| 23 | |||
| 24 | 2 | our @EXPORT_OK = qw( | |
| 25 | mix | ||
| 26 | deg2rad | ||
| 27 | rad2deg | ||
| 28 | dot2_product | ||
| 29 | ); | ||
| 30 | |||
| 31 | 2 | Acme::MITHALDU::XSGrabBag::Inline->import( | |
| 32 | C => join "\n", | ||
| 33 | _mix(), | ||
| 34 | _deg2rad(), | ||
| 35 | _rad2deg(), | ||
| 36 | _dot2_product(), | ||
| 37 | ); | ||
| 38 | |||
| 39 | |||
| 40 | 2 | ▶ | sub _mix { |
|
Subroutine
_mix: called CC=1 SCAR=1.2
| |||
| 41 | 0 | ▶ | <<'...'; |
|
Subroutine
_mix: not called CC=1 SCAR=1.2
| |||
| 42 | int mix(int a, int b, int c) { | ||
| 43 | a -= b; a -= c; a ^= (c>>13); | ||
| 44 | b -= c; b -= a; b ^= (a<<8); | ||
| 45 | c -= a; c -= b; c ^= (b>>13); | ||
| 46 | a -= b; a -= c; a ^= (c>>12); | ||
| 47 | b -= c; b -= a; b ^= (a<<16); | ||
| 48 | c -= a; c -= b; c ^= (b>>5); | ||
| 49 | a -= b; a -= c; a ^= (c>>3); | ||
| 50 | b -= c; b -= a; b ^= (a<<10); | ||
| 51 | c -= a; c -= b; c ^= (b>>15); | ||
| 52 | return c; | ||
| 53 | } | ||
| 54 | ... | ||
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | 2 | ▶ | sub _deg2rad { |
|
Subroutine
_deg2rad: called CC=1 SCAR=1.2
| |||
| 59 | 0 | ▶ | <<'...'; |
|
Subroutine
_deg2rad: not called CC=1 SCAR=1.2
| |||
| 60 | float deg2rad(float degrees) { | ||
| 61 | return 0.0174532925 * degrees; | ||
| 62 | } | ||
| 63 | ... | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | 2 | ▶ | sub _rad2deg { |
|
Subroutine
_rad2deg: called CC=1 SCAR=1.2
| |||
| 68 | 0 | ▶ | <<'...'; |
|
Subroutine
_rad2deg: not called CC=1 SCAR=1.2
| |||
| 69 | float rad2deg(float radians) { | ||
| 70 | return 57.2957795786 * radians; | ||
| 71 | } | ||
| 72 | ... | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | 2 | ▶ | sub _dot2_product { |
|
Subroutine
_dot2_product: called CC=1 SCAR=1.2
| |||
| 77 | 0 | ▶ | <<'...'; |
|
Subroutine
_dot2_product: not called CC=1 SCAR=1.2
| |||
| 78 | int dot2_product( int xa, int ya, int xb, int yb ) { | ||
| 79 | int sum = 0; | ||
| 80 | sum += xa * xb; | ||
| 81 | sum += ya * yb; | ||
| 82 | return sum; | ||
| 83 | } | ||
| 84 | ... | ||
| 85 | } | ||
| 86 | |||
| 87 | 2 | 1; | |
| 88 | |||
| 89 | __END__ | ||