Prev Next a_double_ad_binary_xam.pm Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Perl: a_double Binary Operators With AD Result: Example and Test
package a_double_ad_binary_xam;
sub a_double_ad_binary_xam() {
     # check for standard perl programming conventions
     use strict;
     use warnings;
     #
     # load the Cppad Swig library
     use pm_cppad;
     #
     # initilaize return variable
     my $ok = 1;
     # ---------------------------------------------------------------------
     my $two = new pm_cppad::a_double(2.0);
     my $three = new pm_cppad::a_double(3.0);
     #
     my $five = $two + $three;
     my $six = $two * $three;
     my $neg_one = $two - $three;
     my $two_thirds = $two / $three;
     #
     $ok = $ok && $five->value() == 5.0;
     $ok = $ok && $six->value() == 6.0;
     $ok = $ok && $neg_one->value() == -1.0;
     $ok = $ok && 0.5 < $two_thirds->value();
     $ok = $ok && $two_thirds->value() < 1.0;
     $ok = $ok && $five < $six;
     #
     return( $ok );
}

Input File: build/lib/example/perl/a_double_ad_binary_xam.pm