comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: slow processing of my k-nearest neighour code
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: slow processing of my k-nearest neighour code [message #49784 is a reply to message #49783] Mon, 14 August 2006 08:30 Go to previous messageGo to previous message
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
Karl Schultz wrote:
> On Mon, 14 Aug 2006 10:11:30 -0400, Ben Tupper wrote:
>
>> humphreymurray@gmail.com wrote:
>>
>>>> ; Calculate the squared distance for each attribute.
>>>> squared = make_array(num_training_elements, num_attributes)
>>>> for attrib = 0, num_attributes-1 do begin
>>>> squared[*,attrib] = (testing_data[i, attrib] -
>>>> training_data[*,attrib])^2
>>>> endfor
>>>>
>>
>> Hi,
>>
>> You might try replacing the above for inner-loop with the following
>>
>> squared = (testing_data - training_data)^2
>>

I don't think this works here because you lose the dependence on the i
index -- the value of "squared" will differ for each value of "i".
But another one of David Fanning's pages could help, see
http://www.dfanning.com/code_tips/asterisk.html
and rewrite the assignment as

squared[0,attrib] = (testing_data[i, attrib] -
training_data[*,attrib])^2

--Wayne
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help with GRID_TPS
Next Topic: Re: SHMMAP and structures

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:09:48 PDT 2025

Total time taken to generate the page: 0.00609 seconds