<div dir="ltr">Hey,<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 30, 2016 at 12:56 PM, Filippo giacchè <span dir="ltr"><<a href="mailto:filippo.giacche@gmail.com" target="_blank">filippo.giacche@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi to everyone,<div>I m trying to optimize ScInterpreter::ScGCD and ScInterpreter::ScLCM (in <span style="font-size:medium;color:rgb(0,0,0);font-family:monospace">/</span><a href="http://opengrok.libreoffice.org/xref/core" style="font-size:medium;color:rgb(16,88,2);text-decoration:none;font-family:monospace" target="_blank">core</a><span style="font-size:medium;color:rgb(0,0,0);font-family:monospace">/</span><a href="http://opengrok.libreoffice.org/xref/core/sc" style="font-size:medium;color:rgb(16,88,2);text-decoration:none;font-family:monospace" target="_blank">sc</a><span style="font-size:medium;color:rgb(0,0,0);font-family:monospace">/</span><a href="http://opengrok.libreoffice.org/xref/core/sc/source" style="font-size:medium;color:rgb(16,88,2);text-decoration:none;font-family:monospace" target="_blank">source</a><span style="font-size:medium;color:rgb(0,0,0);font-family:monospace">/</span><a href="http://opengrok.libreoffice.org/xref/core/sc/source/core" style="font-size:medium;color:rgb(16,88,2);text-decoration:none;font-family:monospace" target="_blank">core</a><span style="font-size:medium;color:rgb(0,0,0);font-family:monospace">/</span><a href="http://opengrok.libreoffice.org/xref/core/sc/source/core/tool" style="font-size:medium;color:rgb(16,88,2);text-decoration:none;font-family:monospace" target="_blank">tool</a><span style="font-size:medium;color:rgb(0,0,0);font-family:monospace">/</span><a href="http://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr5.cxx" style="font-size:medium;color:rgb(16,88,2);text-decoration:none;font-family:monospace" target="_blank"><wbr>interpr5.cxx</a>) as mentioned in bug tdf#89387..</div><div>From what I understood , these function are not optimal in the matrix case (evenif the algorithms look good in my opinion) and need to be changed. So my question is how can I do it? If I create function in /core/sc/source/core/tool/<wbr>ScMatrix.cxx that take as input a matrix and retuns the GCD(or LCM) I'll do ok?or is not the right way to proceed? thanks ,<span style="background-color:rgb(252,252,255);color:rgb(20,20,20);font-family:verdana,arial,tahoma,calibri,geneva,sans-serif;font-size:13.3333px">I welcome any advice that you can give me.</span></div><br></div><br></blockquote><div><br></div><div>The task is not about changing the algorithm. The new matrix backend does not have O(1) index based access any more so stuff like:<br><br></div><div>for (int i = 0; i < n; ++i)<br>{<br></div><div>    matrix.set(i, y, value);<br>}<br><br></div><div>is not a O(n) algorithm anymore.<br><br></div><div>However the new matrix backend provides some alternatives that allow to write more efficient implementations (that are even faster -- by a constant factor) than the old one. For that we need to use some of the constructs written as part of this bug by . As an example for such a change look at <a href="https://cgit.freedesktop.org/libreoffice/core/commit/?id=9a7959cd63be7b2f36da8af25e7673a525c4d66c">https://cgit.freedesktop.org/libreoffice/core/commit/?id=9a7959cd63be7b2f36da8af25e7673a525c4d66c</a> and try to understand how ApplyOperation and the operator play together. All of this should make sense if you realize that we have no O(n) index access but that iterator access is in O(1).<br><br></div><div>If you need a bit more details after looking at some of the commits in the bug report you can ping me again.<br><br></div><div>Regards,<br></div><div>Markus <br></div></div><br></div></div>