[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructor
From: |
John W. Eaton |
Subject: |
[Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructor |
Date: |
Wed, 25 Jun 2008 08:00:21 -0400 |
On 25-Jun-2008, David Bateman wrote:
| The attached changeset adds a constructor for ArrayN<octave_idx_type>
| that seems to me might be used whether indexes are created. It then uses
| it in Flookup.
| diff --git a/src/ov.cc b/src/ov.cc
| --- a/src/ov.cc
| +++ b/src/ov.cc
| @@ -564,6 +564,15 @@ octave_value::octave_value (const ArrayN
| octave_value::octave_value (const ArrayN<float>& a)
| : rep (new octave_float_matrix (a))
| {
| + maybe_mutate ();
| +}
| +
| +octave_value::octave_value (const ArrayN<octave_idx_type>& a)
| +{
| + NDArray tmp (a.dims ());
| + for (octave_idx_type i = 0; i < a.numel (); i++)
| + tmp(i) = a(i);
| + rep = new octave_matrix (tmp);
| maybe_mutate ();
| }
It might be better to use
double *ptmp = tmp.fortran_vec ();
for (octave_idx_type i = 0; i < a.numel (); i++)
ptmp[i] = a(i);
to avoid repeatedly checking the reference count. This is a change
that we should consider in many other places as well, if someone is
looking for a small project...
Also, should we do anything about octave_idx_type values that can't be
represented exactly in an NDArray element?
jwe