moin Erik,

If I understand correctly and your PDLs are 1-dimensional vectors, I
believe you can do what you want with index(), otherwise with indexND():

  ##-- for 1-dimensional data:
  $which = pdl(indx, [0,1,2,4,6,7]);     ##-- indices with gaps
  $vals     = ($which*10);                     ##-- sampled values (dummy)
  $data     = zeroes($vals->type,$which->max+1)->setvaltobad(0); ##--
piddle to hold expanded data
  $data->index($which) .= $vals;
  print $data;

... this gives me [0 10 20 BAD 40 BAD 60 70] as expected.  The list of all
index values without gaps is $data->xvals, and the "missing" index values
are$data->xvals->where($data->isbad).

If your data has more than one dimension, you can do pretty much the same
thing with indexND(), <plug>or use PDL:::CCS from CPAN, which was
explicitly built to handle (lots of) gaps in index-value pairs</plug>:

 $which =  pdl(indx,[[0,0],[1,2],[2,3],[3,2],[5,1]]);
 $vals     = sequence($which->dim(0)) * 10;
 $ccs      =
PDL::CCS::Nd->newFromWhich($which,$vals,missing=>pdl(0)->setvaltobad(0));
 $data    = $ccs->decode();
 print $data;

...  this gives me:
[
 [  0 BAD BAD BAD BAD BAD]
 [BAD BAD BAD BAD BAD  40]
 [BAD  10 BAD  30 BAD BAD]
 [BAD BAD  20 BAD BAD BAD]
]

marmosets,
  Bryan


On Wed, Aug 29, 2018 at 9:31 PM Erik Butchert via pdl-general <
[email protected]> wrote:

> Hi
>
> I am reading in a series of PDL's using rcols representing co-ordinates
> of hole positions from a CMM.  My problem is that the measurement device
> does not  recognize every hole so that there are gaps in the first PDL
> that contains the number of each hole, so instead of
> 0,1,2,3,4,5,6,7.......................  I get
> 0,1,2,4,6,7..................... or similar.  Is there a way to fill in
> the missing elements as a PDL or do I need to convert back to a Perl
> list.  Once I have the filled first PDL I would then like to convert the
> other PDL's from the same file to put in BAD values in the corresponding
> positions.  Hopefully this will allow me to compare two files where the
> device has recognized a different number of holes from what should be
> the same pattern.
>
> --
> Erik
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general
>


-- 
Bryan Jurish                           "There is *always* one more bug."
[email protected]         -Lubarsky's Law of Cybernetic Entomology
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to