HΦ  3.2.0
eigenIO.c File Reference
#include "eigenIO.h"
+ Include dependency graph for eigenIO.c:

Go to the source code of this file.

Functions

int comp (const void *p, const void *q)
 
int OutputRealEigenValue (int xNsize, double *ene, char *filename)
 
int OutputCmpEigenValue (int xNsize, complex double *ene, char *filename)
 
int OutputRealEigenVec (int xNsize, const int nene, double **vec, const int nproc, char *filename)
 
int OutputCmpEigenVec (int xNsize, const int nene, complex double **vec, const int nproc, char *filename)
 
int InputRealEigenValue (int xNsize, double *ene, char *filename)
 
int InputCmpEigenValue (int xNsize, complex double *ene, char *filename)
 
int InputRealEigenVec (int xNsize, const int nene, double **vec, const int nproc, char *filename)
 
int InputCmpEigenVec (int xNsize, const int nene, complex double **vec, const int nproc, char *filename)
 

Function Documentation

◆ comp()

int comp ( const void *  p,
const void *  q 
)

Definition at line 19 of file eigenIO.c.

Referenced by OutputCmpEigenValue(), and OutputRealEigenValue().

19  {
20  if(*(double *)p > *(double *)q) return 1;
21  if(*(double *)p < *(double *)q) return -1;
22  return 0;
23 }
+ Here is the caller graph for this function:

◆ InputCmpEigenValue()

int InputCmpEigenValue ( int  xNsize,
complex double *  ene,
char *  filename 
)

Definition at line 118 of file eigenIO.c.

118  {
119  FILE *fp = NULL;
120  int i = 0;
121 
122  fp = fopen(filename, "rb+");
123  if(fp == NULL) {
124  return -1;
125  }
126 
127  fread(ene, sizeof(complex double), xNsize, fp);
128 
129  fclose(fp);
130 
131  return 0;
132 }

◆ InputCmpEigenVec()

int InputCmpEigenVec ( int  xNsize,
const int  nene,
complex double **  vec,
const int  nproc,
char *  filename 
)

Definition at line 149 of file eigenIO.c.

149  {
150  FILE *fp = NULL;
151 
152  fp = fopen(filename, "rb+");
153  if(fp == NULL) {
154  return -1;
155  }
156 
157  fread(vec[nene], sizeof(complex double), xNsize, fp);
158 
159  fclose(fp);
160 
161  return 0;
162 }
double complex ** vec
Definition: global.h:45

◆ InputRealEigenValue()

int InputRealEigenValue ( int  xNsize,
double *  ene,
char *  filename 
)

Definition at line 103 of file eigenIO.c.

103  {
104  FILE *fp = NULL;
105 
106  fp = fopen(filename, "rb+");
107  if(fp == NULL) {
108  return -1;
109  }
110 
111  fread(ene, sizeof(double), xNsize, fp);
112 
113  fclose(fp);
114 
115  return 0;
116 }

◆ InputRealEigenVec()

int InputRealEigenVec ( int  xNsize,
const int  nene,
double **  vec,
const int  nproc,
char *  filename 
)

Definition at line 134 of file eigenIO.c.

134  {
135  FILE *fp = NULL;
136 
137  fp = fopen(filename, "rb+");
138  if(fp == NULL) {
139  return -1;
140  }
141 
142  fread(vec[nene], sizeof(double), xNsize, fp);
143 
144  fclose(fp);
145 
146  return 0;
147 }
double complex ** vec
Definition: global.h:45

◆ OutputCmpEigenValue()

int OutputCmpEigenValue ( int  xNsize,
complex double *  ene,
char *  filename 
)

Definition at line 49 of file eigenIO.c.

References comp().

49  {
50  FILE *fp = NULL;
51  int i;
52  double *buffene = (double *) malloc(xNsize * sizeof(double));
53 
54  for(i = 0; i < xNsize; i++)
55  buffene[i] = creal(ene[i]);
56 
57  qsort(buffene, xNsize, sizeof(double), comp);
58 
59  fp = fopen(filename, "wb+");
60  if(fp == NULL) {
61  free(buffene);
62  return -1;
63  }
64 
65  fwrite(buffene, sizeof(double), xNsize, fp);
66 
67  fclose(fp);
68  free(buffene);
69 
70  return 0;
71 }
int comp(const void *p, const void *q)
Definition: eigenIO.c:19
+ Here is the call graph for this function:

◆ OutputCmpEigenVec()

int OutputCmpEigenVec ( int  xNsize,
const int  nene,
complex double **  vec,
const int  nproc,
char *  filename 
)

Definition at line 88 of file eigenIO.c.

88  {
89  FILE *fp = NULL;
90 
91  fp = fopen(filename, "wb+");
92  if(fp == NULL) {
93  return -1;
94  }
95 
96  fwrite(vec[nene], sizeof(complex double), xNsize, fp);
97 
98  fclose(fp);
99 
100  return 0;
101 }
double complex ** vec
Definition: global.h:45

◆ OutputRealEigenValue()

int OutputRealEigenValue ( int  xNsize,
double *  ene,
char *  filename 
)

Definition at line 25 of file eigenIO.c.

References comp().

25  {
26  FILE *fp = NULL;
27  int i;
28  double *buffene = (double *) malloc(xNsize * sizeof(double));
29 
30  for(i = 0; i < xNsize; i++)
31  buffene[i] = ene[i];
32 
33  qsort(buffene, xNsize, sizeof(double), comp);
34 
35  fp = fopen(filename, "wb+");
36  if(fp == NULL) {
37  free(buffene);
38  return -1;
39  }
40 
41  fwrite(buffene, sizeof(double), xNsize, fp);
42 
43  fclose(fp);
44  free(buffene);
45 
46  return 0;
47 }
int comp(const void *p, const void *q)
Definition: eigenIO.c:19
+ Here is the call graph for this function:

◆ OutputRealEigenVec()

int OutputRealEigenVec ( int  xNsize,
const int  nene,
double **  vec,
const int  nproc,
char *  filename 
)

Definition at line 73 of file eigenIO.c.

73  {
74  FILE *fp = NULL;
75 
76  fp = fopen(filename, "wb+");
77  if(fp == NULL) {
78  return -1;
79  }
80 
81  fwrite(vec[nene], sizeof(double), xNsize, fp);
82 
83  fclose(fp);
84 
85  return 0;
86 }
double complex ** vec
Definition: global.h:45