Table Functions

Overview

This class manages tabular data that represents scalar or vector values as a function of an independent variable. Typical use cases include temperature-dependent material data or time-dependent load factors. Table functions can be defined from scratch, merged from existing functions and evaluated at arbitrary independent values.

The functions associated with a TableFunction object are the following.

Define the function type and dimensionality with define(). Tabular data is entered with setPiecewiseLinear(), which accepts arrays of independent and dependent values in either single or double precision. Once defined, the number of points, independent values and dependent values can be queried with getPointCount(), getIndependentValues() and getDependentValues(). Use setDependentValues() to modify existing data without redefining the complete function.

Table parameters control how the input argument is transformed before interpolation. The evaluation follows

\[y(x) = \text{Scale} \cdot \text{CURVE}\left( \frac{x - \text{Offset}}{\text{Divisor}} \right) - \text{Shift}.\]

Scale, Shift, Divisor and Offset are defined with setFactor(). Additional behavior is configured through DoubleParameter and IntegerParameter, allowing you to set interpolation tolerance, enable or disable extrapolation and specify evaluation hints.

Use evaluate() to compute values for any set of independent arguments. Functions can be merged into higher dimensional tables with merge(), and checkMatchingIndependentValues() helps verify that two tables share the same sampling of the independent variable before combining their data.

Class Members Descriptions

The currently available TableFunction enumerations and functions are described in detail in this section.

class TableFunction

Public Types

enum class Type

Table function type.

Values:

enumerator PWLINEAR

Piecewise linear function.

enumerator EQUATION

Equation-based function.

enumerator EXPRESSION

Expression-based function.

enum class TableParameter

Table parameter types for scaling and shifting.

Values:

enumerator SCALE

Scale factor.

enumerator SHIFT

Shift value.

enumerator DIVISOR

Divisor value.

enumerator OFFSET

Offset value.

enum class DoubleParameter

Double precision parameter types.

Values:

enumerator TOLERANCE

Tolerance value.

enum class IntegerParameter

Integer parameter types.

Values:

enumerator EXTRAPOLATE

Extrapolation flag.

Public Functions

ErrorCode getErrorCode()

Return the current ErrorCode of the TableFunction object.

Returns: ErrorCode - The current error code, or NONE if no error.
Status setId(int id)

Set the table function id.

Parameters:id – Table function id
Returns:Status
Status getId(int *id)

Get the table function id.

Parameters:id[out] Table function id
Returns:Status
Status setName(const char *name)

Attach a name to the table function. Inquire of specified name as an output argument using getName() .

Parameters:name – String with table function name
Returns:Status
Status getName(char name[])

Get the table function name string.

See Also setName()

Parameters:name[out] Table function name
Returns:Status
Status define(Type type, int dimension)

Specify the type ( Type ) and dimension of the table function. For a scalar function of an independent variable enter dimension = 1. Use setPiecewiseLinear() to enter the values of the function for all values of the independent variable. Use merge() to define a function as the combination of functions.

Errors
VALUE is generated if an improper dimension is specified.

Parameters:
  • type Type
  • dimension – Dimension of vector valued function
Returns:

Status

Status inquire(Type *type, int *dimension)

Inquire of defined type and dimension as output arguments.

See Also define()

Parameters:
  • type[out] Type
  • dimension[out] Dimension of vector valued function
Returns:

Status

Status setFactor(TableParameter type, float factor)

Specify table parameter type ( TableParameter ) and value factor. The evaluation function is of the form:

y(x) = Scale * CURVE((x - Offset) / Divisor) - Shift
By default, SCALE is set to 1, SHIFT is set to 0, DIVISOR is set to 1, and OFFSET is set to 0.

Errors
VALUE is generated if a zero DIVISOR is specified.

Parameters:
Returns:

Status

Status setFactor(TableParameter type, double factor)

Specify table parameter type ( TableParameter ) and value factor. See setFactor() (float version) for details.

Parameters:
Returns:

Status

Status getFactor(TableParameter type, float *factor)

Get table parameter type ( TableParameter ) as float.

Parameters:
Returns:

Status

Status getFactor(TableParameter type, double *factor)

Get table parameter type ( TableParameter ) as double.

Parameters:
Returns:

Status

Status setDoubleParameter(DoubleParameter type, double value)

Specify a double parameter value: value for type type.

Parameters:
Returns:

Status

Status setIntegerParameter(IntegerParameter type, int value)

