User Tools

Site Tools


boost

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
boost [2018/10/18 11:22] giovaneboost [2019/05/07 20:24] (current) giovane
Line 18: Line 18:
 -I dir/pasta-onde-o-boost-foi-instalado -I dir/pasta-onde-o-boost-foi-instalado
 </code> </code>
 +
 +Segue um exemplo de utilização do solver gesv do lapack para matrizes densas gerais:
 +
 +<code>
 +#include <boost/numeric/ublas/matrix.hpp>                // importa o tipo matrix do boost
 +#include <boost/numeric/ublas/vector.hpp>                // importa o tipo vector do boost
 +#include <boost/numeric/bindings/ublas/matrix.hpp>       // importa as bindings do tipo matrix do boost
 +#include <boost/numeric/bindings/ublas/vector.hpp>       // importa as bindings do tipo vector do boost
 +#include <boost/numeric/bindings/lapack/driver/gesv.hpp> // importa as bindings do solver gesv
 +
 +int main()
 +{
 +    // Definição da matriz A, vetor de solução b e vetor de pivoteamento c
 +    boost::numeric::ublas::matrix<double, boost::numeric::ublas::column_major> A(3, 3, 0.0);
 +    boost::numeric::ublas::vector<double> b(3, 0.0);
 +    boost::numeric::ublas::vector<int> c(3);
 +
 +    //Atribuição de valores
 +    A(0, 0) = 1.0; A(1, 1) = 2.0; A(2, 2) = 1.0;
 +    A(0, 1) = -1.0; A(1, 0) = -1.0;
 +    b(0) = 1.0; b(1) = 2.0; b(2) = 3.0;
 +
 +    //Chamada do solver
 +    boost::numeric::bindings::lapack::gesv(A, c, b);
 +
 +    std::cout <<b(0) <<", " <<b(1) <<", " <<b(2) <<std::endl;
 +    std::cin.get();
 +    return 0;
 +}
 +</code>
 +
  
boost.1539861737.txt.gz · Last modified: by giovane