searching for global extrema

G

Gary Wessle

Hi

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

the way I use it is
vector<double> res;

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
 
M

Michael

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

the way I use it is
vector<double> res;

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
 
M

Mark P

Gary said:
Hi

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

the way I use it is
vector<double> res;

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
 
G

Gary Wessle

Mark P said:
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.
 
B

BobR

Gary Wessle wrote in message ...
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()
 
R

red floyd

Gary said:
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.
 
M

Mark P

Gary said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top