Re: upperBound/lowerBound in algorithm O(log n) or O(n) ?

2020-03-28 Thread peheje
Thank you treeform. Have a nice weekend.

upperBound/lowerBound in algorithm O(log n) or O(n) ?

2020-03-27 Thread peheje
Hi In Java binary search returns a negative index if target not found in array where negative index is where to insert (as positive) to preserve sorted array. Is upperBound/lowerBound following binary search speeds O(log n) worst case or linearly? I'm too stupid to read the source code: [http

Re: Automatic Algorithms Optimization via Fast Matrix Exponentiation

2018-07-24 Thread peheje
Thanks for your answer. I'm not smart enough to begin implementing stuff like that. The guy DannyBee on the hackernews forum claims that GCC easily could do this. [https://news.ycombinator.com/item?id=17592359](https://news.ycombinator.com/item?id=17592359) Just thought it was interesting. Are

Automatic Algorithms Optimization via Fast Matrix Exponentiation

2018-07-23 Thread peheje
I recently stumpled upon this thread on HN: [https://kukuruku.co/post/automatic-algorithms-optimization-via-fast-matrix-exponentiation](https://kukuruku.co/post/automatic-algorithms-optimization-via-fast-matrix-exponentiation)/ Impressive. Can the same thing be achieved in Nim? I tried to use the

Re: Optimizing Nim algorithm (compete with c++)

2018-04-29 Thread peheje
Thank you for the gist. You corrected some of my brainfarts as well. Clang seems to be faster for me than gcc! Now faster than my cpp implementation. What configurations sets gcc as standard when compiling Nim? My results: Clang: 0m0.144s GCC: 0m0.197s I'm on a MBP 2013 with Core i7 I7-4850HQ.

Re: Optimizing Nim algorithm (compete with c++)

2018-04-29 Thread peheje
Hi def You beat me to it! **Thank you** very much for looking into it and replying. You are right! I don't get quite the same performance boost as you do, cpp still seems faster but barely. Might be any number of reasons. Do you have any more nice tricks for the nim code? Did you also wrap the

Re: Optimizing Nim algorithm (compete with c++)

2018-04-29 Thread peheje
Okay. I noticed in another thread ([https://forum.nim-lang.org/t/1268/1#7848](https://forum.nim-lang.org/t/1268/1#7848)) Araq telling to wrap the code in a main proc. I did and now the speed is almost comparable to my cpp! Nim: 0m0.197s cpp 0m0.159s Impressive. I updated the master branch

Optimizing Nim algorithm (compete with c++)

2018-04-29 Thread peheje
I have written a differential evolution algorithm in cpp and Nim. My cpp version is faster (6-8 times) and I was hoping I could get comparable performance with the Nim implementation. I need a hand. Nim version: [https://github.com/peheje/nim_genetic/blob/master/DifferentialEvolution/app.nim

Re: Send data structures between threads?

2017-11-02 Thread peheje
Thanks mratsim!

Re: Send data structures between threads?

2017-10-26 Thread peheje
allel statements, spawn statements or even "bare" threads. Am I doing something wrong? I thought that because the object is a ref object only the ref: the address, would be copied? Code here: [https://github.com/peheje/nim_genetic/blob/master/mutable_state.nim](https://github.com/peh