On Mon, Feb 27, 2012 at 3:39 PM, Jim Magnuson <[email protected]> wrote:
> My bad. I've sorted it now (with help from the list).
>
> To get back to the code, it's brilliant how you do things without looping.
> But I'm still a little lost as to some details...
>
> I get these:
>
> ($inword, $grid) = rcols "$f",0,[], {perlcols=>[0] };
> $kern = $grid->mv(1,0)->norm;
> $nrecs = $kern->dim(1);
>
> But I don't understand:
>
> $sim = inner($kern(,(0)),$kern);
>
> Is this finding inner for all words compared to the first (0th) item? If so,
> then I think I get it. My next step would be to loop through and do this for
> all words. Did I get that right?
Yes, I just calculated the result of the inner
loop against word 0. In general, you would
need to repeat that calculation for each word
index. You could use a where() to skip the
diagonal values, e.g.,
pdl> ($inword, $grid) = rcols 'jmtest.data',0,[], { perlcols=>[0] }
Reading data into piddles of type: [ Double ]
Read in 500 elements.
pdl> $kern = $grid->mv(1,0)->norm
pdl> $nrecs = $kern->dim(1)
pdl> p $kern(,(0))->info
PDL: Double D [676]
pdl> p $kern->info
PDL: Double D [676,500]
pdl> $i = 27
pdl> $sim = inner($kern(,($i)),$kern)
pdl> p $sim->info
PDL: Double D [500]
pdl> $sim_no_i = $sim->where($sim->xvals != $i)
pdl> p $sim_no_i->info
PDL: Double D [499]
In theory, you could calculate all pairwise products
but then you'll have another factor of 50_000 in
memory requirements which is likely to blow the
budget.
Working through the examples in the new
PDL Book (feed back and errata welcome!) and
working through the tutorial on threading on our
wiki at
http://sourceforge.net/apps/mediawiki/pdl/index.php?title=Introduction_to_PDL_Threading
can help you understand how to take advantage
of the vectorization in PDL.
Also, I've re-re-added the perldl list so that others
can be helped by our discussion. Good luck and
happy PDL-ing!
--Chris
> Thank you VERY much,
>
> jim
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl