das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
form_cplx.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Chris Piker <chris-piker@uiowa.edu>
2 *
3 * Author: C. Piker, via Claude Opus 5
4 *
5 * This file is part of das2C, the Core Das2 C Library.
6 *
7 * Das2C is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License version 2.1 as published
9 * by the Free Software Foundation.
10 *
11 * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
18 */
19
65#ifndef _das_form_cplx_h_
66#define _das_form_cplx_h_
67
68#include <das3/form.h>
69
70/* For the shared component-system numbering ONLY -- DAS_VSYS_UNKNOWN is the
71 whole space's "no system" sentinel and form_vector.h is where the space is
72 chartered. This file learns nothing else about vectors from it: complex
73 has no rule for one and declines the pairing. form_geoloc.h reaches for the
74 same header for the same reason. */
75#include <das3/form_vector.h>
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
81/* --- component systems, the complex half --------------------------------- *
82 *
83 * The codes CONTINUE the numbering form_vector.h opens and form_geoloc.h
84 * extends, for the reason stated there: one ubyte must read the same next to
85 * whichever formalism handed it out. A second space starting over at 1 would
86 * make a bare system code meaningless without knowing its issuer, which is the
87 * exact confusion the shared space exists to prevent.
88 *
89 * Sharing the space does NOT make these geometric. das_vsys_str() and
90 * das_geosys_str() answer NULL for both of them, which is correct: a complex
91 * plane has no third component, no frame and no cross product, so no code in
92 * this file may be handed to das_vsys_toCart().
93 */
94
95#define DAS_VSYS_RECT 0x00000007 /* real, imaginary */
96#define DAS_VSYS_POLAR 0x00000008 /* magnitude, phase */
97
98#define DAS_VSYS_CPLX_MIN 0x00000007
99#define DAS_VSYS_CPLX_MAX 0x00000008
100
106DAS_API const char* das_cplxsys_str(ubyte uSys);
107
111DAS_API ubyte das_cplxsys_id(const char* sSys);
112
114DAS_API const char* das_cplxsys_desc(ubyte uSys);
115
118DAS_API const char* das_cplxsys_symbol(ubyte uSys, int iComp);
119
122DAS_API bool das_cplx_toRect(ubyte uSys, const double* pIn, double* pOut);
123
126DAS_API bool das_cplx_fromRect(ubyte uSys, const double* pIn, double* pOut);
127
128/* Exported so that its address can be compared. Client code uses the
129 DAS_FORM_CPLX macro below and has no reason to name this directly. */
130DAS_API extern const DasForm_VTbl das_form_cplx_vtbl;
131
135#define DAS_FORM_CPLX (&das_form_cplx_vtbl)
136
143DAS_API DasForm* new_DasFormCplx(ubyte uSysType);
144
148DAS_API ubyte DasFormCplx_sysType(const DasForm* pThis);
149
150/* To read a complex datum's two components use das_datum_toDoubles(). Values
151 come back as stored, so a polar variable returns a magnitude and a phase in
152 degrees. Use das_cplx_toRect() above to convert them. */
153
154#ifdef __cplusplus
155}
156#endif
157
158#endif /* _das_form_cplx_h_ */
What a variable's values (i.e.
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 ...
DAS_API bool das_cplx_fromRect(ubyte uSys, const double *pIn, double *pOut)
A rectangular (real, imaginary) pair to components as stored.
DAS_API bool das_cplx_toRect(ubyte uSys, const double *pIn, double *pOut)
Components as stored to a rectangular (real, imaginary) pair.
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_str(ubyte uSys)
Wire token for a complex system code, NULL if it is not one of these two.
DAS_API const char * das_cplxsys_desc(ubyte uSys)
One line of prose about a complex system, for a "notes" property.
A frame-tagged geometric vector.