Psi4
linear_algebra.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
32 #ifndef _opt_linear_algebra_h_
33 #define _opt_linear_algebra_h_
34 
35 // C functions called by opt which use BLAS/LAPACK routines
36 extern "C" {
37 
38 // matrix multiplications
39 void opt_matrix_mult(double **A, bool tA, double **B, bool tB, double **C, bool tC,
40  int nr, int nl, int nc, bool add);
41 
42 // eigenvector/eigenvalues
43 bool opt_symm_matrix_eig(double **A, int dim, double *evals);
44 
45 bool opt_asymm_matrix_eig(double **A, int dim, double *evals);
46 
47 }
48 
49 namespace opt {
50 
51 // invert a symmetric matrix
52 double ** symm_matrix_inv(double **A, int dim, bool redundant=true);
53 
54 // allocate memory and return a copy of a matrix
55 double ** matrix_return_copy(double **A, int nr, int nc);
56 bool ** matrix_return_copy(bool **A, int nr, int nc);
57 
58 void matrix_copy(double **from, double **to, int nr, int nc);
59 
60 void array_copy(double *from, double *to, int n);
61 double array_dot(double *v1, double *v2, int n);
62 double array_norm(double *v1, int n);
63 void array_normalize(double *v1, int n);
64 void array_scm(double *v1, double a, int n);
65 double array_abs_max(double *v1, int n);
66 double array_max(double *v1, int n);
67 double array_rms(double *v1, int n);
68 // Compute matrix ^1/2 or ^-1/2 if inverse=true
69 void matrix_root(double **A, int dim, bool inverse);
70 
71 }
72 
73 #endif
double array_max(double *v1, int n)
Definition: linear_algebra.cc:325
void opt_matrix_mult(double **A, bool tA, double **B, bool tB, double **C, bool tC, int nr, int nl, int nc, bool add)
Definition: linear_algebra.cc:83
void matrix_copy(double **from, double **to, int nr, int nc)
Definition: linear_algebra.cc:290
double array_abs_max(double *v1, int n)
Definition: linear_algebra.cc:318
double ** matrix_return_copy(double **A, int nr, int nc)
Definition: linear_algebra.cc:266
bool opt_symm_matrix_eig(double **A, int dim, double *evals)
Definition: linear_algebra.cc:117
double array_norm(double *v1, int n)
Definition: linear_algebra.cc:309
void array_copy(double *v_from, double *v_to, int n)
Definition: linear_algebra.cc:285
bool opt_asymm_matrix_eig(double **A, int dim, double *evals)
Definition: linear_algebra.cc:144
double ** symm_matrix_inv(double **A, int dim, bool redundant)
Definition: linear_algebra.cc:222
double array_rms(double *v1, int n)
Definition: linear_algebra.cc:332
void array_normalize(double *v1, int n)
Definition: linear_algebra.cc:304
Definition: PsiFileImpl.h:38
void array_scm(double *v1, double a, int n)
Definition: linear_algebra.cc:313
void matrix_root(double **A, int dim, bool inverse)
Definition: linear_algebra.cc:339
double array_dot(double *v1, double *v2, int n)
Definition: linear_algebra.cc:297