.\" gd_alter_bit.3. The gd_alter_bit man page. .\" .\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" .\" This file is part of the GetData project. .\" .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.2 or .\" any later version published by the Free Software Foundation; with no .\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" .TH gd_alter_bit 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_bit, gd_alter_carray, gd_alter_clincom, gd_alter_const, gd_alter_cpolynom, gd_alter_crecip, gd_alter_divide, gd_alter_lincom, gd_alter_linterp, gd_alter_multiply, gd_alter_phase, gd_alter_polynom, gd_alter_raw, gd_alter_recip, gd_alter_sbit \(em modify a field in a dirfile .SH SYNOPSIS .B #include .HP .nh .ad l .BI "int gd_alter_bit(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", int " bitnum ", int " numbits ); .HP .BI "int gd_alter_carray(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " const_type ", size_t " array_len ); .HP .BI "int gd_alter_clincom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " n_fields ", const char **" in_fields ", const double complex *" cm , .BI "const double complex *" cb ); .HP .BI "int gd_alter_const(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " const_type ); .HP .BI "int gd_alter_cpolynom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " poly_ord ", const char *" in_field ", const double complex *" ca ); .HP .BI "int gd_alter_crecip(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", complex double " cdividend ); .HP .BI "int gd_alter_divide(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field1 ", const char *" in_field2 ); .HP .BI "int gd_alter_lincom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " n_fields ", const char **" in_fields ", const double *" m , .BI "const double *" b ); .HP .BI "int gd_alter_linterp(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", const char *" table ", int " rename_table ); .HP .BI "int gd_alter_mplex(DIRFILE *" dirfile ", const char *" field_name , .BI "const char *" in_field ", const char *" count_field , .BI "int " count_val ", int " period ); .HP .BI "int gd_alter_multiply(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field1 ", const char *" in_field2 ); .HP .BI "int gd_alter_phase(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", gd_shift_t " shift ); .HP .BI "int gd_alter_polynom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " poly_ord ", const char *" in_field ", const double *" ca ); .HP .BI "int gd_alter_raw(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " data_type ", unsigned int " spf ", int " recode ); .HP .BI "int gd_alter_recip(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", double " dividend ); .HP .BI "int gd_alter_sbit(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", int " bitnum ", int " numbits ); .HP .BI "int gd_alter_window(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", const char *" check_field , .BI "gd_windop_t " windop ", gd_triplet_t " threshold ); .hy .ad n .SH DESCRIPTION These functions provide alternatives to using the .BR gd_alter_entry (3) function to modify a field of the indicated type in the dirfile specified by .IR dirfile . .PP In all of these calls, .I field_code indicates the the field to be modified, which may be a regular field, or a metafield specified by its full (slashed) field code, but should not contain a representation suffix. The meaning and valid types of other arguments may be obtained from the .BR get_entry (3) and .BR dirfile-format (5) manual pages. The .B gd_shift_t type is a signed 64-bit integer type. The .B gd_triplet_t type is defined as: .PP .in +4n .nf .fam C typedef union { gd_int64_t i; gd_uint64_t u; double r; } gd_triplet_t; .fam .fi .in .PP Which element of this .B gd_triplet_t union to set depends on the operator selected for the .B WINDOW field. See .BR gd_entry (3) for details. The .BR gd_alter_clincom () and .BR gd_alter_cpolynom () functions are identical to .BR gd_alter_lincom () and .BR gd_alter_polynom (), except they take complex scalar parameters, instead of purely real values. This only matters for the input of .I new parameters; if the scalar parameters are not changed (by passing NULL instead of a list of scalars), the functions can be used interchangeably, regardless of whether the altered field has complex scalar parameters or not. If the corresponding parameters are to be changed, the .BR gd_alter_lincom () and .BR gd_alter_clincom () functions take pointers to three arrays of length .I n_fields containing the input field names .RI ( in_fields ), the gain factors .RI ( m " or " cm ), and the offset terms .RI ( b " or " cb ). Similarly, .BR gd_alter_polynom () and .BR gd_alter_cpolynom () take an array of length .I poly_ord + 1 containing the polynomial co-efficients .RI ( a " or " ca ). Some field parameters have special values which indicate no change should be made to the parameter. These special values are: .TP .B NULL\fR: any of the string parameters, also .IR m ", " b ", " a ", " cm ", " cb ", or " ca ; .TP .B 0\fR: .IR spf ", " n_fields ", " numbits ", " cdividend ", " dividend ", or " array_len ; .TP .B -1\fR: .IR bitnum " or " period ; .TP .B GD_NULL\fR: .IR data_type " or " const_type ; .TP .B GD_WINDOP_UNK\fR: .IR windop . .PP 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 .BR gd_alter_entry (3), .BR gd_alter_spec (3) or .BR gd_malter_spec (3), as appropriate. If .I rename_table is non-zero, the look-up table referenced by the .B LINTERP field will be renamed to the path given by .IR table . If .I recode is non-zero, the binary file associated with the .B RAW field will be re-encoded to reflect the new field parameters. In this case, the field's I/O pointer will be reset to the beginning-of-frame. If .BR gd_alter_carray () is used to increase the length of a .B CARRAY field, the added elements will be uninitialised. Use .BR gd_put_carray_slice (3) or equivalent to initialise them. See .B NOTES below for information on using .BR gd_alter_clincom "(), " gd_alter_crecip (), and .BR gd_alter_cpolynom () in the C89 GetData API. .SH RETURN VALUE On success, any of these functions returns zero. On error, -1 is returned and the dirfile error is set to a non-zero error value. Possible error values are: .TP 8 .B GD_E_ACCMODE The specified dirfile was opened read-only. .TP .B GD_E_ALLOC The library was unable to allocate memory. .TP .B GD_E_BAD_CODE The field specified by .I field_code was not found, or a supplied field code did not contain the appropriate prefix or suffix. .TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP .B GD_E_BAD_ENTRY One or more of the field parameters specified was invalid. .TP .B GD_E_BAD_FIELD_TYPE The field specified by .I field_code was of the wrong type for the function called. .TP .B GD_E_BAD_TYPE The .IR data_type " or " const_type argument was invalid. .TP .B GD_E_IO An I/O error occurred while translating the binary file associated with a modified .B RAW field, or an I/O error occurred while attempting to rename a .B LINTERP table file. .TP .B GD_E_PROTECTED The metadata of the fragment was protected from change. Or, a request to translate the binary file associated with a .B RAW field was attempted, but the data of the fragment was protected. .TP .B 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 .B RAW field. .TP .B GD_E_UNSUPPORTED The encoding scheme of the indicated format specification fragment does not support translating the binary file associated with a modified .B RAW field. .PP The dirfile error may be retrieved by calling .BR gd_error (3). A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). .SH NOTES The C89 GetData API provides different prototypes for .BR gd_alter_clincom "(), " gd_alter_cpolynom (), and .BR gd_alter_crecip (): .PP .nf .B #define GD_C89_API .br .B #include .fi .HP .nh .ad l .BI "int gd_alter_clincom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " n_fields ", const char **" in_fields ", const double *" cm , .BI "const double *" cb ); .HP .BI "int gd_alter_cpolynom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " poly_ord ", const char *" in_fields ", const double *" ca ); .HP .BI "int gd_alter_crecip(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", const double " cdividend\fR[2] ); .hy .ad n .PP In this case, the array pointers passed as .IR cm ", " cb or .IR ca should have twice as many (purely real) elements, consisting of alternating real and imaginary parts for the complex data. That is, for example, .IR ca [0] should be the real part of the first co-efficient, .IR ca [1] the imaginary part of the first co-efficient, .IR ca [2] the real part of the second co-efficient, .IR ca [3] the imaginary part of the second co-efficient, and so on. Similarly, the .I cdividend parameter becomes a double precision array of length two. .PP For .BR gd_alter_clincom () and .BR gd_alter_cpolynom (), these are simply different (but equivalent) declarations of the C99 function entry point. For .BR gd_alter_crecip (), however, a different entry point is needed (since the .I cdividend parameter is passed by reference instead of by value). In the interests of portability, the C89 version of .BR gd_alter_crecip () is always available, and may be accessed as .BR gd_alter_crecip89 (), with the C89 prototype, in both the C99 and C89 APIs. Passing NULL as .I cdividend is equivalent to specifying a dividend of zero: it indicates no change to the dividend parameter. .SH SEE ALSO .BR gd_alter_entry (3), .BR gd_alter_spec (3), .BR gd_error (3), .BR gd_error_string (3), .BR gd_malter_spec (3), .BR gd_metaflush (3), .BR gd_open (3), .BR gd_put_carray_slice (3), .BR dirfile-format (5)