Dear all, Recently I stumbled upon a very efficient C++ code which allows for fast drawing a random sample of unique integers from within a given range. The code is by Jon Bentley, http://netlib.bell-labs.com/cm/cs/pearls/code.html (yes, THIS Bentley). Since the webpage says "You may use this code for any purpose, as long as you leave the copyright notice and book citation attached", I have written a small Oct-file which implements this functionality into Octave, see
main/miscellaneous/src/sample.cc As suggested long time ago by Paul Kienzle, sample() can serve as a basis for an improved sprand.m, which presently sometimes suffers from returning matrices of slightly lower density than requested. I prepared a new version of sprand, which utilizes sample() and indeed does a better job in a reasonable time. The code is in main/linear-algebra/inst/sprand.m (well, the function best fits the "sparse" category, but this one disappeared some time ago). With best regards, Piotr Krzyzanowski ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev