Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

matlab to fortran 1

Status
Not open for further replies.

smile23

Programmer
Oct 17, 2010
3
IT
hello how can i convert this expression fronm matlab to fortran?

for i=1:dt
y:),i+1)=A*y:),i);
end

where A is a matrix N*N and y a vector N*M

thanks
 
Almost the same programming, except the use of the intrinsic function MATMUL :

Code:
double precision :: a(n,n),y(n,m)
integer :: i
...
do i=1,m-1
  y(:,i+1)=matmul(a,y(:,i))
enddo
 
thanks!
is there also a intrinsic function for the sum of arrays?
 
is there also a intrinsic function for the sum of arrays?

Yes : "+" to add two arrays term by term (they must have the same shape and dimensions, the result being an array) and "sum" to sum the elements of an array. Notice that * is usable for arrays as well in multiplying term by term two arrays having the same shape and same dimensions (the result is an array). + and * may be used also to add/multiply an array by a scalar.

And there is also dot_product, transpose, product, maxval, minval, maxloc, minloc ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top