00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028 #include "sparse-base-lu.h"
00029
00030 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00031 lu_type
00032 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Y (void) const
00033 {
00034 octave_idx_type nr = Lfact.rows ();
00035 octave_idx_type nc = Ufact.rows ();
00036 octave_idx_type rcmin = (nr > nc ? nr : nc);
00037
00038 lu_type Yout (nr, nc, Lfact.nnz() + Ufact.nnz());
00039 octave_idx_type ii = 0;
00040 Yout.xcidx(0) = 0;
00041
00042 for (octave_idx_type j = 0; j < nc; j++)
00043 {
00044 for (octave_idx_type i = Ufact.cidx (j); i < Ufact.cidx(j + 1); i++)
00045 {
00046 Yout.xridx (ii) = Ufact.ridx(i);
00047 Yout.xdata (ii++) = Ufact.data(i);
00048 }
00049 if (j < rcmin)
00050 {
00051
00052 for (octave_idx_type i = Lfact.cidx (j) + 1;
00053 i < Lfact.cidx(j +1); i++)
00054 {
00055 Yout.xridx (ii) = Lfact.ridx(i);
00056 Yout.xdata (ii++) = Lfact.data(i);
00057 }
00058 }
00059 Yout.xcidx(j + 1) = ii;
00060 }
00061
00062 return Yout;
00063 }
00064
00065 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00066 p_type
00067 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Pr (void) const
00068 {
00069
00070 octave_idx_type nr = Lfact.rows ();
00071
00072 p_type Pout (nr, nr, nr);
00073
00074 for (octave_idx_type i = 0; i < nr; i++)
00075 {
00076 Pout.cidx (i) = i;
00077 Pout.ridx (P (i)) = i;
00078 Pout.data (i) = 1;
00079 }
00080 Pout.cidx (nr) = nr;
00081
00082 return Pout;
00083 }
00084
00085 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00086 ColumnVector
00087 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Pr_vec (void) const
00088 {
00089
00090 octave_idx_type nr = Lfact.rows ();
00091
00092 ColumnVector Pout (nr);
00093
00094 for (octave_idx_type i = 0; i < nr; i++)
00095 Pout.xelem (i) = static_cast<double> (P(i) + 1);
00096
00097 return Pout;
00098 }
00099
00100 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00101 PermMatrix
00102 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Pr_mat (void) const
00103 {
00104 return PermMatrix (P, false);
00105 }
00106
00107 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00108 p_type
00109 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Pc (void) const
00110 {
00111 octave_idx_type nc = Ufact.cols ();
00112
00113 p_type Pout (nc, nc, nc);
00114
00115 for (octave_idx_type i = 0; i < nc; i++)
00116 {
00117 Pout.cidx (i) = i;
00118 Pout.ridx (i) = Q (i);
00119 Pout.data (i) = 1;
00120 }
00121 Pout.cidx (nc) = nc;
00122
00123 return Pout;
00124 }
00125
00126 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00127 ColumnVector
00128 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Pc_vec (void) const
00129 {
00130
00131 octave_idx_type nc = Ufact.cols ();
00132
00133 ColumnVector Pout (nc);
00134
00135 for (octave_idx_type i = 0; i < nc; i++)
00136 Pout.xelem (i) = static_cast<double> (Q(i) + 1);
00137
00138 return Pout;
00139 }
00140
00141 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00142 PermMatrix
00143 sparse_base_lu <lu_type, lu_elt_type, p_type, p_elt_type> :: Pc_mat (void) const
00144 {
00145 return PermMatrix (Q, true);
00146 }