KernelFunction

KernelFunction[f]

represents a function to be evaluated in the Wolfram Language kernel, even when called from compiled code.

Details

  • The function f in KernelFunction[f] can be a built-in Wolfram Language function, a Function object or a function with definitions given by the user.
  • Typically, KernelFunction is wrapped in TypeHint to specify the type of the function.

Examples

open allclose all

Basic Examples  (1)

Use the Wolfram Engine evaluator to compute the AiryAi function from compiled code:

Execute the compiled function:

The result compares with the direct call:

Call a pure function that executes with the evaluator:

Define a function in the Wolfram Engine:

Call the function from compiled code:

Scope  (4)

Use the result of KernelFunction as an internal function:

A KernelFunction can return a function:

Returning a function from KernelFunction allows operations such as Fit to be integrated into the compiler:

The function returned from KernelFunction can itself be dynamically compiled:

Use KernelFunction to integrate file operations:

Properties & Relations  (1)

Use KernelFunction alongside FunctionDeclaration to declare functions that require the evaluator:

Neat Examples  (1)

Integrate NDSolve into compiled code:

Wolfram Research (2019), KernelFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/KernelFunction.html.

Text

Wolfram Research (2019), KernelFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/KernelFunction.html.

CMS

Wolfram Language. 2019. "KernelFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/KernelFunction.html.

APA

Wolfram Language. (2019). KernelFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KernelFunction.html

BibTeX

@misc{reference.wolfram_2024_kernelfunction, author="Wolfram Research", title="{KernelFunction}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/KernelFunction.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_kernelfunction, organization={Wolfram Research}, title={KernelFunction}, year={2019}, url={https://reference.wolfram.com/language/ref/KernelFunction.html}, note=[Accessed: 22-December-2024 ]}