[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
1D NDArray -> octave_value
From: |
Teemu Ikonen |
Subject: |
1D NDArray -> octave_value |
Date: |
Thu, 14 Dec 2006 16:21:18 +0100 |
Hi,
I wrote some oct-functions which return NDArray values by calling
something like return octave_value(nda).squeeze() (see
octave-forge/extra/xraylib for the code)
For arrays with ndims > 1 this seems to work fine, but for 1D arrays
the returned value is a hybrid between 1D and the 2D. If t is a 1D
value returned by my function, then
octave:51> ndims(t)
ans = 2
but
octave:53> size(t)
ans = 100
i.e. the one element result vector shows that t is really only
one-dimensional. Otherwise this wouldn't be a problem, but e.g. the
plotting functions refuse to work with this kind of vectors.
I have to fix my own code anyway, but maybe a change like this to
ov-base-mat.h would not hurt (just for example, the patch is
completely untested) ?
--- ov-base-mat.h.orig 2006-12-14 15:34:21.000000000 +0100
+++ ov-base-mat.h 2006-12-14 15:57:56.000000000 +0100
@@ -59,6 +59,8 @@
{
if (matrix.ndims () == 0)
matrix.resize (dim_vector (0, 0));
+ else if (matrix.ndims () == 1)
+ matrix.resize (dim_vector (matrix.dims().elem(0), 1));
}
octave_base_matrix (const MT& m, const MatrixType& t)
Teemu
- 1D NDArray -> octave_value,
Teemu Ikonen <=