Mathematical functions

If you choose to generate mathematical functions, BladeSmith generates the following mathematical functions that take two opaque data type arguments, return an opaque data type, and are bound to operators:
  • Plus() (+)
  • Minus() (-)
  • Times() (*)
  • Divide() (/)
BladeSmith generates the following mathematical functions that take one opaque data type argument, return an opaque data type, and are bound to operators:
  • Positive() (+)
  • Negate() (-)

The C name of each of these functions is prefixed by the name of the opaque data type for which they are defined.

BladeSmith generates only template code for these mathematical functions.

The generated code

These functions have an unused MI_FPARAM argument and one or two opaque data type arguments, and they return a pointer to the resulting opaque type structure.

In the generated code, the return value is set to 0. You must add code to perform the required operation.

Complete the code

To complete the code for these mathematical functions, you must:
  • Add your declarations, if necessary.
  • Remove the call to mi_db_error_raise(), which raises an error stating that the routine is not implemented.
  • Compute the return value and store it in the Gen_RetVal argument.

The database server frees the allocated memory when it has finished processing the result.

See Informix® User-Defined Routines and Data Types Developer's Guide for more information about these functions.

Example

The Matrix DataBlade® module contains some of the mathematical functions.