in reply to Random Values (1-5) for a PDL?

I would like to initialize my pdl as 100x100 with random values in the range of 1-5

I don't know if it can be done in one line. Would the following be a satisfactory workaround:
$a = random(100, 100); $a *= 4; $a += 1;
Update: As plobsing has demonstrated, it *can* be done in one line ... but it's really, really, really difficult :-)

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Random Values (1-5) for a PDL?
by plobsing (Friar) on Mar 06, 2009 at 02:22 UTC

    Whats wrong with the following?

    my $pdl = random(100, 100) * 4 + 1;
      It's the same:
      The following binary perl operators act on piddles: + * - / ** > < <= >= == != << >> | & ^ ! % <=> these behave identically to their ordinary Perl equivalents, except th +ey act element-by-element on the whole piddle.
      ...but you probably already knew that. :)
        Thanks for all the input. This makes sense.

        I think I'm starting to get used to working with PDL, but there are still so many oddities that I'm unaware of. It has definitely been a learning process.