Specify an integer parameter value: value for type: type

Parameters:
Returns:

Status

Status getIntegerParameter(IntegerParameter type, int *value)

Return a defined real parameter as double.

Parameters:
Returns:

Status

Status setPiecewiseLinear(int pointCount, float x[], float y[])

Define a function as a piecewise linear function at pointCount values of the independent variable x. The function values y are input as a vector valued function of dimension specified in define() .

Parameters:
  • pointCount – Number of points for which function is defined
  • x – Array of values of independent variable
  • y – Array of values of function
Returns:

Status

Status setPiecewiseLinear(int pointCount, double x[], double y[])

Define a function as a piecewise linear function at pointCount values of the independent variable x (double version). The function values y are input as a vector valued function of dimension specified in define() .

Parameters:
  • pointCount – Number of points for which function is defined
  • x – Array of values of independent variable
  • y – Array of values of function
Returns:

Status

Status getPointCount(int *count)

Query for the number of values of the independent variable for which the function is defined.

Parameters:count[out] Number of points on function curve
Returns:Status
Status getIndependentValues(int pointCount, int pointIndexes[], float values[])

Query for the values of the independent variable for which the function is defined. The point indices pointIndexes are indexed starting from 1.

Parameters:
  • pointCount – Number of points on function curve to return
  • pointIndexes – Array of point indices
  • values[out] Values of independent variable
Returns:

Status

Status getIndependentValues(int pointCount, int pointIndexes[], double values[])

Query for the values of the independent variable for which the function is defined. The point indices pointIndexes are indexed starting from 1.

Parameters:
  • pointCount – Number of points on function curve to return
  • pointIndexes – Array of point indices
  • values[out] Values of independent variable
Returns:

Status

Status getDependentValues(int pointCount, int pointIndexes[], float values[])

Query for the values of the dependent variable for which the function is defined.

Parameters:
  • pointCount – Number of points on function curve to return
  • pointIndexes – Array of point indices
  • values[out] Values of dependent variable
Returns:

Status

Status getDependentValues(int pointCount, int pointIndexes[], double values[])

Query for the values of the dependent variable for which the function is defined.

Parameters:
  • pointCount – Number of points on function curve to return
  • pointIndexes – Array of point indices
  • values[out] Values of dependent variable
Returns:

Status

Status setDependentValues(int pointCount, int pointIndexes[], float values[])

Set the values of the dependent variable for the function.

Parameters:
  • pointCount – Number of points on function curve to set
  • pointIndexes – Array of point indices
  • values – Values of dependent variable
Returns:

Status

Status setDependentValues(int pointCount, int pointIndexes[], double values[])

Set the values of the dependent variable for the function.

Parameters:
  • pointCount – Number of points on function curve to set
  • pointIndexes – Array of point indices
  • values – Values of dependent variable
Returns:

Status

Status evaluate(int pointCount, float independentValues[], float dependentValues[])

Evaluate the function at pointCount values independentValues of the independent variable.

Parameters:
  • pointCount – Number of points to evaluate
  • independentValues – Values of independent variable
  • dependentValues[out] Values of function
Returns:

Status

Status evaluate(int pointCount, double independentValues[], double dependentValues[])

Evaluate the function at pointCount values independentValues of the independent variable.

Parameters:
  • pointCount – Number of points to evaluate
  • independentValues – Values of independent variable
  • dependentValues[out] Values of function
Returns:

Status

Status merge(int count, TableFunction **functionArray)

Define a function as a combination of count functions functionArray. The dimension of the function defined using define() must be equal to the sum of the dimensions of the count functions functionArray. The number of values of the independent variable will be equal to the union of the values of the functions functionArray. The function must be of type PWLINEAR .

Parameters:
  • count – Number of functions to merge
  • functionArray – Array of pointers to TableFunction objects to merge
Returns:

Status

Status checkMatchingIndependentValues(int pointCount, float independentValues[], int *flag)

Check if the given independent values match those of the function.

Parameters:
  • pointCount – Number of points to check
  • independentValues – Values of independent variable
  • flag[out] 1 if matching, 0 otherwise
Returns:

Status

Status print()

Print the contents of the TableFunction object to standard output.

Returns:Status
int isEqualTo(TableFunction *function)

Check if this TableFunction is equal to another TableFunction.

Parameters:function – TableFunction to compare with
Returns:1 if equal, 0 otherwise