getrf(&mm, &nn, values, &mm, &ipiv[0], &info);
Assert(info >= 0, ExcInternalError());
-
+
// if info >= 0, the factorization has been completed
state = lu;
-
+
AssertThrow(info == 0, LACExceptions::ExcSingular());
}
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2014 - 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// Tests LAPACKFullMatrix::operator*= and operator/=
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/lapack_full_matrix.h>
+
+#include <fstream>
+#include <iostream>
+
+
+
+void test(const bool is_singular)
+{
+ const unsigned int n=10;
+ LAPACKFullMatrix<double> A(n,n);
+ A = 0;
+
+ // generate a singular matrix if is_singular == true
+ for (unsigned int i=0; i<n; ++i)
+ for (unsigned int j=0; j<n; ++j)
+ if (i==j && (i != n-1 || !is_singular))
+ A(i,j) = 1.0;
+
+ try
+ {
+ A.compute_lu_factorization();
+ }
+ catch (std::exception &exc)
+ {
+ deallog << "matrix is singular" << std::endl;
+ }
+
+ Vector<double> v(n);
+ v = 1.0;
+ v(n-1) = 0.0;
+ // LU factorization can only be applied if state == lu!
+ A.apply_lu_factorization(v,false);
+
+ deallog << "apply lu factorization succeeded with norm " << v.l2_norm() << std::endl;
+}
+
+int main()
+{
+ const std::string logname = "output";
+ std::ofstream logfile(logname.c_str());
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.threshold_double(1.e-10);
+
+ test(false);
+ test(true);
+}