in reply to Re: OT: Finding Factor Closest To Square Root
in thread OT: Finding Factor Closest To Square Root

Thanks. The other replies seem to be converging to this idea too. I still need to do some benchmarking to determine if this approach saves me time for what I'm using it for.

Unfortunately, my Benchmark module seems to be broken. Specifically, cmpthese and timethese give really weird results, like some counter is initialized wrong or overflowing. I can time a single pass with new Benchmark, but the timethese loop always warns about not enough iterations, gives practically 0 times, but takes minutes to run. I'll have to dig into it more, and maybe post something here later.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^3: OT: Finding Factor Closest To Square Root
by Limbic~Region (Chancellor) on Feb 24, 2005 at 16:20 UTC
    QM,
    My latest obsession is with Perl internals, improving my C skills. Inline::C is a great way to do both, so I figured I would translate my previous code (minus the %seen cache). It actually loses when checking just one number, but running it in a loop of a lot of numbers it wins hands down. I am sure someone more knowledgeable could make the C cleaner if not faster.

    Cheers - L~R

    Updated - copy/paste fixed as sleepingsquirrel pointed out below

      I took a quick glance at your code, and found this snippet to be a little odd...
      end_pos = p; for (p = 0; p <= end_pos; ++p) { }
      ...perhaps there was something between the brackes in an earlier version?


      -- All code is 100% tested and functional unless otherwise noted.
Re^3: OT: Finding Factor Closest To Square Root
by Limbic~Region (Chancellor) on Feb 23, 2005 at 19:33 UTC
    QM,
    If you summarize the routines that produce valid solutions, I will be happy to benchmark. To remove the unfair advantage of determining the prime factorization - this will be done before hand and will be common to all routines

    Cheers - L~R

      It seems that I'm not going to have the time to summarize this and take advantage of your offer. But thanks for trying.

      Maybe in a few weeks I can revisit this and follow up. Otherwise, is someone else with a similar interest up to the task?

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of