Permalink
Browse files

t/print.t and pod fixes

  • Loading branch information...
1 parent 3cb3b2d commit 38047df046f528e17223e213533276c41c9e8746 leto committed Mar 2, 2008
Showing with 52 additions and 17 deletions.
  1. +4 −4 Build.PL
  2. +5 −0 Changes
  3. +2 −0 MANIFEST
  4. +3 −3 META.yml
  5. +14 −10 lib/Math/ODE.pm
  6. +24 −0 t/print.t
View
@@ -7,11 +7,11 @@ my $builder = Module::Build->new(
license => 'perl',
dist_author => 'Jonathan Leto <jonathan@leto.net>',
dist_version_from => 'lib/Math/ODE.pm',
- dist_abstract => 'Solve N-th Order Differential Equations (Initial Value Problems)',
+ dist_abstract => 'Solve N-th Order Differential Equations',
build_requires => {
- 'Test::More' => 0,
- 'Data::Dumper' => 0,
- 'Carp' => 0,
+ 'Test::More' => 0,
+ 'Data::Dumper' => 0,
+ 'Carp' => 0,
},
add_to_cleanup => [ 'Math::ODE-*' ],
create_makefile_pl => 'traditional',
View
@@ -1,3 +1,8 @@
+0.05 Sun Mar 02 09:18:24 EST 2008
+------------------------------------
+ - fixed POD errors
+
+
0.04 Fri Feb 29 22:54:30 EST 2008
-------------------------------------
- ported to Module::Build
View
@@ -18,4 +18,6 @@ t/error.t
t/ode_systems.t
t/odes.t
t/values_at.t
+t/print.t
TODO
+Makefile.PL
View
@@ -1,9 +1,9 @@
---
name: Math-ODE
-version: 0.04
+version: 0.05
author:
- 'Jonathan Leto <jonathan@leto.net>'
-abstract: Solve N-th Order Differential Equations (Initial Value Problems)
+abstract: Solve N-th Order Differential Equations
license: perl
resources:
license: http://dev.perl.org/licenses/
@@ -14,7 +14,7 @@ build_requires:
provides:
Math::ODE:
file: lib/Math/ODE.pm
- version: 0.04
+ version: 0.05
generated_by: Module::Build version 0.280801
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
View
@@ -4,7 +4,7 @@ use strict;
require 5.005;
use Data::Dumper;
use Carp;
-my $VERSION = '0.04';
+my $VERSION = '0.05';
$Data::Dumper::Varname = "y";
$Data::Dumper::Indent = 0;
@@ -32,11 +32,14 @@ sub evolve {
}
$t += $h;
+ my $str = join $delim, map { sprintf "%0.12f", $_ } ($t, @$y);
+ chop $str;
+
if( defined $file ){
- my $str = join $delim, map { sprintf "%0.12f", $_ } ($t, @$y);
- chop $str;
print FD "$str\n";
- }
+ } elsif ( ! $self->{keep_values} ) {
+ print "$str\n";
+ }
}
close FD if defined $file;
return 42;
@@ -260,12 +263,12 @@ Returns the end point on the interval if no arguments are given.
C<$o-E<gt>file($somefile)>
Save data in $somefile. Returns the file in which the data is being saved if no
-arguments are given. If no file is specified, data is printed to STDOUT. The
-data file will have $N+1 columns (where $N is the number of equations to
-solve), and can be fed directly to gnuplot. The first column is the independent
-variable, and the remaining are the first through nth components of the
-dependent vector. Examples of graphing the data file are in the example/
-directory of the source distribution.
+arguments are given. If no file is specified and keep_values is set to a
+non-true value , data is printed to STDOUT. The data file will have $N+1
+columns (where $N is the number of equations to solve), and can be fed directly
+to gnuplot. The first column is the independent variable, and the remaining are
+the first through nth components of the dependent vector. Examples of graphing
+the data file are in the example/ directory of the source distribution.
=item *
@@ -291,6 +294,7 @@ C<my $solution_code_ref = sub { my $x = shift; 5 * $x ** 2 };>
C<$o-E<gt>max_error( [ $solution_code_ref ] )>;
Returns the maximum error from the computed values and a reference to a list of code references.
+This should be called after C<$o-E<gt>evolve>.
=back
View
@@ -0,0 +1,24 @@
+use Test::More tests => 1;
+use File::Spec;
+use lib File::Spec->catfile("..","lib");
+use Math::ODE;
+use Data::Dumper;
+
+# analytic solution is y(x) = 5 x
+my $o = new Math::ODE (
+ step => 0.1,
+ initial => [0],
+ keep_values => 0,
+ ODE => [ \&DE1 ],
+ t0 => 0,
+ tf => 1 );
+
+# check print to STDOUT?
+
+if ( $o->evolve ) {
+ ok( 1, "keep_values => 0 and file => undef prints to STDOUT");
+} else {
+ ok( 0, "keep_values => 0 and file => undef prints to STDOUT");
+}
+
+sub DE1 { my ($t,$y) = @_; return 5; }

0 comments on commit 38047df

Please sign in to comment.