octave-maintainers
[Top][All Lists]
Advanced

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

Re: [Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructo


From: Jaroslav Hajek
Subject: Re: [Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructor
Date: Wed, 25 Jun 2008 14:16:21 +0200

On Wed, Jun 25, 2008 at 2:00 PM, John W. Eaton <address@hidden> wrote:
> 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);
>

Or use "tmp.xelem(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?
>

I think we have discussed that before, when lookup was comitted, and
the conclusion was that the compatibility problems outweigh the
benefits.

> jwe
>
>
>
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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