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

Elementwise complex math operator. More...

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

Go to the source code of this file.

Classes

struct  SimComplexMathOperatorConfig
 Configuration for the complex math operator. More...
 

Typedefs

typedef enum SimComplexMathMode SimComplexMathMode
 Elementwise complex math operation.
 
typedef enum SimComplexMathRhsSource SimComplexMathRhsSource
 Right-hand side source for binary ops.
 
typedef enum SimComplexMathOutputComponent SimComplexMathOutputComponent
 Output component selection when writing into real fields.
 
typedef enum SimComplexMathPhaseWrap SimComplexMathPhaseWrap
 Phase wrap policy for phase outputs.
 
typedef struct SimComplexMathOperatorConfig SimComplexMathOperatorConfig
 Configuration for the complex math operator.
 

Enumerations

enum  SimComplexMathMode {
  SIM_COMPLEX_MATH_ADD = 0 , SIM_COMPLEX_MATH_SUB , SIM_COMPLEX_MATH_MUL , SIM_COMPLEX_MATH_DIV ,
  SIM_COMPLEX_MATH_POW , SIM_COMPLEX_MATH_EXP , SIM_COMPLEX_MATH_LOG , SIM_COMPLEX_MATH_SIN ,
  SIM_COMPLEX_MATH_COS , SIM_COMPLEX_MATH_TAN , SIM_COMPLEX_MATH_SINH , SIM_COMPLEX_MATH_COSH ,
  SIM_COMPLEX_MATH_TANH , SIM_COMPLEX_MATH_SQRT , SIM_COMPLEX_MATH_CONJ , SIM_COMPLEX_MATH_ABS ,
  SIM_COMPLEX_MATH_ARG , SIM_COMPLEX_MATH_REAL , SIM_COMPLEX_MATH_IMAG , SIM_COMPLEX_MATH_NEG
}
 Elementwise complex math operation. More...
 
enum  SimComplexMathRhsSource { SIM_COMPLEX_MATH_RHS_FIELD = 0 , SIM_COMPLEX_MATH_RHS_CONSTANT }
 Right-hand side source for binary ops. More...
 
enum  SimComplexMathOutputComponent { SIM_COMPLEX_MATH_OUTPUT_REAL = 0 , SIM_COMPLEX_MATH_OUTPUT_IMAG , SIM_COMPLEX_MATH_OUTPUT_MAGNITUDE , SIM_COMPLEX_MATH_OUTPUT_PHASE }
 Output component selection when writing into real fields. More...
 
enum  SimComplexMathPhaseWrap { SIM_COMPLEX_MATH_PHASE_NONE = 0 , SIM_COMPLEX_MATH_PHASE_SIGNED , SIM_COMPLEX_MATH_PHASE_UNSIGNED , SIM_COMPLEX_MATH_PHASE_UNIT }
 Phase wrap policy for phase outputs. More...
 

Functions

SimResult sim_add_complex_math_operator (struct SimContext *context, const SimComplexMathOperatorConfig *config, size_t *out_index)
 Register a complex math operator with the provided configuration.
 
SimResult sim_complex_math_config (struct SimContext *context, size_t operator_index, SimComplexMathOperatorConfig *out_config)
 Retrieve the configuration currently bound to a complex math operator.
 
SimResult sim_complex_math_update (struct SimContext *context, size_t operator_index, const SimComplexMathOperatorConfig *config)
 Update an existing complex math operator in-place.
 

Detailed Description

Elementwise complex math operator.

Enumeration Type Documentation

◆ SimComplexMathMode

Elementwise complex math operation.

Enumerator
SIM_COMPLEX_MATH_ADD 

Complex addition.

SIM_COMPLEX_MATH_SUB 

Complex subtraction.

SIM_COMPLEX_MATH_MUL 

Complex multiplication.

SIM_COMPLEX_MATH_DIV 

Complex division.

SIM_COMPLEX_MATH_POW 

Complex power.

SIM_COMPLEX_MATH_EXP 

Complex exponential.

SIM_COMPLEX_MATH_LOG 

Principal complex logarithm.

SIM_COMPLEX_MATH_SIN 

Complex sine.

SIM_COMPLEX_MATH_COS 

Complex cosine.

SIM_COMPLEX_MATH_TAN 

Complex tangent.

SIM_COMPLEX_MATH_SINH 

Complex hyperbolic sine.

SIM_COMPLEX_MATH_COSH 

Complex hyperbolic cosine.

SIM_COMPLEX_MATH_TANH 

Complex hyperbolic tangent.

SIM_COMPLEX_MATH_SQRT 

Principal complex square root.

SIM_COMPLEX_MATH_CONJ 

Complex conjugate.

SIM_COMPLEX_MATH_ABS 

Complex magnitude.

SIM_COMPLEX_MATH_ARG 

Complex phase angle.

SIM_COMPLEX_MATH_REAL 

Real component extraction.

SIM_COMPLEX_MATH_IMAG 

Imaginary component extraction.

SIM_COMPLEX_MATH_NEG 

Complex negation.

◆ SimComplexMathOutputComponent

Output component selection when writing into real fields.

Enumerator
SIM_COMPLEX_MATH_OUTPUT_REAL 

Write real component.

SIM_COMPLEX_MATH_OUTPUT_IMAG 

Write imaginary component.

SIM_COMPLEX_MATH_OUTPUT_MAGNITUDE 

Write magnitude.

SIM_COMPLEX_MATH_OUTPUT_PHASE 

Write phase angle.

◆ SimComplexMathPhaseWrap

Phase wrap policy for phase outputs.

Enumerator
SIM_COMPLEX_MATH_PHASE_NONE 

Leave phase unwrapped.

SIM_COMPLEX_MATH_PHASE_SIGNED 

Wrap phase to a signed angular interval.

SIM_COMPLEX_MATH_PHASE_UNSIGNED 

Wrap phase to an unsigned angular interval.

SIM_COMPLEX_MATH_PHASE_UNIT 

Normalize phase to the unit interval.

◆ SimComplexMathRhsSource

Right-hand side source for binary ops.

Enumerator
SIM_COMPLEX_MATH_RHS_FIELD 

Read RHS values from rhs_field.

SIM_COMPLEX_MATH_RHS_CONSTANT 

Use rhs_constant_* as RHS values.

Function Documentation

◆ sim_add_complex_math_operator()

SimResult sim_add_complex_math_operator ( struct SimContext context,
const SimComplexMathOperatorConfig config,
size_t *  out_index 
)

Register a complex math operator with the provided configuration.

Parameters
contextSimulation context that will own the operator.
configOptional complex 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 validation, allocation, or split registration.

◆ sim_complex_math_config()

SimResult sim_complex_math_config ( struct SimContext context,
size_t  operator_index,
SimComplexMathOperatorConfig out_config 
)

Retrieve the configuration currently bound to a complex math operator.

Parameters
contextSimulation context containing the operator.
operator_indexIndex returned by sim_add_complex_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 complex-math state.

◆ sim_complex_math_update()

SimResult sim_complex_math_update ( struct SimContext context,
size_t  operator_index,
const SimComplexMathOperatorConfig config 
)

Update an existing complex math operator in-place.

Passing NULL for config keeps the current configuration and reapplies normalization. A successful update refreshes symbolic metadata.

Parameters
contextSimulation context containing the operator.
operator_indexIndex of the complex math operator to update.
configOptional replacement complex math configuration.
Returns
SIM_RESULT_OK on success, SIM_RESULT_INVALID_ARGUMENT for a NULL context, SIM_RESULT_NOT_FOUND for a missing operator, or SIM_RESULT_INVALID_STATE when the operator has no complex-math state.