octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #53185] Range data type needs nnz implementati


From: Rik
Subject: [Octave-bug-tracker] [bug #53185] Range data type needs nnz implementation
Date: Thu, 8 Mar 2018 14:32:00 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Update of bug #53185 (project octave):

                  Status:               Confirmed => In Progress            
                 Release:                   4.2.1 => dev                    

    _______________________________________________________

Follow-up Comment #2:

@Maor: This is looking good, but I have a few more requests.

First, can you configure your editor to use spaces rather than tabs?  Tab
alignment always produces problems because people set the tab expansion to
different values.  It is an Octave coding convention to use spaces only for
indentation.

Second, I would like the Range data type to support nnz.  This means moving
the algorithm you coded from libinterp/octave-value/ov-range.[h|cc] in to
liboctave/array/Range.[h|cc].  In this way, people who write their own C++
code and link against liboctave will have access to this function.  The
octave_value class is only known by Octave's interpreter.  There will then be
a little bit of effort to connect the octave_value nnz function to the Range
data type function in ov-range.h, but it should be as simple as this:


  octave_value nnz (void) const { return range.nnz (); }


Also, it would be good to write some BIST tests and place them in data.cc
below the definition of nnz.

Some simple examples


/*
%!assert (nnz (1:5), 5)
%!assert (nnz (-5:-1), 5)
%!assert (nnz (-5:5), 10)
*/


And some harder ones


%!assert (nnz (1:5) * 0, 0)
%!assert (nnz (-2+eps(-2):1:2), 5)


Incidentally, the last test is failing.  The number of non-zero elements is 5,
but is reported as 4


octave:26> nnz (-2+eps(-2):1:2)
ans =  4
octave:27> x = -2+eps(-2):1:2
x =

   -2.0000   -1.0000    0.0000    1.0000    2.0000

octave:28> x != 0
ans =

  1  1  1  1  1





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53185>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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