-
Notifications
You must be signed in to change notification settings - Fork 1
/
Utils.h
62 lines (44 loc) · 2.25 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** ***************************************************** **/
/** ** Phonon Vibration Analysis ** **/
/** **/
/** ** Version 2 ** **/
/** **/
/** By: Pedro Brandimarte ([email protected]) and **/
/** Alexandre Reily Rocha ([email protected]) **/
/** **/
/** ***************************************************** **/
/** Interface for some math-physics definitions and **/
/** matrix (vector) algebra utilities. **/
/** ***************************************************** **/
/** ******************** Definitions ******************** **/
/* Constants (from CODATA - 2012). */
#define hbar 6.58211928e-16 /* eV*s */
#define amu2kg 1.660538921e-27 /* kg */
#define eV2joule 1.602176565e-19 /* eV -> joule */
#define bohr2ang 0.52917721092 /* angstrom */
#define rydberg2eV 13.60569253 /* Ry*hc -> eV */
/* C matrix indexation (row-major order) */
/* #define idx(i, j, ncol) ((i) * (ncol) + j) */
/* Fortran matrix indexation (column-major order) */
#define idx(i, j, nrow) (i + (j) * (nrow))
#define idx3d(i, j, k, nrow, ncol) (i + (j) * (nrow) + (k) * (nrow) * (ncol))
/** *********************** Types *********************** **/
/* Complex number. */
typedef struct {
double re; /* real part */
double im; /* imaginary part */
} cdouble;
/** *********** Matrix and Vectors Utilities ************ **/
/* Allocates and initialize a vector 'V[n]' of integers. */
void *UTILintVector (int n);
/* Allocates and initializes a vector 'V[n]' of doubles. */
void *UTILdoubleVector (int n);
/* Resets a vector 'V[n]' of doubles with 0.0's. */
void UTILresetDoubleVector (int n, double *V);
/* Copies the elements form a vector 'Orig[n]' to 'Dest[n]'. */
void UTILcopyVector (double *Dest, double *Orig, int n);
/* Checks if the matrix 'M[n][n]' is symetric. */
void UTILcheckSym (char *name, double *M, int n, double lim);
/* Computes the Euclidean norm of a double precision vector 'V[n]'. */
double UTILnorm (int n, double *V);
/* ************************ Drafts ************************* */