WOLFRAM

DownValuesFunction
Copy to clipboard.
DownValuesFunction

[Experimental]

Copy to clipboard.

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

Details

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

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

Out[2]=2

Use the compiled function with an integer argument:

Out[3]=3

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

Out[4]=4

The result is the same:

Out[5]=5

Scope  (5)Survey of the scope of standard use cases

Multiple Definitions  (5)

Several definitions attached to the same symbol can be used:

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

Out[2]=2

This calls the definition that uses a condition:

Out[3]=3

This calls the definition that uses a literal 2:

Out[4]=4

This calls the last catchall definition:

Out[5]=5

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:

Out[2]=2

Call the integer case:

Out[3]=3

Call the real case:

Out[4]=4

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

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

Out[2]=2

Call the integer case:

Out[3]=3

Call the real case:

Out[4]=4

Function declarations that use a symbol definition can call themselves:

Make a declaration and compile a function that uses it:

Out[2]=2

Call the function:

Out[3]=3

Function declarations that do not apply to all inputs can use a predicate to strip out:

Make a polymorphic declaration:

This compiles for a Boolean type, but the predicate for the Floor case is known to be False at compile time, so it is stripped out:

Out[3]=3

This compiles for a real type and uses the branch with the Floor:

Out[4]=4

Applications  (1)Sample problems that can be solved with this function

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:

Out[4]=4

A vector plot based on the data that was created:

Out[6]=6

The compiled version is much faster:

Out[7]=7
Out[8]=8

An animation of the output:

Out[9]=9

Possible Issues  (3)Common pitfalls and unexpected behavior

Updating  (2)

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

Out[3]=3

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

Out[5]=5

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

Out[3]=3

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

Out[5]=5

Defintion Restrictions  (1)

If there is no definition that applies to all cases, an error case will be added:

Out[2]=2

This works fine:

Out[3]=3

This triggers the error case:

Out[4]=4

Patterns with a head specification are not supported:

Out[6]=6

Compound settings are not supported:

Out[8]=8

Sequence patterns are not supported:

Out[10]=10

Optional patterns are not supported:

Out[12]=12

Alternative patterns are not supported:

Out[14]=14

Alternative patterns are not supported:

Out[16]=16

Held patterns are not supported:

Out[18]=18

Verbatim patterns are not supported:

Out[20]=20

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

Out[22]=22
Wolfram Research (2022), DownValuesFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/DownValuesFunction.html.
Copy to clipboard.
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.

Copy to clipboard.
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.

Copy to clipboard.
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

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

BibTeX

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

Copy to clipboard.
@misc{reference.wolfram_2025_downvaluesfunction, author="Wolfram Research", title="{DownValuesFunction}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/DownValuesFunction.html}", note=[Accessed: 21-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_downvaluesfunction, organization={Wolfram Research}, title={DownValuesFunction}, year={2022}, url={https://reference.wolfram.com/language/ref/DownValuesFunction.html}, note=[Accessed: 21-April-2025 ]}

Copy to clipboard.
@online{reference.wolfram_2025_downvaluesfunction, organization={Wolfram Research}, title={DownValuesFunction}, year={2022}, url={https://reference.wolfram.com/language/ref/DownValuesFunction.html}, note=[Accessed: 21-April-2025 ]}