Skip to content

Commit

Permalink
convert test data to type needed - PDLPorters/pdl#511
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 20, 2024
1 parent c0cbde2 commit 5646944
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- update test data to match types more carefully (https://github.com/PDLPorters/pdl/issues/511)

0.0106 2022-02-23
- fix setting HAVE_LAPACK to 1 - thanks @YuryPakhomov for report

Expand Down
22 changes: 11 additions & 11 deletions t/liblevmar.t
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ sub rosenbrock {
my $rderiv = sub {
my ($p,$d,$t) = @_;
my ($p0,$p1) = list $p;
$d((0)) .= (-2 + 2 * $p0-4 *$ROSD*($p1-$p0*$p0)*$p0);
$d((1)) .= (2*$ROSD*($p1-$p0*$p0));
$d((0)) .= pdl($d->type, (-2 + 2 * $p0-4 *$ROSD*($p1-$p0*$p0)*$p0));
$d((1)) .= pdl($d->type, 2*$ROSD*($p1-$p0*$p0));
};
my $rf = sub {
my ($p,$x,$t) = @_;
Expand Down Expand Up @@ -667,14 +667,14 @@ register int j=0;
my $pd = sub {
my ($p,$d,$t) = @_;
my ($p0,$p1,$p2,$p3) = list $p;
$d .= 0;
$d(0,0) .= 1.0;
$d(0,1) .= 1.0;
$d(1,1) .= -.5 / sqrt($p((1)) );
$d(1,2) .= 1.;
$d(2,2) .= -.5 / sqrt($p((2)) );
$d(2,3) .= 1;
$d(3,3) .= -.5 / sqrt($p((3)) );
$d .= pdl($d->type, 0);
$d(0,0) .= pdl($d->type, 1.0);
$d(0,1) .= pdl($d->type, 1.0);
$d(1,1) .= pdl($d->type, -.5 / sqrt $p1);
$d(1,2) .= pdl($d->type, 1.);
$d(2,2) .= pdl($d->type, -.5 / sqrt $p2);
$d(2,3) .= pdl($d->type, 1);
$d(3,3) .= pdl($d->type, -.5 / sqrt $p3);
};

my $defst = '
Expand Down Expand Up @@ -718,7 +718,7 @@ my $defst = '
my $dmax = PDL::Fit::Levmar::get_dbl_max();
my $ub = ones($Type, 4);
$ub *= $dmax;
$ub(1) .= 0.8;
$ub(1) .= pdl($ub->type, 0.8);

my $correct_minimum = pdl $Type, [0.947214, 0.8, 0.64, 0.4096];

Expand Down
2 changes: 1 addition & 1 deletion t/ndim.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sub gauss2d {
my $t1 = $t(:,*$n); # first coordinate
my $t2 = $t(*$n,:); # second coordinate
my $x = $xin->splitdim(0,$n);
$x .= $p0 * exp( -$p1*$t1*$t1 - $p2*$t2*$t2);
$x .= ($p0 * exp( -$p1*$t1*$t1 - $p2*$t2*$t2))->convert($x->type->enum);
}

sub fit_gauss2d {
Expand Down

0 comments on commit 5646944

Please sign in to comment.