Example #1
0
        print("\t%s" % integrand.signature)

    #Add file dependencies
    for dependency in args.dependencies:
        if args.verbose:
            print("Adding dependency for \"%s\"" % dependency)
        integrand.add_include_dependency(dependency)

    #Create the correct code generator
    if args.backend not in ["gsl", "opencl"]:
        print("Invalid backend specified: %s" % args.backend)
        sys.exit(1)
    if args.verbose:
        print("Using backend: %s" % args.backend)
    if args.backend == "gsl":
        integrator = GslMonteCarloFunctionIntegrator(integrand,
                                                     args.integrator_name)
    else:
        integrator = OpenClMonteCarloFunctionIntegrator(
            integrand, args.integrator_name)
    if args.verbose:
        print("Integral signature:")
        print("\t%s" % integrator.evaluation_function.signature)

    #Compute output paths
    if args.header_output_path != None:
        output_header = args.header_output_path
    elif args.output_file_base != None:
        output_header = args.output_file_base + ".h"
    else:
        raise RuntimeError("Unable to compute header output path.  " \
                           "You must specify either header-output-path " \
Example #2
0
    #Add file dependencies
    for dependency in args.dependencies:
        if args.verbose:
            print("Adding dependency for \"%s\"" % dependency)
        integrand.add_include_dependency(dependency)

    #Create the correct code generator
    if args.backend not in ["gsl",  
                            "opencl"]:
        print("Invalid backend specified: %s" % args.backend)
        sys.exit(1)
    if args.verbose:
        print("Using backend: %s" % args.backend)
    if args.backend == "gsl":
        integrator = GslMonteCarloFunctionIntegrator(integrand, 
                                                     args.integrator_name)
    else:
        integrator = OpenClMonteCarloFunctionIntegrator(integrand,
                                                        args.integrator_name)
    if args.verbose:
        print("Integral signature:")
        print("\t%s" % integrator.evaluation_function.signature)

    #Compute output paths
    if args.header_output_path != None:
        output_header = args.header_output_path
    elif args.output_file_base != None:
        output_header = args.output_file_base + ".h"
    else:
        raise RuntimeError("Unable to compute header output path.  " \
                           "You must specify either header-output-path " \
Example #3
0
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()