|
From: Alexander S. <so...@co...> - 2015-04-15 13:37:14
|
Hi Peter:
We were able to solve the errors such as the one you mentioned in your post
by operator overloading in boost namespace. The code sample is below in this
email.
Best regards
Alex
Sample error message:
1>c:\projects\quantlib\dependencies\cpp\boost\numeric\ublas\detail\matrix_assign.hpp(34):
error C2678: binary '<' : no operator found which takes a left-hand operand
of type 'boost::numeric::ublas::matrix_scalar_unary<E,F>' (or there is no
acceptable conversion)
Code snippet which fixes this error:
#include <cppad/cppad.hpp>
namespace boost {
namespace numeric {
namespace ublas
{
template<class M>
class sparse_matrix_element;
template<class T, class L, std::size_t IB, class IA,
class TA>
class compressed_matrix;
template<class T, class ALLOC>
class unbounded_array;
namespace detail {
template <typename Left, typename Right>
inline bool operator < (Left const& left,
CppAD::AD<Right> const& right)
{
#pragma message ("overload operator < : " __FUNCSIG__)
// This is only for demonstrate
// Ensure that adjoint logic will workable
return left < CppAD::Value(right);
}
}
}
}
}
#include <boost/numeric/ublas/lu.hpp>
using namespace std;
int main() {
typedef CppAD::AD<double> T;
boost::numeric::ublas::matrix<T> a(5, 5);
boost::numeric::ublas::permutation_matrix<std::size_t> pert(5);
// lu decomposition
const std::size_t s = lu_factorize(a, pert);
return 0;
}
--
View this message in context: http://quantlib.10058.n7.nabble.com/Adjoint-Greeks-tp16147p16486.html
Sent from the quantlib-dev mailing list archive at Nabble.com.
|