das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
Macros | Functions
form_cplx.h File Reference

A complex number: two components, one value. More...

#include <das3/form.h>
#include <das3/form_vector.h>
Include dependency graph for form_cplx.h:

Go to the source code of this file.

Macros

#define DAS_FORM_CPLX   (&das_form_cplx_vtbl)
 A complex number, two components making a single value.
 

Functions

DAS_API const char * das_cplxsys_str (ubyte uSys)
 Wire token for a complex system code, NULL if it is not one of these two.
 
DAS_API ubyte das_cplxsys_id (const char *sSys)
 Wire token to complex system code, DAS_VSYS_UNKNOWN if unrecognized.
 
DAS_API const char * das_cplxsys_desc (ubyte uSys)
 One line of prose about a complex system, for a "notes" property.
 
DAS_API const char * das_cplxsys_symbol (ubyte uSys, int iComp)
 The canonical symbol for component iComp of a complex system, NULL if the system is not one of these two or the component is not 0 or 1.
 
DAS_API bool das_cplx_toRect (ubyte uSys, const double *pIn, double *pOut)
 Components as stored to a rectangular (real, imaginary) pair.
 
DAS_API bool das_cplx_fromRect (ubyte uSys, const double *pIn, double *pOut)
 A rectangular (real, imaginary) pair to components as stored.
 

Detailed Description

A complex number: two components, one value.

A transfer function, a cross spectral density, a calibration response. Two numbers that are not two measurements: they are one quantity that happens to need a plane rather than a line to sit in. That is the whole reason this is a formalism and not a labeled 2-bundle – multiplication of a bundle is component-wise and multiplication of a complex number is not, so a reader that guessed would produce a confident wrong answer.

complex +- complex  = complex
complex *   complex = complex   (ac - bd, ad + bc), NOT component-wise
complex /   complex = complex
complex op  real    = complex   the real promotes to (v, 0)
real    op  complex = complex   stated explicitly, never inferred

A real number entering complex arithmetic is promoted to a zero-imaginary complex, so every rule above is one rule with a promotion in front of it. That is why there is no separate scale path here the way form_vector.c has one: scaling a complex IS multiplying by (v, 0).

Parameters:

system= rectangular | polar. Default rectangular.

Two representations, one meaning:

rectangular   real, imaginary
polar         magnitude, phase

ANGLES ARE ALWAYS DEGREES on the wire, the same law form_vector.h states, so a polar variable's units= describes the MAGNITUDE and the phase carries no units of its own. Both components of a rectangular variable share the one units= between them, since a real part and an imaginary part of different scales would not be a number.

The arithmetic runs in rectangular and converts back to the LEFT operand's system, so a polar variable stays polar through a multiply.

EXACTLY TWO COMPONENTS, one level: intern="2". A complex vector – three complex numbers making up a spectral E-field, say – is real and common and is its own formalism yet to be written, not this one with a bigger shape. Only one <ops> fits on a composite, so the pairing cannot be expressed by stacking this kind on top of a vector.

Macro Definition Documentation

◆ DAS_FORM_CPLX

#define DAS_FORM_CPLX   (&das_form_cplx_vtbl)

A complex number, two components making a single value.

Multiplication is the complex rule and not component by component.

See also
DasForm_isKind(), DasVar_formIs().

Function Documentation

◆ das_cplxsys_str()

DAS_API const char * das_cplxsys_str ( ubyte  uSys)

Wire token for a complex system code, NULL if it is not one of these two.

Deliberately narrow: this is not a superset lookup the way das_geosys_str() is over the geometric six. Nothing needs to switch over a geometric system and a complex one in the same statement, so nothing here invites it.

◆ das_cplxsys_id()

DAS_API ubyte das_cplxsys_id ( const char *  sSys)

Wire token to complex system code, DAS_VSYS_UNKNOWN if unrecognized.

Accepts the leading "rect" and "polar" the way das_vsys_id() accepts "cart", since abbreviating a system name is long-standing wire practice.

◆ das_cplx_toRect()

DAS_API bool das_cplx_toRect ( ubyte  uSys,
const double *  pIn,
double *  pOut 
)

Components as stored to a rectangular (real, imaginary) pair.

pIn and pOut may not overlap.

Returns
false on a loud error.

◆ das_cplx_fromRect()

DAS_API bool das_cplx_fromRect ( ubyte  uSys,
const double *  pIn,
double *  pOut 
)

A rectangular (real, imaginary) pair to components as stored.

pIn and pOut may not overlap.

Returns
false on a loud error.