laurent exsteens writes: > > What I search now is a scaling function... I have > a matrix whith vectors in rows, and I want to > center them before using SVD decomposition... I > read the PDL::Transfom and find map but I'm not > sure this is what I need...
Not sure what you mean by scaling and centering. If you mean linear transformation, then you can use normal multiplication and addition together with the PDL threading feature to get what you want. Here are some examples from the perldl shell. The spacing may be off but you should be able to run the examples in the shell yourself: perldl> p $a = (random(3,4)*10)->floor # make an example matrix [ [9 4 1] [5 7 6] [7 2 9] [7 0 3] ] perldl> p pdl(2,4,1,0) # rows by default [2 4 1 0] perldl> p pdl(2,4,1,0)->dummy(0) # generate col vector instead [ [2] [4] [1] [0] ] perldl> p $a * pdl(2,4,1,0)->dummy(0) # to scale the rows [ [18 8 2] [20 28 24] [ 7 2 9] [ 0 0 0] ] perldl> p $a + 2 # add const to all elements [ [11 6 3] [ 7 9 8] [ 9 4 11] [ 9 2 5] ] perldl> p $a + pdl(1,3,0) # add vector to each row [ [10 7 1] [ 6 10 6] [ 8 5 9] [ 8 3 3] ] perldl> p $a + pdl(1,3,0,-10)->(*,:) # add vector to each column (NiceSlice) perldl> p $a + pdl(1,3,0,-10)->dummy(0) # same as above (with dummy) [ [ 10 5 2] [ 8 10 9] [ 7 2 9] [ -3 -10 -7] ]
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
