You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The equivalence of NumPy fancy indexing and Fortran vector subscripts could be discussed. The Python
from numpy import array
a = array([10, 20, 30])
print(a[[0, 2]])
is equivalent to the Fortran
integer :: a(3)
a = [10, 20, 30]
print*,a([1, 3])
An alternative to the where example in Fortran is a nested merge:
program main
implicit none
integer :: a(10), b(10)
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
where (a > 5)
b = a - 3
elsewhere (a > 2)
b = 1
elsewhere
b = 0
end where
print*,b
! lines below added by me
b = merge(a-3, merge(1, 0, a > 2), a > 5)
print*,b
end program main
The text was updated successfully, but these errors were encountered:
I posted some comments at https://fortran-lang.discourse.group/t/python-fortran-rosetta-stone-ported-from-fortran-90/5907/4
Here are some further comments.
The equivalence of NumPy fancy indexing and Fortran vector subscripts could be discussed. The Python
is equivalent to the Fortran
An alternative to the
where
example in Fortran is a nested merge:The text was updated successfully, but these errors were encountered: