raise RuntimeError("Unable to compute header output path. " \ "You must specify either header-output-path " \ "or output-file-base from the command line.") if args.source_output_path != None: output_source = args.source_output_path elif args.output_file_base != None: output_source = args.output_file_base + ".cpp" else: raise RuntimeError("Unable to compute source output path. " \ "You must specify either source-output-path " \ "or output-file-base from the command line.") if args.verbose: print("Header output path: %s" % output_header) print("Source output path: %s" % output_source) #Create intermediate directories header_dir = os.path.dirname(output_header) source_dir = os.path.dirname(output_source) if not os.path.isdir(header_dir): os.makedirs(header_dir) if not os.path.isdir(source_dir): os.makedirs(source_dir) #Generate the code! integrator.generate_code( output_header, output_source, primary_header_include=args.primary_header_include) if args.verbose: print("Code successfully generated!")
else: raise RuntimeError("Unable to compute header output path. " \ "You must specify either header-output-path " \ "or output-file-base from the command line.") if args.source_output_path != None: output_source = args.source_output_path elif args.output_file_base != None: output_source = args.output_file_base + ".cpp" else: raise RuntimeError("Unable to compute source output path. " \ "You must specify either source-output-path " \ "or output-file-base from the command line.") if args.verbose: print("Header output path: %s" % output_header) print("Source output path: %s" % output_source) #Create intermediate directories header_dir = os.path.dirname(output_header) source_dir = os.path.dirname(output_source) if not os.path.isdir(header_dir): os.makedirs(header_dir) if not os.path.isdir(source_dir): os.makedirs(source_dir) #Generate the code! integrator.generate_code(output_header, output_source, primary_header_include = args.primary_header_include) if args.verbose: print("Code successfully generated!")
from os.path import join #Common example modules from common import example_share_path #Feynman modules from feynman.parsing import CFile from feynman.integration import FunctionIntegral, \ GslMonteCarloFunctionIntegrator #Grab the source code integrand_header_path = join(example_share_path, "integrand.h") #Parse the source code integrand_header = CFile(integrand_header_path) #Grab the function we're interested in integrand = integrand_header["unit_cylinder"] print("The integrand function is: %s" % integrand.signature) #Create an integral for it integral = FunctionIntegral(integrand) print("The integral function is: %s" % integral.signature) #Add the header dependency for the interal integral.add_include_dependency("integrand.h") #Generate code for the function integrator = GslMonteCarloFunctionIntegrator(integral) integrator.generate_code()