00001
00002
00003
00004
00005 #ifndef UTILS_H
00006 #define UTILS_H
00007
00008 #include <iostream>
00009 #include <iomanip>
00010 #include <fstream>
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <math.h>
00014 #include <cstdlib>
00015 #include <ctime>
00016 #include <sys/time.h>
00017
00018 #include "constants.h"
00019
00020 using namespace std;
00021
00022 void trans(double* A, double* B, int m, int n);
00023 int Diagonalize(double* A, double* eigen, int size);
00024 int SVD(double* A, double* Ut, double* eigen, int size1, int size2);
00025 int Invert(double* A, int m);
00026
00027 int mat_root(double* A, int size);
00028 int mat_root_inv(double* A, int size);
00029
00030 int mat_times_mat(double* C, double* A, double* B, int size);
00031 int mat_times_mat_bt(double* C, double* A, double* B, int size);
00032 int mat_times_mat_at_bt(double* C, double* A, double* B, int size);
00033 int mat_times_mat(double* C, double* A, double* B, int N, int M, int K);
00034 int mat_times_mat_bt(double* C, double* A, double* B, int N, int M, int K);
00035
00036 int sign(double x);
00037 void cross(double* x, double* r1, double* r2);
00038 int close_val(double x1, double x2, double diff);
00039 int check_array(int size, double* A);
00040
00041 namespace Utils
00042 {
00043
00044 void normalize_string_step_direc(double** a, int nstring, int LEN);
00045
00046 double step_direc_overlap(double** a, double** b, int nstring, int LEN);
00047
00048 void display_matrix(double** a, int LEN);
00049
00050 void eigen_decomp(double** mat, double** evecs, double* evals, int n);
00051
00052 void matrix_times_matrix(double** A, double** B, double** C, int LEN);
00053
00054 void display_structure_nonames(double* a, int natoms);
00055 void display_structure(double* a, int natoms, string* anames);
00056
00057 void jacobi(float **a, int n, float d[], float **v, int *nrot);
00058 void eigsrt(float d[], float **v, int n);
00059
00060 void S_straight_line_in_angs(double** string_angs, double* S, int nstring, int natoms);
00061
00062 void subtract_arrays(double* a, double* b, double* diff, int LEN);
00063
00064 void vector_outer_prod(double* vec1, double* vec2, int LEN, double** output);
00065 void copy_2D_array(double** pointer1, double** pointer2, int LEN1, int LEN2);
00066
00067 void copy_structure(double* structure1, double* structure2, int natoms);
00068 void alloc_dpointer_1D(double* pointer_name, int LEN);
00069 void alloc_dpointer_2D(double** pointer_name, int LEN1, int LEN2);
00070 void alloc_dpointer_3D(double*** pointer_name, int LEN1, int LEN2, int LEN3);
00071
00072 void get_rotation_matrix(double** rotMat, double* thetas);
00073 void Rotate_structure(double** RotMat, double* structure, int natoms);
00074 void Rotate_hessian(double** Rot_mat, double** hessian, int natoms);
00075
00076 void Rot_around_vec(double* vec, double* structure, int natoms);
00077
00078 void mwc_to_ang(double** angs, double** mwc, int nstring, int natoms, double* amasses);
00079 void mwc_to_ang(double* angs, double* mwc, int natoms, double* amasses);
00080 void ang_to_mwc(double** mwc, double** ang, int nstring, int natoms, double* amasses);
00081 void ang_to_mwc(double* mwc, double* ang, int natoms, double* amasses);
00082
00083 void mwcgrad_to_anggrad(double** ang_grad, double** mwc_grad, int nstring, int natoms, double* amasses);
00084 void mwcgrad_to_anggrad(double* ang_grad, double* mwc_grad, int natoms, double* amasses);
00085 void anggrad_to_mwcgrad(double** mwc_grad, double** ang_grad, int nstring, int natoms, double* amasses);
00086 void anggrad_to_mwcgrad(double* mwc_grad, double* ang_grad, int natoms, double* amasses);
00087 void diagonalize3x3(double** hmwc, double** smwc,
00088 double* w2, int ndiag);
00089
00090 void projectfrommatrix3x3(double* vector, double** hmwc);
00091 double randomf(double a, double b);
00092
00093 void Mat_times_vec(double** d2S_1, double* dS, double* prod, int LEN);
00094 void normalize(double* u, int LEN);
00095 void invertNxN(double** Mat, double** Inverse, int n);
00096 void ludcmp(double **a, int n, int *indx, double *d);
00097 void lubksb(double **a, int n, int *indx, double b[]);
00098
00099
00100 double det3x3(double A[1+3][1+3]);
00101 void adjoint3x3(double A[4][4], double Aadj[4][4]);
00102 double det2x2(double A[3][3]);
00103 void gramschmidt(int LEN, double* v_out, double* u_in, double* v_in);
00104 void splineTangents(int LEN, double* x, double* y, double* y2, double* y1);
00105 void getSpline(int LEN, double* x, double* y, double* y2);
00106 double evalSpline(int LEN, double x, double* xa, double* ya, double* y2a);
00107 void S_from_angs(double** angs, double* S, double* masses, int LEN, int natoms);
00108 void Rmat_from_lincart(double** r, double* xyz, int natoms);
00109 void normalize_S(double* normalized_s, double* S, int LEN);
00110 void angs_to_mwcs(double** temparray, int nn, int natoms, double* amasses);
00111 void anggrads_to_mwcgrads(double** temparray, int nn, int natoms, double* amasses);
00112 double dotProd(double* v, double* u, int LEN);
00113 double vecMag(double* u, int LEN);
00114
00115 void generate_Project_RT_tan(double** Proj, double* structure, double* tangent);
00116 void generate_Project_RT(double** Proj, double* structure);
00117
00118
00119 };
00120
00121 #endif
00122
00123
00124
00125