Oh, OK. Bitwise shift was probably obvious to everyone, but in case someone
is reading that's a novice like me.
[1 2 3 4] in binary is [0001 0010 0011 0100]
After shifting individual bits becomes [0010 0100 0110 1000] which back in
decimal land is
[2 4 6 8]

--Art

On Mon, Apr 14, 2008 at 10:46 AM, Art Davis <[EMAIL PROTECTED]> wrote:

> perldl> $a=sequence(5)
> perldl> p$a
> [0 1 2 3 4]
> perldl> $b=pdl(1)
> perldl> $c=$a->shiftleft($b,0);
> perldl> p$c
> [0 2 4 6 8]
>
> Looks like the syntax is OK and it's being interpreted by perldl. Pete
> said that the shift command works bitwise and I haven't invested the mental
> energy to comprehend what that means yet.
>
> --Art
>
>
>
> On Thu, Apr 10, 2008 at 3:03 PM, Judd Taylor <[EMAIL PROTECTED]>
> wrote:
>
> > I'm glad someone was able to help you out.
> >
> > Does anyone know why his code didn't work, though? He got docs on a
> > shiftleft function, so it's supposed to work, right?
> >
> > It looks to me like perl is picking another shiftleft sub, rather than
> > the PDL one when he uses the () in the call. If he leaves it out, he
> > gets the PDL usage doc.
> >
> > If that is the problem, then this should also work (and if it does, then
> > we'll know what the real problem is):
> >
> > perldl> $c = $a->shiftleft($b, 0);
> >
> > Please give it a shot and let me know if that works or not.
> >
> > Thanks,
> >        Judd
> >
> >
> > On Wed, 2008-04-09 at 15:22 -0400, Art Davis wrote:
> > > Excellent. Problem solved (and education furthered). Thanks for the
> > > rapid answers!
> > >
> > > --Art
> > >
> > > On Wed, Apr 9, 2008 at 3:11 PM, Craig DeForest
> > > <[EMAIL PROTECTED]> wrote:
> > >         Sorry, am stealing minutes from a meeting.  That is a roll-
> > >         left operation.  For a shift-left, you would just want a
> > >         different boundary condition:
> > >
> > >         $cs = $a->range($b,[$a->dims],'t');
> > >
> > >
> > >
> > >         On Apr 9, 2008, at 3:06 PM, Craig DeForest wrote:
> > >                 You can use range for that:
> > >                 $a = sequence(5)
> > >                 $b = pdl(1);
> > >                 $c = $a->range($b,[$a->dims],'p');
> > >
> > >
> > >
> > >                 On Apr 9, 2008, at 3:00 PM, Art Davis wrote:
> > >
> > >                         I haven't been able to make shiftleft work the
> > >                         way I want it. It may not even be the right
> > >                         command, I can't understand the POD
> > >                         documentation for it.
> > >
> > >                         What I want:
> > >                         perldl> $a=sequence(5); p$a;
> > >                         [ 0 1 2 3 4 ]
> > >                         perldl> $c=<some PerlDL syntax on $a>; p$c;
> > >                         [ 1 2 3 4 0 ]
> > >
> > >                         What I've tried:
> > >                         perldl> $a=sequence(5); $b=pdl(1);
> > >                         perldl> $c=shiftleft($a,$b,0);
> > >                         Undefined subroutine &main::shiftleft called
> > >                         perldl> $c = shiftleft $a, $b, 0;
> > >                         Usage:  PDL::shiftleft(a,b,c,swap) (you may
> > >                         leave temporaries or output variables out of
> > >                         list)
> > >                         perldl> $c = $a << $b; p$c;
> > >                         [0 2 4 6 8]
> > >                         perldl> $a->inplace->shiftleft($b,0); p$a;
> > >                         [0 2 4 6 8]
> > >
> > >                         Making $b a Perl scalar doesn't seem to help.
> > >
> > >                         Can someone explain and/or provide a full
> > >                         example of the usage of shiftleft and/or
> > >                         provide a tip for shifting an array?
> > >
> > >                         ActivePerl 5.10
> > >                         PDL 2.4.3
> > >
> > >
> > >                         Thanks!
> > >                         --Art
> > >
> > _______________________________________________
> > >                         Perldl mailing list
> > >                         [email protected]
> > >
> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Perldl mailing list
> > > [email protected]
> > > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> > --
> > ____________________________
> > Judd Taylor
> > Software Engineer
> >
> > Orbital Systems, Ltd.
> > 3807 Carbon Rd.
> > Irving, TX 75038-3415
> >
> > [EMAIL PROTECTED]
> > (972) 915-3669 x127
> >
>
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to