DownValuesFunction

DownValuesFunction[sym]

represents a function that uses definitions attached to sym when compiling.

Details

Examples

open allclose all

Basic Examples  (1)

Define a squaring function and use its definition to create a compiled function for the integer-typed case:

Use the compiled function with an integer argument:

Alternatively, use FunctionDeclaration to associate the definition of a function with a type specification:

The result is the same:

Scope  (4)

Multiple Definitions  (4)

Several definitions attached to the same symbol can be used:

Make a declaration and compile a function that uses the definitions:

This calls the definition that uses a condition:

This calls the definition that uses a literal 2:

This calls the last catchall definition:

Definitions attached to a symbol can be used in more than one declaration with different types:

Make two declarations with different types and compile functions that use each:

Call the integer case:

Call the real case:

Definitions attached to a symbol can be declared with a polymorphic type:

Make two declarations with different types and compile functions that use each:

Call the integer case:

Call the real case:

Function declarations that use a symbol definition can call themselves:

Make a declaration and compile a function that uses it:

Call the function:

Applications  (1)

Symbol Definitions  (1)

Declarations that use symbol definitions are useful if the declaration is used more than once:

A FunctionDeclaration that refers to the symbol:

A function that uses the symbol:

Compiled code for the function:

A vector plot based on the data that was created:

The compiled version is much faster:

An animation of the output:

Possible Issues  (3)

Updating  (2)

DownValuesFunction uses the definitions used when the compilation is carried out:

The result uses the definitions in place when the compilation is done:

KernelFunction uses the definitions used when the computation is carried out:

The result uses the definitions in place when the computation is done:

Defintion Restrictions  (1)

There must always be a definition that applies to all cases:

Patterns with a head specification are not supported:

Compound settings are not supported:

Sequence patterns are not supported:

Optional patterns are not supported:

Alternative patterns are not supported:

Alternative patterns are not supported:

Held patterns are not supported:

Verbatim patterns are not supported:

All the branches of pattern definitions must have a consistent type:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2022_downvaluesfunction, author="Wolfram Research", title="{DownValuesFunction}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/DownValuesFunction.html}", note=[Accessed: 04-February-2023 ]}

BibLaTeX

@online{reference.wolfram_2022_downvaluesfunction, organization={Wolfram Research}, title={DownValuesFunction}, year={2022}, url={https://reference.wolfram.com/language/ref/DownValuesFunction.html}, note=[Accessed: 04-February-2023 ]}