Csound Csound-dev Csound-tekno Search About

How to optimize array sorting?

Date2017-01-27 19:25
FromGleb
SubjectHow to optimize array sorting?
Guys,

In my algorithm I have to check if some spectral values are higher then
their neighbors.

There are three zones in a spectra. For the first one I have to check only 4
neighbors (ki+1, ki+2, ki-1, ki-2).
For the second - 6 neighbor lines (three lines upper and three lines lower).
For the last zone I have to check 12 neighbor lines.

I guess I solved it rather straight (see included csd made in CsoundQT),
using tree-like algorithm to avoid useless operations if say first couple of
neighbors are not weaker. 

Would you propose any other approach?

Thank you!

mpeg_fft.csd
  



-----
Gleb Rogozinsky, PhD
Associated Professor
Interactive Arts Department
Saint-Petersburg University of Film and Television

Deputy Director of Medialab
Saint-Petersburg University of Telecommunications
--
View this message in context: http://csound.1045644.n5.nabble.com/Csnd-How-to-optimize-array-sorting-tp5754181.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-01-27 19:56
FromSteven Yi
SubjectRe: How to optimize array sorting?
Hi Gleb,

I'm not sure I understood your code exactly, but I would have imagined
using multiple loops, something like:

until (kndx > 127) do
  kcount = 0
  kmax = 0
  until (kcount > 4) do
    kmax = max(kmax, kndx + kcount)
    kcount += 1
  od
  ;; do something with kmax
  kindx += 1
od

to get the maxima across neighbors (the above would have to be
adjusted for the 0 and max bounds).

I don't know if this was something you tried or perhaps it is the
inefficient strategy, but it's just what came to my mind.

steven


On Fri, Jan 27, 2017 at 2:25 PM, Gleb  wrote:
> Guys,
>
> In my algorithm I have to check if some spectral values are higher then
> their neighbors.
>
> There are three zones in a spectra. For the first one I have to check only 4
> neighbors (ki+1, ki+2, ki-1, ki-2).
> For the second - 6 neighbor lines (three lines upper and three lines lower).
> For the last zone I have to check 12 neighbor lines.
>
> I guess I solved it rather straight (see included csd made in CsoundQT),
> using tree-like algorithm to avoid useless operations if say first couple of
> neighbors are not weaker.
>
> Would you propose any other approach?
>
> Thank you!
>
> mpeg_fft.csd
> 
>
>
>
> -----
> Gleb Rogozinsky, PhD
> Associated Professor
> Interactive Arts Department
> Saint-Petersburg University of Film and Television
>
> Deputy Director of Medialab
> Saint-Petersburg University of Telecommunications
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Csnd-How-to-optimize-array-sorting-tp5754181.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-01-27 20:03
FromGleb
SubjectRe: How to optimize array sorting?
Thanks Steven!

Your idea has triggered some new thoughts... I gonna try them now. 

 



-----
Gleb Rogozinsky, PhD
Associated Professor
Interactive Arts Department
Saint-Petersburg University of Film and Television

Deputy Director of Medialab
Saint-Petersburg University of Telecommunications
--
View this message in context: http://csound.1045644.n5.nabble.com/Csnd-How-to-optimize-array-sorting-tp5754181p5754183.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here