Friday 15 May 2015

c++ - matrix inversion in boost -


I am trying to handle a simple matrix inversion by promoting. But I'm getting an error in fact what I'm trying to find is inversted_matrix = inverse (trans (matrix) * matrix) but I'm getting an error

  file boost_1_53_0 / Boost / numeric / ublas / lu.hpp in failed row 299: expansion :: expression_type_check (prod (triangular_adaptor & lt; const_matrix_type, upper & gt; (m), e), cm2) 'boost :: numeric :: After throwing an example of ublas :: internal_logic, what is said: Logic aborted (core dump)   

My attempt:

  #include & lt ; Boost / numeric / ublas / matrix.hpp & gt; #include & lt; Boost / numeric / ublas / vector.hpp & gt; #include & lt; Boost / numeric / ublas / io.hpp & gt; #include & lt; Boost / numeric / ublas / vector_proxy.hpp & gt; #include & lt; Boost / numeric / ublas / matrix.hpp & gt; #include & lt; Boost / numeric / ublas / triangular.hpp & gt; #include & lt; Boost / numeric / ublas / lu.hpp & gt; Namespace ublas = boost :: numeric :: ublas; Template & lt; Class T & gt; Bool InvertMatrix (const ublas :: matrix & lt; T & gt; and Input, ublas :: Matrix & lt; T & gt; and Inverse) {Namespace Boost :: Numerical :: ublas; Typingformement_matrix & lt; Std :: size_t & gt; Pmatrix; // Copy the work of input matrix & lt; T & gt; One (input); // Create a sequence matrix for LU-factorization pmatrix pm (Acea 1 ()); // display LU-factorization int res = lu_factorize (A, pm); If (res! = 0) return false; // Create inverse.assign (ublas :: identity_matrix & lt; T & gt; identification matrix) (Size 1 ()); // backsubstitute to get reverse lu_substitute (A, pm, inverse) ;; True;} true (& quot; double> V (4); vector of & lt; double & gt; meter (4,5); vector of {{namepace boost :: numeric :: ublas; K & lt; double & gt; thetas; m (0,0) = 1; m (0,1) = 2104; m (0,2) = 5; m (0,3) = 1; m (0, 4) = 45; m (1,0) = 1; m (1,1) = 1416; m (1,2) = 3; m (1,3) = 2; m (1,4) = 40; M (2,0) = 1; m (2,1) = 1534; m (2,2) = 3; m (2,3) = 2; m (2,4) = 30; m (3,0 ) = 1; m (3,1) = 852; m (3, 2) = 2; m (3,3) = 1; m (3,4) = 36; std :: court & lt; ; & Lt; & Lt; std :: endl; & lt; double & gt; Product = Prod (trans (m), m) of matrix; std :: The & lt;    

Boost to ensure numerical stability among other things Ublas has been given a runtime check. If you look at the source of error, you can see that it tries to make sure that U * X = B, X = U ^ -1 * B, U * X = B (Or smth like that) is coated inside a few episodes if you have a much more deviation than numeric, it probably will not be caught.

You can disable checks via -DBOOST_UBLAS_NDEBUG or repeat with BOOST_UBLAS_TYPE_CHECK_EPSILON, BOOST_UBLAS_TYPE_CHECK_MIN .

No comments:

Post a Comment