メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

base-lu.cc

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 ;;; Local Variables: ***
00107 ;;; mode: C++ ***
00108 ;;; End: ***
00109 */

Wed Dec 29 11:50:55 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送