gimme-alpha 0.1

nextnano_wavefunction_conversion.h File Reference

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

Go to the source code of this file.

Functions

struct mstar_wavefunction_1dconvert_nextnano_mstar_wavefunction_to_general_1d (GList *wf, const char *xtitle, const char *real_title, const char *imaginary_title, const char *title_terminator, unsigned short int eigval)

Function Documentation

struct mstar_wavefunction_1d* convert_nextnano_mstar_wavefunction_to_general_1d ( GList *  wf,
const char *  xtitle,
const char *  real_title,
const char *  imaginary_title,
const char *  title_terminator,
unsigned short int  eigval 
) [read]

Definition at line 73 of file nextnano_wavefunction_conversion.c.

References approx_coordinate_density_sorter(), mstar_wavefunction_1d_free(), mstar_wavefunction_1d_new(), NEXTNANO_FIELD_TITLE_BUFFER_LEN, mstar_wavefunction_1d::points, and unlikely.

Referenced by read_effectivemass_complex_wavefunction2().

                                                                                                                                                                                                                             {
  char rtitle[NEXTNANO_FIELD_TITLE_BUFFER_LEN];
  char ititle[NEXTNANO_FIELD_TITLE_BUFFER_LEN];
  snprintf(rtitle, NEXTNANO_FIELD_TITLE_BUFFER_LEN, "%s%03d%s", real_title, eigval, title_terminator);
  rtitle[NEXTNANO_FIELD_TITLE_BUFFER_LEN-1]='\0';
  snprintf(ititle, NEXTNANO_FIELD_TITLE_BUFFER_LEN, "%s%03d%s", imaginary_title, eigval, title_terminator);
  ititle[NEXTNANO_FIELD_TITLE_BUFFER_LEN-1]='\0';
  struct mstar_wavefunction_1d* wavefunc;
  if(unlikely((wavefunc = mstar_wavefunction_1d_new(g_list_length(wf))) == NULL)) {
    return NULL;
  }
  register int i;
  GList *l;
  double *v;
  /*We make a copy because we don't want to modify the calling wavefuntion.*/
  GList *m = g_list_sort(g_list_copy(wf), approx_coordinate_density_sorter);
  for(i=0, l=g_list_first(m); l != NULL; i++, l=g_list_next(l)) {
    if(unlikely((v = g_hash_table_lookup((GHashTable*)(l->data), xtitle)) == NULL)) {
      fprintf(stderr, "convert_netnano_mstar_wavefunction_to_general_1d: INTERNAL ERROR: a wavefunction's x coordinate (i=%d; title=\"%s\") was NULL!\n", i, xtitle);
      g_list_free(m);
      mstar_wavefunction_1d_free(wavefunc);
      return NULL;
    }
    ((wavefunc->points)[i]).x = *v;
    if(unlikely((v = g_hash_table_lookup((GHashTable*)(l->data), rtitle)) == NULL)) {
      fprintf(stderr, "convert_netnano_mstar_wavefunction_to_general_1d: INTERNAL ERROR: a wavefunction's real value (i=%d; title=\"%s\") was NULL!\n", i, rtitle);
      g_list_free(m);
      mstar_wavefunction_1d_free(wavefunc);
      return NULL;
    }
    ((wavefunc->points)[i]).re = *v;
    if(unlikely((v = g_hash_table_lookup((GHashTable*)(l->data), ititle)) == NULL)) {
      fprintf(stderr, "convert_netnano_mstar_wavefunction_to_general_1d: INTERNAL ERROR: a wavefunction's imaginary value (i=%d; title=\"%s\") was NULL!\n", i, ititle);
      g_list_free(m);
      mstar_wavefunction_1d_free(wavefunc);
      return NULL;
    }
    ((wavefunc->points)[i]).im = *v;
  }
  g_list_free(g_list_first(m));
  return wavefunc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

 All Classes Files Functions Variables Enumerations Enumerator Defines