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: David Bateman
Subject: Re: [Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructor
Date: Wed, 25 Jun 2008 14:10:56 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080306)

John W. Eaton wrote:
> 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);
>   
That makes sense. Do you want to do it, or do you want a new patch.
> 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...
>   
I didn't just do it straight away for things like Fsort, Ffind etc as
you have to be careful with zero and one based indexing. Maybe it would
be better if the constructor was in fact

octave_value (const ArrayN<octave_idx_type>& a, bool zero_base = false);

octave_value::octave_value (const ArrayN<octave_idx_type>& a, bool
zero_base)
{
  NDArray tmp (a.dims ());
  double *ptmp = tmp.fortran_vec ();
  if (zero_based)
    for (octave_idx_type i = 0; i < a.numel (); i++)
      ptmp[i] = a(i) + 1;
  else
    for (octave_idx_type i = 0; i < a.numel (); i++)
      ptmp[i] = a(i);
  rep = new octave_matrix (tmp);
  maybe_mutate ();
 }

to allow this to be more easily handled.

> Also, should we do anything about octave_idx_type values that can't be
> represented exactly in an NDArray element?
>   
2^52 is a very big number I think we can wait till we have to be careful
with that few a few decades at least :-)

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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