GNU Astronomy Utilities List of double

Double precision floating point numbers can accurately store real number until 15.9 decimals and consume 8 bytes (64-bits) of memory, see Numeric data types. This level of precision makes them very good for serious processing in the middle of a program’s execution: in many cases, the propagation of errors will still be insignificant compared to actual observational errors in a data set. But since they consume 8 bytes and more CPU processing power, they are often not the best choice for storing and transferring of data.

Type (C struct): gal_list_f64_t

A single node in a list containing a 64-bit double precision double value: see Numeric data types.

typedef struct gal_list_f64_t
  double v;
  struct gal_list_f64_t *next;
} gal_list_f64_t;
gal_list_f64_add (gal_list_f64_t **list, double value)

Add a new node (containing value) to the top of the list of doubles and update list. Here is one short example of initializing and adding elements to a string list:

gal_list_f64_t *list=NULL;
gal_list_f64_add(&list, 3.8129395763193);
gal_list_f64_add(&list, 1.239378923931e-20);
gal_list_f64_pop (gal_list_f64_t **list)

Pop the top element of list and return the value. This function will also change list to point to the next node in the list. If *list==NULL, then this function will return GAL_BLANK_FLOAT64 (NaN, see Library blank values (blank.h)).

gal_list_f64_number (gal_list_f64_t *list)

Return the number of nodes in list.

gal_list_f64_last (gal_list_f64_t *list)

Return a pointer to the last node in list.

gal_list_f64_print (gal_list_f64_t *list)

Print the values within each node of *list on the standard output in the same order that they are stored. Each floating point number is printed on one line. This function is mainly good for checking/debugging your program. For program outputs, it is best to make your own implementation with a better, more user-friendly format. For example, in the following code snippet. You can also modify it to print all values in one line, etc., depending on the context of your program.

size_t i=0;
gal_list_f64_t *tmp;
for(tmp=list; tmp!=NULL; tmp=tmp->next)
  printf("Number %zu: %f\n", ++i, tmp->v);
gal_list_f64_reverse (gal_list_f64_t **list)

Reverse the order of the list such that the top node in the list before calling this function becomes the bottom node after it.

double *
gal_list_f64_to_array (gal_list_f64_t *list, int reverse, size_t *num)

Dynamically allocate an array and fill it with the values in list. The function will return a pointer to the allocated array and put the number of elements in the array into the num pointer. If reverse has a non-zero value, the array will be filled in the inverse of the order of elements in list. This function can be useful after you have finished reading an initially unknown number of values and want to put them in an array for easy random access.

gal_data_t *
gal_list_f64_to_data (gal_list_f64_t *list, uint8_t type, size_t minmapsize, int quietmmap)

Write the values in the given list into a gal_data_t dataset of the requested type. The order of the values in the dataset will be the same as the order from the top of the list.

gal_list_f64_free (gal_list_f64_t *list)

Free every node in list.