24#include <ql/math/matrix.hpp>
25#if defined(QL_PATCH_MSVC)
27#pragma warning(disable:4180)
28#pragma warning(disable:4127)
31#if BOOST_VERSION == 106400
32#include <boost/serialization/array_wrapper.hpp>
34#include <boost/numeric/ublas/vector_proxy.hpp>
35#include <boost/numeric/ublas/triangular.hpp>
36#include <boost/numeric/ublas/lu.hpp>
38#if defined(QL_PATCH_MSVC)
45 QL_REQUIRE(m.
rows() == m.
columns(),
"matrix is not square");
47 boost::numeric::ublas::matrix<Real> a(m.
rows(), m.
columns());
49 std::copy(m.
begin(), m.
end(), a.data().begin());
51 boost::numeric::ublas::permutation_matrix<Size> pert(m.
rows());
56 singular = lu_factorize(a, pert);
57 }
catch (
const boost::numeric::ublas::internal_logic& e) {
58 QL_FAIL(
"lu_factorize error: " << e.what());
59 }
catch (
const boost::numeric::ublas::external_logic& e) {
60 QL_FAIL(
"lu_factorize error: " << e.what());
62 QL_REQUIRE(singular == 0,
"singular matrix given");
64 boost::numeric::ublas::matrix<Real>
65 inverse = boost::numeric::ublas::identity_matrix<Real>(m.
rows());
69 boost::numeric::ublas::lu_substitute(a, pert,
inverse);
70 }
catch (
const boost::numeric::ublas::internal_logic& e) {
71 QL_FAIL(
"lu_substitute error: " << e.what());
82 QL_REQUIRE(m.
rows() == m.
columns(),
"matrix is not square");
84 boost::numeric::ublas::matrix<Real> a(m.
rows(), m.
columns());
85 std::copy(m.
begin(), m.
end(), a.data().begin());
89 boost::numeric::ublas::permutation_matrix<Size> pert(m.
rows());
90 lu_factorize(a, pert);
Matrix used in linear algebra.
const_iterator begin() const
const_iterator end() const
std::size_t Size
size of a container
Real determinant(const Matrix &m)
Matrix inverse(const Matrix &m)