473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

searching for global extrema

Hi

I have a routine
double myRou ( double x, double y ) { ... };

the way I use it is
vector<doubleres;

for(double i = 1; i < 1000; ++i) {
for( double j = 1; j < 1000; ++j) {
res.push_back( myRou( i, j );
}
}

then I go to find the maximum or minimum values in res.

is there some algorithm that can help me find the global min/max?

thanks
Oct 31 '06 #1
6 1435
I have a routine
double myRou ( double x, double y ) { ... };

the way I use it is
vector<doubleres;

for(double i = 1; i < 1000; ++i) {
for( double j = 1; j < 1000; ++j) {
res.push_back( myRou( i, j );
}
}

is there some algorithm that can help me find the global min/max?
min_element and max_element in <algorithm>.

E.g.
double theMin = *min_element(res.begin(), res.end());

Michael

Oct 31 '06 #2
Gary Wessle wrote:
Hi

I have a routine
double myRou ( double x, double y ) { ... };

the way I use it is
vector<doubleres;

for(double i = 1; i < 1000; ++i) {
for( double j = 1; j < 1000; ++j) {
res.push_back( myRou( i, j );
}
}

then I go to find the maximum or minimum values in res.

is there some algorithm that can help me find the global min/max?

thanks
std::min_element
std::max_element
Oct 31 '06 #3
Mark P <us****@fall2005REMOVE.fastmailCAPS.fmwrites:
Gary Wessle wrote:
Hi
I have a routine double myRou ( double x, double y ) { ... };
the way I use it is
vector<doubleres;
for(double i = 1; i < 1000; ++i) {
for( double j = 1; j < 1000; ++j) { res.push_back( myRou(
i, j );
}
}
then I go to find the maximum or minimum values in res.
is there some algorithm that can help me find the global min/max?
thanks

std::min_element
std::max_element
I feel I was not clear.
I did not mean to find the min and max of the res vector but rather to
find the global extrema with out the loop.
Oct 31 '06 #4

Gary Wessle wrote in message ...
>Mark P <us****@fall2005REMOVE.fastmailCAPS.fmwrites:
>Gary Wessle wrote:
Hi
<snip misleading loops>
is there some algorithm that can help me find the global min/max?
thanks

std::min_element
std::max_element

I feel I was not clear.
I did not mean to find the min and max of the res vector but rather to
find the global extrema with out the loop.

// #include <limits>
std::numeric_limits<double>::max()
std::numeric_limits<double>::min()

--
Bob R
POVrookie
Oct 31 '06 #5
Gary Wessle wrote:
Mark P <us****@fall2005REMOVE.fastmailCAPS.fmwrites:
>>
I feel I was not clear.
I did not mean to find the min and max of the res vector but rather to
find the global extrema with out the loop.
wrong group. Try comp.programming, and ask for an extrema algorithm.

Oct 31 '06 #6
Gary Wessle wrote:
Mark P <us****@fall2005REMOVE.fastmailCAPS.fmwrites:
>Gary Wessle wrote:
>>Hi
I have a routine double myRou ( double x, double y ) { ... };
the way I use it is
vector<doubleres;
for(double i = 1; i < 1000; ++i) {
for( double j = 1; j < 1000; ++j) { res.push_back( myRou(
i, j );
}
}
then I go to find the maximum or minimum values in res.
is there some algorithm that can help me find the global min/max?
thanks
std::min_element
std::max_element

I feel I was not clear.
I did not mean to find the min and max of the res vector but rather to
find the global extrema with out the loop.
What do you mean? Do you want to know the maximum and minimum
attainable values of the function myRou over all possible values for x
and y?
Oct 31 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Uli | last post by:
Is there a way of searching across all microsoft news groups (news.microsoft.com) on the server side? Regards Uli
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
1
Corster
by: Corster | last post by:
I went through a great deal of hassle to figure this out for myself, but now it is complete, I would like to share it with the world! I know afew other people have had trouble with FindFirst and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.