.\" gd_madd_bit.3. The gd_madd_bit man page. .\" .\" Copyright (C) 2008, 2009, 2010, 2012, 2013 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_madd_bit 3 "30 September 2013" "Version 0.9.0" "GETDATA" .SH NAME gd_madd_bit, gd_madd_carray, gd_madd_clincom, gd_madd_const, gd_madd_cpolynom, gd_madd_crecip, gd_madd_divide, gd_madd_lincom, gd_madd_linterp, gd_madd_multiply, gd_madd_phase, gd_madd_polynom, gd_madd_recip, gd_madd_sbit, gd_madd_string \(em add a field to a dirfile .SH SYNOPSIS .B #include .HP .nh .ad l .BI "int gd_madd_bit(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "const char *" in_field ", int " bitnum ", int " numbits ); .HP .BI "int gd_madd_carray(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "gd_type_t " const_type ", size_t " array_len ", gd_type_t " data_type , .BI "void *" value ); .HP .BI "int gd_madd_clincom(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", int " n_fields ", const char **" in_fields , .BI "const double complex *" cm ", const double complex *" cb ); .HP .BI "int gd_madd_const(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "gd_type_t " const_type ", gd_type_t " data_type ", void *" value ); .HP .BI "int gd_madd_cpolynom(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", int " poly_ord ", const char *" in_field , .BI "const double complex *" ca ); .HP .BI "int gd_madd_crecip(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", const char *" in_field , .BI "double complex " cdividend ", int " fragment_index ); .HP .BI "int gd_madd_divide(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI " const char *" in_field1 ", const char *" in_field2 ); .HP .BI "int gd_madd_lincom(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", int " n_fields ", const char **" in_fields , .BI "const double *" m ", const double *" b ); .HP .BI "int gd_madd_linterp(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "const char *" in_field ", const char *" table ); .HP .BI "int gd_madd_mplex(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "const char *" in_field ", const char *" count_field , .BI "int " count_val ", int " period ); .HP .BI "int gd_madd_multiply(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI " const char *" in_field1 ", const char *" in_field2 ); .HP .BI "int gd_madd_polynom(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", int " poly_ord ", const char *" in_field , .BI "const double *" a ); .HP .BI "int gd_madd_phase(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "const char *" in_field ", gd_shift_t " shift ); .HP .BI "int gd_madd_recip(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", const char *" in_field , .BI "double " dividend ", int " fragment_index ); .HP .BI "int gd_madd_sbit(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "const char *" in_field ", int " bitnum ", int " numbits ); .HP .BI "int gd_madd_string(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", const char *" value ); .HP .BI "int gd_madd_window(DIRFILE *" dirfile , .BI "const char *" parent ", const char *" field_name , .BI "const char *" in_field ", const char *" check_field ", gd_windop_t" .IB windop ", gd_triplet_t " threshold ); .hy .ad n .SH DESCRIPTION These functions add a new metafield of the indicated type under the parent field given by .I parent in the dirfile specified by .IR dirfile . .PP In all of these calls, .I field_name indicates the name of the field to be added. It should not be the full .IB / field code. The meaning and valid types of other arguments may be obtained from the .BR gd_entry (3) and .BR dirfile-format (5) manual pages. The .BR gd_madd_clincom () and .BR gd_madd_cpolynom () functions are identical to .BR gd_madd_lincom () and .BR gd_madd_polynom (), except they take complex scalar parameters, instead of purely real values. The .BR gd_madd_lincom () and .BR gd_madd_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_madd_polynom () and .BR gd_madd_cpolynom () take an array of length .I poly_ord + 1 containing the polynomial co-efficients .RI ( a " or " ca ). The .BR gd_madd_string (),\~ gd_madd_carray , and .BR gd_madd_const () functions both add the field and set the value of the field to .IR value . For .BR gd_madd_const () and .BR gd_madd_carray (), the .I const_type argument specifies the storage type for the const, while .I data_type specifies the data type of the value pointed to by .IR value . 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. .PP All fields added with this interface must contain numerical parameters. Fields with scalar fields as parameters cannot be added with these functions. Those fields must be added with .BR gd_madd (3) or .BR gd_madd_spec (3). See .BR gd_add_bit (3), &c. for an alternate way of adding metafields with explicit parameters. See .B NOTES below for information on using .BR gd_madd_clincom "(), " gd_madd_cpolynom (), and .BR gd_madd_crecip () 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 .IR field_name argument contained invalid characters. Alternately, the .I parent field code was not found, or was already a metafield. .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_TYPE The .IR data_type " or " const_type argument provided to .BR gd_madd_const () or .BR gd_madd_carray () was invalid. .TP .B GD_E_DUPLICATE The .IR field_name provided duplicated that of an already existing field. .TP .B GD_E_PROTECTED The metadata of the fragment was protected from change. .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_madd_clincom (),\~ gd_madd_cpolynom (), and .BR gd_madd_crecip (): .PP .B #define GD_C89_API .br .B #include .HP .nh .ad l .BI "int gd_madd_clincom(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", int " n_fields ", const char **" in_fields , .BI "const double *" cm ", const double *" cb ); .HP .BI "int gd_madd_cpolynom(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", int " poly_ord ", const char *" in_field , .BI "const double *" ca ); .HP .BI "int gd_madd_crecip(DIRFILE *" dirfile ", const char *" parent , .BI "const char *" field_name ", const char *" in_field , .BI "double " cdividend\fR[2] ", int " fragment_index ); .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_madd_clincom () and .BR gd_madd_cpolynom (), these are simply different (but equivalent) declarations of the C99 function entry point. For .BR gd_madd_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_madd_crecip () is always available, and may be accessed as .BR gd_madd_crecip89 (), with the C89 prototype, in both the C99 and C89 APIs. .SH SEE ALSO .BR gd_add_bit (3), .BR gd_add_const (3), .BR gd_add_divide (3), .BR gd_add_lincom (3), .BR gd_add_linterp (3), .BR gd_add_mplex (3), .BR gd_add_multiply (3), .BR gd_add_phase (3), .BR gd_add_polynom (3), .BR gd_add_recip (3), .BR gd_add_string (3), .BR gd_add_windop (3), .BR gd_entry (3), .BR gd_error (3), .BR gd_error_string (3), .BR gd_madd (3), .BR gd_madd_spec (3), .BR gd_metaflush (3), .BR gd_open (3), .BR dirfile-format (5)