|
Ublas : |
From: Prasad Ramanan (prasad.ramanan_at_[hidden])
Date: 2005-11-14 19:58:32
I wrote the following code to solve Ax = rhs:
#include <iostream>
#include <fstream>
#include <string>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/lu.hpp>
using namespace boost::posix_time;
using namespace std;
void matrixTest() {
namespace ublas = boost::numeric::ublas;
const n = 10;
ublas::matrix<double> A(n,n);
ublas::vector<double> x(n);
ublas::vector<double> rhs(n);
for(int i = 0; i < n; i++) {
A(i,i) = 1;
rhs(i) = i;
}
ublas::permutation_matrix<double> P(n);
ublas::lu_factorize(A,P);
x = rhs;
ublas::lu_substitute(A,P,rhs);
}
And I get the following types of errors in compilation. Sorry for
listing so many but I think they are all related. There are actually
more errors, all related to the lu.hpp header file.
I've used other parts of the ublas library successfully. Can someone
tell me what I am doing wrong? I am using boost 1.32. I got this
example off the mailing list in a reply posted by Gunter Winkler on
Thursday, January 13, 2005.
Thanks in advance for your help.
s:\Boost\include\boost-1_32\boost\numeric\ublas\lu.hpp(152) : error
C2440: 'type cast' : cannot convert from
'boost::numeric::ublas::matrix<T>' to
'boost::numeric::ublas::triangular_adaptor<M,F>'
with
[
T=double
]
and
[
M=matrix_type,
F=boost::numeric::ublas::unit_lower
]
Source or target has incomplete type
s:\Boost\include\boost-1_32\boost\numeric\ublas\lu.hpp(152) :
see reference to class template instantiation
'boost::numeric::ublas::triangular_adaptor<M,F>' being compiled
with
[
M=matrix_type,
F=boost::numeric::ublas::unit_lower
]
h:\Production\Factors\Test.cpp(154) : see reference to
function template instantiation
'boost::numeric::ublas::matrix<T>::size_type
boost::numeric::ublas::lu_factorize<boost::numeric::ublas::matrix<T>,boost::numeric::ublas::permutation_matrix<T>>(M
&,PM &)' being compiled
with
[
T=double,
M=boost::numeric::ublas::matrix<double>,
PM=boost::numeric::ublas::permutation_matrix<double>
]
s:\Boost\include\boost-1_32\boost\numeric\ublas\lu.hpp(152) : error
C2440: 'type cast' : cannot convert from
'boost::numeric::ublas::matrix<T>' to
'boost::numeric::ublas::triangular_adaptor<M,F>'
with
[
T=double
]
and
[
M=matrix_type,
F=boost::numeric::ublas::upper
]
Source or target has incomplete type
s:\Boost\include\boost-1_32\boost\numeric\ublas\lu.hpp(152) :
see reference to class template instantiation
'boost::numeric::ublas::triangular_adaptor<M,F>' being compiled
with
[
M=matrix_type,
F=boost::numeric::ublas::upper
]
Prasad