On 6/23/2010 8:43 PM, P Kishor wrote: > > That seems the various methods don't seem to work analogously. For > example, $a->reshape() changes $a, but $b->dummy() doesn't change $b.
I believe reshape works in place. I would prefer that it work otherwise unless inplace is requested. You are right about the inconsistency.... > [ > [0 1 x] > [2 3 x] > [4 5 x] > [0 0 x] > ] > > Where 'x' is a custom value. For example, I want a 0 for every 'x', or > I want a random number between 20 and 30 for every 'x'. How do I do > that? I know there is the 'random' method. But that creates a new > piddle with random values between 0 and 1. So, I tried a different > tactic $x = $a((2),:) $x .= floor($x->random * 10 + 20) > perldl> $a = ones 2,3 > perldl> p $a > [ > [1 1] > [1 1] > [1 1] > ] > perldl> $a = $a * (int(rand(10)) + 20) > perldl> p $a > [ > [25 25] > [25 25] > [25 25] > ] (int(rand(10)) + 20) is all perl scalar operations. I think you may be confusing operations on piddles with standard scalar perl stuff. > No. I didn't want the random integer generated and then every value in > $a multiplied by it. I wanted every value to be multiplied by a > different random integer between 20 and 30. How do I do that? > > I fiddled a bit more with 'random' > > perldl> $a = random 2,3 > perldl> p $a > > [ > [ 0.22621636 0.72198009] > [ 0.63921956 0.41760895] > [0.0059526254 0.90491115] > ] > perldl> $a = $a * 100 > perldl> p $a > [ > [ 22.621636 72.198009] > [ 63.921956 41.760895] > [0.59526254 90.491115] > ] > perldl> $a = int($a) > perldl> p $a > 0 int() is a perl built-in function. See perldoc -f int for what it does. HINT: it doesn't know anything about piddles. > Wha!!! What happened there? Why does $a = $a * 100 multiply every > element in $a by 100, but int($a) converts $a to 0? Cheers, Chris _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
