| 1 |
/*! \file C_KernDetect.hpp |
| 2 |
\brief Kernel detection algorithm : symm <= DOI: 10.1002/nme.4729 / unsymm |
| 3 |
\author Atsushi Suzuki, Laboratoire Jacques-Louis Lions |
| 4 |
\date Jun. 20th 2014 |
| 5 |
\date Jul. 12th 2015 |
| 6 |
\date Nov. 30th 2016 |
| 7 |
*/ |
| 8 |
|
| 9 |
// This file is part of Dissection |
| 10 |
// |
| 11 |
// Dissection 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 3 of the License, or |
| 14 |
// (at your option) any later version. |
| 15 |
// |
| 16 |
// Linking Dissection statically or dynamically with other modules is making |
| 17 |
// a combined work based on Disssection. Thus, the terms and conditions of |
| 18 |
// the GNU General Public License cover the whole combination. |
| 19 |
// |
| 20 |
// As a special exception, the copyright holders of Dissection give you |
| 21 |
// permission to combine Dissection program with free software programs or |
| 22 |
// libraries that are released under the GNU LGPL and with independent modules |
| 23 |
// that communicate with Dissection solely through the Dissection-fortran |
| 24 |
// interface. You may copy and distribute such a system following the terms of |
| 25 |
// the GNU GPL for Dissection and the licenses of the other code concerned, |
| 26 |
// provided that you include the source code of that other code when and as |
| 27 |
// the GNU GPL requires distribution of source code and provided that you do |
| 28 |
// not modify the Dissection-fortran interface. |
| 29 |
// |
| 30 |
// Note that people who make modified versions of Dissection are not obligated |
| 31 |
// to grant this special exception for their modified versions; it is their |
| 32 |
// choice whether to do so. The GNU General Public License gives permission to |
| 33 |
// release a modified version without this exception; this exception also makes |
| 34 |
// it possible to release a modified version which carries forward this |
| 35 |
// exception. If you modify the Dissection-fortran interface, this exception |
| 36 |
// does not apply to your modified version of Dissection, and you must remove |
| 37 |
// this exception when you distribute your modified version. |
| 38 |
// |
| 39 |
// This exception is an additional permission under section 7 of the GNU |
| 40 |
// General Public License, version 3 ("GPLv3") |
| 41 |
// |
| 42 |
// Dissection is distributed in the hope that it will be useful, |
| 43 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 44 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 45 |
// GNU General Public License for more details. |
| 46 |
// |
| 47 |
// You should have received a copy of the GNU General Public License |
| 48 |
// along with Dissection. If not, see <http://www.gnu.org/licenses/>. |
| 49 |
// |
| 50 |
|
| 51 |
#ifndef _DRIVER_C_KERNDETECT |
| 52 |
#define _DRIVER_C_KERNDETECT |
| 53 |
|
| 54 |
#include "Compiler/arithmetic.hpp" |
| 55 |
#include "Compiler/blas.hpp" |
| 56 |
#include "Driver/C_BlasRoutines.hpp" |
| 57 |
|
| 58 |
template<typename T, typename U> |
| 59 |
void copy_matrix_permute_(const int lda, int n, |
| 60 |
U *b, T *a, int *permute); |
| 61 |
|
| 62 |
template<typename T, typename U> |
| 63 |
void copy_matrix_permute_complex_(const int lda, int n, |
| 64 |
complex<U> *b, complex<T> *a, int *permute); |
| 65 |
|
| 66 |
|
| 67 |
template<typename T, typename U> |
| 68 |
bool check_kern(const int n0, const int lda, const int n, T *a_ini, |
| 69 |
int *permute, |
| 70 |
const int dim_augkern, const U &eps, |
| 71 |
const U &eps_param, const bool flag_sym, U *errors, |
| 72 |
const bool verbose, FILE *fp); |
| 73 |
|
| 74 |
//template<typename T, typename U, typename W, typename Y = W> |
| 75 |
template<typename T, typename U, typename W, typename Y> |
| 76 |
bool check_kern_(const int n0, const int lda, const int n, T *a_ini, |
| 77 |
int *permute, |
| 78 |
const int dim_augkern, const U &eps, |
| 79 |
const U &eps_param, const bool flag_sym, U *errors, |
| 80 |
const bool verbose, FILE *fp); |
| 81 |
|
| 82 |
template<typename T, typename U> |
| 83 |
U check_matrixerr(const int lda, const int n, |
| 84 |
T *a, |
| 85 |
const int dim_augkern, const int k, |
| 86 |
int *permute, |
| 87 |
const U &eps, |
| 88 |
const bool flag_sym); |
| 89 |
|
| 90 |
template<typename T, typename U, typename W> |
| 91 |
U check_matrixerr_(const int lda, const int n, |
| 92 |
T *a, |
| 93 |
const int dim_augkern, const int k, |
| 94 |
int *permute, |
| 95 |
const U &eps, |
| 96 |
const bool flag_sym); |
| 97 |
|
| 98 |
template<typename T, typename U> |
| 99 |
void verify_kernels(const int n0, const int n, const T *a_ini, const int lda, |
| 100 |
const bool isSym, const double eps, U *errors); |
| 101 |
|
| 102 |
template<typename T, typename U> |
| 103 |
int hqr_pivot(const int n, T *a, int *permute); |
| 104 |
|
| 105 |
template<typename T> |
| 106 |
void HouseholderVector(int n, T *x, T *v, T *gamma); |
| 107 |
|
| 108 |
template<typename T, typename U> |
| 109 |
void HouseholderVector_complex(int n, T *x, T *v, T *gamma); |
| 110 |
|
| 111 |
template<typename T> |
| 112 |
void HouseholderReflection(int n, T *a, int lda, T *v, T *w, const T &gamma); |
| 113 |
|
| 114 |
template<typename T, typename U> |
| 115 |
bool ComputeDimKernel(int *n0, bool *flag_unsym_permute, |
| 116 |
const T *a_, const int n, |
| 117 |
const bool sym_flag, |
| 118 |
const int dim_augkern, |
| 119 |
const U eps_machine, |
| 120 |
const double eps_piv, |
| 121 |
const bool verbose, |
| 122 |
FILE *fp); |
| 123 |
|
| 124 |
template<typename T, typename U, typename W, typename Y> |
| 125 |
bool ComputeDimKernel_(int *n0, bool *flag_unsym_permute, |
| 126 |
const T *a_, const int n, |
| 127 |
const bool sym_flag, |
| 128 |
const int dim_augkern, |
| 129 |
const U eps_machine, |
| 130 |
const double eps_piv, |
| 131 |
const bool verbose, |
| 132 |
FILE *fp); |
| 133 |
|
| 134 |
template<typename T, typename U, typename W, typename Y> |
| 135 |
bool VerifyDimKernel(int *nn0_, |
| 136 |
int *permute_q, |
| 137 |
int n_dim, W* a_fact, |
| 138 |
vector<int> &kernel_dim, |
| 139 |
const bool sym_flag, |
| 140 |
const int dim_augkern, |
| 141 |
const U eps_machine, |
| 142 |
const bool verbose, |
| 143 |
FILE *fp); |
| 144 |
#endif |