Oakfield API Documentation 1.0.0
Numerical core APIs
Loading...
Searching...
No Matches
math_operator.h File Reference

Elementwise math operator with discrete-friendly operations. More...

#include "oakfield/operator_split.h"
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for math_operator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SimElementwiseMathOperatorConfig
 Configuration parameters for the elementwise math operator. More...
 

Typedefs

typedef enum SimElementwiseMathMode SimElementwiseMathMode
 Elementwise math operations.
 
typedef enum SimElementwiseMathRhsSource SimElementwiseMathRhsSource
 RHS source for binary operations.
 
typedef struct SimElementwiseMathOperatorConfig SimElementwiseMathOperatorConfig
 Configuration parameters for the elementwise math operator.
 

Enumerations

enum  SimElementwiseMathMode {
  SIM_ELEMENTWISE_MATH_FLOOR = 0 , SIM_ELEMENTWISE_MATH_FRACT , SIM_ELEMENTWISE_MATH_MOD , SIM_ELEMENTWISE_MATH_STEP ,
  SIM_ELEMENTWISE_MATH_EQ , SIM_ELEMENTWISE_MATH_LT , SIM_ELEMENTWISE_MATH_GT , SIM_ELEMENTWISE_MATH_SELECT
}
 Elementwise math operations. More...
 
enum  SimElementwiseMathRhsSource { SIM_ELEMENTWISE_MATH_RHS_FIELD = 0 , SIM_ELEMENTWISE_MATH_RHS_CONSTANT }
 RHS source for binary operations. More...
 

Functions

SimResult sim_add_elementwise_math_operator (struct SimContext *context, const SimElementwiseMathOperatorConfig *config, size_t *out_index)
 Register an elementwise math operator with the provided configuration.
 
SimResult sim_elementwise_math_config (struct SimContext *context, size_t operator_index, SimElementwiseMathOperatorConfig *out_config)
 Retrieve the configuration currently bound to a math operator.
 
SimResult sim_elementwise_math_update (struct SimContext *context, size_t operator_index, const SimElementwiseMathOperatorConfig *config)
 Update an existing math operator in-place.
 

Detailed Description

Elementwise math operator with discrete-friendly operations.

Enumeration Type Documentation

◆ SimElementwiseMathMode

Elementwise math operations.

Enumerator
SIM_ELEMENTWISE_MATH_FLOOR 

Floor operation.

SIM_ELEMENTWISE_MATH_FRACT 

Fractional-part operation.

SIM_ELEMENTWISE_MATH_MOD 

Modulo operation.

SIM_ELEMENTWISE_MATH_STEP 

Threshold step operation.

SIM_ELEMENTWISE_MATH_EQ 

Equality comparison.

SIM_ELEMENTWISE_MATH_LT 

Less-than comparison.

SIM_ELEMENTWISE_MATH_GT 

Greater-than comparison.

SIM_ELEMENTWISE_MATH_SELECT 

Select true/false output based on condition.

◆ SimElementwiseMathRhsSource

RHS source for binary operations.

Enumerator
SIM_ELEMENTWISE_MATH_RHS_FIELD 

Read RHS values from rhs_field.

SIM_ELEMENTWISE_MATH_RHS_CONSTANT 

Use rhs_constant as RHS value.

Function Documentation

◆ sim_add_elementwise_math_operator()

SimResult sim_add_elementwise_math_operator ( struct SimContext context,
const SimElementwiseMathOperatorConfig config,
size_t *  out_index 
)

Register an elementwise math operator with the provided configuration.

Parameters
contextSimulation context that will own the operator.
configOptional elementwise math configuration; NULL selects normalized defaults.
[out]out_indexOptional destination for the registered operator index.
Returns
SIM_RESULT_OK on success, or an error code from argument validation, field/type compatibility checks, allocation, or split registration.

◆ sim_elementwise_math_config()

SimResult sim_elementwise_math_config ( struct SimContext context,
size_t  operator_index,
SimElementwiseMathOperatorConfig out_config 
)

Retrieve the configuration currently bound to a math operator.

Parameters
contextSimulation context containing the operator.
operator_indexIndex returned by sim_add_elementwise_math_operator().
[out]out_configReceives the normalized configuration.
Returns
SIM_RESULT_OK on success, SIM_RESULT_INVALID_ARGUMENT for NULL pointers, SIM_RESULT_NOT_FOUND for a missing operator, or SIM_RESULT_INVALID_STATE when the operator has no math state.

◆ sim_elementwise_math_update()

SimResult sim_elementwise_math_update ( struct SimContext context,
size_t  operator_index,
const SimElementwiseMathOperatorConfig config 
)

Update an existing math operator in-place.

Passing NULL for config keeps the current configuration and reapplies normalization. A successful update validates field/type compatibility, refreshes symbolic metadata, and invalidates the scheduler plan.

Parameters
contextSimulation context containing the operator.
operator_indexIndex of the elementwise math operator to update.
configOptional replacement elementwise math configuration.
Returns
SIM_RESULT_OK on success, or an error code from argument validation, lookup, field/type compatibility checks, or state validation.