# This test fails in Octave and so is skipped by make check_lib_octave package a_double_unary_fun_xam; sub a_double_unary_fun_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; # --------------------------------------------------------------------- # # fabs my $one = new pm_cppad::a_double(1.0); my $abs_one = $one->fabs(); $ok = $ok && $abs_one->value() == 1.0; # # pi/4 my $pi_4 = $one->atan(); # # sqrt(2) my $tmp = new pm_cppad::a_double(2.0); my $r2 = $tmp->sqrt(); # # sin(pi/4) * sqrt(2) = 1.0; $tmp = $r2 * $pi_4->sin() ; $ok = $ok && $tmp->near_equal($one) ; # # cos(pi/4) * sqrt(2) = 1.0; $tmp = $r2 * $pi_4->cos() ; $ok = $ok && $tmp->near_equal($one) ; # # tan(pi/4) = 1.0; $tmp = $pi_4->tan() ; $ok = $ok && $tmp->near_equal($one) ; # return( $ok ); }