CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Array Comparison in Fortran 90/95 (http://www.cfd-online.com/Forums/main/15713-array-comparison-fortran-90-95-a.html)

M Malik September 11, 2008 10:50

Array Comparison in Fortran 90/95
 
Hi FORTRAN 90/95 Users: Want to know some efficient way of comparing two or more large size arrays in FORTRAN 90/95. Thanks

M Malik September 11, 2008 11:10

Re: Array Comparison in Fortran 90/95
 
To be a little more specific: The arrays could be of different lengths and want to compare them for duplication. -Malik

Jed September 11, 2008 12:55

Re: Array Comparison in Fortran 90/95
 
Oh, they are integer arrays representing sets? You want to determine what integers appear in both arrays? If the range of possible values is known and reasonable, you can mask a bit-array. Otherwise, just sort the arrays.

M Malik September 11, 2008 13:41

Re: Array Comparison in Fortran 90/95
 
Thanks Jed. Yes, I have integer arrays. The range is not known all the time. Comparison by sorting turns out to be very time consuming. Some other suggestion, please!

Jed September 11, 2008 14:14

Re: Array Comparison in Fortran 90/95
 
Keep the arrays sorted or partially sorted. If you don't sort, you end up with O(n^2) which is much worse. A radix sort shouldn't be that bad. Where do these arrays come from? How big are they? I assume you solve equations at some point? Or is this for mesh manipulation? Would a different data structure be better?


All times are GMT -4. The time now is 01:09.