#NEWLINE# def test_partial_loops_f( ) : #NEWLINE# #INDENT# from sympy.tensor import IndexedBase , Idx #NEWLINE# from sympy import symbols #NEWLINE# ( n , m , o , p ) = symbols ( 'n m o p' , integer = True ) #NEWLINE# A = IndexedBase ( 'A' , shape = ( m , p ) ) #NEWLINE# x = IndexedBase ( 'x' ) #NEWLINE# y = IndexedBase ( 'y' ) #NEWLINE# i = Idx ( 'i' , ( o , ( m - 5 ) ) ) #NEWLINE# j = Idx ( 'j' , n ) #NEWLINE# ( ( f1 , code ) , ( f2 , interface ) ) = codegen ( ( 'matrix_vector' , Eq ( y [ i ] , ( A [ ( i , j ) ] * x [ j ] ) ) ) , 'F95' , 'file' , header = False , empty = False ) #NEWLINE# expected = ( 'subroutine matrix_vector(A, m, n, o, p, x, y)\nimplicit none\nINTEGER*4, intent(in) :: m\nINTEGER*4, intent(in) :: n\nINTEGER*4, intent(in) :: o\nINTEGER*4, intent(in) :: p\nREAL*8, intent(in), dimension(1:m, 1:p) :: A\nREAL*8, intent(in), dimension(1:n) :: x\nREAL*8, intent(out), dimension(1:%(iup-ilow)s) :: y\nINTEGER*4 :: i\nINTEGER*4 :: j\ndo i = %(ilow)s, %(iup)s\n   y(i) = 0\nend do\ndo i = %(ilow)s, %(iup)s\n   do j = 1, n\n      y(i) = %(rhs)s + y(i)\n   end do\nend do\nend subroutine\n' % { #NEWLINE# #INDENT# 'rhs' : '%(rhs)s' , #NEWLINE# 'iup' : str ( ( m - 4 ) ) , #NEWLINE# 'ilow' : str ( ( 1 + o ) ) , #NEWLINE# 'iup-ilow' : str ( ( ( m - 4 ) - o ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( ( code == ( expected % { #NEWLINE# #INDENT# 'rhs' : 'A(i, j)*x(j)' , #NEWLINE# #UNINDENT# } ) ) or ( code == ( expected % { #NEWLINE# #INDENT# 'rhs' : 'x(j)*A(i, j)' , #NEWLINE# #UNINDENT# } ) ) )