00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00024 #pragma implementation
00025 #endif
00026
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031 #include "base-lu.h"
00032
00033 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00034 lu_type
00035 base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: L (void) const
00036 {
00037 int a_nr = a_fact.rows ();
00038 int a_nc = a_fact.cols ();
00039 int mn = (a_nr < a_nc ? a_nr : a_nc);
00040
00041 lu_type l (a_nr, mn, lu_elt_type (0.0));
00042
00043 for (int i = 0; i < a_nr; i++)
00044 {
00045 if (i < a_nc)
00046 l.xelem (i, i) = 1.0;
00047
00048 for (int j = 0; j < (i < a_nc ? i : a_nc); j++)
00049 l.xelem (i, j) = a_fact.xelem (i, j);
00050 }
00051
00052 return l;
00053 }
00054
00055 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00056 lu_type
00057 base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: U (void) const
00058 {
00059 int a_nr = a_fact.rows ();
00060 int a_nc = a_fact.cols ();
00061 int mn = (a_nr < a_nc ? a_nr : a_nc);
00062
00063 lu_type u (mn, a_nc, lu_elt_type (0.0));
00064
00065 for (int i = 0; i < mn; i++)
00066 {
00067 for (int j = i; j < a_nc; j++)
00068 u.xelem (i, j) = a_fact.xelem (i, j);
00069 }
00070
00071 return u;
00072 }
00073
00074 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00075 p_type
00076 base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: P (void) const
00077 {
00078 int a_nr = a_fact.rows ();
00079
00080 Array<int> pvt (a_nr);
00081
00082 for (int i = 0; i < a_nr; i++)
00083 pvt.xelem (i) = i;
00084
00085 for (int i = 0; i < ipvt.length(); i++)
00086 {
00087 int k = ipvt.xelem (i);
00088
00089 if (k != i)
00090 {
00091 int tmp = pvt.xelem (k);
00092 pvt.xelem (k) = pvt.xelem (i);
00093 pvt.xelem (i) = tmp;
00094 }
00095 }
00096
00097 p_type p (a_nr, a_nr, p_elt_type (0.0));
00098
00099 for (int i = 0; i < a_nr; i++)
00100 p.xelem (i, pvt.xelem (i)) = 1.0;
00101
00102 return p;
00103 }
00104
00105
00106
00107
00108
00109