Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > pairwise comparison

Reply
Thread Tools

pairwise comparison

 
 
gianluca
Guest
Posts: n/a
 
      08-08-2008
Hy list
I have to build a function for pairwise comparation of matrix
elements. The most logical approach is with several for(; but my
matrix is very large (5000 x 5000) elements (is a raster geographical
map) and required a huge machine resource. Is there a more efficient
algorithm for my pourpuse.
Thanks

Gianluca
 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      08-08-2008
In article <7e29380f-97a3-4ff6-ba7d->,
gianluca <> wrote:

>I have to build a function for pairwise comparation of matrix
>elements. The most logical approach is with several for(; but my
>matrix is very large (5000 x 5000) elements (is a raster geographical
>map) and required a huge machine resource. Is there a more efficient
>algorithm for my pourpuse.


Is your matrix sparse or dense? Are all elements to be compared to
all other elements?

If all elements are to be compared to all other elements, then
you can probably achieve significant speed-ups by processing
the data in "blocks", paying attention to the amount of data that
will fit into your processor's cache, and paying attention to
cache line conflicts. Unfortunately there is no portable C method of
determining processor cache or cache-line information (cache is
a hardware detail that doesn't affect the semantics of C), so
you will have to make your routine somewhat system dependant, at
least to the point of determining those parameters (but then
you could have a block-processing routine that did its best within
the supplied parameters.)

Note: when you have a choice in the matter, ensure that your output
matrix does not have cache line conflicts with your input matrix.
Some compilers, given the appropriate system-specific options, will
automatically put in padding to promote good cache performance.

Block and cache aware routines will usually be more complex, and will
usually not *obviously* be more efficient. If you have to do 25 million
comparisons then you have to do 25 million comparisons, and efficiency
gains are made by working with the hardware efficiency limitations and
with working with processor instruction pipelines and other
system and hardware specific techniques.
--
"And that's the way it is." -- Walter Cronkite
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison of 2 files and generating the output based on comparison Deepu Perl Misc 1 02-07-2011 03:09 PM
Price Comparison Service. Best Deal. Special Coupon atBest-Price-Comparison.com rapee Digital Photography 0 03-14-2008 06:46 AM
pairwise comparison and merging of vector elements Alan C++ 1 06-04-2007 06:12 PM
parsing large text file and pairwise comparison Alan C++ 7 10-27-2006 02:37 AM
Remove elements pairwise from vector koperenkogel C++ 11 04-11-2005 12:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57