bugGNU Octave - Bugs: bug #40813, atan2, fmod, hypot returns no...

 
 

bug #40813: atan2, fmod, hypot returns no results for sparse matrices

Submitted by:  Rik <rik5>
Submitted on:  Thu 05 Dec 2013 01:14:41 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Wed 04 Jun 2014 05:13:27 PM UTC, comment #8:

Well, there's not much left from my original patch - so thanks for keeping the author name. :)

Stefan Mahr <dac922>
Mon 02 Jun 2014 05:15:42 PM UTC, comment #7:

@Stefan: I compacted your Sparse-Sparse implementation and checked it in on the stable branche here (http://hg.savannah.gnu.org/hgweb/octave/rev/658d23da2c46).

Next, I added my modifications for the scalar-Sparse, Sparse-scalar routines (http://hg.savannah.gnu.org/hgweb/octave/rev/dccbc8bff5cb). I also added built-in self-tests (%!tests) which was part of the problem. The issue with the original changeset back in 3.2.X would have been caught if there had been tests for the sparse implementations.

Finally, I marked the atan2 functions which are part of the Sparse class as deprecated. They will be deleted in Octave 4.4. Nothing in the core is using these implementations, since everything is piped through binmap. However, there might be someone out there who is using atan2 directly in an oct-file so I thought I would give them some warning before removing the code.

Rik <rik5>
Project Administrator
Sun 01 Jun 2014 03:27:42 PM UTC, comment #6:

Rik, if you have time to review my patch, please use the latest one from here:
http://inversethought.com/hg/octave-nkf/graph/nkf-ready

Since I can't push to Jordis hg server, I attach my latest patch for the binmap - sparse/sparse problem

(file #31482)

Stefan Mahr <dac922>
Sun 01 Jun 2014 03:25:04 PM UTC, comment #5:

The problems with this section of code just keep expanding. In addition to no results, and infinite loops, the following code will cause a segfault.

I've re-written the scalar-Sparse and Sparse-scalar functions. It looks like Sparse-Sparse needs to be re-written as well.

Rik <rik5>
Project Administrator
Thu 29 May 2014 07:47:53 PM UTC, comment #4:

Yes, the infinite loop problem is located somewhere in the for-loop around oct-binmap.h:258

Stefan Mahr <dac922>
Thu 29 May 2014 03:25:13 PM UTC, comment #3:

Using Mercurial I have traced the problem back to changeset 6a271334750c. In that changeset the implementation of atan2, fmod, and hypot were switched over to binmap().

Indeed, the first problem that I reported with atan2 also exists for fmod.

So part of the problem seems to be that a scalar is not expanded in the same way as it would be for a full matrix. I won't have time to look at this or the submitted patch until the weekend.

Rik <rik5>
Project Administrator
Mon 20 Jan 2014 05:12:20 PM UTC, comment #2:

While debugging if found, this code ends in an infinite loop

Stefan Mahr <dac922>
Mon 20 Jan 2014 04:54:57 PM UTC, comment #1:

Attached a possible fix. Don't know if 'copy_or_memcopy' is ok here, but seems the be the fastest solution.

One option would be to copy the whole sparse matrix using existing method, but then data is copied for nothing. Other possibility is to rewrite column and row index within for loop, but this is slow. Third option: Create new method?

Also, MATLABs behaviour differs a little bit. This is also fixed with the attached patch.

This is the MATLAB result:

(file #30320)

Stefan Mahr <dac922>
Thu 05 Dec 2013 01:14:41 AM UTC, original submission:

atan2 seems to have been broken in the transition from 3.2 (works) to 3.4.

The following simple call to atan2 should work, but returns nothing instead.

For possible reference, there is atan2 code in liboctave/array/dSparse.cc but it is never called. Using gdb I found that the pathway is actually to the Sparse-Scalar template in liboctave/util/oct-binmap.h

Rik <rik5>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #31482:  binmap.diff added by dac922 (4KiB - text/x-patch)
file #30320:  atan2_spare.patch added by dac922 (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dac922 (Updated the item)
  • -unavailable- added by rik5 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 02 Jun 2014 05:15:42 PM UTCrik5StatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Sun 01 Jun 2014 03:27:42 PM UTCdac922Attached File-=>Added binmap.diff, #31482
    Sun 01 Jun 2014 03:25:04 PM UTCrik5StatusNone=>In Progress
    Thu 29 May 2014 03:25:13 PM UTCrik5Summaryatan2 returns no results for sparse matrices=>atan2, fmod, hypot returns no results for sparse matrices
    Mon 20 Jan 2014 04:54:57 PM UTCdac922Attached File-=>Added atan2_spare.patch, #30320

    Back to the top


    Powered by Savane 3.1-cleanup1