Hi-

First off, you can use the PDL on-line documentation to
find relevant commands to try:

  pdldoc -a maximum

or

  pdl> apropos maximum

in the pdl2 or perldl shells includes the following items:

   maximum             Project via maximum to N-1 dimensions
   maximum_ind       Like maximum but returns the index rather than the
value
   maximum_n_ind   Returns the index of `m' maximum elements

where maximum_n_ind is what you are looking for.  Here is a
sample pdl2 session showing the calculation.  You can use
the PDL shells and the online documentation to understand
fully how it works:


pdl> floor(random(10,10)*10)
> pdl> p $m
> [
>  [4 7 5 0 6 7 8 4 6 7]
>  [0 7 0 2 5 3 0 4 6 6]
>  [5 4 3 6 9 5 8 4 4 1]
>  [9 6 7 7 4 1 4 2 0 8]
>  [5 1 3 3 7 7 1 2 8 5]
>  [2 0 8 7 3 1 5 7 7 6]
>  [5 9 6 2 7 2 6 7 0 2]
>  [6 3 1 1 8 2 1 9 9 9]
>  [6 7 9 3 5 2 2 5 9 3]
>  [4 5 0 4 7 9 3 3 1 6]
> ]
>
> pdl> $top5 = zeros indx, 5;   # size of $top5 determines n
> pdl> $m->flat->maximum_n_ind($top5)  # get top 5 element indexes
> pdl> p pdl($m->one2nd($top5))              # convert linear to ND index
> [
>  [4 0 1 7 8]
>  [2 3 6 7 7]
> ]
>
>
>
Hope this helps,
Chris


On Fri, Oct 17, 2014 at 11:54 AM, Ronak Agrawal <[email protected]>
wrote:

> First I would Thank You for your constant help...it has helped me a lot in
> improving my skills
> -------
>
> I have generated a Hankel Matrix by the following operation
>
> // $a is a svd and therby this operation will always form Hankel Matrix
> $matrix = $a x transpose($a);
>
>  [image: [a b c d e; b c d e f; c d e f g; d e f g h; e f g h i].]
>
> I need to find the top K minimum elements ( 2D) with their 2 Dimesional
> indices ..
> Can you suggest me some good approach for this
>
> I though to do following but it is not optimized
> Converting the Lower triangular Matrix as Bad Values or 0
> Then Finding the mimimum row_wise and column_wise using minimum function
>
> Thanks
>
>
>
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to