- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a one-dimensional Real(8):: array(dim) which beginsat 0.D0, goes up to a calculated value, say 51.5787511797424, stays constant there a while and then goes back to 0.D0. I am trying to find the location of the maximum value in this array.
MaxLoc should find the first occurrence of the maximum value, but it finds sometimes the first occurrence of the maximum constant value and sometimes the last one depending on the input values to the program. I can see that the hex valuesare different -
sometimes #4049CA1484C6C1E8,
sometimes #4049CA1484C6C1EC, and
sometimes #4049CA1484C6C1F0.
My question is: how can I always find the first occurrence of that "constant" decimal value which is "seen", the first "top" point, regardless of those tiny fluctuations which follow the first top point?I can not think of aMASK which canbe usedthere.
I am talking about CVF.
Thanks for any help.
Sabalan.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand you correctly, you want maxloc() to work as if you first converted the values to decimal, e.g. with a g15 format. This would be fairly complicated, depending on your exact requirements.If you displayed the values you quoted with 17 decimal significant digits, no doubt you would see the differences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Yugoslav. I had own DO loop there and changed it to MaxLoc because the curve happens not to beascendant all the way to the top.
Thanks Tim. That is all decimals which the debugger shows me and I don't know if I can change this setting. But my problem was the opposit: I wanted to make MaxLoc NOT to see those last decimals, and I found, for my case, a very simple solution:
M_Loc = MaxLoc(SNGL(array))
This cuts away last decimals and makes MaxLoc stop at the first occurrence of the "constant" maximum.
Sabalan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MaxLoc is returning the correct value
sometimes #4049CA1484C6C1E8,
sometimes #4049CA1484C6C1EC, and
sometimes #4049CA1484C6C1F0.
The last in the list is the highest value. The solutionj you found may be too aggressive (i.e. discarding more precision than you want). Also the you must be sure your exponent doesn't max out.
If you want to reduce the precision fast then make a union of your real(8) with an integer(8) and make a prepass (filter) using bitwise AND to truncate (or round)the least significant bits that you deem are insignificant. If you want to keep the original data then copy with bitwise AND and get the max from the copy.
Jim Dempsey
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page