00:07
pharx has quit [Read error: 104 (Connection reset by peer)]
00:38
GreyLensman has joined #ocaml
01:21
gim_ has joined #ocaml
01:21
gim has quit [Read error: 110 (Connection timed out)]
01:26
GreyLensman has quit ["Leaving"]
01:59
voxel has joined #ocaml
02:04
gim__ has joined #ocaml
02:10
gim_ has quit [Read error: 110 (Connection timed out)]
02:54
CosmicRay has joined #ocaml
03:03
gim__ has quit ["pula"]
03:20
monochrom has quit ["hello"]
03:37
CosmicRay has quit ["Leaving"]
04:04
vezenchio has joined #ocaml
04:31
vezenchio has quit ["Deadpool still votes for Perot. Every time. Just in case."]
04:34
vezenchio has joined #ocaml
04:45
cmeme has quit [Connection timed out]
04:46
cmeme has joined #ocaml
05:07
mlh has quit [Client Quit]
05:12
mrsolo has joined #ocaml
07:02
mlh has joined #ocaml
08:09
avn has quit [Remote closed the connection]
08:14
avn has joined #ocaml
08:35
vezenchio has quit ["Deadpool still votes for Perot. Every time. Just in case."]
08:36
vezenchio has joined #ocaml
09:13
solarwind has quit ["leaving"]
09:23
solarwind has joined #ocaml
09:33
solarwind has quit ["leaving"]
10:11
daapp has joined #ocaml
10:36
smimou has joined #ocaml
10:50
daapp has left #ocaml []
11:07
mlh has quit [Client Quit]
11:17
lus|wazz has joined #ocaml
11:36
vezenchio has quit [Read error: 110 (Connection timed out)]
11:39
smimou has quit [Read error: 110 (Connection timed out)]
11:40
smimou has joined #ocaml
11:43
smimou has quit [Client Quit]
11:47
srv has quit [Read error: 104 (Connection reset by peer)]
11:51
srv has joined #ocaml
11:57
dxlvi has joined #ocaml
12:14
solarwind has joined #ocaml
12:32
Herrchen has joined #ocaml
13:27
fremo has joined #ocaml
13:29
moonfish has joined #ocaml
13:31
<
moonfish >
can someone here answer a question on let-polymorphism?
13:35
<
moonfish >
let twoTuple () = let f x = x in (f 1, f false);; works
13:35
<
moonfish >
let twoTuple f = (f 1, f false);; doesn't
13:36
<
moonfish >
I want to be able to call twoTuple like: twoTuple id;;
13:36
<
moonfish >
is that at all possible?
13:37
<
moonfish >
thanks. I'll take a look.
13:38
<
moonfish >
I was googling around but that link didn't come up, for some reason.
13:40
eugos has joined #ocaml
13:43
_fab has quit [Remote closed the connection]
13:43
<
moonfish >
The answer appears to be that it can't be done. See the "My program is not polymorphic (enough)?" question. Is that correct?
13:44
<
moonfish >
I meant "How to write a function with polymorphic arguments ?".
13:50
<
moonfish >
solarwind: that's FAQ question matching my earlier question. and the answer is "you can't".
13:52
Herrchen has quit ["bye"]
14:12
Nic has joined #ocaml
14:29
CosmicRay has joined #ocaml
14:30
eugos has quit ["Leaving"]
14:31
eugos has joined #ocaml
14:37
dxlvi has quit ["ey"]
14:37
dxlvi has joined #ocaml
14:37
dxlvi has quit [Remote closed the connection]
14:44
<
Nic >
how can I know if a number is a square ? or if the root square of a number is natural ?
14:44
<
Nic >
is there a root square function in caml?
14:45
<
Nic >
ha yes thanks
14:45
<
Nic >
what about the first question ?
14:45
<
solarwind >
external sqrt : float -> float = "sqrt_float" "sqrt" "float"
14:45
<
solarwind >
It's in pervasives.
14:46
<
solarwind >
Nic: I think all the numbers have a square. Hence your question is the last one.
14:47
<
Nic >
a natural one
14:47
<
Nic >
not sure if it's the right word
14:47
<
Nic >
25 is a square because sqrt(25)=5
14:48
<
solarwind >
A wild guess, you can check if that number's square mod'ed 2 has the result 0 or 1.
14:49
<
pango >
I don't know if that property can be checked in constant time... You could try finding square root thru dichotomia...
14:49
<
Nic >
do I really need that ?
14:49
<
Nic >
you think it will be faster ?
14:50
<
pango >
there's also a way to compute square root "by hand", it may give ideas on how to solve the problem
14:50
<
vincenz >
it's quite easy
14:50
<
vincenz >
just find the sqr-root
14:50
<
vincenz >
round down
14:50
<
vincenz >
and see if it's equal to iteself
14:51
<
vincenz >
or, transfor to int and see if the number % the found sqrroot is 0
14:51
<
vincenz >
shouldn't be too hard, but this treally smells like homework
14:51
<
Nic >
how do I transfer to int ?
14:51
<
Nic >
or how do I round down ?
14:51
<
pango >
I don't like going thru floats in that case
14:51
<
vincenz >
that's called "look in docs"
14:52
<
Nic >
thought it was rtfm
14:52
<
vincenz >
rtfm, but I was being polite
14:53
<
solarwind >
RTFM sounds like a formatting method for some docs.
14:53
<
vincenz >
yes, RTF is windows crap
14:53
<
solarwind >
Rich Text Format.
14:53
<
vincenz >
back to away
14:59
monochrom has joined #ocaml
14:59
<
Nic >
pango: not really appropriate in my case, but interesting though
14:59
<
pango >
Nic: problem of going thru floats is rounding errors
14:59
gim has joined #ocaml
15:01
<
Nic >
pango: what do you mean ?
15:01
<
pango >
what if 4 is translated into 3.9999..., sqrt gives 1.9999...., in turn rounded to 1 ? then 4 is not a square number
15:02
<
avlondono >
Nic: what is this for?
15:02
<
Nic >
pango: this could really happen ?
15:02
<
pango >
Nic: happens all the time with floats
15:02
<
Nic >
avlondono: for a little math exercise
15:03
<
pango >
Nic: we're dealing with finite precision numbers
15:03
<
avlondono >
oh, so don't kill it like this, there is a nice (cool) simple recursion for this. enough tip I guess.
15:03
<
Nic >
I need to found all the numbers, for which a*a + (a+1)*(a+1)=c*c
15:03
<
Nic >
a=3 and c=5 for example
15:03
<
pango >
avlondono: based on the square root computation (URL above ?)
15:04
smimou has joined #ocaml
15:04
<
avlondono >
I think not
15:07
<
pango >
Nic: ok, you iterate over a, and check if a^2 + (a+1)^2 is a square, correct ?
15:09
<
pango >
Nic: then just keep c around, checking if a^2 + (a+1)^2 is within [c^2, (c+1)^2] range, increasing c when it's over
15:13
<
Nic >
then I check if it works with the last value of c?
15:15
<
Nic >
the function to test if a number is a square or not seems to work. so I could use my basic method
15:15
<
Nic >
int list = [100; 81; 64; 49; 36; 25; 16; 9; 4; 1; 0]
15:15
<
pango >
keep a and c so that c^2 <= a^2 + (a+1)^2 < (c+1)^2
15:16
<
pango >
checking each time if you need to increase a or c
15:21
<
Nic >
it'll be faster ? or more accurate ?
15:21
<
pango >
certainly both
15:22
<
pango >
you can keep a*a, (a+1)*(a+1), c*c and (c+1)*(c+1) around to avoid computing more often than necessary, but that's an optimization
15:31
lus|wazz is now known as vezenchio
15:32
<
Nic >
how do I comment a function ? I don't remember, and I really don't know where to search in the manual :p
15:33
<
Nic >
ha yes thanks
15:33
<
Nic >
I thought it was like in C /* */ :p
15:34
<
Smerdyakov >
Try searching the grammar.
15:34
<
Smerdyakov >
(for future questions like that)
15:36
<
Smerdyakov >
Oh no! You're using Caml Light? :O
15:37
<
Smerdyakov >
Well, it's still obvious where to look in the manual.
15:38
<
Nic >
but I already don't know anything in caml light. I would have to learn the both
15:38
<
Smerdyakov >
I'm saying that it's obvious where to look in the
_Caml_Light_ manual.
15:39
_fab has joined #ocaml
15:39
<
Nic >
you said Oh no! it means it's bad and I agree. I can't even compile the additional libraries (like the graphics one)
15:41
<
Smerdyakov >
All I'm talking about now is how easy it is to resolve any questions about syntax.
15:42
<
Nic >
now, it still isn't obvious for me, as I'm pretty bad in english, and dumber than you I guess
15:43
<
Smerdyakov >
Well, let's see. There are four big section headings in the TOC. Do you know which would contain such information?
15:47
<
Nic >
hmm ok, I'm sorry
15:47
<
Smerdyakov >
Hm? Is that an answer to the question?
15:47
<
Nic >
core caml light language, then lexical conventions
15:48
<
Smerdyakov >
Tada! Easy, yes? :)
15:52
eugos has quit ["Leaving"]
15:55
smimou has quit [Read error: 110 (Connection timed out)]
16:07
smimou has joined #ocaml
16:14
<
Nic >
hmm my version isn't similar to yours :) it was almost done, but I'm having a small problem, so I don't even know if it works :p
16:19
<
Nic >
pango: you tried it?
16:19
<
pango >
0, 1: 0^2 + 1^2 = 1^2
16:19
<
pango >
3, 5: 3^2 + 4^2 = 5^2
16:19
<
pango >
20, 29: 20^2 + 21^2 = 29^2
16:19
<
pango >
119, 169: 119^2 + 120^2 = 169^2
16:19
<
pango >
696, 985: 696^2 + 697^2 = 985^2
16:19
<
pango >
4059, 5741: 4059^2 + 4060^2 = 5741^2
16:23
<
Nic >
finally, I don't get it
16:24
<
Nic >
once you've c^2 <= a^2 + (a+1)^2 < (c+1)^2 , why does it mean c^2 = a^2 + (a+1)^2 ?
16:26
smimram has joined #ocaml
16:30
<
Nic >
it isn't the program itself, its the algorithm. I don't see how it works. see my previous question
16:32
<
pango >
if c^2 = a^2 + (a+1)^2, you have a solution
16:32
smimou has quit [Read error: 60 (Operation timed out)]
16:32
<
Nic >
but its isnt =
16:33
<
pango >
if c^2 < a^2 + (a+1)^2 < (c+1)^2 then there's no solution with that c, you can go on with another value for a
16:33
<
pango >
if a^2 + (a+1)^2 >= (c+1)^2 then maybe a higher c value will do
16:34
<
pango >
correction, "if c^2 < a^2 + (a+1)^2 < (c+1)^2 then there's no solution with that a, you can go on with another value for a"
16:36
<
pango >
or in other words, a^2 + (a+1)^2 is between two consecutive square numbers, so there's no solution with that value of a
16:38
<
Nic >
sorry finally it's very clear, but I confused myself :p
16:39
<
Nic >
I didn't even do the right cases
16:40
<
pango >
the optimized version just threads the values of a^2, a+1, (a+1)^2, a^2+(a+1)^2 and c^2 to avoid recomputing them
16:40
<
Nic >
yep I saw that
16:43
<
Nic >
let (a,c) = (0,1) in for i = 1 to n do let (a,c) = next(a+1,c); done; (a,c);;
16:44
<
Nic >
whats wrong there ? it said there is a syntax error with done
16:44
<
pango >
let syntax is let var = expr in expr
16:45
<
pango >
unless it's a global declaration, but that's not the case here
16:45
<
Smerdyakov >
'let' is not an 'assignment statement.'
16:45
<
Smerdyakov >
It's completely useless in the way you're trying to use it.
16:45
<
Nic >
how do I do that?
16:45
<
Smerdyakov >
You don't.
16:45
<
Nic >
I don't get it
16:45
<
Smerdyakov >
'let' cannot be used by itself to introduce imperative features.
16:46
<
Nic >
I meant : why should I use then ?
16:46
<
Smerdyakov >
Never use 'for.'
16:46
<
Smerdyakov >
Use a recursive function instead.
16:46
<
Nic >
ha yes, sorry :)
16:54
<
pango >
ain't that great to know that 159140519^2 + 159140520^2 = 225058681^2 ? ;)
16:56
smimram has quit [Read error: 110 (Connection timed out)]
17:00
chantry has joined #ocaml
17:00
Nic has quit [Read error: 104 (Connection reset by peer)]
17:00
<
chantry >
hmm I don't if its caml that hardlocked my laptop, but it was very fun
17:00
chantry is now known as Nic
17:01
<
Nic >
I miss the last msg, if there was any
17:05
<
Nic >
pango: are you able to calculate the 6th solution ?
17:11
chantry has joined #ocaml
17:11
Nic has quit [Read error: 104 (Connection reset by peer)]
17:11
<
chantry >
hardlock again :p
17:12
<
pango >
chantry: must be running a non tail recursive program with too few virtual memory
17:13
<
chantry >
my mem wasnt totally used in top
17:13
<
chantry >
the swap wasnt even hitten
17:13
<
pango >
or you have an overheating cpu
17:13
<
chantry >
but the proc was used at 99%
17:13
<
chantry >
hmm yep maybe
17:13
<
pango >
to answer your question, it's not difficult, I just added an additionnal n parameter:
17:14
<
chantry >
so it works for you?
17:14
<
pango >
$ time ./problem3int64 6
17:14
<
pango >
4059, 5741: 4059^2 + 4060^2 = 5741^2
17:14
<
pango >
./problem3int64 6 0,02s user 0,00s system 1373% cpu 0,001 total
17:14
<
pango >
system usage is interesting ;)
17:16
Smerdyakov has quit [Remote closed the connection]
17:16
Demitar has quit [Read error: 104 (Connection reset by peer)]
17:17
<
chantry >
hmm I need ocaml for that :)
17:18
<
chantry >
pango: why is my version so bad ? I could make it tail recursive ?
17:18
<
avlondono >
just wanted to note that (n + 1)^2 = n^2 + 2n + 1 (for a really unnecessary speedup)
17:19
<
pango >
avlondono: yes
17:20
<
pango >
using Int64.shift_left ;)
17:20
<
chantry >
pango: did you compare your different versions ? it would be interesting
17:28
<
chantry >
pango: wow it's impressive :)
17:29
Demitar has joined #ocaml
17:30
<
chantry >
you should have edited your last version
17:31
<
pango >
what did I miss ?
17:31
<
chantry >
to run it like that : ./a.out n
17:32
<
pango >
btw, 927538920^2 + 927538921^2 = 1311738121^2
17:34
Kevin_ has joined #ocaml
17:42
<
chantry >
hmm the last one isnt faster there
17:43
<
pango >
depends on how a Int64.mul fares compared to an Int64.shilft_left, a Int64.add and an Int64.succ
17:44
<
chantry >
so Int64.mul is faster in this case
17:44
<
chantry >
on my comp at least
17:45
<
pango >
yes, it depends on several factors (functions implementation, compiler, CPU)
17:45
<
pango >
it was just to make the code look uglier ;)
17:46
<
avlondono >
neat please, neat
17:46
<
chantry >
whats strange is my version, is that its very fast until 5
17:46
<
chantry >
and for 6, it never ends
17:46
<
chantry >
time ./myversion 5
17:46
<
chantry >
4059 5741
17:46
<
chantry >
real 0m0.007s
17:46
<
chantry >
user 0m0.005s
17:46
<
chantry >
sys 0m0.002s
17:50
<
chantry >
I think I'll hardlock soon :)
17:55
<
chantry >
I'm running for 4 min at 99% and I'm stilll there
17:55
<
chantry >
don't know why it hardlocked so fast before
17:55
<
chantry >
I'm using ocamlc instead of camllight, its maybe that
17:58
<
chantry >
mine still didnt end after 8 min
18:00
<
chantry >
pango: nice, its faster :)
18:00
Godeke has quit [Remote closed the connection]
18:01
<
chantry >
5.372 vs 7.58 for the previous and 5.9 for the Int64.mul one
18:02
pango has quit [Nick collision from services.]
18:02
pango_ has joined #ocaml
18:02
<
pango_ >
$ time ./problem3pint64 6
18:02
<
pango_ >
4059, 5741: 4059^2 + 4060^2 = 5741^2
18:03
<
pango_ >
./problem3pint64 6 0,02s user 0,00s system 42% cpu 0,047 total
18:03
<
chantry >
ha t'es fr
18:03
<
pango_ >
(using ocamlopt)
18:04
<
chantry >
t'es sous linux la ?
18:04
<
chantry >
il est bizarre ton time
18:05
<
pango_ >
yes, don't know why... I enabled oprofile, maybe it confuses things :/
18:06
<
pango_ >
all I can tell is that it's almost instantaneous
18:06
<
chantry >
pango_: my prog would be a lot faster if it was tail recursive ?
18:07
<
pango_ >
"next" looks tail recursive, unless I'm missing something
18:08
<
pango_ >
but that shouldn't matter too much, it's no deeper than n calls
18:10
<
chantry >
I'm not even able to get u(6)
18:10
<
pango_ >
I wonder what's u computing exactly, through
18:10
<
chantry >
the nth solution
18:12
<
pango_ >
sometimes u result is some next output, but u results are also used for next arguments...
18:14
<
chantry >
ha yes :)
18:15
<
pango_ >
looks like you have a problem with "let" again
18:16
<
chantry >
next(u(n-1))=u(n-1) so I can't do that
18:17
Godeke has joined #ocaml
18:19
<
pango_ >
mmmh no maybe I wrong, next takes and returns int pairs, that looks ok
18:21
<
chantry >
the let thing isnt the problem
18:21
<
chantry >
its still the same without it
18:21
<
chantry >
works fine for 1..5
18:22
<
chantry >
but takes more than 9 min for 6
18:22
monochrom has quit ["hello"]
18:31
<
pango_ >
chantry: you're hitting int overflows when computing the square of numbers >= 32768
18:32
<
chantry >
yep it was strange that there was a such big difference between 5 and 6
18:35
<
chantry >
pango_: so I need Int64 too ?
18:35
<
chantry >
pango_: you first versions would have done the same as mine ?
18:36
<
pango_ >
they did. They stopped at 4059, 5741 also
18:36
<
chantry >
and btw, you were right, i think I did a tail recursive version, but it isnt faster
18:37
<
chantry >
hey finally my version is the fastest for that :)
18:38
<
chantry >
for 4059, 5741
18:38
<
chantry >
I didnt notice my u(5) = your u(6)
18:38
<
pango_ >
yes, your n is 0 based while mine is 1 based
18:38
<
pango_ >
s/your/yours/
18:39
<
chantry >
Int64 is the only way or is there other types I could try ?
18:40
<
chantry >
I have to use it in the same way ?
18:41
<
pango_ >
Big_int module provides similar function, check the .mli
18:42
<
pango_ >
but then, I think the algorithm will need further optimization...
18:43
<
pango_ >
a^2 + (a+1)^2 grows faster than c^2, so looking for solution by incrementing c is somewhat too slow
18:45
<
pango_ >
if you can find an upper bound for c as a function of a, it may become faster to use dichotomia (for example) that just increments
18:45
<
pango_ >
s/that/than/
18:47
<
pango_ >
like, c <= (a+1)*(sqrt 2)
18:48
<
Nutssh >
There is an upper bound... a^2 = c^2-b^2 = (c-b)(c+b) So factor a into all possible pairs x*y, and solve for c-b=x, c+b=y
18:58
* avlondono
was just giving tips, but they where blind to the tips ...
18:59
<
avlondono >
blindness!!! :-)
18:59
<
Nutssh >
Minor bug, you wnat the prime factorization of a^2, then enumerate them. Time: O(n^.5/log n) for the factorization.
19:04
<
Nutssh >
I prefer algorithmic improvements whenever possible.
19:11
<
chantry >
it becomes way too complicated for me :)
19:11
<
chantry >
well it was just a math exercise, not an informatic one
19:11
<
chantry >
I just needed a basic algorithmic
19:12
<
chantry >
but it can indeed be interesting :)
19:15
<
Nutssh >
With a tiny bit of care, this is O(size of result), once you have the prime factorization.
19:21
Smerdyakov has joined #ocaml
19:56
vezenchio has quit ["Deadpool still votes for Perot. Every time. Just in case."]
20:13
<
chantry >
gcc : 0m0.278s
20:13
<
chantry >
ocaml : 0m5.399s
20:14
m3ga has joined #ocaml
20:14
chantry is now known as Nic
20:14
<
Smerdyakov >
What is the point of that?
20:15
<
Nic >
I don't understand why the same prog in C is so fast, or why it's so slow in ocaml
20:16
<
Smerdyakov >
Obviously it's not "the same prog."
20:16
<
Nic >
I wrote the C one, so it can't be better
20:16
<
Smerdyakov >
And you wrote the OCaml version?
20:16
<
Nic >
I wrote one, but tried the pango's one too
20:17
<
Smerdyakov >
Are the two versions on the web somewhere?
20:17
<
Smerdyakov >
Where?
20:19
<
Smerdyakov >
Ugh. Kind of a pain to read through that. I'd suggest translating it to SML and trying it with MLton. OCaml does a very poor job of optimization.
20:21
<
Smerdyakov >
I would bet that OCaml is boxing all the Int64's.
20:21
<
Smerdyakov >
Since it even boxes the basic int type.
20:21
<
pango_ >
Smerdyakov: boxing ints ?
20:21
<
Smerdyakov >
Er, Int32 type
20:22
<
Smerdyakov >
pango_, yes
20:23
<
pango_ >
yes, Int32s
20:23
<
Nic >
even with the int type, there is a difference, but the times are very small in both cases
20:23
<
Nic >
0.008 s vs 0.002 s
20:23
<
Nic >
for the big numbers I can compute with my ocaml version
20:24
<
pango_ >
you used doubles in C, not 64 bit ints
20:24
<
Smerdyakov >
Nic, do you understand what it means that OCaml boxes Int64's? Every one has heap memory allocated for it, and it is referenced with a pointer.
20:24
<
pango_ >
don't know how they compare in speed
20:24
<
Nic >
Smerdyakov: ha
20:25
<
pango_ >
Nic: btw, the time you gave are for what n value ?
20:26
<
Nic >
pango_: pango_ 10
20:26
<
pango_ >
27304196^2 + 27304197^2 = 38613965^2 ?
20:27
<
Nic >
nah, my C prog is like yours
20:27
m3ga has quit ["Client exiting"]
20:27
<
pango_ >
ok, 1 based
20:32
<
pango_ >
C program is slower with long long, but still faster
20:34
<
pango_ >
maybe it's boxing, maybe it's ocaml compiler that doesn't handle well tail recusion with so many parameters, I don't know. Only looking at generated asm will tell
20:36
<
Nic >
well, even if my prog in C is faster, the caml one looks nicer
20:36
<
Nic >
I think I'll keep it
20:36
<
mrvn >
How far do you let it run?
20:37
<
mrvn >
mrvn@frosties:~% time ./foo
20:37
<
mrvn >
3^2 + 4^2 = 5^2
20:37
<
mrvn >
20^2 + 21^2 = 29^2
20:37
<
mrvn >
119^2 + 120^2 = 169^2
20:37
<
mrvn >
696^2 + 697^2 = 985^2
20:37
<
mrvn >
4059^2 + 4060^2 = 5741^2
20:37
<
mrvn >
23660^2 + 23661^2 = 33461^2
20:37
<
mrvn >
137903^2 + 137904^2 = 195025^2
20:37
<
mrvn >
803760^2 + 803761^2 = 1136689^2
20:37
<
mrvn >
4684659^2 + 4684660^2 = 6625109^2
20:37
<
mrvn >
27304196^2 + 27304197^2 = 38613965^2
20:37
<
mrvn >
./foo 0.35s user 0.00s system 97% cpu 0.359 total
20:39
<
Nic >
I only compared with precise values of n
20:39
<
Smerdyakov >
OK, I've run some experiments that use 64-bit integers to sum the numbers from 0 to 100000000.
20:40
<
Smerdyakov >
Without any special command-line flags:
20:40
<
Smerdyakov >
gcc takes 0m0.638s
20:40
<
mrvn >
./foo 1.30s user 0.00s system 99% cpu 1.307 total
20:40
<
Smerdyakov >
ocaml takes 0m12.197s
20:40
<
Smerdyakov >
mlton takes 0m1.119s
20:40
<
Nic >
a lot better indeed
20:40
<
Smerdyakov >
gcc down to .142 if compiled with -O5.
20:41
<
Nic >
whats mlton ? it can compile the same code ?
20:41
<
Smerdyakov >
No. MLton is an SML compiler.
20:42
<
mrvn >
Smerdyakov: How does your sourec look like?
20:42
<
Smerdyakov >
Why is that "ha"?
20:43
<
Nic >
Smerdyakov: because I didn't know it
20:45
<
mrvn >
I'm using 63bit ints for the above square sum problem and it takes just 1s till 100000000.
20:45
<
mrvn >
Having a decent cpu is a big plus.
20:46
<
Smerdyakov >
I believe I do have a decent CPU.
20:47
<
Smerdyakov >
Besides, it's the ratios that are interesting.
20:48
<
mrvn >
Answer: 5000000050000000
20:48
<
mrvn >
./foo2 0.25s user 0.00s system 97% cpu 0.257 total
20:48
<
Smerdyakov >
What about the C version?
20:49
<
mrvn >
zsh: segmentation fault ./test64
20:49
<
mrvn >
./test64 0.00s user 0.00s system 0% cpu 0.000 total
20:49
<
Smerdyakov >
You have to run it with an argument that tells how many to sum.
20:49
<
mrvn >
hehe, it helps to pass an argument.
20:49
<
mrvn >
./test64 100000000 0.10s user 0.00s system 93% cpu 0.107 total
20:49
<
Smerdyakov >
Use 100000000
20:49
<
Smerdyakov >
OK, now try my test64.ml.
20:50
<
mrvn >
That would be foo2
20:50
<
mrvn >
except with 63bit ints.
20:51
<
Smerdyakov >
Ah. But the requirement is 64-bit. :)
20:51
<
Smerdyakov >
(I don't think "CPU's" have anything to do with this. You changed the program!)
20:51
<
mrvn >
pango_: get lost. That is awfull code.
20:51
<
mrvn >
Smerdyakov: 63bit is usualy enough. 31bit ints are too little.
20:51
<
pango_ >
mrvn: it's not a beauty contest
20:51
<
Smerdyakov >
How do I use 63-bit?
20:52
<
mrvn >
Smerdyakov: You buy a 64bit cpu.
20:52
<
Smerdyakov >
mrvn, do you have MLton installed?
20:53
<
mrvn >
E: Couldn't find package mlton
20:53
<
Smerdyakov >
There is no 64-bit version of it for Debian, if that's what you mean.
20:53
<
Smerdyakov >
The 32-bit version should work fine, though.
20:54
<
pango_ >
mrvn: so you have a 64 bits, and now what ?
20:55
<
Smerdyakov >
Well, my point is that I suspect that MLton would trounce OCaml by some significant amount, if you could try it out.
20:56
<
mrvn >
Smerdyakov: comparing 64bit code against 32bit code wouldn't be fair and I'm not going to install a 32bit ocaml with all its libs.
20:56
<
Smerdyakov >
I would be interested in the unfair results, all the same.
20:56
<
mrvn >
pango_: The difference is I don't square. Probably doesn't make much of a difference for 64bit but for say 1024 bit numbers it would.
20:57
<
pango_ >
mrvn: I have a version that don't square too (doesn't * 2 either, use shift instead), but Nic said it wasn't any faster for him
20:58
<
mrvn >
*2 and shift for ints should result in the same code.
20:58
<
pango_ >
mrvn: I don't know, I'm not a compiler
20:59
mrvn_ has joined #ocaml
20:59
<
mrvn_ >
Int64.sqr is probably faster than a2 += 2 * a + 1 due to the extra function calls.
21:00
<
mrvn_ >
pango_: I was thinking that maybe c could be increased by more than 1 if c^2 is too small.
21:01
<
pango_ >
mrvn: yes, for big values of a and c, incrementing c by one is too slow
21:02
<
Nic >
mrvn_: they already talked a bit about that :)
21:02
<
pango_ >
if you have a log of the channel, it was said around 7:43pm
21:02
<
mrvn_ >
pango_: and what time is it now?
21:03
<
pango_ >
I have 10:02pm (sorry I should have mentionned TZ)
21:05
<
mellum >
You mean not everybody is from France here?
21:05
<
pango_ >
I must have some kind of sinusitis, my brain is on fire, I have a hard time thinking straight :/
21:06
<
mrvn_ >
And why do you use pm? 24h clocks are so much easier.
21:07
<
pango_ >
do you people care about the problem at hand, or just about making me miserable ? :)
21:07
<
mrvn_ >
Just killing time.
21:07
<
pango_ >
yes, successfully
21:08
<
calvin_ >
how does one sqrt in ocaml?
21:08
<
calvin_ >
nevermind :P
21:12
<
pango_ >
time to get the red pill...
21:13
mrvn has quit [Read error: 104 (Connection reset by peer)]
21:14
<
pango_ >
Have you seen The Matrix (ep.1) ?
21:26
<
Nic >
but I don't remember what the pills mean
21:30
<
pango_ >
check the scene when Neo and Morpheus meet for the first time... or google for "matrix red pill blue pill"... that's totally off topic :)
21:31
Demitar has quit [Remote closed the connection]
21:35
<
async >
Smerdyakov: u there?
21:35
<
Nic >
you're leaving the matrix ? :)
21:36
<
Nic >
it seems the ocaml prog is more limited too. It never ends for n=14
21:37
<
Nic >
I didn't even notice I was running it for nearly one hour :)
21:39
<
pango_ >
Nic: it's also probable that, using doubles, the C program may miss some solutions
21:39
<
pango_ >
Nic: comparing a floating type value to 0 is always dangerous
21:39
monochrom has joined #ocaml
21:41
<
Nutssh >
This problem has a closed form.
21:42
mrsolo has quit [Operation timed out]
21:48
mlh has joined #ocaml
21:57
<
pango_ >
for(;;) { x = x + 1; i = i + 1; if(i*i-x*x != 0) break; } => x = 3037000500 (not too bad)
21:58
<
pango_ >
I forgot double x = 0; long long i = 0;
22:05
dxlvi has joined #ocaml
22:18
pharx has joined #ocaml
22:29
dxlvi has quit ["brb .)"]
22:35
Kevin_ has quit ["Quit"]
23:01
CosmicRay has quit ["Client exiting"]
23:10
Nic has quit ["leaving"]
23:30
skylan has quit [Client Quit]
23:35
skylan has joined #ocaml
23:46
gim has quit ["..."]
23:51
monochrom has quit ["hello"]