--- Log opened Wed May 30 00:00:08 2012 |
00:01 | <@VV> | If you want to start with pure water, y(0) = 0, so C = 30 / e^(-0/12) = -30. |
00:02 | < Tarinaky> | VV: Why does multiplying by an integrating factor not work? |
00:02 | < Tarinaky> | Aside from being more work shouldn't it either fail catastrophically or arive at the same answer in more time? |
00:03 | <@VV> | I don't know. I haven't tried integrating factor. I don't remember how to generate the integrating factor either, so I haven't tried. |
00:05 | <@VV> | You may not have it in the right form when you try to generate the integrating factor. |
00:06 | < Tarinaky> | Integrating factor is that if you have y' + P(x) y = Q(x) then you can multiply both sides by e^(integral[P(x),dx]) to get an expression of the chain rule. |
00:07 | <@VV> | But the other thing is - the integrating factor, the exact thing it does is make the resulting equation separable. |
00:07 | <@VV> | Okay. that's what I was looking for, let me do this. |
00:08 | <@VV> | y' + 1/12 y = 5/2; e^(x/12)y' + 1/12 e^(x/12)y = 5e^(x/12)/2... |
00:09 | <@VV> | man it's been a while hasn't it. |
00:10 | < Tarinaky> | Which gives you d/dx[e^(x/12) y] = 5/2 e^(x/12) |
00:10 | < Tarinaky> | (Stop me if I'm wrong) |
00:13 | <@VV> | I'll believe you for now, but I'm running on 4 hours sleep and 5 hours weeding my parents' garden and I don't have my references in front of me. |
00:14 | < Tarinaky> | Ah. Sorry. |
00:14 | < Tarinaky> | I'm just not sure what I'm 'missing'. |
00:14 | | Tamber [tamber@furryhelix.co.uk] has quit [Ping timeout: 121 seconds] |
00:14 | < Tarinaky> | Anyway. That gives you y = integral [5/2 e^x/12,dx] / e^(x/12) |
00:15 | < Tarinaky> | Which is about the point we obviously diverge from the seperable result. |
00:15 | | Attilla [Obsolete@Nightstar-30884e4a.threembb.co.uk] has quit [[NS] Quit: ] |
00:20 | | Tamber [tamber@furryhelix.co.uk] has joined #code |
00:20 | | mode/#code [+o Tamber] by ChanServ |
00:23 | | Attilla [Obsolete@Nightstar-aae824b5.as43234.net] has joined #code |
00:26 | <@VV> | There may be a form change error here. |
00:27 | | Derakon[AFK] is now known as Derakon |
00:27 | <@VV> | Oh it's not chain rule it's product rule, that's where I was getting befuddled. |
00:28 | <@VV> | Okay, now I get what you got. |
00:28 | <@VV> | Let me see now. |
00:36 | <@VV> | y = (60/2 e^x/12 + C) / e^(x/12) = 30 + Ce^(-x/12) |
00:38 | <@VV> | which is exactly what I got earlier. |
00:38 | <@VV> | So, um |
00:39 | <@VV> | No, that worked. |
00:42 | <@VV> | What did you get off that last part? Because up through there there was no problem. |
00:55 | | You're now known as TheWatcher[T-2] |
01:01 | | You're now known as TheWatcher[zZzZ] |
01:52 | <@rms> | http://imgur.com/r/gaming/EWgr9 |
01:54 | | himi [fow035@D741F1.243F35.CADC30.81D435] has joined #code |
01:54 | | mode/#code [+o himi] by ChanServ |
01:56 | <@VV> | rms: clearly that rep has coded some hardware requirements checks! |
02:12 | | Attilla [Obsolete@Nightstar-aae824b5.as43234.net] has quit [Ping timeout: 121 seconds] |
02:13 | | himi [fow035@D741F1.243F35.CADC30.81D435] has quit [Connection closed] |
02:13 | | himi [fow035@D741F1.243F35.CADC30.81D435] has joined #code |
02:13 | | mode/#code [+o himi] by ChanServ |
02:47 | | Kindamoody[zZz] [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has quit [Connection closed] |
02:47 | | Kindamoody|out [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has joined #code |
02:47 | | mode/#code [+o Kindamoody|out] by ChanServ |
02:47 | | Kindamoody|out is now known as Kindamoody |
03:44 | < celticminstrel> | Whee, I have an almost nice-looking menu. |
03:48 | < Rhamphoryncus> | Oh yeah, C++ is really elevating my error checking |
03:48 | < Rhamphoryncus> | throw std::invalid_argument("Matrix() literals must be <whatever the template was told> long, not <whatever you gave>"); |
03:49 | < Rhamphoryncus> | I suspect I could define my own exception type to carry the two parameters with it |
03:51 | < Rhamphoryncus> | Heh, I almost did something really stupid. I want to flip the columns/rows of a matrix so I was going to iterate over each i,j and swap it with j,i |
03:56 | | Tamber [tamber@furryhelix.co.uk] has quit [Ping timeout: 121 seconds] |
04:02 | | Tamber [tamber@furryhelix.co.uk] has joined #code |
04:02 | | mode/#code [+o Tamber] by ChanServ |
04:09 | < celticminstrel> | I get the impression that std::exception::what() is (rather uselessly) returning the string "std::exception". |
04:10 | < Rhamphoryncus> | Does it? I haven't dug into it |
04:12 | | Kindamoody is now known as Kindamoody|breakfast |
04:14 | < celticminstrel> | Well, I haven't seen any useful information in the console when I get a SIGABORT. |
04:14 | < celticminstrel> | Despite catching the exception. |
04:14 | < celticminstrel> | (Catch, print what(), rethrow.) |
04:22 | < Rhamphoryncus> | Ah, I would never expect something sane from catching a signal |
04:22 | < Rhamphoryncus> | I would always use sigwait() in a dedicated thread |
04:25 | < celticminstrel> | No, I'm not catching the SIGABORT. |
04:25 | < celticminstrel> | I'm catching an exception and rethrowing it. |
04:25 | < celticminstrel> | That's where the signal comes from. |
04:26 | < celticminstrel> | Uncaught exception = SIGABORT (by default, at least) |
04:26 | < Rhamphoryncus> | ahh |
04:26 | < Rhamphoryncus> | Not flushing stdout? |
04:27 | < celticminstrel> | I think it was stderr, and endl does a flush anyway, so I doubt that's it. |
04:27 | < Rhamphoryncus> | yeah |
04:27 | < celticminstrel> | Yeah, "cerr << x.what() << endl" |
04:27 | < Rhamphoryncus> | Could throw in a sleep |
04:28 | < celticminstrel> | Well, by "nothing useful" I don't necessarily mean "nothing"; I did see "std::exception" in the console prior to "terminate called blah blah blah" |
04:29 | < Rhamphoryncus> | ahh |
04:40 | | Kindamoody|breakfast [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has quit [Connection closed] |
04:41 | | Kindamoody|out [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has joined #code |
04:41 | | mode/#code [+o Kindamoody|out] by ChanServ |
04:41 | | Kindamoody|out is now known as Kindamoody |
04:48 | | VV [Vash@Nightstar-a60eef95.ct.comcast.net] has quit [[NS] Quit: I <3Lovecraft<3 Vorn!] |
05:08 | | Kindamoody is now known as Kindamoody|afk |
05:14 | | iospace is now known as iospacedout |
05:25 | | Kindamoody|afk is now known as Kindamoody |
05:29 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
05:57 | | ErikMesoy|sleep is now known as ErikMesoy |
06:38 | | Kindamoody|out [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has joined #code |
06:38 | | mode/#code [+o Kindamoody|out] by ChanServ |
06:39 | | Kindamoody [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has quit [Client closed the connection] |
06:39 | | Kindamoody|out is now known as Kindamoody |
06:42 | | Derakon is now known as Derakon[AFK] |
07:19 | | * McMartin wins a staring contest with Nyarlathotep. |
07:41 | | himi [fow035@D741F1.243F35.CADC30.81D435] has quit [Ping timeout: 121 seconds] |
08:46 | | Reiv [reiverta@5B433A.3CF6C7.5B7F91.A55E2A] has joined #code |
09:20 | | You're now known as TheWatcher |
09:29 | <@TheWatcher> | McM: wut |
09:40 | | Reiv [reiverta@5B433A.3CF6C7.5B7F91.A55E2A] has quit [[NS] Quit: BRB: Rebooting] |
09:42 | | Reiv [reiverta@5B433A.3CF6C7.5B7F91.A55E2A] has joined #code |
10:14 | | RichyB [MyCatVerbs@Nightstar-3b2c2db2.bethere.co.uk] has joined #code |
10:20 | | Kindamoody is now known as Kindamoody|out |
10:31 | | Attilla [Obsolete@Nightstar-aae824b5.as43234.net] has joined #code |
12:01 | | * TheWatcher eyes this warning |
12:01 | <@TheWatcher> | "warning: dereferencing type-punned pointer will break strict-aliasing rules" |
12:01 | <@TheWatcher> | Great. Now the compilers are punning, too. |
12:26 | | Alek [omegaboot@Nightstar-efc8dc53.il.comcast.net] has joined #code |
12:26 | | mode/#code [+o Alek] by ChanServ |
12:39 | < RichyB> | TheWatcher, C99 semantics says that your compiler is allowed to assume that pointers with different types will never alias each other, IIRC except for char* (which might alias just about anything). |
12:39 | | * TheWatcher nod |
12:40 | < RichyB> | TheWatcher, gcc is giving you that warning because you're doing something that recent versions of the C spec say are permitted to cause undefined behaviour. Segfaults or worse. |
12:40 | < RichyB> | Er, sorry for twirping at you if you already knew that and were just making a joke. >> |
12:41 | <@TheWatcher> | Heh, I was, just not very obviously (and it's actually graphviz that does it) |
12:42 | < RichyB> | Aww, silly graphviz. :) |
14:00 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code |
14:27 | <&McMartin> | Er |
14:27 | <&McMartin> | Type punning is Kind Of Important. |
14:27 | | iospacedout is now known as iofficespace |
14:27 | <&McMartin> | Presumably there is some way where you can tell the compiler in advance "stop me if you've heard this one" or some such. |
14:28 | <&McMartin> | (My guess: unions) |
14:30 | <@TheWatcher> | it was being caused by -fstrict-aliasing being set in the compiler flags graphviz was using |
14:30 | | Reiv [reiverta@5B433A.3CF6C7.5B7F91.A55E2A] has quit [Client closed the connection] |
14:31 | <@TheWatcher> | (which is turned on by default at -O2 or above, IIRC) |
14:32 | <@TheWatcher> | (I think you need to give it an explicit -fno-strict-aliasing to stop it) |
14:34 | < Rhamphoryncus> | Yeah, -fno-strict-aliasing is also known as -fmy-code-is-broken-but-I'll-fix-it-later |
14:35 | <&McMartin> | -fthis-is-ML-code |
14:35 | <&McMartin> | -fimplements-bits-of-float |
14:36 | <@TheWatcher> | ... for some reason my brain seems to think the first of those should be -fTHIS-IS-ML |
14:36 | <@TheWatcher> | I will have it taken out and shot later. |
14:48 | <&McMartin> | It was applied to Clojure, not ML proper, but it works for ML too. |
14:48 | <&McMartin> | "Rifle-Oriented Programming" |
14:51 | < iofficespace> | phase two and three of coming out at work: telling the team i'm on and letting the company know ._. |
15:01 | | maoranma [nbarr@Nightstar-fefda721.pools.spcsdns.net] has joined #code |
15:02 | | Noah [nbarr@Nightstar-fefda721.pools.spcsdns.net] has quit [Client closed the connection] |
15:09 | | maoranma is now known as Noah |
15:14 | < RichyB> | McMartin, yes, there are ways of punning types that the C99 spec considers explicit, and therefore which don't count as violating the strict aliasing requirements. |
15:14 | < RichyB> | I still can't remember what they are, though. :) |
16:40 | | Noah [nbarr@Nightstar-fefda721.pools.spcsdns.net] has quit [Client closed the connection] |
16:40 | | Noah [nbarr@Nightstar-fefda721.pools.spcsdns.net] has joined #code |
16:56 | | Noah [nbarr@Nightstar-fefda721.pools.spcsdns.net] has quit [Client closed the connection] |
16:56 | | Noah [nbarr@Nightstar-fefda721.pools.spcsdns.net] has joined #code |
17:01 | | RichyB [MyCatVerbs@Nightstar-3b2c2db2.bethere.co.uk] has quit [[NS] Quit: Leaving] |
17:17 | | Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has quit [Client exited] |
18:32 | | Kindamoody|out is now known as Kindamoody |
18:37 | | Kindamoody|out [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has joined #code |
18:37 | | mode/#code [+o Kindamoody|out] by ChanServ |
18:38 | | Kindamoody [Kindamoody@Nightstar-6154a72a.tbcn.telia.com] has quit [Client closed the connection] |
18:38 | | Kindamoody|out is now known as Kindamoody |
18:45 | | Alek [omegaboot@Nightstar-efc8dc53.il.comcast.net] has quit [Ping timeout: 121 seconds] |
18:46 | | Derakon [chriswei@Nightstar-a3b183ae.ca.comcast.net] has joined #code |
18:46 | | mode/#code [+ao Derakon Derakon] by ChanServ |
18:46 | <&Derakon> | Check this out: http://derakon.dyndns.org/~chriswei/temp2/crosspattern.png |
18:46 | <&Derakon> | It's some data we're trying to denoise. |
18:47 | <&Derakon> | The bright dots are signal, and there's some dimmer dots that you can kind of see which we want to enhance. |
18:47 | <&Derakon> | But I think our algorithm is getting confused by the grid pattern, which is not signal. |
18:47 | <&Derakon> | Any bright ideas for how we could subtract the grid pattern from the image somehow? |
18:48 | <&McMartin> | Not off the top of my head. I'm wondering how it got there. image addition and overlap? |
18:49 | <&Derakon> | It's some kind of systemic noise in the data collection apparatus. |
18:49 | <&Derakon> | It's not quite grid-aligned -- if you draw a horizontal line across it you can see that it's rotated slightly. |
18:50 | <&Derakon> | I estimate about 4-5 degrees off of aligned. |
18:51 | <&McMartin> | Can you just specify the lines and do a luminance subtraction? |
18:51 | <&Derakon> | I don't think the lines are on average brighter than the parts that aren't on the lines, though. |
18:55 | < sshine> | Derakon, a friend just followed an image analysis course and I helped him brainstorm some similar algorithms. |
18:56 | <&Derakon> | The only idea I've had was to hope that the Fourier transform of the image would represent the cross pattern at a specific set of frequencies that could be subtracted out...but my signal analysis knowledge is so horribly out of date I doubt it'd actually work that way. |
18:57 | < sshine> | I don't even really know how Fourier transforms work... I just come up with shady ideas. |
18:57 | <&Derakon> | Heh. |
18:57 | <&Derakon> | Fourier transforms are basically representing your image as the sum of sine waves. |
18:57 | < sshine> | ah yes |
18:58 | <&Derakon> | So intuitively it would make sense that a periodic feature in the image would show as a strong coefficient for a specific frequency. |
18:58 | < sshine> | there was one thing my friend did that didn't really help him out, but I think it's an approach that works sometimes. he differentiated the image. |
18:58 | <&jerith> | Derakon: DFT will probably peak at that grid pattern. |
18:58 | <&jerith> | Are they Moire patterns, perhaps? |
18:58 | < sshine> | i.e., calculate gradient differences from left to right and from right to left, added them and replaced the pixel values with the differences. |
18:59 | <&Derakon> | Jerith: I honestly don't know. |
18:59 | <&jerith> | https://en.wikipedia.org/wiki/Moir%C3%A9_pattern |
18:59 | <&jerith> | Specifically, https://en.wikipedia.org/wiki/File:Moir%C3%A9_grid.svg |
18:59 | <&Derakon> | Yeah, I know what Moire patterns are. |
19:00 | <&Derakon> | I don't know if this is one because I have no idea what caused it. |
19:00 | <&Derakon> | But it could be. |
19:00 | <&Derakon> | (FWIW this is X-ray crystallography data) |
19:00 | < sshine> | Derakon, another approach he did when looking for bright spots was: map over each pixel, filter it in or out based on some threshold (either constant or determined by a function of the average brightness of the image) |
19:00 | < sshine> | Derakon, then clump those filtered pixels together into disjoint sets of adjacent pixels. some of those disjoint sets will be big, some will be small. |
19:01 | <&Derakon> | sshine: remember that the grid pattern does not exhibit a characteristic brightness variation with respect to the oveoverall image. |
19:01 | <&jerith> | If the crystal lattice is angled relative to the detector grid, it could be Moire. |
19:01 | <&jerith> | But that's a random guess. |
19:02 | < sshine> | Derakon, doesn't that simply mean that there will be fewer positives as a result of noise? |
19:02 | <&McMartin> | Presumably if you run a sharpener on it, it starts standing out |
19:02 | <&McMartin> | Can you do a grid subtraction *then*? |
19:02 | <&jerith> | It's worth looking at the DFT if you can easily get one. |
19:02 | <&Derakon> | McM: hm, don't know. |
19:02 | <&Derakon> | Jerith: yeah, I'm making one now. |
19:02 | | Alek [omegaboot@Nightstar-efc8dc53.il.comcast.net] has joined #code |
19:02 | | mode/#code [+o Alek] by ChanServ |
19:03 | <&jerith> | You might be able to do something smarter with wavelets, but you really need to know the maths for that kind of thing. |
19:03 | < sshine> | Derakon, oh, I misunderstood. the noise can suddenly be very bright. it is only the pattern you can go from? |
19:03 | <&Derakon> | ...yeah, all I can remember about wavelets is thinking "this is so far out of my league." |
19:04 | <&Derakon> | sshine: yeah, it's the pattern, not the intensity. |
19:04 | <&jerith> | Derakon: I used wavelet transforms in my MSc work. I ended up just doing them by cookbook and citing other people's work. |
19:04 | <&Derakon> | The actual background intensity of the image is reasonably constant for a given region of the image, and the grid pattern represents some variable deviation away from that background. |
19:04 | <&Derakon> | Both higher and lower. |
19:04 | | * Derakon eyes this DFT, wonders if he used the tool incorrectly. |
19:04 | <&jerith> | Derakon: Do you have more than one image with this property? |
19:04 | < sshine> | Derakon, can you personally spot a positive spot in an area of white noise? i.e., is there still a difference in intensity between an area to be included and an area of noise surrounding it? |
19:05 | <&Derakon> | Jerith: I have 3072x3072x127 pixels worth of data. |
19:05 | <&Derakon> | Every image I've checked (every 3072x3072 region) has exhibited this "feature". |
19:06 | <&Derakon> | sshine: the spots are visible in the noise, yes, but part of the goal is to bring out spots that humans can't actually see in the noise. |
19:06 | <&jerith> | Derakon: Right. So you're looking for something systematic rather than a once-off manual clean. |
19:06 | <&Derakon> | Our denoising algorithm has worked miracles in the past. |
19:06 | < sshine> | Derakon, oh! |
19:06 | <&Derakon> | Jerith: correct. |
19:06 | <&jerith> | Can you show me the DFT? |
19:06 | < sshine> | (what's DFT?) |
19:07 | <&Derakon> | Discrete Fourier Transform. |
19:07 | <&jerith> | My image processing is a dim memory, but looking at it might dredge something up. |
19:07 | <&Derakon> | ...the dimensions on this DFT are weird. |
19:08 | <&Derakon> | How does a 1024x1024 source image result in a narrower, wider DFT image? |
19:09 | <&Derakon> | Okay, 1/2 scale DFT of a 1024x1024 patch exhibiting the grid pattern: http://derakon.dyndns.org/~chriswei/temp2/crosspatterndft.png |
19:12 | <&jerith> | I'm confused by your DFT. |
19:13 | <&Derakon> | I admit I may not have used the tool correctly. |
19:14 | < Noah> | That's a pretty cool picture of... |
19:14 | < Noah> | What am I looking at there? |
19:15 | <&Derakon> | Here, with the "Zero frequency centered" option checked: http://derakon.dyndns.org/~chriswei/temp2/crosspatterndft2.png |
19:15 | <&Derakon> | BRB. |
19:16 | <&jerith> | Derakon: Can you DFT an image of vertical stripes or something? |
19:16 | <&jerith> | That'll tell us whether the tool's generating weird output or not. |
19:18 | <&Derakon> | Uh...that may prove tricky. |
19:18 | <&Derakon> | Give me a bit. |
19:19 | <&jerith> | The second one looks like it's only giving you half the frequency domain. |
19:21 | <&jerith> | The top and bottom look almost, but not quite, mirror imaged. |
19:24 | <&Derakon> | Okay, source image on the left, DFT on the right. http://derakon.dyndns.org/~chriswei/temp2/crosspatterndft3.png |
19:25 | <&jerith> | That looks like the kind of DFT I'm expecting. |
19:25 | <&Derakon> | Good. |
19:25 | <&jerith> | Is it also double-height? |
19:25 | <&Derakon> | 257x512. |
19:26 | <&Derakon> | (Source image was 512x512) |
19:26 | <&jerith> | Ah, so half-width. |
19:27 | <&Derakon> | Yeah, I'm just used to only looking at a small window of the non-transformed 1024x1024 image, which doesn't work for the DFT version, of course. |
19:27 | <&Derakon> | So I got confused. |
19:38 | <&jerith> | Derakon: Anyways, it doesn't look like there's anything immediately useful in the DFT. :-/ |
19:39 | <&jerith> | (I wasn't really expecting there to be, given the lack of luminosity difference between the grid and the not-grid, but it was worth a shot.) |
19:40 | <&Derakon> | Well, thanks for taking a more-educated look than I could provide. |
19:42 | <&jerith> | What I was looking for in there was a slightly rotated line or series of dots. |
19:45 | <&Derakon> | If it helps, here's a zoom-in on the origin area: http://derakon.dyndns.org/~chriswei/temp2/crosspatterndft4.png |
19:47 | <&jerith> | The feature would have the same offset as the noise grid. |
19:47 | | Kindamoody is now known as Kindamoody[zZz] |
19:48 | <&Derakon> | I suppose part of the issue would be that the signal we want to preserve is also fairly periodic. |
19:48 | <&Derakon> | Anyway, must get foods. Thanks again! |
20:12 | | Derakon [chriswei@Nightstar-a3b183ae.ca.comcast.net] has quit [[NS] Quit: Lost terminal] |
20:40 | | Noah [nbarr@Nightstar-fefda721.pools.spcsdns.net] has quit [Ping timeout: 121 seconds] |
20:56 | | iofficespace is now known as io|gone |
21:37 | | Vash [Vash@Nightstar-241cb5d4.wlfrct.sbcglobal.net] has joined #code |
21:37 | | mode/#code [+o Vash] by ChanServ |
21:46 | | Attilla [Obsolete@Nightstar-aae824b5.as43234.net] has quit [[NS] Quit: ] |
21:50 | | * Vornicus examines the lastfew hours on this channel, which had awesome stuff in it. |
22:03 | | * Vornicus pokes at euler 60, which he's shaved 10% of time off of by switching to lists instead of sets and using break instead of continue, but still takes 3 minutes. |
22:09 | <~Vornicus> | Using pypy gives (using internal timing, not the time util) a minute 40. I really, really don't see what I can do to cut this down. |
22:10 | <&McMartin> | What the shit, Fedora |
22:10 | <&McMartin> | Fedora 17 is codenamed "Beefy Miracle" |
22:11 | | Attilla [Obsolete@Nightstar-10aa5f6c.threembb.co.uk] has joined #code |
22:13 | | * Vornicus should actually see if he can figure out how to use cython to build c modules just in case that helps some. |
22:16 | < Attilla> | is cython some kind of horrifying c/python hybrid? |
22:16 | <&McMartin> | I think it's the bindings layer between C and Python |
22:18 | <@ToxicFrog> | Neither |
22:18 | <@ToxicFrog> | Cython is a superset of Python that compiles to C/++ code that uses the Python/C API |
22:19 | <@ToxicFrog> | It's meant for easy creation of Python bindings to C/++ libraries, and fast conversion of performance-critical Python code into C/++. |
22:19 | <~Vornicus> | Which I can use to build .dlls or .sos that I can import into python |
22:20 | <~Vornicus> | In my particular case I have some very critical prime number code that could use it. |
22:27 | <&jerith> | Vornicus: You're probably better off sticking with pure Python and pypy for that kind of thing. |
22:28 | <&jerith> | Once the JIT warms up, it'll probably outperform cython-generated code. |
22:29 | <&jerith> | Your prime generator caches, right? |
22:29 | <~Vornicus> | Yeah. |
22:29 | <~Vornicus> | Well. |
22:30 | <~Vornicus> | It caches primes. It does not cache composites above its current seive limit; however, this particular program also caches results on its own, because it cares about both directions. |
22:32 | <~Vornicus> | Actually... |
22:35 | <~Vornicus> | It occurs to me, this: seiving is a lot faster at generating/checking lots of primes in an interval, and what I've really got is a lot of intervals of several thousand numbers each. |
22:38 | <~Vornicus> | But I can't make a single big sieve and do it that way - this is what stopped me doing it before, because I'm generating candidates up to 10 digits long, and I get OutOfMemory errors doing that. |
22:40 | <~Vornicus> | ---mmm, but that only covers half the primes I need to test. |
22:44 | <&jerith> | Vornicus: My sieve also has a thing that lets me test primality without actually sieveing all the way up. |
22:44 | <~Vornicus> | Yeah, as do I. |
22:45 | <~Vornicus> | But I'm generating 4.5 million candidate primes. |
22:46 | <&jerith> | So, my stored answer for that one is only 5 digits. |
22:46 | <~Vornicus> | RIght. |
22:46 | | Alek [omegaboot@Nightstar-efc8dc53.il.comcast.net] has quit [Ping timeout: 121 seconds] |
22:46 | <&jerith> | So you shouldn't be needing 10-digit primes. |
22:46 | <~Vornicus> | But the top two primes are also five digits each, and you're concatting them |
22:46 | <~Vornicus> | Voila, ten digit primes. |
22:47 | <&jerith> | And then testing primality, which only needs known primes up to sqrt(candidate). |
22:48 | <&jerith> | Which is 5 digits or so. |
22:48 | | Alek [omegaboot@Nightstar-efc8dc53.il.comcast.net] has joined #code |
22:48 | | mode/#code [+o Alek] by ChanServ |
22:48 | <~Vornicus> | WHich is still a large number of primes. |
22:49 | <&jerith> | Fewer than a hundred thousand of them.~ |
22:49 | <~Vornicus> | I seive to get trial division candidates, yes - but if I didn't switch over to Miller-Rabin, this program would take an hour, not two minutes. |
22:49 | <~Vornicus> | What I'm looking at is picking higher intervals to seive. |
22:53 | <~Vornicus> | Which should be considerably faster than testing every candidate individually; however, even this only ends up covering half the candidates |
22:54 | <~Vornicus> | (the largest number I test primality on is 1300913007) |
22:55 | <&jerith> | My Erlang solution takes a few seconds. |
22:55 | <&jerith> | I put a lot of effort into my primes library, though. |
22:56 | <~Vornicus> | This is the most work-intensive problem in my solutions by about 5 times - I don't know any others that take more than 20 seconds. |
22:56 | <&jerith> | I use Miller-Rabin as well. |
22:56 | <~Vornicus> | One of the frustrating things is |
22:57 | <~Vornicus> | I read the thread and all these other people have "fast" solutions except that they're not actually verifying that the solution is the right one. |
22:58 | <~Vornicus> | THey don't see if they can generate a smaller possible solution, they just go for the first one they find. |
22:59 | | * jerith checks to see if he's guilty of that. |
23:00 | <&jerith> | Bleh. I can't read Erlang clearly anymore. |
23:00 | <~Vornicus> | If you iterate clique sum, or continue checking after you've found a solution while iterating largest prime, then you're innocent. When I did the second, I got an answer in about 1/3 of the time it takes to verify that it is The answer. |
23:02 | <&jerith> | I "cheat" slightly by excluding 2 and 5 from my initial starting set. |
23:02 | <&jerith> | Since no multi-digit prime can end with either of those. |
23:04 | <~Vornicus> | not much of a cheat; it only covers about 0.2% of candidates and even those fail fast. |
23:05 | <~Vornicus> | (in 1 to 3 divisions, instead of the hundreds and then miller-rabin powmods that others would use) |
23:06 | < celticminstrel> | Functional undo/redo system! \o/ |
23:06 | <&McMartin> | ? |
23:09 | < celticminstrel> | I just made one. |
23:12 | <&jerith> | Vornicus: Every iteration, I get a new prime and test it against all primes I know about to find a list of primes that it concats with primely. |
23:12 | <&jerith> | Then I create new sets containing the new prime and primes from that list. |
23:13 | < celticminstrel> | Hm... if I independently create two shared_ptrs to the same object, will it work properly? |
23:14 | <&jerith> | I also create new sets by adding the new prime to every set containing only primes in the list. |
23:14 | <&McMartin> | celticminstrel: ISTR there's some hidden global state. Test it with a custom deleter but I'm pretty sure that works. |
23:14 | <&jerith> | After this, I check to see if I have any sets containing 5 elements. If so, I pick the one with the smallest sum and I'm done. |
23:15 | <&jerith> | So yeah, I think I'm guilty. :-/ |
23:17 | <&jerith> | Naively, I could probably continue until I hit the first prime larger than my smallest sum. |
23:18 | <&jerith> | Less naively, I could continue until I hit the first prime larger than my smallest sum less the sum of the smallest 4-set. |
23:19 | <&jerith> | Both of these require messy bookkeeping. |
23:21 | <~Vornicus> | So you go to some limit on primes and then stop? |
23:21 | <~Vornicus> | Yeah, I did the less-naively way. |
23:21 | <&jerith> | I go until I find the first appropriate set. |
23:21 | <~Vornicus> | Ah, yes, guilty! |
23:22 | <~Vornicus> | My first attempt used that method as well, and did the less-naively thing. |
23:22 | <&McMartin> | TWELVE GALAXIES GUILTIED BY A VORNOTRONIC EULER SOCIETY |
23:22 | <&jerith> | It's /possible/ that I somehow convinced myself that this would also be the smallest sum. |
23:23 | <&jerith> | This all happened a number of years ago, though. |
23:23 | <~Vornicus> | I've been very carefully avoiding hardcoded limits |
23:24 | <&jerith> | I don't have hardcoded limits. |
23:24 | <~Vornicus> | Indeed. |
23:24 | <~Vornicus> | but for a few moments I thought you had. |
23:24 | <~Vornicus> | It always makes me grumpy when I see people saying "I had to put the search limit higher to get the answer" |
23:24 | <&jerith> | Well. I may have some in some problems, but those would be analytically determined or something. |
23:25 | | Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has joined #code |
23:25 | <~Vornicus> | Right. |
23:25 | | * jerith avoids grumping the Vorn. |
23:26 | <~Vornicus> | I had one, uh, the one where it searches words for ones with a triangular number for values, and I precached the triangular numbers, with the possibility of generating more... but I chose the starting precache so that it would never call for more. |
23:27 | <&jerith> | Precaching is fine as long as you actually compute the cache. |
23:27 | <&jerith> | I hardcode the first 5 primes in my prime generator. |
23:27 | <&jerith> | I also often hardcode a handful of starting values for various things. |
23:27 | <~Vornicus> | Yeah, that's not a problem. |
23:28 | <&jerith> | Usually enough to get things going and handle a few special cases. |
23:28 | <&jerith> | (Like skipping 2 and 5 in this problem.) |
23:29 | < Rhamphoryncus> | I wouldn't quite consider starting values to be caching. You just happen to be putting them in the cache you're using it anyway |
23:30 | <~Vornicus> | starting values, caching, even precaching, those aren't "hard limits" |
23:30 | <&jerith> | Rhamphoryncus: You could have 20 or 30 "starting values", though. |
23:30 | < Rhamphoryncus> | hrm |
23:30 | <~Vornicus> | I generate the first 250ish primes (starting from just 2 and 3) for use as a first-pass primality test before I go into miller-rabin |
23:31 | < Rhamphoryncus> | yeah, it's pretty grey |
23:31 | < Rhamphoryncus> | Just as long as you don't behave like openttd's scaled sprite cache ;) |
23:32 | < celticminstrel> | Turns out the answer is "no", but it doesn't actually matter after all. |
23:32 | <~Vornicus> | I don't have any problem at all with caching - though I won't cache to disk. I really really dislike when people feel the need to set some hard computation limit. |
23:38 | <~Vornicus> | (I would cache to disk if i were building something more awesome, but it feels like cheating in euler.) |
23:52 | | * TheWatcher performs quite horrible tricks with perl objects, inheritance, and overloading |
23:52 | <@TheWatcher> | (If I don't get at least two elder horrors emerging from rips in the fabric of reality from this, I will be put out) |
23:54 | | Attilla [Obsolete@Nightstar-10aa5f6c.threembb.co.uk] has quit [[NS] Quit: ] |
23:56 | | Attilla [Obsolete@Nightstar-aae824b5.as43234.net] has joined #code |
--- Log closed Thu May 31 00:00:23 2012 |