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

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

[Octave-bug-tracker] [bug #63646] Long creation times for sparseimages.m


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #63646] Long creation times for sparseimages.m in manual due to -svgconvert option to print
Date: Fri, 13 Jan 2023 22:16:32 -0500 (EST)

Follow-up Comment #8, bug #63646 (project octave):

For the example in this report, the nested loops in the following code in
octave_polygon::reconstruct end up calling mergepoly around 52 million times
(if I understand, correctly, it would be (10200^2-10200)/2 == 52014900 calls).
 That appears to be what takes all the time and the result for this example is
that no merges ever happen.  I guess that's good though, because if any merge
is detected, the whole loop will be executed again, and in the worst case, as
few as one polygon might have been added to the unused list.  Is there a
better way to do this job other than by an exhaustive search?  How important
is it to merge the polygons?  Could we make it optional?


    bool tryagain = (m_polygons.count () > 1);

    while (tryagain)
      {
        tryagain = false;
        for (auto ii = 0; ii < m_polygons.count (); ii++)
          {
            if (! unused[ii])
              {
                QPolygonF polygon = m_polygons[ii];
                for (auto jj = ii+1; jj < m_polygons.count (); jj++)
                  {
                    if (! unused[jj])
                      {
                        QPolygonF newpoly = mergepoly (polygon,
m_polygons[jj]);
                        if (newpoly.count ())
                          {
                            polygon = newpoly;
                            m_polygons[ii] = newpoly;
                            unused[jj] = true;
                            tryagain = true;
                          }
                      }
                  }
              }
          }
      }



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63646>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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