X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 27 Jun 2010 03:02 AM by  anon
Multi-Array comparison
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
27 Jun 2010 03:02 AM
    Multi-Array comparison Hello everybody, I have three fltarr(460,483) and I would like to compare them, finding for each element i,j of the arrays which one among the three guarantee the maximum value. However, since I just need to know a sort of "best server" index, I'm looking for the percentage so finding the total amount will be enough. I've found out the WHERE function, but in my case (three or more arrays) should I make a loop? Any ideas? Thanks, Giuseppe

    Deleted User



    New Member


    Posts:
    New Member


    --
    01 Jul 2010 12:04 AM
    Hello. If I get you right I think you can use WHERE in your case. Given P arrays of size MxN. Then the following code will give you array of max values and array of numbers of array with max value for each element. arr = fltarr(M, N, P) ; given arrays maxarr = fltarr(M, N) ; here we put maximum values Imaxidx = intarr(M, N) ; here for each element we put number of array where this element is greatest among all other arrays maxarr[*, *] = -999999 ; or something really impossible for i = 0, P-1 do begin curarr = arr[*, *, i] ; let's take the i-th array idx = where ( curarr gt maxarr) ; find indices of elements of current array which are greater than such elements of maxarr if (idx[0] ne -1) then begin ; if there are any... maxarr[idx] = curarr[idx] ; ... we store maximum values for future comparison... maxidx[idx] = i ; ... and ordinal number (i) of current array for each maximum element endif endfor Should work. :) Bye!
    You are not authorized to post a reply.