[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 1D NDArray -> octave_value
From: |
John W. Eaton |
Subject: |
Re: 1D NDArray -> octave_value |
Date: |
Thu, 14 Dec 2006 13:32:54 -0500 |
On 14-Dec-2006, Teemu Ikonen wrote:
| On 12/14/06, John W. Eaton <address@hidden> wrote:
| > It should not be possible to create 1-d vectors in Octave, so this may
| > be a bug. Are you using the CVS sources? Can you please post a short
| > example that shows precisely how a vector like this can be created?
|
| Sorry, I sent the previous mail before it was ready. I'm using Octave
| 2.9.9 in Debian and here's a testcase. This produces a 10 element 1D
| vector.
|
| #include <octave/oct.h>
|
|
| DEFUN_DLD(bug, args, nargout, "bug")
| {
| dim_vector dv;
| octave_value retval;
|
| dv = dim_vector();
| dv.resize(1);
| dv.elem(0) = 10;
| NDArray y(dv);
| for(int i = 0; i < 10; i++) {
| y(i) = 1.0;
| }
|
| retval = octave_value(y).squeeze();
| return retval;
|
| }
You are not supposed to do that. Every object created by Octave
should have at least two dimensions. Should we modify the dim_vector
class to enforce that? What should it do if you try to create a
dim_vector with less than two dimensions (error, warning)?
jwe