
    \hB                     "   S SK Jr  S SKJrJrJrJrJrJr  S SK	J
r
  S SKJr  S SKJr  S SKJr  S SKJrJr  S SKJrJrJrJrJrJrJrJrJrJrJr  S S	K J!r!  S S
K"J#r#  SGS jr$S r%S r&S r'S r(S r)S r*S r+S r,S r-S r.S r/S r0S r1S r2S r3S r4S r5S r6S r7S r8S  r9S! r:S" r;S# r<S$ r=S% r>S& r?S' r@S( rAS) rBS* rCS+ rDS, rES- rFS. rGS/ rHS0 rIS1 rJS2 rKS3 rLS4 rMS5 rNS6 rOS7 rPS8 rQS9 rRS: rSS; rTS< rUS= rVS> rWS? rXS@ rYSA rZSB r[SC r\SD r]SE r^gF)H    )StringIO)symbolsEqpiCatalanLambdaDummyEquality)Symbol)erf)Integral)MatrixMatrixSymbol)codegenmake_routineCCodeGen
C89CodeGen
C99CodeGenInputArgumentCodeGenErrorFCodeGenCodeGenArgumentListErrorOutputArgumentInOutArgument)raises)implemented_functionc                 n    [        5       nU " XX#U5        UR                  5       nUR                  5         U$ )a  Wrapper for dump_fn. dump_fn writes its results to a stream object and
this wrapper returns the contents of that stream as a string. This
auxiliary function is used by many tests below.

The header and the empty lines are not generated to facilitate the
testing of the output.
)r   getvalueclose)dump_fnroutinesprefixheaderemptyoutputsources          Z/var/www/auris/envauris/lib/python3.13/site-packages/sympy/utilities/tests/test_codegen.py
get_stringr)      s1     ZFHfe4__F
LLNM    c                  Z  ^^	^
^^ [        S5      u  mm
mmT
T-   T-  m	[        [        U	U
U4S j5        [        [        UU	U
UU4S j5        [        S[	        TT	5      TT
TT/S9n U R
                   Vs/ s H  oR                  PM     snTT
TT/:X  d   eU R
                   Vs/ s H  n[        U5      PM     sn[        [        [        [        /:X  d   e[        S[	        TT	5      TT
T/S9n U R
                   Vs/ s H  n[        U5      PM     sn[        [        [        /:X  d   eSSKJnJn  [        USS	/5      u  pE[        S
SS9nU" SU5      n[        S[	        XG   XW   5      XTU/S9n U R
                   Vs/ s H  oR                  PM     snUR                  UR                  U/:X  d   e[!        T
T-  T-  T
SS4TSS45      m	[        S[	        TT	5      TT
TT/S9n U R
                   Vs/ s H  oR                  PM     snTT
TT/:X  d   eg s  snf s  snf s  snf s  snf s  snf )Nza x y zc                     > [        ST TT/S9$ Ntestargument_sequencer   )exprxzs   r(   <lambda>-test_Routine_argument_order.<locals>.<lambda>&   s    \&$V.%r*   c                  4   > [        S[        T T5      TTT/S9$ r-   )r   r   )ar2   r3   yr4   s   r(   r5   r6   (   s"    \&"QC%&1I./r*   r.   r/   r   IndexedBaseIdxABmTintegeri         )r   r   r   r   r   	argumentsnametyper   r   r   sympy.tensorr;   r<   maplabelr   )rargr;   r<   r=   r>   r?   rB   r8   r2   r3   r9   r4   s           @@@@@r(   test_Routine_argument_orderrN   #   s   #JAq!QE19D
# &% &
# &/ &/ 0VR4[Q1aLIA!".#XX.1aA,>>>"#++/+3T#Y+/}nm4G G G GVR4[Q1IFA"#++/+3T#Y+/}m46 6 6 6 .{S#J'DAT"ACAVRad^ayIA!".#XX.177AGGQ2GGGGAaCEAq!9q!Qi0DVR4[Q1aLIA!".#XX.1aA,>>>! // 0 / /s   3H#H;H<H#1H(c                  T    [        5       n [        U R                  / 5      nUS:X  d   eg )Nz$#include "file.h"
#include <math.h>
r   r)   dump_ccode_genr'   s     r(   test_empty_c_coderT   >   s(    |H,F????r*   c                  n    [        5       n [        U R                  / SS9nUS S S:X  d   eUSS  S:X  d   eg )NTr$   R   zR/******************************************************************************
 *   a  *
 *                                                                            *
 *              See http://www.sympy.org/ for more information.               *
 *                                                                            *
 *                       This file is part of 'project'                       *
 ******************************************************************************/
#include "file.h"
#include <math.h>
rP   rR   s     r(   test_empty_c_code_with_commentrY   D   sV    |HD9F#2;]   #$< ["   r*   c                  T    [        5       n [        U R                  / 5      nUS:X  d   eg )Nz9#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
#endif
)r   r)   dump_hrR   s     r(   test_empty_c_headerr\   V   s(    |H,FSSSSr*   c                      [        S5      u  pnX-   U-  n[        SU5      n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nx,y,zr.   #include "file.h"
#include <math.h>
double test(double x, double y, double z) {
   double test_result;
   test_result = z*(x + y);
   return test_result;
}
r   r   r   r)   rQ   r3   r9   r4   r2   routinerS   r'   expecteds           r(   test_simple_c_coderd   \   sX    gGA!E19D64(G|H'3F	  r*   c                      [        S5      u  pnX-   U-  n[        SU5      n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nzif, typedef, whiler.   z#include "file.h"
#include <math.h>
double test(double if_, double typedef_, double while_) {
   double test_result;
   test_result = while_*(if_ + typedef_);
   return test_result;
}
)r   r   r   r)   rQ   ra   s           r(   test_c_code_reserved_wordsrf   n   sY    *+GA!EQ;D64(G|H'3F	  r*   c                      [        S[        [        -  5      n [        5       n[	        UR
                  U /5      nS[        R                  " S5      -  nX#:X  d   eg )Nr.   z#include "file.h"
#include <math.h>
double test() {
   double test_result;
   double const Catalan = %s;
   test_result = pow(M_PI, Catalan);
   return test_result;
}
   )r   r   r   r   r)   rQ   evalfrb   rS   r'   rc   s       r(   test_numbersymbol_c_coderk      sS    62w;/G|H'3F	 	b	H r*   c                      [        S5      u  pnX-   n[        SX2X/S9n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nr^   r.   r/   z#include "file.h"
#include <math.h>
double test(double z, double x, double y) {
   double test_result;
   test_result = x + y;
   return test_result;
}
r`   ra   s           r(   test_c_code_argument_orderrm      sX    gGA!5D64q9EG|H'3F	  r*   c                      [        S5      u  pnX-   U-  n[        SU5      n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nr^   r.   d#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
double test(double x, double y, double z);
#endif
)r   r   r   r)   r[   ra   s           r(   test_simple_c_headerrp      sX    gGA!E19D64(G|H'3F	  r*   c                  b    [        S5      u  pnX-   U-  nSS/n[        SU4SSSSS9nXT:X  d   eg )	Nr^   )file.cr_   )file.hro   r.   CfileFr$   r%   r   r   )r3   r9   r4   r2   rc   results         r(   test_simple_c_codegenry      sP    gGA!E19D		H fd^S&eLFr*   c                     ^^ [        S5      u  pnX-   U-  nX-
  U-  n[        SX4/5      m[        5       m[        [        UU4S j5        g )Nr^   r.   c                  2   > [        T R                  T/5      $ Nr)   r[   rS   rb   s   r(   r5   )test_multiple_results_c.<locals>.<lambda>       HOOgY!Gr*   )r   r   r   r   r   r3   r9   r4   expr1expr2rS   rb   s        @@r(   test_multiple_results_cr      sM    gGA!UAIEUAIE	G |H
<GHr*   c                  &    [        [        S 5        g )Nc                      [        S/ 5      $ Nr.   r1    r*   r(   r5   #test_no_results_c.<locals>.<lambda>       |FB7r*   r   
ValueErrorr   r*   r(   test_no_results_cr          
:78r*   c                     SSK Jn   SSKJn  SSKJnJnJn  SSKJ	nJ
n  SSKJn  SSKJnJn	Jn
JnJnJn  [)        S5      nS	U " U5      4S
U" U5      4SU	" U5      4SU
" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4/n[+        USSSSS9nUS   S   S:X  d   eUS   S   S:X  d   eUS   S   S:X  d   eUS   S   S :X  d   eg )!Nr   Abslogcoshsinhtanh)ceilingfloorsqrtacosasinatancossintanr3   	test_fabs	test_acos	test_asin	test_atan	test_ceiltest_cos	test_cosh
test_floortest_logtest_lntest_sin	test_sinh	test_sqrttest_tan	test_tanhC89ru   Frv   rr   rC   a  #include "file.h"
#include <math.h>
double test_fabs(double x) {
   double test_fabs_result;
   test_fabs_result = fabs(x);
   return test_fabs_result;
}
double test_acos(double x) {
   double test_acos_result;
   test_acos_result = acos(x);
   return test_acos_result;
}
double test_asin(double x) {
   double test_asin_result;
   test_asin_result = asin(x);
   return test_asin_result;
}
double test_atan(double x) {
   double test_atan_result;
   test_atan_result = atan(x);
   return test_atan_result;
}
double test_ceil(double x) {
   double test_ceil_result;
   test_ceil_result = ceil(x);
   return test_ceil_result;
}
double test_cos(double x) {
   double test_cos_result;
   test_cos_result = cos(x);
   return test_cos_result;
}
double test_cosh(double x) {
   double test_cosh_result;
   test_cosh_result = cosh(x);
   return test_cosh_result;
}
double test_floor(double x) {
   double test_floor_result;
   test_floor_result = floor(x);
   return test_floor_result;
}
double test_log(double x) {
   double test_log_result;
   test_log_result = log(x);
   return test_log_result;
}
double test_ln(double x) {
   double test_ln_result;
   test_ln_result = log(x);
   return test_ln_result;
}
double test_sin(double x) {
   double test_sin_result;
   test_sin_result = sin(x);
   return test_sin_result;
}
double test_sinh(double x) {
   double test_sinh_result;
   test_sinh_result = sinh(x);
   return test_sinh_result;
}
double test_sqrt(double x) {
   double test_sqrt_result;
   test_sqrt_result = sqrt(x);
   return test_sqrt_result;
}
double test_tan(double x) {
   double test_tan_result;
   test_tan_result = tan(x);
   return test_tan_result;
}
double test_tanh(double x) {
   double test_tanh_result;
   test_tanh_result = tanh(x);
   return test_tanh_result;
}
rs   a  #ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
double test_fabs(double x);
double test_acos(double x);
double test_asin(double x);
double test_atan(double x);
double test_ceil(double x);
double test_cos(double x);
double test_cosh(double x);
double test_floor(double x);
double test_log(double x);
double test_ln(double x);
double test_sin(double x);
double test_sinh(double x);
double test_sqrt(double x);
double test_tan(double x);
double test_tanh(double x);
#endif
)$sympy.functions.elementary.complexesr   &sympy.functions.elementary.exponentialr   %sympy.functions.elementary.hyperbolicr   r   r   #sympy.functions.elementary.integersr   r   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r3   	name_exprrx   s                    r(   test_ansi_math1_codegenr      s_   8:HHD=ZZA	c!f	d1g	d1g	d1g	gaj!	SV	d1g	uQx 	SV	CF	SV	d1g	d1g	SV	d1gI" Yve5IF!9Q<8###!9Q<	F  $ !9Q<8###!9Q<	0
 
 
r*   c                      SSK Jn   [        S5      u  pSU " X5      4SX-  4/n[        USSSSS	9nUS   S   S
:X  d   eUS   S   S:X  d   eUS   S   S:X  d   eUS   S   S:X  d   eg )Nr   atan2x,y
test_atan2test_powr   ru   Frv   rr   rC   a*  #include "file.h"
#include <math.h>
double test_atan2(double x, double y) {
   double test_atan2_result;
   test_atan2_result = atan2(x, y);
   return test_atan2_result;
}
double test_pow(double x, double y) {
   double test_pow_result;
   test_pow_result = pow(x, y);
   return test_pow_result;
}
rs   z#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
double test_atan2(double x, double y);
double test_pow(double x, double y);
#endif
r   r   r   r   )r   r3   r9   r   rx   s        r(   test_ansi_math2_codegenr     s    >5>DA	uQ{#	QTI Yve5IF!9Q<8###!9Q<	N  
 !9Q<8###!9Q<	  r*   c                     SSK Jn JnJn  [	        S5      u  p4nSU" U5      U " U5      -   U" U5      -   S-  R                  5       4SU " U " U " U " U " U " U " U " X4-   U-   5      5      5      5      5      5      5      5      4/n[        USSS	S	S
9nUS   S   S:X  d   eUS   S   S:X  d   eUS   S   S:X  d   eUS   S   S:X  d   eg )Nr   r   r   r   r^   test1   test2r   ru   Frv   rr   rC   a-  #include "file.h"
#include <math.h>
double test1(double x, double y, double z) {
   double test1_result;
   test1_result = pow(sin(x), 7) + 7*pow(sin(x), 6)*cos(y) + 7*pow(sin(x), 6)*tan(z) + 21*pow(sin(x), 5)*pow(cos(y), 2) + 42*pow(sin(x), 5)*cos(y)*tan(z) + 21*pow(sin(x), 5)*pow(tan(z), 2) + 35*pow(sin(x), 4)*pow(cos(y), 3) + 105*pow(sin(x), 4)*pow(cos(y), 2)*tan(z) + 105*pow(sin(x), 4)*cos(y)*pow(tan(z), 2) + 35*pow(sin(x), 4)*pow(tan(z), 3) + 35*pow(sin(x), 3)*pow(cos(y), 4) + 140*pow(sin(x), 3)*pow(cos(y), 3)*tan(z) + 210*pow(sin(x), 3)*pow(cos(y), 2)*pow(tan(z), 2) + 140*pow(sin(x), 3)*cos(y)*pow(tan(z), 3) + 35*pow(sin(x), 3)*pow(tan(z), 4) + 21*pow(sin(x), 2)*pow(cos(y), 5) + 105*pow(sin(x), 2)*pow(cos(y), 4)*tan(z) + 210*pow(sin(x), 2)*pow(cos(y), 3)*pow(tan(z), 2) + 210*pow(sin(x), 2)*pow(cos(y), 2)*pow(tan(z), 3) + 105*pow(sin(x), 2)*cos(y)*pow(tan(z), 4) + 21*pow(sin(x), 2)*pow(tan(z), 5) + 7*sin(x)*pow(cos(y), 6) + 42*sin(x)*pow(cos(y), 5)*tan(z) + 105*sin(x)*pow(cos(y), 4)*pow(tan(z), 2) + 140*sin(x)*pow(cos(y), 3)*pow(tan(z), 3) + 105*sin(x)*pow(cos(y), 2)*pow(tan(z), 4) + 42*sin(x)*cos(y)*pow(tan(z), 5) + 7*sin(x)*pow(tan(z), 6) + pow(cos(y), 7) + 7*pow(cos(y), 6)*tan(z) + 21*pow(cos(y), 5)*pow(tan(z), 2) + 35*pow(cos(y), 4)*pow(tan(z), 3) + 35*pow(cos(y), 3)*pow(tan(z), 4) + 21*pow(cos(y), 2)*pow(tan(z), 5) + 7*cos(y)*pow(tan(z), 6) + pow(tan(z), 7);
   return test1_result;
}
double test2(double x, double y, double z) {
   double test2_result;
   test2_result = cos(cos(cos(cos(cos(cos(cos(cos(x + y + z))))))));
   return test2_result;
}
rs   z#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
double test1(double x, double y, double z);
double test2(double x, double y, double z);
#endif
r   r   r   r   r   expandr   )r   r   r   r3   r9   r4   r   rx   s           r(   test_complicated_codegenr   ,  s    HHgGA!	CFSVOc!f,q088:;	#c#c#c#c!%!)n*=&>"?@ABCDI Yve5IF!9Q<8###!9Q<.	0 0 0b !9Q<8###!9Q<	  r*   c            	         SSK Jn Jn  SSKJn  U" SSS9u  p4U " S5      nU " S5      nU " S	5      nU" S
U5      nU" SU5      n	[        S[        Xx   XXU	4   Xi   -  5      4SSSSS9u  u  pu  pU
S:X  d   eSnXSSX-  U	-   -  0-  :X  d8  XSSXU-  -   -  0-  :X  d&  XSSX-  U	-   -  0-  :X  d  XSSXU-  -   -  0-  :X  d   eUS:X  d   eUS:X  d   eg )Nr   r:   r   n mTr@   r=   r3   r9   rB   jmatrix_vectorC99ru   Frv   rr   a  #include "file.h"
#include <math.h>
void matrix_vector(double *A, int m, int n, double *x, double *y) {
   for (int i=0; i<m; i++){
      y[i] = 0;
   }
   for (int i=0; i<m; i++){
      for (int j=0; j<n; j++){
         y[i] = %(rhs)s + y[i];
      }
   }
}
rhs
A[%s]*x[j]
x[j]*A[%s]rs   z|#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
void matrix_vector(double *A, int m, int n, double *x, double *y);
#endif
rI   r;   r<   sympy.core.symbolr   r   r   r;   r<   r   nr?   r=   r3   r9   rB   r   f1codef2	interfacerc   s                  r(   test_loops_cr   p  s;   -)5$'DACACACACACA")	"QT1T714<015&V[#]JR >>	  |qsQw'?@@@|qQ3w'?@@@|qsQw'?@@@|qQ3w'?@@@B A >>	  r*   c                     SSK Jn Jn  [        SS[        S9u  p#U " S5      nU " S5      nU" X#5      nSUR
                  R                  UR                  S	.-  n[        S
[        XR   XB   5      5      n[        5       n[        5       n	[        U	R                  U/5      n
X:X  d   e[        [        5         [        UR                  U/5        S S S 5        g ! , (       d  f       g = f)Nr   r:   i mTrA   clsr3   r9   z#include "file.h"
#include <math.h>
void test_dummies(int m_%(mno)i, double *x, double *y) {
   for (int i_%(ino)i=0; i_%(ino)i<m_%(mno)i; i_%(ino)i++){
      y[i_%(ino)i] = x[i_%(ino)i];
   }
}
)inomnotest_dummies)rI   r;   r<   r   r	   rK   dummy_indexr   r   r   r   r)   rQ   r   NotImplementedError)r;   r<   rB   r?   r3   r9   rc   rL   c89c99r   s              r(   test_dummy_loops_cr     s    -5$E2DACACAA	A	 ##AMM:;H 	^Rad^4A
,C
,Ccjj1#&D	#	$3::s# 
%	$	$s   3C
C"c            	         SSK Jn Jn  SSKJn  U" SSS9u  p4pVU " SXF4S9nU " S	5      nU " S
5      n	U" SXTS-
  45      n
U" SU5      n[        S[        X   XzU4   X   -  5      4SSSSS9u  u  pu  pUS:X  d   eSUS-
  SS.-  nUUSSX-  U-   -  0-  :X  d;  UUSSXU-  -   -  0-  :X  d(  UUSSX-  U-   -  0-  :X  d  UUSSXU-  -   -  0-  :X  d   eUS:X  d   eUS:X  d   eg )Nr   r:   r   n m o pTr@   r=   shaper3   r9   rB      r   r   r   ru   Frv   rr   a#  #include "file.h"
#include <math.h>
void matrix_vector(double *A, int m, int n, int o, int p, double *x, double *y) {
   for (int i=o; i<%(upperi)s; i++){
      y[i] = 0;
   }
   for (int i=o; i<%(upperi)s; i++){
      for (int j=0; j<n; j++){
         y[i] = %(rhs)s + y[i];
      }
   }
}
   %(rhs)s)upperir   r   r   r   rs   z#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
void matrix_vector(double *A, int m, int n, int o, int p, double *x, double *y);
#endif
r   r;   r<   r   r   r?   opr=   r3   r9   rB   r   r   r   r   r   rc   s                    r(   test_partial_loops_cr     sb    .)D1JA!Cv&ACACAC!UACA")	"QT1T714<015&V[#]JR >>	 q5+,H H|qsQw'?@@@H|qQ3w'?@@@H|qsQw'?@@@H|qQ3w'?@@@B A >>	  r*   c            	          SSK Jn   SSKJnJn  [        S5      u  p4n[        SU " XB" U5      5      U" U5      /5      n[        5       nUR                  U/SSSS9nUS   S   S	:X  d   eS
n	US   S   U	:X  d   eg )Nr   r
   r   r   r^   foor.   Frv   test.cz#include "test.h"
#include <math.h>
double foo(double x, double *y) {
   (*y) = sin(x);
   double foo_result;
   foo_result = cos(x);
   return foo_result;
}
rC   	sympy.core.relationalr   r   r   r   r   r   r   write
r   r   r   r3   r9   r4   rL   crx   rc   s
             r(   test_output_arg_cr     s    .CgGA!UXaQ0#a&9:AAWWaS&eW<F!9Q<8###	  !9Q<8###r*   c            	          SSK Jn   SSKJnJn  [        S5      u  p4n[        SU " XB" U5      5      U" U5      /5      n[        5       nUR                  U/SSSS9nUS   S   S	:X  d   eS
n	US   S   U	:X  d   eg )Nr   r
   r   zif, while, zr   r.   Frv   r   z#include "test.h"
#include <math.h>
double foo(double if_, double *while_) {
   (*while_) = sin(if_);
   double foo_result;
   foo_result = cos(if_);
   return foo_result;
}
rC   r   r   s
             r(    test_output_arg_c_reserved_wordsr     s    .Cn%GA!UXaQ0#a&9:AAWWaS&eW<F!9Q<8###	  !9Q<8###r*   c                  2   [        SSS5      n [        SSS5      n[        U 5      n[        U5      nX#-  n[        SSS9nUR                  SU5      nS	UR                  S
   l        S	UR                  S
   l        [        UR                  U/SS9nSnXx:X  d   eg )Nr=   rE   brC   r.   T)projectcser   out)r#   z#include "test.h"
#include <math.h>
void c(double *A, double *b, double *out) {
   out[0] = A[0]*b[0] + A[1]*b[1] + A[2]*b[2];
   out[1] = A[3]*b[0] + A[4]*b[1] + A[5]*b[2];
   out[2] = A[6]*b[0] + A[7]*b[1] + A[8]*b[2];
}
)	r   r   r   rb   rF   
result_var_namer)   rQ   )	A_symb_symr=   r  r   cgenrL   r   rc   s	            r(   test_multidim_c_argument_cser    s    a#Ea#EuAuA	AF-DS!A!&AKKO!AKKOdkkA3v6D	  r*   c                     [        S5      u  pn[        S5      u  p4[        SSS5      n[        U[        SSU //5      5      n[        X@U-   U-  5      n[        USU -  5      nSXgU/4n	Sn
[	        U	S	SS
S
XX!XS4S9nUS   S   nX:X  d   eg )Nr^   B,Cr=   rC   rE   rD   r.   z#include "test.h"
#include <math.h>
void test(double x, double *C, double z, double y, double *A, double *B) {
   (*C) = z*(x + y);
   A[0] = 1;
   A[1] = 2;
   A[2] = x;
   (*B) = 2*x;
}
r   Fr$   r%   r0   r   r   r   r   r   r   )r3   r9   r4   r>   rt   r=   r   r   expr3r   rc   rx   r'   s                r(    test_ccode_results_named_orderedr    s    gGA!5>DAS!QAQAq	{+,EQQ	"EQ!E%./I	  YVE()aA'9;FAYq\Fr*   c            	         [        SSS5      n [        SSS5      n[        SSS5      n[        SSS5      nS[        XS	S S 24   5      [        X SS S 24   5      [        X0S S 2S
4   5      /4n[        USSSSS9nUS	   S   nSnXg:X  d   eg )Nr=   r   rE   r>   rC   rt   Dr.   r   rD   r   Frv   a  #include "test.h"
#include <math.h>
void test(double *A, double *B, double *C, double *D) {
   B[0] = A[0];
   B[1] = A[1];
   B[2] = A[2];
   C[0] = A[3];
   C[1] = A[4];
   C[2] = A[5];
   D[0] = A[2];
   D[1] = A[5];
   D[2] = A[8];
   D[3] = A[11];
   D[4] = A[14];
}
r   r   r   r=   r>   rt   r  r   rx   r'   rc   s           r(   test_ccode_matrixsymbol_slicer  8  s    S!QAS!QAS!QAS!QA(11g."11g."11g.0 1I Yve5IFAYq\F	 " r*   c            
          [        S5      u  pp#[        SSS5      nS[        U[        X-  /X-  X#-  -   /X-  U-  U-  //5      5      /4n[	        SS9n[        XVSSS	9nUS
   S   nSn	X:X  d   eg )Nza b c derE   rC   r.   T)r  F)rS   r$   r%   r   z#include "test.h"
#include <math.h>
void test(double a, double b, double c, double d, double *e) {
   const double x0 = a*b;
   const double x1 = c*d;
   e[0] = x0;
   e[1] = x0 + x1;
   e[2] = x0*x1;
}
)r   r   r   r   r   r   )
r8   r  r   dr  r   	generatorrx   r'   rc   s
             r(   test_ccode_cser  U  s    #JA!S!QA(1fqseacACi[13q57)-L&MNOPIT"IY5NFAYq\F	  r*   c                  r    [        SSS5      n Sn[        5       n[        XSSU 4S9nUS   S   nSnXE:X  d   eg )	Nr3   rD   rC   )r.   g      ?F)rS   r$   r%   r0   r   z#include "test.h"
#include <math.h>
double test(double *x) {
   double test_result;
   test_result = 1.0;
   return test_result;
}
)r   r   r   )r3   r   r  rx   r'   rc   s         r(   test_ccode_unused_array_argr  i  sU    S!QAI
IY5bcaefFAYq\F	  r*   c            	          [        SSS5      n [        SSS5      n[        SSS9nSU S	   U S   -   4n[        US
SSXU4S9nUS	   S   nSnXV:X  d   eg )NXrE   rC   Yr4   Tr@   testBugr   rt   F)languager$   r%   r0   z#include "testBug.h"
#include <math.h>
double testBug(double *X, double *Y, int z) {
   double testBug_result;
   testBug_result = X[0] + X[1];
   return testBug_result;
}
)r   r   r   )r   r!  r4   r   rx   r'   rc   s          r(    test_ccode_unused_array_arg_funcr$  |  s~    S1AS1Ad#AAaD1Q4K(IYU%\]bc[deFAYq\F	  r*   c                  T    [        5       n [        U R                  / 5      nUS:X  d   eg N r   r)   dump_f95rR   s     r(   test_empty_f_coder*    s'    zH))2.FR<<r*   c                  n    [        5       n [        U R                  / SS9nUS S S:X  d   eUSS  S:X  d   eg )NTrV   rW   zR!******************************************************************************
!*rX   a  *
!*                                                                            *
!*              See http://www.sympy.org/ for more information.               *
!*                                                                            *
!*                       This file is part of 'project'                       *
!******************************************************************************
r(  rR   s     r(   test_empty_f_code_with_headerr,    sY    zH))2d;F#2;]   #$< [`   r*   c                  T    [        5       n [        U R                  / 5      nUS:X  d   eg r&  )r   r)   r[   rR   s     r(   test_empty_f_headerr.    s%    zH,FR<<r*   c                      [        S5      u  pnX-   U-  n[        SU5      n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nr^   r.   REAL*8 function test(x, y, z)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
test = z*(x + y)
end function
r   r   r   r)   r)  ra   s           r(   test_simple_f_coder2    sZ    gGA!E19D64(GzH))G95F	  r*   c                      [        S[        [        -  5      n [        5       n[	        UR
                  U /5      nS[        R                  " S5      < S[        R                  " S5      < S3nX#:X  d   eg )Nr.   zDREAL*8 function test()
implicit none
REAL*8, parameter :: Catalan = rh   zd0
REAL*8, parameter :: pi = z#d0
test = pi**Catalan
end function
)r   r   r   r   r)   r)  ri   rj   s       r(   test_numbersymbol_f_coder4    sZ    62w;/GzH))G95F 
r	BHHRL*H r*   c                      [        S5      n [        S[        U 5      [        SU -  5      -
  5      n[        5       n[	        UR
                  U/5      nSnX4:X  d   U5       eg )Nr3   r.   zhREAL*8 function test(x)
implicit none
REAL*8, intent(in) :: x
test = erf(x) + erf(2.0d0*x)
end function
)r   r   r   r   r)   r)  )r3   rb   rS   r'   rc   s        r(   test_erf_f_coder7    s`    A63q6CQK#78GzH))G95F	  %v%r*   c                      [        S5      u  pnX-   n[        SX2X/S9n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nr^   r.   r/   zREAL*8 function test(z, x, y)
implicit none
REAL*8, intent(in) :: z
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
test = x + y
end function
r1  ra   s           r(   test_f_code_argument_orderr9    sZ    gGA!5D64q9EGzH))G95F	  r*   c                      [        S5      u  pnX-   U-  n[        SU5      n[        5       n[        UR                  U/5      nSnXg:X  d   eg )Nr^   r.   interface
REAL*8 function test(x, y, z)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
end function
end interface
)r   r   r   r)   r[   ra   s           r(   test_simple_f_headerr<    sX    gGA!E19D64(GzH'3F	  r*   c                  b    [        S5      u  pnX-   U-  n[        SU4SSSSS9nSS/nXE:X  d   eg )	Nr^   r.   F95ru   Frv   )file.f90r0  )rs   r;  rw   )r3   r9   r4   r2   rx   rc   s         r(   test_simple_f_codegenr@    sT    gGA!E19D	ve5BF		H& r*   c                     ^^ [        S5      u  pnX-   U-  nX-
  U-  n[        SX4/5      m[        5       m[        [        UU4S j5        g )Nr^   r.   c                  2   > [        T R                  T/5      $ r|   r}   r~   s   r(   r5   )test_multiple_results_f.<locals>.<lambda>"  r   r*   )r   r   r   r   r   r   s        @@r(   test_multiple_results_frD    sM    gGA!UAIEUAIE	G zH
<GHr*   c                  &    [        [        S 5        g )Nc                      [        S/ 5      $ r   r1   r   r*   r(   r5   #test_no_results_f.<locals>.<lambda>&  r   r*   r   r   r*   r(   test_no_results_frH  %  r   r*   c                     SSK Jn   SSKJn  SSKJnJnJn  SSKJ	n  SSK
JnJnJnJn	Jn
Jn  [#        S5      nSU " U5      4S	U" U5      4S
U" U5      4SU" U5      4SU	" U5      4SU" U5      4SU" U5      4SU" U5      4SU
" U5      4SU" U5      4SU" U5      4SU" U5      4SU" U5      4/n[%        USSSSS9nUS   S   S:X  d   eSnUS   S   U:X  d   eUS   S   S:X  d   eSnUS   S   U:X  d   eg )Nr   r   r   r   r   r   r3   test_absr   r   r   r   r   r   r   r   r   r   r   r   r>  ru   Frv   r?  a   REAL*8 function test_abs(x)
implicit none
REAL*8, intent(in) :: x
test_abs = abs(x)
end function
REAL*8 function test_acos(x)
implicit none
REAL*8, intent(in) :: x
test_acos = acos(x)
end function
REAL*8 function test_asin(x)
implicit none
REAL*8, intent(in) :: x
test_asin = asin(x)
end function
REAL*8 function test_atan(x)
implicit none
REAL*8, intent(in) :: x
test_atan = atan(x)
end function
REAL*8 function test_cos(x)
implicit none
REAL*8, intent(in) :: x
test_cos = cos(x)
end function
REAL*8 function test_cosh(x)
implicit none
REAL*8, intent(in) :: x
test_cosh = cosh(x)
end function
REAL*8 function test_log(x)
implicit none
REAL*8, intent(in) :: x
test_log = log(x)
end function
REAL*8 function test_ln(x)
implicit none
REAL*8, intent(in) :: x
test_ln = log(x)
end function
REAL*8 function test_sin(x)
implicit none
REAL*8, intent(in) :: x
test_sin = sin(x)
end function
REAL*8 function test_sinh(x)
implicit none
REAL*8, intent(in) :: x
test_sinh = sinh(x)
end function
REAL*8 function test_sqrt(x)
implicit none
REAL*8, intent(in) :: x
test_sqrt = sqrt(x)
end function
REAL*8 function test_tan(x)
implicit none
REAL*8, intent(in) :: x
test_tan = tan(x)
end function
REAL*8 function test_tanh(x)
implicit none
REAL*8, intent(in) :: x
test_tanh = tanh(x)
end function
rC   rs   aA  interface
REAL*8 function test_abs(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_acos(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_asin(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_atan(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_cos(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_cosh(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_log(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_ln(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_sin(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_sinh(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_sqrt(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_tan(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
interface
REAL*8 function test_tanh(x)
implicit none
REAL*8, intent(in) :: x
end function
end interface
)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r3   r   rx   rc   s                   r(   test_intrinsic_math_codegenrK  )  sK   8:HH=ZZA	SV	d1g	d1g	d1g	SV	d1g	SV	CF	SV	d1g	d1g	SV	d1gI Yve5IF!9Q<:%%%@	 F !9Q<8###!9Q<8###M	 ` !9Q<8###r*   c                      SSK Jn   [        S5      u  pSU " X5      4SX-  4/n[        USSSSS	9nUS   S   S
:X  d   eSnUS   S   U:X  d   eUS   S   S:X  d   eSnUS   S   U:X  d   eg )Nr   r   r   r   r   r>  ru   Frv   r?  zREAL*8 function test_atan2(x, y)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
test_atan2 = atan2(x, y)
end function
REAL*8 function test_pow(x, y)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
test_pow = x**y
end function
rC   rs   a  interface
REAL*8 function test_atan2(x, y)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
end function
end interface
interface
REAL*8 function test_pow(x, y)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
end function
end interface
r   )r   r3   r9   r   rx   rc   s         r(   test_intrinsic_math2_codegenrM    s    >5>DA	uQ{#	QTI Yve5IF!9Q<:%%%	  !9Q<8###!9Q<8###	   !9Q<8###r*   c                     SSK Jn JnJn  [	        S5      u  p4nSU" U5      U " U5      -   U" U5      -   S-  R                  5       4SU " U " U " U " U " U " U " U " X4-   U-   5      5      5      5      5      5      5      5      4/n[        USSS	S	S
9nUS   S   S:X  d   eSnUS   S   U:X  d   eUS   S   S:X  d   eSnUS   S   U:X  d   eg )Nr   r   r^   r   r   r   r>  ru   Frv   r?  a{  REAL*8 function test1(x, y, z)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
test1 = sin(x)**7 + 7*sin(x)**6*cos(y) + 7*sin(x)**6*tan(z) + 21*sin(x) &
      **5*cos(y)**2 + 42*sin(x)**5*cos(y)*tan(z) + 21*sin(x)**5*tan(z) &
      **2 + 35*sin(x)**4*cos(y)**3 + 105*sin(x)**4*cos(y)**2*tan(z) + &
      105*sin(x)**4*cos(y)*tan(z)**2 + 35*sin(x)**4*tan(z)**3 + 35*sin( &
      x)**3*cos(y)**4 + 140*sin(x)**3*cos(y)**3*tan(z) + 210*sin(x)**3* &
      cos(y)**2*tan(z)**2 + 140*sin(x)**3*cos(y)*tan(z)**3 + 35*sin(x) &
      **3*tan(z)**4 + 21*sin(x)**2*cos(y)**5 + 105*sin(x)**2*cos(y)**4* &
      tan(z) + 210*sin(x)**2*cos(y)**3*tan(z)**2 + 210*sin(x)**2*cos(y) &
      **2*tan(z)**3 + 105*sin(x)**2*cos(y)*tan(z)**4 + 21*sin(x)**2*tan &
      (z)**5 + 7*sin(x)*cos(y)**6 + 42*sin(x)*cos(y)**5*tan(z) + 105* &
      sin(x)*cos(y)**4*tan(z)**2 + 140*sin(x)*cos(y)**3*tan(z)**3 + 105 &
      *sin(x)*cos(y)**2*tan(z)**4 + 42*sin(x)*cos(y)*tan(z)**5 + 7*sin( &
      x)*tan(z)**6 + cos(y)**7 + 7*cos(y)**6*tan(z) + 21*cos(y)**5*tan( &
      z)**2 + 35*cos(y)**4*tan(z)**3 + 35*cos(y)**3*tan(z)**4 + 21*cos( &
      y)**2*tan(z)**5 + 7*cos(y)*tan(z)**6 + tan(z)**7
end function
REAL*8 function test2(x, y, z)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
test2 = cos(cos(cos(cos(cos(cos(cos(cos(x + y + z))))))))
end function
rC   rs   a4  interface
REAL*8 function test1(x, y, z)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
end function
end interface
interface
REAL*8 function test2(x, y, z)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
end function
end interface
r   )	r   r   r   r3   r9   r4   r   rx   rc   s	            r(   test_complicated_codegen_f95rO  	  s   HHgGA!	CFSVOc!f,q088:;	#c#c#c#c!%!)n*=&>"?@ABCDI Yve5IF!9Q<:%%%	 < !9Q<8###!9Q<8###	 $ !9Q<8###r*   c            	      *   SSK Jn Jn  SSKJn  U" SSS9u  p4[        U S5      u  pVnU" SU5      nU" S	U5      n	[        S
[        Xx   XXU	4   Xi   -  5      4SSSSS9u  u  pu  pU
S:X  d   eSnXSS0-  :X  d  XSS0-  :X  d   eUS:X  d   eUS:X  d   eg )Nr   r:   r   zn,mTr@   AxyrB   r   r   r>  ru   Frv   r?  a~  subroutine matrix_vector(A, m, n, x, y)
implicit none
INTEGER*4, intent(in) :: m
INTEGER*4, intent(in) :: n
REAL*8, intent(in), dimension(1:m, 1:n) :: A
REAL*8, intent(in), dimension(1:n) :: x
REAL*8, intent(out), dimension(1:m) :: y
INTEGER*4 :: i
INTEGER*4 :: j
do i = 1, m
   y(i) = 0
end do
do i = 1, m
   do j = 1, n
      y(i) = %(rhs)s + y(i)
   end do
end do
end subroutine
r   A(i, j)*x(j)x(j)*A(i, j)rs   a  interface
subroutine matrix_vector(A, m, n, x, y)
implicit none
INTEGER*4, intent(in) :: m
INTEGER*4, intent(in) :: n
REAL*8, intent(in), dimension(1:m, 1:n) :: A
REAL*8, intent(in), dimension(1:n) :: x
REAL*8, intent(out), dimension(1:m) :: y
end subroutine
end interface
)rI   r;   r<   r   r   rJ   r   r   r   s                  r(   
test_loopsrT  G  s    -)5$'DA+u%GA!CACA")	"QT1T714<015&V[#]JR 	 * un555E>2223 3>>		  r*   c                  6   SSK Jn Jn  [        SS[        S9u  p#U " S5      nU " S5      nU" X#5      nSUR
                  R                  UR                  S	.-  n[        S
[        XR   XB   5      5      n[        5       n[        UR                  U/5      n	X:X  d   eg )Nr   r:   r   Tr   r3   r9   a>  subroutine test_dummies(m_%(mcount)i, x, y)
implicit none
INTEGER*4, intent(in) :: m_%(mcount)i
REAL*8, intent(in), dimension(1:m_%(mcount)i) :: x
REAL*8, intent(out), dimension(1:m_%(mcount)i) :: y
INTEGER*4 :: i_%(icount)i
do i_%(icount)i = 1, m_%(mcount)i
   y(i_%(icount)i) = x(i_%(icount)i)
end do
end subroutine
)icountmcountr   )rI   r;   r<   r   r	   rK   r   r   r   r   r)   r)  )
r;   r<   rB   r?   r3   r9   rc   rL   r   r   s
             r(   test_dummy_loops_f95rX  z  s    -5$E2DACACAA	A		 77&&!--@AH 	^Rad^4A
Aajj1#&Dr*   c            	      h   SSK Jn Jn  SSKJn  U" SSS9u  p4pVU" S5      u  pxn	U " U5      U" X65      U" XE5      4   nU " U5      U" XE5         nU " U	5      U" X65         n	[        S[        XXx-  -   5      4S	S
SSS9u  u  pu  pU
S:X  d   eSnXSS0-  :X  d  XSS0-  :X  d   eUS:X  d   eUS:X  d   eg )Nr   r:   r   zi,j,n,mTr@   zA,x,yr   r>  ru   Frv   r?  aa  subroutine matrix_vector(A, m, n, x, y)
implicit none
INTEGER*4, intent(in) :: m
INTEGER*4, intent(in) :: n
REAL*8, intent(in), dimension(1:m, 1:n) :: A
REAL*8, intent(in), dimension(1:n) :: x
REAL*8, intent(inout), dimension(1:m) :: y
INTEGER*4 :: i
INTEGER*4 :: j
do i = 1, m
   do j = 1, n
      y(i) = %(rhs)s + y(i)
   end do
end do
end subroutine
r   rR  rS  rs   a  interface
subroutine matrix_vector(A, m, n, x, y)
implicit none
INTEGER*4, intent(in) :: m
INTEGER*4, intent(in) :: n
REAL*8, intent(in), dimension(1:m, 1:n) :: A
REAL*8, intent(in), dimension(1:n) :: x
REAL*8, intent(inout), dimension(1:m) :: y
end subroutine
end interface
r   )r;   r<   r   rB   r   r   r?   r=   r3   r9   r   r   r   r   rc   s                  r(   test_loops_InOutrZ    s    -)D1JA!gGA!As1y#a)+,AAs1y!AAs1y!A")	"QAC.)5&e#UJR 	 $ ~666~6668 7>>		  r*   c            	      z   SSK Jn Jn  SSKJn  U" SSS9u  p4pVU " SXF4S9nU " S	5      nU " S
5      n	U" SXTS-
  45      n
U" SU5      n[        S[        X   XzU4   X   -  5      4SSSSS9u  u  pu  pSS[        US-
  5      [        SU-   5      [        US-
  U-
  5      S.-  nUUSS0-  :X  d  UUSS0-  :X  d   eg g )Nr   r:   r   r   Tr@   r=   r   r3   r9   rB   r   r   r   r>  ru   Frv   a  subroutine matrix_vector(A, m, n, o, p, x, y)
implicit none
INTEGER*4, intent(in) :: m
INTEGER*4, intent(in) :: n
INTEGER*4, intent(in) :: o
INTEGER*4, intent(in) :: p
REAL*8, intent(in), dimension(1:m, 1:p) :: A
REAL*8, intent(in), dimension(1:n) :: x
REAL*8, intent(out), dimension(1:%(iup-ilow)s) :: y
INTEGER*4 :: i
INTEGER*4 :: j
do i = %(ilow)s, %(iup)s
   y(i) = 0
end do
do i = %(ilow)s, %(iup)s
   do j = 1, n
      y(i) = %(rhs)s + y(i)
   end do
end do
end subroutine
r   r   rC   )r   iupilowziup-ilowr   rR  rS  )rI   r;   r<   r   r   r   r   strr   s                    r(   test_partial_loops_fr_    s    .)D1JA!Cv&ACACAC!UACA")	"QT1T714<015&V[#]JR	* 1q5zAE
A	N		+H8 8un555E>2223 32 6r*   c            	          SSK Jn   SSKJnJn  [        S5      u  p4n[        SU " XB" U5      5      U" U5      /5      n[        5       nUR                  U/SSSS9nUS   S   S	:X  d   eUS   S
   S:X  d   eg )Nr   r
   r   r^   r   r.   Frv   ztest.f90rC   z~REAL*8 function foo(x, y)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(out) :: y
y = sin(x)
foo = cos(x)
end function
)	r   r   r   r   r   r   r   r   r   )	r   r   r   r3   r9   r4   rL   r   rx   s	            r(   test_output_arg_fra    s    .CgGA!UXaQ0#a&9:A
AWWaS&eW<F!9Q<:%%%!9Q<	  r*   c            
      T   SSK Jn Jn  SSKJn  U" SSS9u  p4[        U S5      u  pVnU" SU5      n[        5       n	[        S	[        X3US
-   -  5      5      n
[        S[        Xx   U
" Xh   5      5      5      n[        U	R                  U/5      nSnSnXU-  :X  d  XUS S S2   -  :X  d   eg g )Nr   r:   r   r   Tr@   rQ  rB   funcrC   test_inlinezsubroutine test_inline(m, x, y)
implicit none
INTEGER*4, intent(in) :: m
REAL*8, intent(in), dimension(1:m) :: x
REAL*8, intent(out), dimension(1:m) :: y
INTEGER*4 :: i
do i = 1, m
   y(i) = %s*%s
end do
end subroutine
)zx(i)z
(x(i) + 1)r  )rI   r;   r<   r   r   rJ   r   r   r   r   r   r)   r)  )r;   r<   r   r   r?   r=   r3   r9   rB   r   rc  rb   r   rc   argss                  r(   test_inline_functionrf    s    -)5$'DA+u%GA!CA
AqQU)(<=D="QT4:*>?Gajj7),D		  "Dd?"4":%%& &% #r*   c                      [        S5      n SnU  H  nX-  nM	     [        SU5      n[        5       n[        UR                  U/5      nSnXV:X  d   eg )Nzx:20r   r.   a  REAL*8 function test(x0, x1, x10, x11, x12, x13, x14, x15, x16, x17, x18, &
      x19, x2, x3, x4, x5, x6, x7, x8, x9)
implicit none
REAL*8, intent(in) :: x0
REAL*8, intent(in) :: x1
REAL*8, intent(in) :: x10
REAL*8, intent(in) :: x11
REAL*8, intent(in) :: x12
REAL*8, intent(in) :: x13
REAL*8, intent(in) :: x14
REAL*8, intent(in) :: x15
REAL*8, intent(in) :: x16
REAL*8, intent(in) :: x17
REAL*8, intent(in) :: x18
REAL*8, intent(in) :: x19
REAL*8, intent(in) :: x2
REAL*8, intent(in) :: x3
REAL*8, intent(in) :: x4
REAL*8, intent(in) :: x5
REAL*8, intent(in) :: x6
REAL*8, intent(in) :: x7
REAL*8, intent(in) :: x8
REAL*8, intent(in) :: x9
test = x0 + x1 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + &
      x19 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9
end function
r1  )r3   r2   symrb   rS   r'   rc   s          r(   test_f_code_call_signature_wrapri     s]    AD 64(GzH))G95FH8 r*   c                  N   ^ ^ [        S5      u  mm [        [        U U4S j5        g )Nzx,Xc                  (   > [        STT -  4SS5      $ )Nr.   f95r#   )r   r   r3   s   r(   r5   !test_check_case.<locals>.<lambda>J  s    &!A#x!Hr*   )r   r   r   rm  s   @@r(   test_check_casero  H  s    5>DAq
<HIr*   c                      [        S5      n [        SSS9n [        SX-  4SS5        g ! [         a8  nUR                  S   R	                  S5      (       a  [        S	5      e S nAg S nAff = f)
Nr3   T)my_assumptionr.   rl  r#   r   zFortran ignores case.z$This exception should not be raised!)r   r   r   re  
startswithAssertionError)x1x2r  s      r(   test_check_case_false_positiverv  M  sn    
 
B	D	)BI1 I66!9 788 !GHH 9Is   ) 
A+.A&&A+c                  t   [        S5      u  pSSU -  4/n[        USSSS9n[        USSSSS9nUS   S   US   S   :X  d   eSX-  4n[        USSSS9n[        USSSSS9nUS   S   US   S   :X  d   eS[        X/X-   X-
  //5      4n[        US	SSS9n[        US	SSSS9nUS   S   US   S   :X  d   eg )
Nr   r   rD   r>  Frv   r   rC   r   )r   r   r   )r3   r9   r   rx   	expresults        r(    test_c_fortran_omit_routine_namery  [  s   5>DA1IYe5AF	5%UKI!9Q<9Q<?***IYe5AF	5%UKI!9Q<9Q<?***ac
345IYe5AF	5%UKI!9Q<9Q<?***r*   c                      [        S5      u  pnX-   n[        X/US//5      nSX444n[        USSSSS9nUS   S   nS	nUR                  5       S
   n	U	R	                  S5      n
U
S   nUSU0-  nXx:X  d   eg )Nr^      r.   rl  Frv   r   rC   a2  REAL*8 function test(x, y, z, out_%(hash)s)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
REAL*8, intent(in) :: z
REAL*8, intent(out), dimension(1:2, 1:2) :: out_%(hash)s
out_%(hash)s(1, 1) = x
out_%(hash)s(2, 1) = z
out_%(hash)s(1, 2) = y
out_%(hash)s(2, 2) = 16
test = x + y
end function
r   _hash)r   r   r   
splitlinessplit)r3   r9   r4   e1e2r   rx   r'   rc   r8   r  r  s               r(   test_fcode_matrix_outputr  m  s    gGA!	
B	!!R!	"B""IYve5IFAYq\F	  	AA	A
A$C63-'Hr*   c                     [        S5      u  pn[        S5      u  p4[        SSS5      n[        U[        SSU //5      5      n[        X@U-   U-  5      n[        USU -  5      nSXgU/4n	[	        U	SSS	S	XXXS4S
9n
U
S   S   nSnX:X  d   eg )Nr^   r  r=   rC   rE   rD   r.   rl  Fr  r   a!  subroutine test(x, z, y, C, A, B)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: z
REAL*8, intent(in) :: y
REAL*8, intent(out) :: C
REAL*8, intent(out) :: B
REAL*8, intent(out), dimension(1:1, 1:3) :: A
C = z*(x + y)
A(1, 1) = 1
A(1, 2) = 2
A(1, 3) = x
B = 2*x
end subroutine
r  )r3   r9   r4   r>   rt   r=   r   r   r  r   rx   r'   rc   s                r(    test_fcode_results_named_orderedr    s    gGA!5>DAS!QAQAq	{+,EQQ	"EQ!E%./IYve5()aA'9;FAYq\F	   r*   c            	         [        SSS5      n [        SSS5      n[        SSS5      n[        SSS5      nS[        XS	S S 24   5      [        X SS S 24   5      [        X0S S 2S4   5      /4n[        US
SSSS9nUS	   S   nSnXg:X  d   eg )Nr=   rD   rE   r>   rC   rt   r  r.   r   rl  Frv   a  subroutine test(A, B, C, D)
implicit none
REAL*8, intent(in), dimension(1:2, 1:3) :: A
REAL*8, intent(out), dimension(1:1, 1:3) :: B
REAL*8, intent(out), dimension(1:1, 1:3) :: C
REAL*8, intent(out), dimension(1:2, 1:1) :: D
B(1, 1) = A(1, 1)
B(1, 2) = A(1, 2)
B(1, 3) = A(1, 3)
C(1, 1) = A(2, 1)
C(1, 2) = A(2, 2)
C(1, 3) = A(2, 3)
D(1, 1) = A(1, 3)
D(2, 1) = A(2, 3)
end subroutine
r  r  s           r(   test_fcode_matrixsymbol_slicer    s    S!QAS!QAS!QAS!QA(11g."11g."11g.0 1I Yve5IFAYq\F	 " r*   c                      [        SSS5      n SU S S 2S4   4n[        USSSSS9nUS	   S   nS
nUR                  5       S   nUR                  S5      nUS   nUSU0-  nX4:X  d   eg )Nr=   rD   rE   r.   rC   rl  Frv   r   zsubroutine test(A, out_%(hash)s)
implicit none
REAL*8, intent(in), dimension(1:2, 1:3) :: A
REAL*8, intent(out), dimension(1:2, 1:1) :: out_%(hash)s
out_%(hash)s(1, 1) = A(1, 2)
out_%(hash)s(2, 1) = A(2, 2)
end subroutine
r|  r}  )r   r   r~  r  )r=   r   rx   r'   rc   r8   r  r  s           r(   &test_fcode_matrixsymbol_slice_autonamer    s    S!QA1a4!IYve5IFAYq\F	  	AA	A
A$C63-'Hr*   c                      [        S5      u  pp#[        SX-  4SSSU4S9nUS   S   nSnXV:X  d   eS	n[        SX-  U-   4S
SSX#4S9nUS   S   nXV:X  d   eg )Nzx y z tfr>  F)r$   r%   global_varsr   rC   zPREAL*8 function f(x)
implicit none
REAL*8, intent(in) :: x
f = x*y
end function
z#include "f.h"
#include <math.h>
double f(double x, double y) {
   double f_result;
   f_result = x*y + z;
   return f_result;
}
rt   rw   )r3   r9   r4   trx   r'   rc   s          r(   test_global_varsr    s    #JA!c13ZuE"#'FAYq\F	  	  c13q5\3uE"#)FAYq\Fr*   c                  8   SSK Jn   SSKJn  U " SSS00S9n[	        S5      u  p4U" X4-   5      n[        US	/S
9nSn[        SU4SSUS9nUS   S   n	X:X  d   e[        US9nUR                  R                  S	5        Sn[        SU4SSUS9nUS   S   n	X:X  d   eg )Nr   C99CodePrinter)expuser_functionsr  fastexp)settingszx yz#include "fastexp.h")printerpreprocessor_statementsz#include "expr.h"
#include "fastexp.h"
double expr(double x, double y) {
   double expr_result;
   expr_result = fastexp(x + y);
   return expr_result;
}
r2   F)r$   r%   rS   rC   )r  z#include "expr.h"
#include <math.h>
#include "fastexp.h"
double expr(double x, double y) {
   double expr_result;
   expr_result = fastexp(x + y);
   return expr_result;
}
)	sympy.printing.cr  r   r  r   r   r   r  append)
r  r  r  r3   r9   r2   genrc   rx   r'   s
             r(   test_custom_codegenr    s    /:'7%9K&LMG5>DAqu:D W.D-EGC	  fd^EMFAYq\F W
%C&&'=>	  fd^EMFAYq\Fr*   c            	          SSK Jn    " S SU 5      n[        S5      nUS-  nSS/n[        S	U4S
SSSU" 5       S9nXT:X  d   eg )Nr   r  c                       \ rS rSrS rSrg)*test_c_with_printer.<locals>.CustomPrinteri*  c                     SR                  U R                  UR                  5      U R                  UR                  5      5      $ )Nzfastpow({}, {}))format_printbaser  )selfr2   s     r(   
_print_Pow5test_c_with_printer.<locals>.CustomPrinter._print_Pow+  s6    $++DKK		,B,0KK,AC Cr*   r   N)__name__
__module____qualname____firstlineno__r  __static_attributes__r   r*   r(   CustomPrinterr  *  s    	Cr*   r  r3   rE   )rr   z#include "file.h"
#include <math.h>
double test(double x) {
   double test_result;
   test_result = fastpow(x, 3);
   return test_result;
}
)rs   zP#ifndef PROJECT__FILE__H
#define PROJECT__FILE__H
double test(double x);
#endif
r.   rt   ru   F)r$   r%   r  )r  r  r   r   )r  r  r3   r2   rc   rx   s         r(   test_c_with_printerr  '  sb    /C C
 	Aa4D		H fd^SUVcVefFr*   c                  R   SS K n SU R                  R                  l        [	        SSS9n[	        SSS9n[        SX-   4SSSSS	9nUS   S
   nSnXE:X  d   e[	        S5      n[	        SSS9n[        SX-   4SSSSS	9nUS   S
   nSnXE:X  d   eSU R                  R                  l        g )Nr   Tr3   )realr9   r.   rl  Frv   rC   zsREAL*8 function test(x, y)
implicit none
REAL*8, intent(in) :: x
REAL*8, intent(in) :: y
test = x + y
end function
z{COMPLEX*16 function test(x, y)
implicit none
COMPLEX*16, intent(in) :: x
REAL*8, intent(in) :: y
test = x + y
end function
)sympy.utilities.codegen	utilitiesr   COMPLEX_ALLOWEDr   )sympyr3   r9   rx   r'   rc   s         r(   test_fcode_complexr  D  s    ".2EOO+sAsAfQS\5&eLFQilF	  sAsAfQS\5&eLFQilF	  .3EOO+r*   N)ru   FF)_ior   
sympy.corer   r   r   r   r   r	   r   r   r   r   'sympy.functions.special.error_functionsr   sympy.integrals.integralsr   sympy.matricesr   r   r  r   r   r   r   r   r   r   r   r   r   r   sympy.testing.pytestr   sympy.utilities.lambdifyr   r)   rN   rT   rY   r\   rd   rf   rk   rm   rp   ry   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r$  r*  r,  r.  r2  r4  r7  r9  r<  r@  rD  rH  rK  rM  rO  rT  rX  rZ  r_  ra  rf  ri  ro  rv  ry  r  r  r  r  r  r  r  r  r   r*   r(   <module>r     st    > > * $ 7 . /    ( 9?6@$T$$"$,	I99x0AH'T$.)X$*$*.4:(&& $&$&6	I9o$d+$\;$|0f0.b,3^&&6%PJ
I+$:<<.8,\:4r*   