home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / octave-2.1.23 / liboctave / dbleLU.cc < prev    next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  84 lines

  1. /*
  2.  
  3. Copyright (C) 1996, 1997 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if defined (__GNUG__)
  24. #pragma implementation
  25. #endif
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include <config.h>
  29. #endif
  30.  
  31. #include "dbleLU.h"
  32. #include "f77-fcn.h"
  33. #include "lo-error.h"
  34.  
  35. // Instantiate the base LU class for the types we need.
  36.  
  37. #include <base-lu.h>
  38. #include <base-lu.cc>
  39.  
  40. template class base_lu <Matrix, double, Matrix, double>;
  41.  
  42. // Define the constructor for this particular derivation.
  43.  
  44. extern "C"
  45. {
  46.   int F77_FCN (dgetrf, DGETRF) (const int&, const int&, double*,
  47.                 const int&, int*, int&);
  48. }
  49.  
  50. LU::LU (const Matrix& a)
  51. {
  52.   int a_nr = a.rows ();
  53.   int a_nc = a.cols ();
  54.  
  55.   if (a_nr == 0 || a_nc == 0 || a_nr != a_nc)
  56.     {
  57.       (*current_liboctave_error_handler) ("LU requires square matrix");
  58.       return;
  59.     }
  60.  
  61.   int n = a_nr;
  62.  
  63.   ipvt.resize (n);
  64.   int *pipvt = ipvt.fortran_vec ();
  65.  
  66.   a_fact = a;
  67.   double *tmp_data = a_fact.fortran_vec ();
  68.  
  69.   int info = 0;
  70.  
  71.   F77_XFCN (dgetrf, DGETRF, (n, n, tmp_data, n, pipvt, info));
  72.  
  73.   if (f77_exception_encountered)
  74.     (*current_liboctave_error_handler) ("unrecoverable error in dgesv");
  75.   else
  76.     ipvt -= 1;
  77. }
  78.  
  79. /*
  80. ;;; Local Variables: ***
  81. ;;; mode: C++ ***
  82. ;;; End: ***
  83. */
  84.