|
From: jrviala <jea...@am...> - 2011-11-07 12:41:09
|
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? -- View this message in context: http://old.nabble.com/How-to-copy-a-Boost%3A%3AMatrix-into-a-Quantlib%3A%3AMatrix-tp32788720p32788720.html Sent from the quantlib-dev mailing list archive at Nabble.com. |
|
From: Luigi B. <lui...@gm...> - 2011-11-08 08:55:41
|
On Mon, 2011-11-07 at 04:40 -0800, jrviala wrote: > 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? It depends on how you initialize the matrices, I guess. What did you try? Luigi -- The first rule of intelligent tinkering is to save all the parts. -- Paul Erlich |
|
From: Bojan N. <bo...@bn...> - 2011-11-08 09:21:58
|
Hi, jrviala <jea...@am...> writes: > 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 |
|
From: Viala Jean-R. (AMUNDI) <jea...@am...> - 2011-11-09 10:16:59
|
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:bo...@bn...]
Sent: Tuesday, November 08, 2011 10:02 AM
To: Viala Jean-Renaud (AMUNDI)
Cc: qua...@li...
Subject: Re: [Quantlib-dev] How to copy a Boost::Matrix into a
Quantlib::Matrix
Hi,
jrviala <jea...@am...> writes:
> 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
|
|
From: Bojan N. <bo...@bn...> - 2011-11-09 11:39:20
|
Hi,
"Viala Jean-Renaud (AMUNDI)" <jea...@am...> writes:
> std::copy(mat.begin(), mat.end(), result.begin());
Possibly you skimmed over it, but in the snippet I sent this was:
std::copy(mat.begin1(), mat.end1(), result.begin());
^ Note the 1 here!
^ here too!
Best,
Bojan
--
Bojan Nikolic || http://www.bnikolic.co.uk
|
|
From: Viala Jean-R. (AMUNDI) <jea...@am...> - 2011-11-10 16:16:04
|
Hi
Thanks I saw it
Your suggestion doesn't work (it doesn't compile) but I think it's
because my mat is not UBLAS
I will try later but right now the solution below works fine
Regards
JRV
for (int i=0; i < N; ++i)
{
std::copy(mat[i].begin(), mat[i].end(),
result.row_begin(i));
}
-----Original Message-----
From: Bojan Nikolic [mailto:bo...@bn...]
Sent: Wednesday, November 09, 2011 12:39 PM
To: Viala Jean-Renaud (AMUNDI)
Cc: qua...@li...
Subject: Re: [Quantlib-dev] How to copy a Boost::Matrix into a
Quantlib::Matrix
Hi,
"Viala Jean-Renaud (AMUNDI)" <jea...@am...> writes:
> std::copy(mat.begin(), mat.end(), result.begin());
Possibly you skimmed over it, but in the snippet I sent this was:
std::copy(mat.begin1(), mat.end1(), result.begin());
^ Note the 1 here!
^ here too!
Best,
Bojan
--
Bojan Nikolic || http://www.bnikolic.co.uk
|