Hello
It works with the following code:
for (int i=0; i < N; ++i)
{
std::copy(mat[i].begin(),
mat[i].end(), result.row_begin(i));
}
With mat being a std::vector<std::vector<double>>
and result a Quantlib Matrix
We tried
std::copy(mat.begin(),
mat.end(), result.begin());
but it did not compile
I have a question: do you favors Quantlib::Matrix or boost::numeric::ublas::matrix<double>
for mathematical calculus?
Regards
JRV
-----Original Message-----
From: Bojan Nikolic [mailto:[hidden email]]
Sent: Tuesday, November 08, 2011 10:02 AM
To:
Cc: [hidden email]
Subject: Re: [Quantlib-dev] How to copy a Boost::Matrix into a Quantlib::Matrix
Hi,
> I'm trying to use std::copy but it fails to compile
> It seems a rather simple problem I'm confident someone has used it
somewhere
> could you tell me the correct wording?
Something like this should work:
boost::numeric::ublas::matrix<double> m (3,
3);
QuantLib::Matrix mm(3,3);
std::copy(m.begin1(), m.end1(),
mm.begin());
Although you need to check the column/row convention (I believe this
will transpose the matrix).
Best,
Bojan
--
Bojan Nikolic
||
http://www.bnikolic.co.uk/ql
Free forum by Nabble | Disable Popup Ads | Edit this page |