Qucs-core
0.0.19
|
00001 /* 00002 * eqnsys.h - equations system solver class definitions 00003 * 00004 * Copyright (C) 2004, 2005, 2006 Stefan Jahn <stefan@lkcc.org> 00005 * 00006 * This is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2, or (at your option) 00009 * any later version. 00010 * 00011 * This software is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this package; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 * $Id$ 00022 * 00023 */ 00024 00025 #ifndef __EQNSYS_H__ 00026 #define __EQNSYS_H__ 00027 00028 #include <limits> 00029 00031 enum algo_type { 00032 ALGO_INVERSE = 0x0001, 00033 ALGO_GAUSS = 0x0002, 00034 ALGO_GAUSS_JORDAN = 0x0004, 00035 ALGO_LU_FACTORIZATION_CROUT = 0x0008, 00036 ALGO_LU_FACTORIZATION_DOOLITTLE = 0x0010, 00037 ALGO_LU_SUBSTITUTION_CROUT = 0x0020, 00038 ALGO_LU_SUBSTITUTION_DOOLITTLE = 0x0040, 00039 ALGO_LU_DECOMPOSITION = 0x0028, 00040 ALGO_LU_DECOMPOSITION_CROUT = 0x0028, 00041 ALGO_LU_DECOMPOSITION_DOOLITTLE = 0x0050, 00042 ALGO_JACOBI = 0x0080, 00043 ALGO_GAUSS_SEIDEL = 0x0100, 00044 ALGO_SOR = 0x0200, 00045 ALGO_QR_DECOMPOSITION = 0x0400, 00046 ALGO_QR_DECOMPOSITION_LS = 0x0800, 00047 ALGO_SV_DECOMPOSITION = 0x1000, 00048 // testing 00049 ALGO_QR_DECOMPOSITION_2 = 0x2000, 00050 }; 00051 00053 enum pivot_type { 00054 PIVOT_NONE = 0x01, 00055 PIVOT_PARTIAL = 0x02, 00056 PIVOT_FULL = 0x04 00057 }; 00058 00059 #include "tvector.h" 00060 #include "tmatrix.h" 00061 00062 namespace qucs { 00063 00064 template <class nr_type_t> 00065 class eqnsys 00066 { 00067 public: 00068 eqnsys (); 00069 eqnsys (eqnsys &); 00070 ~eqnsys (); 00071 void setAlgo (int a) { algo = a; } 00072 int getAlgo (void) { return algo; } 00073 void passEquationSys (tmatrix<nr_type_t> *, tvector<nr_type_t> *, 00074 tvector<nr_type_t> *); 00075 void solve (void); 00076 00077 private: 00078 int update; 00079 int algo; 00080 int pivoting; 00081 int * rMap; 00082 int * cMap; 00083 int N; 00084 nr_double_t * nPvt; 00085 00086 tmatrix<nr_type_t> * A; 00087 tmatrix<nr_type_t> * V; 00088 tvector<nr_type_t> * B; 00089 tvector<nr_type_t> * X; 00090 tvector<nr_type_t> * R; 00091 tvector<nr_type_t> * T; 00092 tvector<nr_double_t> * S; 00093 tvector<nr_double_t> * E; 00094 00095 void solve_inverse (void); 00096 void solve_gauss (void); 00097 void solve_gauss_jordan (void); 00098 void solve_lu_crout (void); 00099 void solve_lu_doolittle (void); 00100 void factorize_lu_crout (void); 00101 void factorize_lu_doolittle (void); 00102 void substitute_lu_crout (void); 00103 void substitute_lu_doolittle (void); 00104 void solve_qr (void); 00105 void solve_qr_ls (void); 00106 void solve_qrh (void); 00107 void factorize_qrh (void); 00108 void substitute_qrh (void); 00109 void factorize_qr_householder (void); 00110 void substitute_qr_householder (void); 00111 void substitute_qr_householder_ls (void); 00112 nr_type_t householder_create_left (int); 00113 void householder_apply_left (int, nr_type_t); 00114 nr_type_t householder_left (int); 00115 nr_type_t householder_create_right (int); 00116 void householder_apply_right (int, nr_type_t); 00117 void householder_apply_right_extern (int, nr_type_t); 00118 nr_type_t householder_right (int); 00119 nr_double_t euclidian_c (int, int r = 1); 00120 nr_double_t euclidian_r (int, int c = 1); 00121 void givens_apply_u (int, int, nr_double_t, nr_double_t); 00122 void givens_apply_v (int, int, nr_double_t, nr_double_t); 00123 void solve_svd (void); 00124 void chop_svd (void); 00125 void factorize_svd (void); 00126 void substitute_svd (void); 00127 void diagonalize_svd (void); 00128 void solve_iterative (void); 00129 void solve_sor (void); 00130 nr_double_t convergence_criteria (void); 00131 void ensure_diagonal (void); 00132 void ensure_diagonal_MNA (void); 00133 int countPairs (int, int&, int&); 00134 void preconditioner (void); 00135 }; 00136 00137 } // namespace qucs 00138 00139 #include "eqnsys.cpp" 00140 00141 #endif /* __EQNSYS_H__ */