Derek Lamb
2013-08-05 21:49:28 UTC
Karl, Christian, etc (original PDL'ers) please weigh in:
I was looking at Basic.pm over the weekend and saw three functions that were unfamiliar, perhaps because they are not documented anywhere: sec, ins, and similar_assign.
1) sec returns a slice of a piddle based on a list of border indices:
pdl> p sec(sequence(10,8),4,6,2,5);
[
[24 25 26]
[34 35 36]
[44 45 46]
[54 55 56]
]
2) ins inserts a piddle into another piddle:
pdl> p ins(sequence(10,8),pdl([4,7,1],[2,8,3]),6,2)
[
[ 0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
[20 21 22 23 24 25 4 7 1 29]
[30 31 32 33 34 35 2 8 3 39]
[40 41 42 43 44 45 46 47 48 49]
[50 51 52 53 54 55 56 57 58 59]
[60 61 62 63 64 65 66 67 68 69]
[70 71 72 73 74 75 76 77 78 79]
]
3) similar_assign is supposed to check that the dim list of two piddles is the same before assigning one to the other, though I am not sure how effective it actually is:
pdl> $a=xvals(5);$b=xvals(5)+3;
pdl> similar_assign($a,$b);
pdl> p $a,$b
[0 1 2 3 4] [0 1 2 3 4] #OK
pdl> $a=xvals(5);$b=xvals(4)+3;
pdl> p $a,$b
[0 1 2 3 4] [3 4 5 6]
pdl> p similar_assign($a,$b)
PDL: PDL::Ops::assgn(a,b): Parameter 'b':
Mismatched implicit thread dimension 0: should be 5, is 4
##presumably similar_assign's check should have caught that--I think it has to do with @{$from->dims} instead of just $from->dims.
Note that range() can do both sec and ins.
All three appeared in Karl's initial import of v1.99987 on 1998-09-20. They are not documented, not tested, and as far as I can tell, do not appear to be used anywhere else in active code in the PDL distribution (similar_assign is used in the defunct Gaussian.pm).
But maybe somebody has some legacy code that uses these? Given their age, I thought I'd check first before deciding to either remove them or add documentation & tests.
cheers,
Derek
I was looking at Basic.pm over the weekend and saw three functions that were unfamiliar, perhaps because they are not documented anywhere: sec, ins, and similar_assign.
1) sec returns a slice of a piddle based on a list of border indices:
pdl> p sec(sequence(10,8),4,6,2,5);
[
[24 25 26]
[34 35 36]
[44 45 46]
[54 55 56]
]
2) ins inserts a piddle into another piddle:
pdl> p ins(sequence(10,8),pdl([4,7,1],[2,8,3]),6,2)
[
[ 0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
[20 21 22 23 24 25 4 7 1 29]
[30 31 32 33 34 35 2 8 3 39]
[40 41 42 43 44 45 46 47 48 49]
[50 51 52 53 54 55 56 57 58 59]
[60 61 62 63 64 65 66 67 68 69]
[70 71 72 73 74 75 76 77 78 79]
]
3) similar_assign is supposed to check that the dim list of two piddles is the same before assigning one to the other, though I am not sure how effective it actually is:
pdl> $a=xvals(5);$b=xvals(5)+3;
pdl> similar_assign($a,$b);
pdl> p $a,$b
[0 1 2 3 4] [0 1 2 3 4] #OK
pdl> $a=xvals(5);$b=xvals(4)+3;
pdl> p $a,$b
[0 1 2 3 4] [3 4 5 6]
pdl> p similar_assign($a,$b)
PDL: PDL::Ops::assgn(a,b): Parameter 'b':
Mismatched implicit thread dimension 0: should be 5, is 4
##presumably similar_assign's check should have caught that--I think it has to do with @{$from->dims} instead of just $from->dims.
Note that range() can do both sec and ins.
All three appeared in Karl's initial import of v1.99987 on 1998-09-20. They are not documented, not tested, and as far as I can tell, do not appear to be used anywhere else in active code in the PDL distribution (similar_assign is used in the defunct Gaussian.pm).
But maybe somebody has some legacy code that uses these? Given their age, I thought I'd check first before deciding to either remove them or add documentation & tests.
cheers,
Derek