49 lines
855 B
C++
49 lines
855 B
C++
#include <boost/numeric/ublas/io.hpp>
|
|
#include "lu_solve.hpp"
|
|
|
|
namespace bnu=boost::numeric::ublas;
|
|
|
|
void test1()
|
|
{
|
|
bnu::matrix<double> A(3,3);
|
|
A(0,0) = 1; A(0,1) = 2; A(0,2) = 3;
|
|
A(1,0) = 3; A(1,1) = 5; A(1,2) = 7;
|
|
A(2,0) = 1; A(2,1) = 3; A(2,2) = 4;
|
|
|
|
std::cout<<"A="<<A<<std::endl;
|
|
|
|
bnu::vector<double> v(3);
|
|
v(0) = 3; v(1) = 0; v(2) = 1;
|
|
std::cout<<"b="<<v<<std::endl;
|
|
|
|
lu_solve(A,v);
|
|
|
|
std::cout<<"x="<<v<<std::endl;
|
|
}
|
|
|
|
void test2(size_t N=1024)
|
|
{
|
|
bnu::matrix<double> A(N,N);
|
|
for(size_t i=0; i<N; i++)
|
|
A(i,i) = 1;
|
|
|
|
bnu::vector<double> v(N);
|
|
for(size_t i=0; i<N; i++)
|
|
v(i) = i/10.0;
|
|
|
|
lu_solve(A,v);
|
|
|
|
// std::cout<<"x="<<v<<std::endl;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
std::cout<<"start..."<<std::endl;
|
|
// test1();
|
|
test2(500);
|
|
std::cout<<"stop"<<std::endl;
|
|
return 0;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|