help-octave
[Top][All Lists]
Advanced

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

Re: Can Octave (Matlab code) be added to C++ as a library?


From: evansste
Subject: Re: Can Octave (Matlab code) be added to C++ as a library?
Date: Thu, 9 Apr 2020 15:51:16 -0500 (CDT)

Thanks so much, Michaell, for all of that information.

The matricies, which are inputs for "ismember", each contain over a million
rows, and the number of rows is identical for each input.  So I wrote a
program which employs the last idea that you mentioned.

I'm happy to say that it was way faster than any of the other algorithms
I've tried.  In order for it to work, I had to find a sortrows function.  I
was able to find one, but it takes a lot longer than the actual comparison
part of the algorithm.  The program takes about twenty minutes to sort each
of the inputs.  However, when passing pre-sorted inputs, I've found that the
actual comparison portion only takes 0.3 seconds.  This is the same amount
of time that it takes to run Octave's "ismember" function on the
non-presorted set.  So unless I find a sortrows algorithm which literally
takes no time, it will still be slower than Octave's implementation. 
However, this is certainly the closest I've gotten to actually solving this
problem and implementing a solution that doesn't take nearly an hour to run,
or longer.

I want to thank you for sharing these algorithms with me.  The last one is
actually fairly simple, but it never would have occurred to me -- not for a
moment.

Even though the sortrows algorithm, which I found online, takes about twenty
minutes to sort each of the inputs, it's still a lot faster than a previous
version, which I wrote.  My version uses a method of swapping neighboring
entries after comparing them to see if a swap is necessary.  I'm sure you're
familiar with the procedure.

Here's the much faster version, which I was able to find online.

https://stackoverflow.com/questions/35324153/sorting-arrays-by-rows-in-fortran

It, too, uses an algorithm that I never would have thought of.

I still don't know exactly what Octave is doing in order to perform the
entire "ismember" operation so quickly.  They may be using a similar
approach, with an infinitely fast sort method.  However that method would
have to be instantaneous in order to offer the performance that it does.

In any case, I feel a whole lot closer to getting this to work.  So, I
greatly appreciate the valuable input you've given.



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

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