• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Perlで任意精度計算
 

Perlで任意精度計算

on

  • 2,028 views

YAPC::Asia Tokyo 2010 presentation

YAPC::Asia Tokyo 2010 presentation

Statistics

Views

Total Views
2,028
Views on SlideShare
2,026
Embed Views
2

Actions

Likes
0
Downloads
4
Comments
0

1 Embed 2

http://orhowilearnedtolovetheperl.com 2

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Perlで任意精度計算 Perlで任意精度計算 Presentation Transcript

  • 3.14159 26535 89793 23846 26433 83279 50288.....
  • use Math::BigFloat; my $x = Math::BigFloat->new(‘3.1415...’); my $y = Math::BigFloat->new(‘2.718281...’); my $z = $x * $y;
  • # my $pi = Math::BigFloat->new(3.141592...); # my $pi = Math::BigFloat->new(‘3.141592...’);
  • use strict; use Math::BigFloat; use Benchmark qw(cmpthese); cmpthese -1, {     plain => sub {         my $x = rand(10);         my $y = rand(10);         my $z = rand(10);         ($x + $y ) * $z;     },     bigfloat => sub {         my $x = rand(10);         my $y = rand(10);         my $z = rand(10);         (Math::BigFloat->new($x) + Math::BigFloat->new($y)) * Math::BigFloat->new($z);     }, };
  • daisuke@beefcake ~$ perl foo.pl               Rate bigfloat plain bigfloat 3380/s -- -100% plain 2383127/s 70403% -- daisuke@beefcake ~$ perl foo.pl               Rate bigfloat plain bigfloat 3380/s -- -100% plain 2360644/s 69738% -- daisuke@beefcake ~$ perl foo.pl               Rate bigfloat plain bigfloat 3380/s -- -100% plain 2406041/s 71081% --
  • > perl benchmark.pl Rate bigfloat plain bigfloat 3901/s -- -100% plain 2338582/s 59849% --
  • •DateTime::Util::Calc •DateTime::Util::Astro •DateTime::Event::Lunar
  • my $v = ( $x + $y ) * $z; #include <mpfr.h> mpfr_t x, y, z, w; mpfr_add( w, x, y, MPFR_RNDN ); mpfr_mul( w, w, z, MPFR_RNDN );
  • mpfr_add( w, x, y, MPFR_RNDN );
  • s/iter bigint xs bigint 2.58 -- -98% mpfr 4.70e-02 5394% --