[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assigning values to Octave matrix in C++ code
From: |
Mike Miller |
Subject: |
Re: Assigning values to Octave matrix in C++ code |
Date: |
Sat, 8 Oct 2016 09:12:06 -0700 |
User-agent: |
NeoMutt/20160916 (1.7.0) |
On Sat, Oct 08, 2016 at 12:40:43 +0200, c. wrote:
>
> On 8 Oct 2016, at 09:14, Shamika Mohanan <address@hidden> wrote:
>
> > Copying is fine. Can you show how to do it in a single operation using a
> > constructor?
>
> There is no constructor that does that,
There actually is a constructor in Octave 4.2 (but not in 4.0) that can
initialize an Array from any STL container:
std::vector<double> v;
// some code to populate the vector
dim_vector dims { 1, v.size () };
Matrix m { Array<double> { v, dims } };
But you're right, if you are still on 4.0 (4.2 is *almost* out), then
calling std::copy is probably the simplest way.
--
mike