For Programmers: Free Programming Magazines  


Home > Archive > Fortran > June 2005 > relative optimas









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author relative optimas
Baloff

2005-06-05, 3:57 pm

Hello group

Is there a function that can help in doing the task below or do I need
to write something up?

I need to get the index of the relative “local” maximums and minimums in
a sequence or real numbers.

Say a={5,4,2,2,2,2,2,7}
The index I need is the one belong to the first occurrence of the number
2, which is the third number in the above sequence for a local minimum.

Say a={5,8,2,1}
The index I need is the one belongs to the number 8, which is the second
in the sequence for the local maximum.

Say a={5,4,2,2,2,7,2}
The index I need is the ones belong to the first 2 and then the 7. as an
index of local minimum and maximum respectively.

Thanks


Michael Metcalf

2005-06-05, 3:57 pm


>
> Say a={5,4,2,2,2,2,2,7}
> The index I need is the one belong to the first occurrence of the number
> 2, which is the third number in the above sequence for a local minimum.
>

index = minloc(a)

> Say a={5,8,2,1}
> The index I need is the one belongs to the number 8, which is the second
> in the sequence for the local maximum.
>


index = maxloc(a)

> Say a={5,4,2,2,2,7,2}
> The index I need is the ones belong to the first 2 and then the 7. as an
> index of local minimum and maximum respectively.
>

index_min = minloc(a)
index_max = maxloc(a)

Regards,

Mike Metcalf


James Van Buskirk

2005-06-05, 8:57 pm

"Michael Metcalf" <michaelmetcalf@compuserve.com> wrote in message
news:d7veje$u19$04$1@news.t-online.com...

> index = minloc(a)


And the answer to his next question is:

index = minloc(a,1)

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


Michael Metcalf

2005-06-05, 8:57 pm


"James Van Buskirk" <not_valid@comcast.net> wrote in message
news:BcCdnXNbc8hw3z7fRVn-jQ@comcast.com...
> "Michael Metcalf" <michaelmetcalf@compuserve.com> wrote in message
> news:d7veje$u19$04$1@news.t-online.com...
>
>
> And the answer to his next question is:
>
> index = minloc(a,1)
>

Whoops, sure thing.

Mike Metcalf


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com