Prev Next a_double_assign_xam.pm Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Perl: a_double Assignment Operators: Example and Test
package a_double_assign_xam;
sub a_double_assign_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 $x = new pm_cppad::a_double(2.0);
     #
     $x = new pm_cppad::a_double(3.0);
     $ok = $ok && $x->value() == 3.0;
     #
     $x += new pm_cppad::a_double(2.0);
     $ok = $ok && $x->value() == 5.0;
     #
     $x -= new pm_cppad::a_double(1.0);
     $ok = $ok && $x->value() == 4.0;
     #
     $x *= new pm_cppad::a_double(3.0);
     $ok = $ok && $x->value() == 12.0;
     #
     $x /= new pm_cppad::a_double(4.0);
     $ok = $ok && $x->value() == 3.0;
     #
     return( $ok );
}

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