Module Expr Str ImportFrom alias alias Import alias ImportFrom alias alias alias ImportFrom alias alias ImportFrom alias ImportFrom alias alias ImportFrom alias Assign NameStore Dict Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str ClassDef bases NameLoad body Expr Str Assign NameStore Str Assign NameStore Str Assign NameStore Dict Str Str Str Str Str Str Str Str NameLoad Str Num Dict NameLoad Str NameLoad Num Assign NameStore Dict Str Str Str Str Str Str Str Str Str Str Assign NameStore Dict Str Str FunctionDef arguments args NameParam NameParam defaults Dict body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Dict Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Str Str body Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Str orelse If CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Str Str body Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Str orelse Raise Call NameLoad BinOpMod Str SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Set Num Num Num Num Num Num If CompareNotIn SubscriptLoad AttributeLoad NameLoad attr Index Str NameLoad body Raise Call NameLoad BinOpMod Str SubscriptLoad AttributeLoad NameLoad attr Index Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Return BinOpMult UnaryOpUSub NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Return Call AttributeLoad Str attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Return GeneratorExp TupleLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListLoad Assign NameStore ListLoad For NameStore NameLoad body Assign TupleStore NameStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr ListLoad AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr Num BinOpAdd AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareNotEq AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad body Raise Call NameLoad Str Assign NameStore ListLoad If Call AttributeLoad NameLoad attr NameLoad body For TupleStore NameStore TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body If CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr BinOpMod Str Call AttributeLoad NameLoad attr NameLoad orelse If BoolOpAnd CompareEq NameLoad BinOpSub Call NameLoad AttributeLoad NameLoad attr Num CompareEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str orelse Expr Call AttributeLoad NameLoad attr BinOpMod Str Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str Return Call AttributeLoad Str attr NameLoad orelse If CompareGtE SubscriptLoad AttributeLoad NameLoad attr Index Str Num body Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Slice Num While NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword NameLoad Return NameLoad orelse Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad Str attr AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr Num BinOpAdd AttributeLoad NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListLoad Assign NameStore ListLoad Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body If BoolOpAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad orelse If BoolOpAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt Call NameLoad NameLoad Num body If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call AttributeLoad NameLoad attr Str body Assign NameStore Str Assign NameStore SubscriptLoad NameLoad Slice Num orelse Assign NameStore Str If CompareLt Call NameLoad NameLoad NameLoad body Assign NameStore BinOpMod Str NameLoad Return BinOpMod Str TupleLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad Call AttributeLoad NameLoad attr BinOpMult UnaryOpUSub AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad orelse Return BinOpMod Str TupleLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad Call AttributeLoad NameLoad attr BinOpMult UnaryOpUSub AttributeLoad NameLoad attr Call NameLoad NameLoad orelse Return Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore ListComp Call NameLoad NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Return Call AttributeLoad NameLoad attr NameLoad orelse Return Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If BoolOpAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return BinOpMod Str Call AttributeLoad NameLoad attr BinOpMult UnaryOpUSub AttributeLoad NameLoad attr NameLoad orelse Return Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call NameLoad NameLoad If CompareEq AttributeLoad NameLoad attr Num body Return BinOpMod Str Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad orelse If CompareEq AttributeLoad NameLoad attr Num body If AttributeLoad AttributeLoad NameLoad attr attr body If AttributeLoad AttributeLoad NameLoad attr attr body Return BinOpMod Str Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Return BinOpMod Str Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Return BinOpMod Str Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Return Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore NameStore NameStore TupleLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Return BinOpMod Str TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str If CompareGt NameLoad Num body Return BinOpMod Str TupleLoad SubscriptLoad NameLoad Slice NameLoad SubscriptLoad NameLoad Slice BinOpAdd NameLoad Num Return BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListComp Call AttributeLoad NameLoad attr NameLoad comprehension NameStore AttributeLoad NameLoad attr Return BinOpMod Str TupleLoad Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore ListLoad For NameStore NameLoad body If Call AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr Call AttributeLoad SubscriptLoad NameLoad Slice Num attr orelse Expr Call AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad BinOpAdd BinOpAdd Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad Str FunctionDef arguments args NameParam NameParam defaults body If CompareLtE Call NameLoad NameLoad NameLoad body Return Call NameLoad NameLoad Assign NameStore NameLoad Assign NameStore Lambda arguments args NameParam defaults BoolOpOr BoolOpAnd CompareIn SubscriptLoad NameLoad Index NameLoad NameLoad CompareNotIn SubscriptLoad NameLoad Index BinOpSub NameLoad Num NameLoad BoolOpAnd CompareNotIn SubscriptLoad NameLoad Index NameLoad NameLoad CompareIn SubscriptLoad NameLoad Index BinOpSub NameLoad Num NameLoad BoolOpAnd CompareIn SubscriptLoad NameLoad Index NameLoad NameLoad CompareNotIn SubscriptLoad NameLoad Index BinOpSub NameLoad Num NameLoad BoolOpAnd CompareNotIn SubscriptLoad NameLoad Index NameLoad NameLoad CompareIn SubscriptLoad NameLoad Index BinOpSub NameLoad Num NameLoad While UnaryOpNot Call NameLoad NameLoad body AugAssignSub NameStore Num If CompareEq NameLoad Num body Return NameLoad Return NameLoad decorator_list Assign NameStore ListLoad If CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Str Str body Assign NameStore Str orelse Assign NameStore Str For NameStore NameLoad body If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr Str Num Num If CompareEq NameLoad Num body Assign NameStore Num Assign NameStore SubscriptLoad NameLoad Slice NameLoad Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad While CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr Str Num Num If BoolOpOr CompareEq NameLoad Num CompareLt Call NameLoad NameLoad Num body Assign NameStore Num Assign NameStore SubscriptLoad NameLoad Slice NameLoad Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad orelse If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore Call NameLoad NameLoad Num Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr If NameLoad body AugAssignAdd NameStore NameLoad Expr Call AttributeLoad NameLoad attr NameLoad While CompareGt Call NameLoad NameLoad Num body Assign NameStore Call NameLoad NameLoad Num Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr If NameLoad body AugAssignAdd NameStore NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad Str attr NameLoad Assign NameStore CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Str Str Assign NameStore ListComp Call AttributeLoad NameLoad attr Str comprehension NameStore NameLoad Assign NameStore TupleLoad Str Str Str Str Str Assign NameStore TupleLoad Str Str Str Str Str Assign NameStore ListComp Call NameLoad Call NameLoad Call NameLoad AttributeLoad NameLoad attr NameLoad comprehension NameStore NameLoad Assign NameStore ListComp Call NameLoad Call NameLoad Call NameLoad AttributeLoad NameLoad attr NameLoad comprehension NameStore NameLoad Assign NameStore ListComp Call NameLoad Call NameLoad Call NameLoad AttributeLoad NameLoad attr ListLoad Str Str comprehension NameStore NameLoad Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore ListLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr NameLoad Continue AugAssignSub NameStore SubscriptLoad NameLoad Index NameLoad If NameLoad body Assign NameStore BinOpMult Str BinOpAdd BinOpMult NameLoad NameLoad NameLoad orelse Assign NameStore BinOpMult BinOpMult Str NameLoad NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad If UnaryOpNot NameLoad body Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr ListLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr NameLoad If SubscriptLoad NameLoad Index NameLoad body Assign NameStore BinOpMult Num NameLoad orelse Assign NameStore Num AugAssignAdd NameStore SubscriptLoad NameLoad Index NameLoad If UnaryOpNot NameLoad body Return Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad kwarg body Expr Str Return Call AttributeLoad Call NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults kwarg body Expr Str Expr Call NameLoad Call NameLoad NameLoad NameLoad decorator_list
N/A N/A 
Fortran code printer

