Debian Codegraph @

t/gtsv.t

raw symbols SCIP
1 # modified from t/dgtsl.t in Photonic by W. Luis Mochán
2
3 use strict;
4 use warnings;
5 use PDL;
6 use PDL::NiceSlice;
7 use PDL::LinearAlgebra::Real;
8 use constant N=>10;
9 use Test::More;
10 use Test::PDL;
11
12 for my $D (3..N+2) { #first differences
13 #solve b_{n+1}-b_n=1 with homogeneous BCs
14 my $c=zeroes($D); $c->((-1)).=0;
15 my $d=-ones($D);
16 my $e=ones($D); $e->((-1)).=0;
17 my $b=ones($D); $b->((-1)).=1-$D;
18 my $info=pdl(short,0);
19 gtsv($c, $d, $e, $b, $info);
20 my $r=sequence($D);
21 is_pdl $b, $r, "1st diff in D=$D";
22 }
23
24 for my $D (3..N+2) { #second differences
25 #solve b_{n+1}-2{b_n}+b_{n-1}=1 with kinda homogeneous BCs
26 my $c=ones($D); $c->((-1)).=0;
27 my $d=-2*ones($D);
28 my $e=ones($D); $e->((-1)).=0;
29 my $b=ones($D);
30 my $info=pdl(short,0);
31 gtsv($c, $d, $e, $b, $info);
32 my $x=sequence($D);
33 my $r=-$D/2-($D-1)/2*$x+1/2*$x*$x;
34 is_pdl $b, $r, "2nd diff in D=$D";
35 }
36
37 done_testing;