"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Libtmp/Transform/transform.pd" between
PDL-2.080.tar.gz and PDL-2.081.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

transform.pd  (PDL-2.080):transform.pd  (PDL-2.081)
skipping to change at line 2614 skipping to change at line 2614
NOTES NOTES
the type/unit fields are currently ignored by t_linear. the type/unit fields are currently ignored by t_linear.
=cut =cut
{ package PDL::Transform::Linear; { package PDL::Transform::Linear;
our @ISA = ('PDL::Transform'); our @ISA = ('PDL::Transform');
*_opt = \&PDL::Transform::_opt; *_opt = \&PDL::Transform::_opt;
*identity = \&PDL::MatrixOps::identity;
sub PDL::Transform::t_linear { PDL::Transform::Linear->new(@_); } sub PDL::Transform::t_linear { PDL::Transform::Linear->new(@_); }
sub new { sub new {
my($class) = shift; my($class) = shift;
my($o) = $_[0]; my($o) = $_[0];
pop @_ if (($#_ % 2 ==0) && !defined($_[-1])); pop @_ if (($#_ % 2 ==0) && !defined($_[-1]));
#suppresses a warning if @_ has an odd number of elements and the #suppresses a warning if @_ has an odd number of elements and the
#last is undef #last is undef
skipping to change at line 2658 skipping to change at line 2659
my $o_dims = _opt($o,['d','dim','dims','Dims']); my $o_dims = _opt($o,['d','dim','dims','Dims']);
$o_dims = PDL->pdl($o_dims) if defined($o_dims); $o_dims = PDL->pdl($o_dims) if defined($o_dims);
my $scale = _opt($o,['s','scale','Scale']); my $scale = _opt($o,['s','scale','Scale']);
$scale = PDL->pdl($scale) if defined($scale); $scale = PDL->pdl($scale) if defined($scale);
# Figure out the number of dimensions to transform, and, # Figure out the number of dimensions to transform, and,
# if necessary, generate a new matrix. # if necessary, generate a new matrix.
my $rot = $me->{params}{rot};
if(defined($me->{params}{matrix})) { if(defined($me->{params}{matrix})) {
my $mat = $me->{params}{matrix} = $me->{params}{matrix}->slice(":,:"); my $mat = $me->{params}{matrix} = $me->{params}{matrix}->slice(":,:");
$me->{idim} = $mat->dim(0); $me->{idim} = $mat->dim(0);
$me->{odim} = $mat->dim(1); $me->{odim} = $mat->dim(1);
} else { } else {
if(defined($me->{params}->{rot}) && if(defined($me->{params}->{rot}) &&
UNIVERSAL::isa($me->{params}->{rot},'PDL')) { UNIVERSAL::isa($me->{params}->{rot},'PDL')) {
$me->{idim} = $me->{odim} = 2 if($me->{params}{rot}->nelem == 1); $me->{idim} = $me->{odim} = 2 if($me->{params}{rot}->nelem == 1);
$me->{idim} = $me->{odim} = 3 if($me->{params}{rot}->nelem == 3); $me->{idim} = $me->{odim} = 3 if($me->{params}{rot}->nelem == 3);
skipping to change at line 2687 skipping to change at line 2689
UNIVERSAL::isa($me->{params}{pre},'PDL') && UNIVERSAL::isa($me->{params}{pre},'PDL') &&
$me->{params}{pre}->getndims > 0) { $me->{params}{pre}->getndims > 0) {
$me->{idim} = $me->{odim} = $me->{params}{pre}->dim(0); $me->{idim} = $me->{odim} = $me->{params}{pre}->dim(0);
} elsif(defined($me->{params}{post}) && } elsif(defined($me->{params}{post}) &&
UNIVERSAL::isa($me->{params}{post},'PDL') && UNIVERSAL::isa($me->{params}{post},'PDL') &&
$me->{params}{post}->getndims > 0) { $me->{params}{post}->getndims > 0) {
$me->{idim} = $me->{odim} = $me->{params}{post}->dim(0); $me->{idim} = $me->{odim} = $me->{params}{post}->dim(0);
} elsif(defined($o_dims)) { } elsif(defined($o_dims)) {
$me->{idim} = $me->{odim} = $o_dims; $me->{idim} = $me->{odim} = $o_dims;
} elsif (UNIVERSAL::isa($rot,'PDL') && (my $nrots = $rot->nelem) > 1) {
$me->{idim} = $me->{odim} = $nrots;
} else { } else {
print "PDL::Transform::Linear: assuming 2-D transform (set dims option to change)\n" if($PDL::Transform::debug); print "PDL::Transform::Linear: assuming 2-D transform (set dims option to change)\n" if($PDL::Transform::debug);
$me->{idim} = $me->{odim} = 2; $me->{idim} = $me->{odim} = 2;
} }
$me->{params}->{matrix} = PDL->zeroes($me->{idim},$me->{odim}); $me->{params}->{matrix} = PDL->zeroes($me->{idim},$me->{odim});
my $tmp; # work around perl -d "feature" my $tmp; # work around perl -d "feature"
($tmp = $me->{params}->{matrix}->diagonal(0,1)) .= 1; ($tmp = $me->{params}->{matrix}->diagonal(0,1)) .= 1;
} }
### Handle rotation option ### Handle rotation option
my $rot = $me->{params}{rot};
if(defined($rot)) { if(defined($rot)) {
# Subrotation closure -- rotates from axis $d->(0) --> $d->(1). # Subrotation closure -- rotates from axis $d->(0) --> $d->(1).
my $subrot = sub { my $subrot = sub {
my($d,$angle,$m)=@_; my($d,$angle,$m)=@_;
my($i) = identity($m->dim(0)); my($i) = identity($m->dim(0));
my($subm) = $i->dice($d,$d); my($subm) = $i->dice($d,$d);
$angle = $angle->at(0) $angle = $angle->at(0)
if(UNIVERSAL::isa($angle,'PDL')); if(UNIVERSAL::isa($angle,'PDL'));
skipping to change at line 2883 skipping to change at line 2886
+======EOD_t_offset ====== +======EOD_t_offset ======
pp_add_exported('t_rot'); pp_add_exported('t_rot');
pp_addpm(<<'+======EOD_t_rot======'); pp_addpm(<<'+======EOD_t_rot======');
=head2 t_rot =head2 t_rot
=for usage =for usage
$f = t_rot(<rotation-in-degrees>) $f = t_rot(\@rotation_in_degrees)
=for ref =for ref
Convenience interface to L</t_linear>. Convenience interface to L</t_linear>.
t_rot produces a rotation transform in 2-D (scalar), 3-D (3-vector), or t_rot produces a rotation transform in 2-D (scalar), 3-D (3-vector), or
N-D (matrix). It acts exactly the same as C<t_linear(Rot=>\<shift\>)>. N-D (matrix). It acts exactly the same as C<t_linear(rot=>shift)>.
=cut =cut
*t_rot = \&t_rotate; *t_rot = \&t_rotate;
sub t_rotate { sub t_rotate {
my $rot = shift; my $rot = shift;
my($y) = shift; my($y) = shift;
return t_linear(rot=>$rot,%{$y}) return t_linear(rot=>$rot,%{$y})
if(ref $y eq 'HASH'); if(ref $y eq 'HASH');
 End of changes. 6 change blocks. 
3 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)