gimme-alpha 0.1

read_nextnano_8x8kp_output.h File Reference

#include <glib.h>
#include <gio/gio.h>
Include dependency graph for read_nextnano_8x8kp_output.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

GList * read_nextnano_8x8kp_get_eigfunc (GFile *base, GHashTable *input, int num, GList **titles)
GList * read_nextnano_8x8kp_get_eigvals (GFile *base, GHashTable *input)

Function Documentation

GList* read_nextnano_8x8kp_get_eigfunc ( GFile *  base,
GHashTable *  input,
int  num,
GList **  titles 
)

Definition at line 36 of file read_nextnano_8x8kp_output.c.

References DOUBLE_TYPE, read_nextnano_8x8kp_get_filename(), read_nextnano_extract_item(), and read_titled_whitespaced_data().

                                                                                                {
  int err;
  char *kpdir_s = read_nextnano_extract_item(input, "output-kp-data", 0, "destination-directory", &err);
  if(err != 0) {
    fprintf(stderr, "Error extracting item from nextnano input.\n");
    return NULL;
  }
  GFile *kpdir = g_file_get_child(base, kpdir_s);
  char eigfunc_file[1024] = {'\0'};
  read_nextnano_8x8kp_get_filename(eigfunc_file, 1024, 8, 1, 1, num, 1, 1, 1, 1);
  //fprintf(stderr, "got eigenfunction file of %s\n", eigfunc_file);
  GFile *eigfunc_f = g_file_get_child(kpdir, eigfunc_file);
  GError *err_func;
  GFileInputStream *eigfunc_stream = g_file_read(eigfunc_f, NULL, &err_func);
  if(eigfunc_stream == NULL) {
    fprintf(stderr, "failed top open the eigenfunction file (%s): eigfunc error was %s\n", eigfunc_file, err_func->message);
    g_object_unref(kpdir);
    g_object_unref(eigfunc_f);
    return NULL;
  }
  *titles = NULL;
  GList *eigfunc = read_titled_whitespaced_data(G_INPUT_STREAM(eigfunc_stream), &err_func, titles, '!', DOUBLE_TYPE);
  /*free the data structures*/
  g_object_unref(kpdir);
  g_object_unref(eigfunc_f);
  g_object_unref(eigfunc_stream);
  return eigfunc;
}

Here is the call graph for this function:

GList* read_nextnano_8x8kp_get_eigvals ( GFile *  base,
GHashTable *  input 
)

Definition at line 66 of file read_nextnano_8x8kp_output.c.

References DOUBLE_TYPE, read_nextnano_8x8kp_get_eigvals_filename(), read_nextnano_extract_item(), and read_titled_whitespaced_data().

                                                                       {
  int err;
  char *kpdir_s = read_nextnano_extract_item(input, "output-kp-data", 0, "destination-directory", &err);
  if(err != 0) {
    fprintf(stderr, "Error extracting item from nextnano input.\n");
    return NULL;
  }
  GFile *kpdir = g_file_get_child(base, kpdir_s);
  char eigval_file[1024] = {'\0'};
  read_nextnano_8x8kp_get_eigvals_filename(eigval_file, 1024, 8, 1, 1, 1, 1);
  GFile *eigval_f = g_file_get_child(kpdir, eigval_file);
  GError *err_val;
  GFileInputStream *eigval_stream = g_file_read(eigval_f, NULL, &err_val);
  if(eigval_stream==NULL) {
    fprintf(stderr, "failed to open the eigvalues stream (file %s): err was %s\n", eigval_file, err_val->message);
    return NULL;
  }
  GList *eigval_titles = g_list_append(NULL, "num");
  eigval_titles = g_list_append(eigval_titles, "value");
  GList *eigvals = read_titled_whitespaced_data(G_INPUT_STREAM(eigval_stream), &err_val, &eigval_titles, '!', DOUBLE_TYPE);
  /*Re-purpose the list so that it's a list of values.*/
  GList *l;
  GHashTable *t;
  double *v;
  for(l=g_list_first(eigvals); l != NULL; l = g_list_next(l)) {
    t = l->data;
    fprintf(stderr, " key=%g value=%g\n", *((double*)g_hash_table_lookup(t, "num")), *((double*)g_hash_table_lookup(t, "value")));
    v = g_hash_table_lookup(t, "value");
    l->data = malloc(sizeof(double));
    *(double*)(l->data) = *(double*)v;
    g_hash_table_unref(t);
  }
  /*Free our datastructures.*/
  g_list_free(eigval_titles);
  g_object_unref(kpdir);
  g_object_unref(eigval_f);
  g_object_unref(eigval_stream);
  return eigvals;
}

Here is the call graph for this function:

 All Classes Files Functions Variables Enumerations Enumerator Defines