help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Assigning values to Octave matrix in C++ code


From: c.
Subject: Re: Assigning values to Octave matrix in C++ code
Date: Sat, 8 Oct 2016 12:40:43 +0200

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, 
but you can copy the data with one single 
command using std::copy :

#include <vector>
#include <algorithm>
#include <octave/oct.h>

std::vector<double> pdblReal (iRows * iCols, 1.0);
Matrix matrix_double (iRows, iCols);

std::copy (pdblReal.start (), pdblReal.end (), matrix_double.fortran_vec ());

the opposite converson can be done with a constructor.

HTH,
c.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]