On 3/8/2011 4:17 AM, Ivan Shmakov wrote: > It's easy to get a span of array's elements in PDL, like: > > use PDL qw (badflag); > my $v > = PDL->pdl ([0 .. 7]); > print ($v->mslice ([3, 5]), "\n"); > # => [3 4 5] > > Now, is there an easy way to get the original array /except/ > that span? (I. e., [0, 1, 2, 6, 7], in the case above.) > > TIA.
where or dice can maintain dataflow: pdl> $a = sequence(8) pdl> p $a [0 1 2 3 4 5 6 7] pdl> $mask = $a->ones pdl> $mask->(3:5) .= 0 pdl> p $mask [1 1 1 0 0 0 1 1] pdl> p $b = $a->where($mask) [0 1 2 6 7] pdl> $b(3) .= 99 pdl> p $a [0 1 2 3 4 5 99 7] append with a couple of slices doesn't maintain dataflow: pdl> $c = append($a(0:2),$a(6:-1)) pdl> p $c [0 1 2 6 7] pdl> $c(3) .= 99 pdl> p $a [0 1 2 3 4 5 6 7] another way with a different "twist" (maintains dataflow): pdl> $d = $a->rotate(-3)->(3:-1)->rotate(3) pdl> p $d [0 1 2 6 7] pdl> $d(3) .= 99 pdl> p $a [0 1 2 3 4 5 99 7] _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
