On Mon, Jun 21, 2010 at 6:10 PM, Craig DeForest
<[email protected]> wrote:
> Well, you have to copy every puddle anyway, to collate them as you desire.
>

Ok. Then I need to understand your code first. Keep in mind, I am
still in trainer-wheels.



Hi, I think I am missing a lot here... here is test code I tried out

# add four 4x5 piddles to @p
push @p, sequence(4, 5) for (0 .. 3);

# add a 3x5 piddle to @p. This is the "wrong" piddle. It really should be 4x5
push @p, sequence(3, 5);

$dims = cat(pdl(map { $_->dims } @p))->mv(-1,0)->maximum;
print $dims;

# Prints
# [4 5 4 5 4 5 4 5 3 5]

$pdl = new_from_specification(0...@p, $dims);

# Error: Undefined subroutine &main::new_from_specification called

# I change the above line to
$pdl = PDL::new_from_specification(0...@p, $dims);

# Now I get the following error
# Error: File Core.pm; Line 1789: Can't call method "initialize" without a
# package or object reference <DATA> line 206

=for

1772 sub PDL::new_from_specification{
1773     my $class = shift;
1774     my $type = ref($_[0]) eq 'PDL::Type' ? ${shift @_}[0]  : $PDL_D;
1775     my $nelems = 1; my @dims;
1776     for (@_) {
1777        if (ref $_) {
1778          barf "Trying to use non-piddle as dimensions?" unless
$_->isa('PDL');
1779          barf "Trying to use multi-dim piddle as dimensions?"
1780               if $_->getndims > 1;
1781          warn "creating > 10 dim piddle (piddle arg)!"
1782               if $_->nelem > 10;
1783          for my $dim ($_->list) {$nelems *= $dim; push @dims, $dim}
1784        } else {
1785          barf "Dimensions must be positive" if $_<=0;
1786          $nelems *= $_; push @dims, $_
1787        }
1788     }
1789     my $pdl = $class->initialize();
1790     $pdl->set_datatype($type);
1791     $pdl->setdims([...@dims]);
1792     print "Dims: ",(join ',',@dims)," DLen: ",(length $
{$pdl->get_dataref}),"\n" if $PDL::debug;
1793     return $pdl;
1794 }

=cut

for my $i (0 .. $#p) {
    $pdl->( ($i) ) .= $p[$i]->range(0 * $dims, $dims, 't');
}

I haven't reached this far, but if I do, what am I going to get? Is
$pdl going to be the new list of piddles (with the correct piddle). I
am guessing @p is going to be the new list, with the piddle at $p[4]
corrected. And, what are its dims going to be? I want the 3x5 piddle
to become 4x5 piddle.

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to