×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

max value between many matrix

max value between many matrix

max value between many matrix

(OP)
Hello, i have a problem to find the maximum value between many array.
I do a "cicle do", and i found 2718 array. I would like to find the maximum value between this 2718 array.
This is one part of the code:
do i=2, 5436, 2
y = Matmul (Om,y) + Matmul (g0, Vm)*H(2,i)+Matmul(g0, Vm)*H(2,i+2)
end do

obviously y assumed 2718 different values in the arrays.
Sorry for my english.
Thx in advance.

RE: max value between many matrix

As I understood, you compute the array y in a loop 2718 times.
Sorry, but I didn't understand what you want to find:
1. a maximum array of all the computed arrays, i.e. one array of the 2718 arrays with the maximum norm ||y||
or
2. one maximum element y(k) of all the 2718 arrays computed
?

RE: max value between many matrix

(OP)
Thx for the Answer.
2. one maximum element y(k) of all the 2718 arrays computed
The matrix have this dimension (2,1). I want to find the maximum element y(1,1) of all the 2718 arrays computed between all the 2718 arrays computed.

RE: max value between many matrix

Quote (Salvanto)


I want to find the maximum element y(1,1) of all the 2718 arrays computed between all the 2718 arrays computed.

If you need the maximum of all values y(1,1) computed in 2718 steps you can enhance the loop with a simple maximum computation like this:

CODE

my_max = 0 ! or if y(1,1) could be negative then the lowest value
do i=2, 5436, 2
  y = Matmul (Om,y) + Matmul (g0, Vm)*H(2,i)+Matmul(g0, Vm)*H(2,i+2)
  ! get the maximum value of y(1,1)
  if (y(1,1) > my_max) then
    my_max = y(1,1)
  end if  
end do
write(*,*) 'my_max = ', my_max 

or if you think that you will need all the values of y(1,1) after the loop for other research you can rather store them first in a separate array and then find the maximum of this array - for example like this:

CODE

! first declare the array my_values of the dimension 2718
j = 0
do i=2, 5436, 2
  y = Matmul (Om,y) + Matmul (g0, Vm)*H(2,i)+Matmul(g0, Vm)*H(2,i+2)
  ! store the value of y(1,1) into the array my_values
  j = j + 1
  my_values(j) = y(1,1)
end do
! get the maximum value of my_values
my_max = my_values(1)
do j=2, 2718
  if (my_values(j) > my_max) then
    my_max = my_values(j)
  end if  
end do
write(*,*) 'my_max = ', my_max 

RE: max value between many matrix

(OP)
Yes thx!!!I have another question!!

But if instead, always from the following expression:

do i=2, 5436, 2
y = Matmul (Om,y) + Matmul (g0, Vm)*H(2,i)+Matmul(g0, Vm)*H(2,i+2)

I would like that in the matrix product "Om * y", the "y" was the one obtained in the previous calculation. I'll explain better, I give the initial conditions of "y", ie y (1,1) = 0 and y (2,1) = 0 and calculate the value of "y" with the previously written expression. In practice I would like to calculate the first value of "y" with those boundary conditions, the second value of "y" according to the value obtained from the first value of "y" and so on.

RE: max value between many matrix

It seems that you already do it that way:
Before the loop you have y=y0
the in the first iteration for i = 2 you will get from the computation y = Matmul (Om,y) + ...
the new value i.e. y1 = Matmul (Om,y0) + ...
in the second iteration for i = 4 you will get from the computation y = Matmul (Om,y) + ...
then new value y2 = Matmul (Om,y1) + ..
... etc ...

If you are unsure prove it, printing the value of the array y in some iterations or inspect it in the debugger.

RE: max value between many matrix

(OP)
Perfect, thx!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close