[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Initializing Matrix object from a double* vector
From: |
John W. Eaton |
Subject: |
Initializing Matrix object from a double* vector |
Date: |
Wed, 10 Sep 2008 13:42:41 -0400 |
On 10-Sep-2008, José Luis García Pallero wrote:
| Hello,
| I have a vector (double* v) that contains a matrix in column major order and
| I need to asign the values to a GNU Octave Matrix object. Is there any
| method for initialize the Matrix object without using for loops, something
| like Matrix a(rows,cols,v), for example?
No, because the Matrix object must "own" the data. So you have to
copy it. You can do
Matrix a (rows, cols);
double *pa = a.fortran_vec ();
for (octave_idx_type i = 0; i < rows * cols; i++)
pa[i] = v[i];
jwe