The FCodePrinter converts single sympy expressions into single Fortran
expressions, using the functions defined in the Fortran 77 standard where
possible. Some useful pointers to Fortran can be found on wikipedia:

http://en.wikipedia.org/wiki/Fortran

Most of the code below is based on the "Professional Programmer's Guide to
Fortran77" by Clive G. Page:

http://www.star.le.ac.uk/~cgp/prof77.html

Fortran is a case-insensitive language. This might cause trouble because
SymPy is case sensitive. The implementation below does not care and leaves
the responsibility for generating properly cased Fortran code to the user.
 __future__ print_function division N/A string sympy.core S Add N sympy.core.compatibility string_types range sympy.core.function Function sympy.printing.codeprinter CodePrinter Assignment sympy.printing.precedence precedence N/A known_functions N/A sin cos tan asin acos atan atan2 sinh cosh tanh log exp erf Abs sign conjugate sin cos tan asin acos atan atan2 sinh cosh tanh log exp erf Abs sign conjg FCodePrinter N/A CodePrinter N/A N/A A printer to convert sympy expressions to strings of Fortran code N/A printmethod _fcode N/A language Fortran N/A _default_settings N/A order full_prec precision user_functions human source_format contract standard None auto 15 N/A True fixed True 77 N/A _operators N/A and or xor equivalent not .and. .or. .neqv. .eqv. .not.  N/A _relationals N/A != /= __init__ N/A N/A self settings N/A N/A N/A N/A N/A N/A CodePrinter __init__ self settings N/A N/A self known_functions N/A dict known_functions N/A userfuncs N/A N/A settings get user_functions N/A N/A N/A N/A N/A self known_functions update userfuncs N/A N/A N/A N/A self _settings N/A source_format fixed N/A N/A N/A self _lead_code N/A N/A self _lead_cont      @  N/A N/A self _lead_comment C      N/A N/A N/A N/A N/A self _settings N/A source_format free N/A N/A N/A self _lead_code N/A N/A self _lead_cont N/A N/A self _lead_comment !  N/A N/A N/A ValueError N/A Unknown source format: %s N/A N/A self _settings N/A source_format N/A standards N/A 66 77 90 95 2003 2008 N/A N/A N/A N/A self _settings N/A standard standards N/A N/A N/A ValueError N/A Unknown Fortran standard: %s N/A N/A self _settings N/A standard N/A _rate_index_position N/A N/A self p N/A N/A N/A N/A N/A p 5 N/A _get_statement N/A N/A self codestring N/A N/A N/A codestring N/A _get_comment N/A N/A self text N/A N/A N/A N/A N/A ! {0} format text N/A _declare_number_const N/A N/A self name value N/A N/A N/A N/A N/A parameter ({0} = {1}) format name value N/A _format_code N/A N/A self lines N/A N/A N/A N/A N/A self _wrap_fortran N/A N/A self indent_code lines N/A _traverse_matrix_indices N/A N/A self mat N/A N/A N/A N/A rows cols N/A mat shape N/A N/A N/A i j N/A j N/A range cols N/A i N/A range rows N/A _get_loop_opening_ending N/A N/A self indices N/A N/A N/A open_lines N/A N/A close_lines N/A N/A i indices N/A N/A N/A var start stop N/A map N/A self _print N/A N/A i label N/A N/A i lower 1 N/A N/A i upper 1 N/A N/A N/A open_lines append N/A do %s = %s, %s N/A var start stop N/A N/A N/A close_lines append end do N/A N/A open_lines close_lines N/A _print_Piecewise N/A N/A self expr N/A N/A N/A N/A N/A N/A N/A expr args N/A -1 cond True N/A N/A N/A ValueError All Piecewise expressions must contain an (expr, True) statement to be used as a default condition. Without one, the generated expression may not evaluate to anything under some condition. N/A lines N/A N/A N/A N/A expr has Assignment N/A N/A N/A i N/A e c N/A enumerate N/A expr args N/A N/A N/A i 0 N/A N/A N/A N/A lines append N/A if (%s) then N/A N/A self _print c N/A N/A N/A N/A i N/A N/A len N/A expr args 1 N/A c True N/A N/A N/A N/A lines append else N/A N/A N/A N/A lines append N/A else if (%s) then N/A N/A self _print c N/A N/A N/A lines append N/A N/A self _print e N/A N/A N/A lines append end if N/A N/A N/A join lines N/A N/A N/A N/A N/A self _settings N/A standard 95 N/A N/A pattern merge({T}, {F}, {COND}) N/A code N/A N/A self _print N/A N/A N/A expr args N/A -1 expr N/A terms N/A list N/A N/A expr args N/A -1 N/A terms N/A N/A N/A e c N/A N/A terms pop N/A expr N/A N/A self _print e N/A cond N/A N/A self _print c N/A code N/A N/A pattern format T expr F code COND cond N/A code N/A N/A N/A NotImplementedError Using Piecewise as an expression using inline operators is not supported in standards earlier than Fortran95. N/A _print_MatrixElement N/A N/A self expr N/A N/A N/A N/A N/A {0}({1}, {2}) format N/A expr parent N/A N/A expr i 1 N/A N/A expr j 1 N/A _print_Add N/A N/A self expr N/A N/A N/A pure_real N/A N/A pure_imaginary N/A N/A mixed N/A N/A arg N/A expr args N/A N/A N/A N/A arg is_number N/A arg is_real N/A N/A N/A N/A pure_real append arg N/A N/A N/A N/A arg is_number N/A arg is_imaginary N/A N/A N/A N/A pure_imaginary append arg N/A N/A N/A N/A mixed append arg N/A N/A N/A len pure_imaginary 0 N/A N/A N/A N/A len mixed 0 N/A N/A PREC N/A precedence expr N/A term N/A Add mixed N/A t N/A N/A self _print term N/A N/A N/A t startswith - N/A N/A sign - N/A t N/A t N/A 1 N/A N/A sign + N/A N/A N/A precedence term PREC N/A N/A t N/A (%s) t N/A N/A cmplx(%s,%s) %s %s N/A N/A N/A self _print N/A Add pure_real N/A N/A self _print N/A N/A N/A S ImaginaryUnit N/A Add pure_imaginary sign t N/A N/A N/A cmplx(%s,%s) N/A N/A N/A self _print N/A Add pure_real N/A N/A self _print N/A N/A N/A S ImaginaryUnit N/A Add pure_imaginary N/A N/A N/A N/A CodePrinter _print_Add self expr N/A _print_Function N/A N/A self expr N/A N/A N/A prec N/A N/A self _settings N/A precision N/A args N/A N/A N a prec N/A a N/A expr args N/A eval_expr N/A N/A expr func args N/A N/A N/A isinstance eval_expr Function N/A N/A N/A N/A self _print eval_expr N/A N/A N/A N/A CodePrinter _print_Function self N/A N/A expr func args N/A _print_ImaginaryUnit N/A N/A self expr N/A N/A N/A cmplx(0,1) N/A _print_int N/A N/A self expr N/A N/A N/A N/A str expr N/A _print_Mul N/A N/A self expr N/A N/A N/A N/A N/A expr is_number N/A expr is_imaginary N/A N/A N/A cmplx(0,%s) N/A N/A self _print N/A N/A N/A S ImaginaryUnit expr N/A N/A N/A N/A CodePrinter _print_Mul self expr N/A _print_Pow N/A N/A self expr N/A N/A N/A PREC N/A precedence expr N/A N/A N/A expr exp -1 N/A N/A N/A 1.0/%s N/A N/A self parenthesize N/A expr base PREC N/A N/A N/A N/A expr exp 0.5 N/A N/A N/A N/A expr base is_integer N/A N/A N/A N/A expr base is_Number N/A N/A N/A sqrt(%s.0d0) N/A N/A self _print N/A expr base N/A N/A N/A sqrt(dble(%s)) N/A N/A self _print N/A expr base N/A N/A N/A sqrt(%s) N/A N/A self _print N/A expr base N/A N/A N/A N/A CodePrinter _print_Pow self expr N/A _print_Rational N/A N/A self expr N/A N/A N/A N/A p q N/A N/A int N/A expr p N/A int N/A expr q N/A N/A %d.0d0/%d.0d0 N/A p q N/A _print_Float N/A N/A self expr N/A N/A N/A printed N/A N/A CodePrinter _print_Float self expr N/A e N/A N/A printed find e N/A N/A e -1 N/A N/A N/A %sd%s N/A N/A printed N/A e N/A printed N/A N/A e 1 N/A N/A %sd0 printed N/A _print_Indexed N/A N/A self expr N/A N/A N/A inds N/A N/A N/A self _print i N/A i N/A expr indices N/A N/A %s(%s) N/A N/A N/A self _print N/A N/A expr base label N/A N/A ,  join inds N/A _print_Idx N/A N/A self expr N/A N/A N/A N/A N/A self _print N/A expr label N/A _pad_leading_columns N/A N/A self lines N/A N/A N/A result N/A N/A line lines N/A N/A N/A N/A line startswith ! N/A N/A N/A N/A result append N/A N/A self _lead_comment N/A N/A N/A line N/A 1 lstrip N/A N/A N/A N/A result append N/A N/A self _lead_code line N/A result N/A _wrap_fortran N/A N/A self lines N/A N/A N/A Wrap long Fortran lines

           Argument:
             lines  --  a list of lines (without \n character)

           A comment line is split at white space. Code lines are split with a more
           complex rule to give nice results.
         N/A my_alnum N/A set N/A N/A _+-. N/A string digits N/A string ascii_letters N/A my_white N/A set  	() split_pos_code N/A N/A line endpos N/A N/A N/A N/A N/A len line endpos N/A N/A N/A len line N/A pos endpos N/A split N/A N/A N/A pos N/A N/A N/A N/A N/A line N/A pos my_alnum N/A N/A line N/A N/A pos 1 my_alnum N/A N/A N/A line N/A pos my_alnum N/A N/A line N/A N/A pos 1 my_alnum N/A N/A N/A line N/A pos my_white N/A N/A line N/A N/A pos 1 my_white N/A N/A N/A line N/A pos my_white N/A N/A line N/A N/A pos 1 my_white N/A N/A N/A split pos N/A N/A pos 1 N/A N/A pos 0 N/A N/A endpos N/A pos N/A N/A result N/A N/A N/A N/A N/A self _settings N/A source_format free N/A N/A trailing  & N/A N/A trailing N/A line lines N/A N/A N/A N/A line startswith N/A self _lead_comment N/A N/A N/A N/A len line 72 N/A N/A pos N/A N/A line rfind 6 72 N/A N/A pos -1 N/A N/A pos 72 N/A hunk N/A line N/A pos N/A line N/A N/A N/A line N/A pos lstrip N/A N/A N/A result append hunk N/A N/A N/A len line 0 N/A N/A pos N/A N/A line rfind 0 66 N/A N/A N/A pos -1 N/A N/A len line 66 N/A N/A pos 66 N/A hunk N/A line N/A pos N/A line N/A N/A N/A line N/A pos lstrip N/A N/A N/A result append N/A %s%s N/A N/A self _lead_comment hunk N/A N/A N/A N/A result append line N/A N/A N/A N/A line startswith N/A self _lead_code N/A N/A pos N/A split_pos_code line 72 N/A hunk N/A N/A N/A line N/A pos rstrip N/A line N/A N/A N/A line N/A pos lstrip N/A line N/A N/A hunk trailing N/A N/A N/A result append hunk N/A N/A N/A len line 0 N/A N/A pos N/A split_pos_code line 65 N/A hunk N/A N/A N/A line N/A pos rstrip N/A line N/A N/A N/A line N/A pos lstrip N/A line N/A N/A hunk trailing N/A N/A N/A result append N/A %s%s N/A N/A self _lead_cont hunk N/A N/A N/A N/A result append line N/A result N/A indent_code N/A N/A self code N/A N/A N/A Accepts a string of code or a list of code lines N/A N/A isinstance code string_types N/A N/A code_lines N/A N/A self indent_code N/A N/A code splitlines True N/A N/A N/A join code_lines N/A free N/A N/A N/A self _settings N/A source_format free N/A code N/A N/A N/A line lstrip N/A line code N/A inc_keyword N/A do  if( if  do
 else N/A dec_keyword N/A end do enddo end if endif else N/A increase N/A N/A int N/A any N/A map N/A line startswith inc_keyword N/A line code N/A decrease N/A N/A int N/A any N/A map N/A line startswith dec_keyword N/A line code N/A continuation N/A N/A int N/A any N/A map N/A line endswith N/A & &
 N/A line code N/A level 0 N/A cont_padding 0 N/A tabwidth 3 N/A new_code N/A N/A N/A i line N/A enumerate code N/A N/A N/A N/A line N/A line N/A N/A N/A N/A new_code append line N/A N/A level N/A decrease N/A i N/A free N/A N/A padding N/A N/A N/A level tabwidth cont_padding N/A N/A padding N/A N/A level tabwidth N/A line N/A %s%s N/A padding line N/A N/A free N/A N/A line N/A N/A N/A self _pad_leading_columns N/A line N/A 0 N/A N/A N/A new_code append line N/A N/A continuation N/A i N/A N/A cont_padding N/A 2 tabwidth N/A N/A cont_padding 0 N/A level N/A increase N/A i N/A N/A free N/A N/A N/A N/A self _wrap_fortran new_code N/A new_code N/A N/A fcode N/A N/A expr assign_to N/A None settings N/A N/A Converts an expr to a string of c code

    Parameters
    ==========

    expr : Expr
        A sympy expression to be converted.
    assign_to : optional
        When given, the argument is used as the name of the variable to which
        the expression is assigned. Can be a string, ``Symbol``,
        ``MatrixSymbol``, or ``Indexed`` type. This is helpful in case of
        line-wrapping, or for expressions that generate multi-line statements.
    precision : integer, optional
        The precision for numbers such as pi [default=15].
    user_functions : dict, optional
        A dictionary where keys are ``FunctionClass`` instances and values are
        their string representations. Alternatively, the dictionary value can
        be a list of tuples i.e. [(argument_test, cfunction_string)]. See below
        for examples.
    human : bool, optional
        If True, the result is a single string that may contain some constant
        declarations for the number symbols. If False, the same information is
        returned in a tuple of (symbols_to_declare, not_supported_functions,
        code_text). [default=True].
    contract: bool, optional
        If True, ``Indexed`` instances are assumed to obey tensor contraction
        rules and the corresponding nested loops over indices are generated.
        Setting contract=False will not generate loops, instead the user is
        responsible to provide values for the indices in the code.
        [default=True].
    source_format : optional
        The source format can be either 'fixed' or 'free'. [default='fixed']
    standard : integer, optional
        The Fortran standard to be followed. This is specified as an integer.
        Acceptable standards are 66, 77, 90, 95, 2003, and 2008. Default is 77.
        Note that currently the only distinction internally is between
        standards before 95, and those 95 and after. This may change later as
        more features are added.

    Examples
    ========

    >>> from sympy import fcode, symbols, Rational, sin, ceiling, floor
    >>> x, tau = symbols("x, tau")
    >>> fcode((2*tau)**Rational(7, 2))
    '      8*sqrt(2.0d0)*tau**(7.0d0/2.0d0)'
    >>> fcode(sin(x), assign_to="s")
    '      s = sin(x)'

    Custom printing can be defined for certain types by passing a dictionary of
    "type" : "function" to the ``user_functions`` kwarg. Alternatively, the
    dictionary value can be a list of tuples i.e. [(argument_test,
    cfunction_string)].

    >>> custom_functions = {
    ...   "ceiling": "CEIL",
    ...   "floor": [(lambda x: not x.is_integer, "FLOOR1"),
    ...             (lambda x: x.is_integer, "FLOOR2")]
    ... }
    >>> fcode(floor(x) + ceiling(x), user_functions=custom_functions)
    '      CEIL(x) + FLOOR1(x)'

    ``Piecewise`` expressions are converted into conditionals. If an
    ``assign_to`` variable is provided an if statement is created, otherwise
    the ternary operator is used. Note that if the ``Piecewise`` lacks a
    default term, represented by ``(expr, True)`` then an error will be thrown.
    This is to prevent generating an expression that may not evaluate to
    anything.

    >>> from sympy import Piecewise
    >>> expr = Piecewise((x + 1, x > 0), (x, True))
    >>> print(fcode(expr, tau))
          if (x > 0) then
             tau = x + 1
          else
             tau = x
          end if

    Support for loops is provided through ``Indexed`` types. With
    ``contract=True`` these expressions will be turned into loops, whereas
    ``contract=False`` will just print the assignment expression that should be
    looped over:

    >>> from sympy import Eq, IndexedBase, Idx
    >>> len_y = 5
    >>> y = IndexedBase('y', shape=(len_y,))
    >>> t = IndexedBase('t', shape=(len_y,))
    >>> Dy = IndexedBase('Dy', shape=(len_y-1,))
    >>> i = Idx('i', len_y-1)
    >>> e=Eq(Dy[i], (y[i+1]-y[i])/(t[i+1]-t[i]))
    >>> fcode(e.rhs, assign_to=e.lhs, contract=False)
    '      Dy(i) = (y(i + 1) - y(i))/(t(i + 1) - t(i))'

    Matrices are also supported, but a ``MatrixSymbol`` of the same dimensions
    must be provided to ``assign_to``. Note that any expression that can be
    generated normally can also exist inside a Matrix:

    >>> from sympy import Matrix, MatrixSymbol
    >>> mat = Matrix([x**2, Piecewise((x + 1, x > 0), (x, True)), sin(x)])
    >>> A = MatrixSymbol('A', 3, 1)
    >>> print(fcode(mat, A))
          A(1, 1) = x**2
             if (x > 0) then
          A(2, 1) = x + 1
             else
          A(2, 1) = x
             end if
          A(3, 1) = sin(x)
     N/A N/A N/A N/A FCodePrinter settings doprint expr assign_to N/A print_fcode N/A N/A expr N/A settings N/A N/A Prints the Fortran representation of the given expression.

       See fcode for the meaning of the optional arguments.
     N/A N/A print N/A fcode expr settings N/A