gd_alter_bit(3)
π gd_alter_bit β GETDATA β bestie edition π
okay so. this is the gd_alter_bit(3) page, and it's a big one, so buckle up π. it's the whole family of gd_alter_* functions from the GetData library β the ones that let you modify a field in a Dirfile. yes, all of them. all twenty-ish. we're doing this together, hand in hand π«Ά
β¨ NAME β¨
gd_alter_bit, gd_alter_carray, gd_alter_clincom, gd_alter_const, gd_alter_cpolynom, gd_alter_crecip, gd_alter_divide, gd_alter_indir, gd_alter_lincom, gd_alter_linterp, gd_alter_multiply, gd_alter_phase, gd_alter_polynom, gd_alter_raw, gd_alter_recip, gd_alter_sarray, gd_alter_sbit, gd_alter_sindir β modify a field in a Dirfile
no cap, that's literally the whole job description. one vibe: change stuff in your Dirfile π
πΈ SYNOPSIS πΈ
#include <getdata.h>
int gd_alter_bit(DIRFILE *dirfile, const char *field_code, const char
*in_field, int bitnum, int numbits);
int gd_alter_carray(DIRFILE *dirfile, const char *field_code, gd_type_t
const_type, size_t array_len);
int gd_alter_clincom(DIRFILE *dirfile, const char *field_code, int
n_fields, const char **in_fields, const double complex *cm, const
double complex *cb);
int gd_alter_const(DIRFILE *dirfile, const char *field_code, gd_type_t
const_type);
int gd_alter_cpolynom(DIRFILE *dirfile, const char *field_code, int
poly_ord, const char *in_field, const double complex *ca);
int gd_alter_crecip(DIRFILE *dirfile, const char *field_code, const char
*in_field, complex double cdividend);
int gd_alter_divide(DIRFILE *dirfile, const char *field_code, const char
*in_field1, const char *in_field2);
int gd_alter_indir(DIRFILE *dirfile, const char *field_code, const char
*index_field, const char *carray_field);
int gd_alter_lincom(DIRFILE *dirfile, const char *field_code, int
n_fields, const char **in_fields, const double *m, const double
*b);
int gd_alter_linterp(DIRFILE *dirfile, const char *field_code, const
char *in_field, const char *table, int rename_table);
int gd_alter_mplex(DIRFILE *dirfile, const char *field_name, const char
*in_field, const char *count_field, int count_val, int period);
int gd_alter_multiply(DIRFILE *dirfile, const char *field_code, const
char *in_field1, const char *in_field2);
int gd_alter_phase(DIRFILE *dirfile, const char *field_code, const char
*in_field, gd_int64_t shift);
int gd_alter_polynom(DIRFILE *dirfile, const char *field_code, int
poly_ord, const char *in_field, const double *ca);
int gd_alter_raw(DIRFILE *dirfile, const char *field_code, gd_type_t
data_type, unsigned int spf, int recode);
int gd_alter_recip(DIRFILE *dirfile, const char *field_code, const char
*in_field, double dividend);
int gd_alter_sarray(DIRFILE *dirfile, const char *field_code, size_t
array_len);
int gd_alter_sbit(DIRFILE *dirfile, const char *field_code, const char
*in_field, int bitnum, int numbits);
int gd_alter_sindir(DIRFILE *dirfile, const char *field_code, const char
*index_field, const char *sarray_field);
int gd_alter_window(DIRFILE *dirfile, const char *field_code, const char
*in_field, const char *check_field, gd_windop_t windop,
gd_triplet_t threshold);
tiny heads up bestie:gd_alter_mplexandgd_alter_windowshow up in the synopsis but not in the NAME list above. that's just how the page is, don't @ me π β i'm keeping every single character exactly where the original put it.
π¦ DESCRIPTION π¦
so. these functions? they're the glow-up versions of just calling gd_alter_entry(3). they let you modify a field of the indicated type in the dirfile specified by dirfile. same energy, more specific, lowkey nicer β¨
In all of these calls, field_code tells you which field you're modifying. it can be a regular field, or a metafield specified by its full (slashed) field code, but it should not contain a representation suffix. π«
the meaning and valid types of the other arguments? go read get_entry(3) and dirfile-format(5), they've got you π
btw the gd_int64_t type is a signed 64-bit integer type. and gd_triplet_t is defined like this, verbatim:
typedef union {
gd_int64_t i;
gd_uint64_t u;
double r;
} gd_triplet_t;
which element of that gd_triplet_t union you set depends on the operator you picked for the WINDOW field. see gd_entry(3) for the details, iykyk π
π the complex ones (they're not scary, promise)
gd_alter_clincom() and gd_alter_cpolynom() are identical to gd_alter_lincom() and gd_alter_polynom(), except they take complex scalar parameters instead of purely real values.
and the way this only matters is for the input of new parameters! if the scalar parameters aren't being changed β because you passed NULL instead of a list of scalars β then the functions are fully interchangeable, no matter whether the altered field has complex scalar parameters or not. slay.
π the array arguments
If the corresponding parameters are being changed:
gd_alter_lincom()andgd_alter_clincom()take pointers to three arrays of lengthn_fields:- the input field names β
in_fields - the gain factors β
morcm - the offset terms β
borcb
- the input field names β
gd_alter_polynom()andgd_alter_cpolynom()take an array of lengthpoly_ord + 1containing the polynomial co-efficients βaorca
π "no change" magic values
some field parameters have special values that mean "bestie do NOT touch this parameter". these are them, and you will memorize them:
NULLβ any of the string parameters, alsom,b,a,cm,cb, orca0βspf,n_fields,numbits,cdividend,dividend, orarray_len-1βbitnumorperiodGD_NULLβdata_typeorconst_typeGD_WINDOP_UNKβwindop
π¨ literal parameters only, bestie
All field parameters introduced with this interface must contain literal parameters. Field parameters which are scalar fields cannot be introduced with these functions. To do that, use gd_alter_entry(3), gd_alter_spec(3) or gd_malter_spec(3), as appropriate. periodt.
π₯ the rename_table / recode behaviour
- If
rename_tableis non-zero, the look-up table referenced by the LINTERP field will be renamed to the path given bytable. - If
recodeis non-zero, the binary file associated with the RAW field will be re-encoded to reflect the new field parameters. in that case, the field's I/O pointer gets reset to the beginning-of-frame.
π«Ά growing arrays (read this before you get confused)
If gd_alter_carray() is used to increase the length of a CARRAY field, the added elements will be uninitialised. use gd_put_carray_slice(3) or equivalent to initialise them, mkay? π
Similarly, increasing the length of a SARRAY with gd_alter_sarray() will set the added elements to the empty string (""). use gd_put_sarray_slice(3) or equivalent to modify them.
heads up: see NOTES below for info on usinggd_alter_clincom(),gd_alter_crecip(), andgd_alter_cpolynom()in the C89 GetData API. it's a whole thing and we get to it in a sec πΈ
β RETURN VALUE β
On success, these functions return zero π. On error, a negative-valued error code is returned π. the possible error codes are:
GD_E_ACCMODEβ the specified dirfile was opened read-only.GD_E_ALLOCβ the library was unable to allocate memory.GD_E_BAD_CODEβ the field specified byfield_codewas not found, or a supplied field code did not contain the appropriate prefix or suffix.GD_E_BAD_DIRFILEβ the supplied dirfile was invalid.GD_E_BAD_ENTRYβ one or more of the field parameters specified was invalid.GD_E_BAD_FIELD_TYPEβ the field specified byfield_codewas of the wrong type for the function called.GD_E_BAD_TYPEβ thedata_type/const_typeargument was invalid.GD_E_IOβ an I/O error occurred while translating the binary file associated with a modified RAW field, or an I/O error occurred while attempting to rename a LINTERP table file.GD_E_PROTECTEDβ the metadata of the fragment was protected from change. Or, a request to translate the binary file associated with a RAW field was attempted, but the data of the fragment was protected.GD_E_UNKNOWN_ENCODINGβ the encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to translate the binary file be associated with a modified RAW field.GD_E_UNSUPPORTEDβ the encoding scheme of the indicated format specification fragment does not support translating the binary file associated with a modified RAW field.
The error code is also stored in the DIRFILE object and may be retrieved after these functions return by calling gd_error(3). A descriptive error string for the error may be obtained by calling gd_error_string(3). π«Ά
π NOTES π
okay so here's the C89 GetData API tea. it provides different prototypes for gd_alter_clincom(), gd_alter_cpolynom(), and gd_alter_crecip():
#define GD_C89_API
#include <getdata.h>
int gd_alter_clincom(DIRFILE *dirfile, const char *field_code, int
n_fields, const char **in_fields, const double *cm, const double
*cb);
int gd_alter_cpolynom(DIRFILE *dirfile, const char *field_code, int
poly_ord, const char *in_fields, const double *ca);
int gd_alter_crecip(DIRFILE *dirfile, const char *field_code, const char
*in_field, const double cdividend[2]);
In this case, the array pointers passed as cm, cb or ca should have twice as many (purely real) elements, consisting of alternating real and imaginary parts for the complex data. That is, for example, ca[0] should be the real part of the first co-efficient, ca[1] the imaginary part of the first co-efficient, ca[2] the real part of the second co-efficient, ca[3] the imaginary part of the second co-efficient, and so on. β¨
Similarly, the cdividend parameter becomes a double precision array of length two.
For gd_alter_clincom() and gd_alter_cpolynom(), these are simply different (but equivalent) declarations of the C99 function entry point. For gd_alter_crecip(), however, a different entry point is needed (since the cdividend parameter is passed by reference instead of by value).
In the interests of portability, the C89 version of gd_alter_crecip() is always available, and may be accessed as gd_alter_crecip89(), with the C89 prototype, in both the C99 and C89 APIs. π
Passing NULL as cdividend is equivalent to specifying a dividend of zero: it indicates no change to the dividend parameter.
β¦and that's part 1, bestie!! more is coming, don't you dare close the tab πβ¨
β¨ HISTORY β¨ (aka the lore drop π«Ά)
okay bestie, gather round, we're doing a little origin story π
- The functions
dirfile_alter_bit(),dirfile_alter_const(),dirfile_alter_lincom(),dirfile_alter_linterp(),dirfile_alter_multiply(),dirfile_alter_phase(), anddirfile_alter_raw()appeared in GetData-0.5.0. the OGs fr fr π - The functions
dirfile_alter_clincom(),dirfile_alter_cpolynom(),dirfile_alter_polynom(), anddirfile_alter_sbit()appeared in GetData-0.6.0. glow up era β¨ - In GetData-0.7.0, the functions were renamed to
gd_alter_bit(),gd_alter_clincom(),gd_alter_const(),gd_alter_cpolynom(),gd_alter_lincom(),gd_alter_linterp(),gd_alter_multiply(),gd_alter_phase(),gd_alter_polynom(),gd_alter_raw(), andgd_alter_sbit(). literally the wholedirfile_β‘οΈgd_rebrand, main character energy π The functionsgd_alter_carray(),gd_alter_crecip(),gd_alter_crecip89(),gd_alter_divide(), andgd_alter_recip()also appeared in this version. not them debuting mid-rebrand π - The functions
gd_alter_mplex()andgd_alter_window()appeared in GetData-0.8.0. slay πΈ - In GetData-0.10.0, the error return from these functions changed from
-1to a negative-valued error code. > heads up bestie: if you were out here checking for exactly-1, that vibe check is over β it's a negative-valued error code now. π The functionsgd_alter_indir(),gd_alter_sarray(), andgd_alter_sindir()also appeared in this version. iconic behavior π
π SEE ALSO π
go read these next, i'm obsessed with them actually π¦
gd_alter_entry(3)gd_alter_spec(3)gd_error(3)gd_error_string(3)gd_malter_spec(3)gd_metaflush(3)gd_open(3)gd_put_carray_slice(3)gd_put_sarray_slice(3)dirfile-format(5)
and that's the whole page bestie, we made it π₯Ήπ this was Version 0.10.0, dated 25 December 2016, and it lives at gd_alter_bit(3) β merry christmas to whoever wrote it that day, no cap πβ¨ mwah, go alter some bits π
π«Ά
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms