Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 07f3abfb2d
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (30 sloc) 1.113 kb
use Test::More tests => 5;
use File::Spec;
use lib File::Spec->catfile("..","lib");
use Math::MatrixReal;
use strict;
do 'funcs.pl';
my $b = Math::MatrixReal->new_from_string(<<XXX);
[ 1 1 0 0 ]
[ 1 2 2 0 ]
[ 0 2 3 3 ]
[ 0 0 3 4 ]
XXX
my $a = Math::MatrixReal->new_tridiag( [1, 2, 3], [1, 2, 3, 4], [1, 2, 3] );
unless ($@){
ok(1, 'new_tridiag exists');
} else {
ok(0, 'new_tridiag fails');
}
ok( ref $a eq 'Math::MatrixReal', 'new_tridiag returns correct object' );
ok_matrix( $a, $b, 'new_tridiag seems to work' );
my ($r,$c) = $a->dim;
ok( $r == 4 && $c == 4, 'new_tridiag returns a matrix of the correct size' );
my $matrix = Math::MatrixReal->new_tridiag( [ 6, 4, 2 ], [1,2,3,4], [1, 8, 9] );
my $correct = <<'MAT';
[ 1.000000000000E+00 1.000000000000E+00 0.000000000000E+00 0.000000000000E+00 ]
[ 6.000000000000E+00 2.000000000000E+00 8.000000000000E+00 0.000000000000E+00 ]
[ 0.000000000000E+00 4.000000000000E+00 3.000000000000E+00 9.000000000000E+00 ]
[ 0.000000000000E+00 0.000000000000E+00 2.000000000000E+00 4.000000000000E+00 ]
MAT
ok( "$matrix" eq $correct, 'new_tridiag' );
Jump to Line
Something went wrong with that request. Please try again.