|
I have a pile of SVG files. They are all basic Bezier curves / lines. If you check the file in a text editor, you can find the path data coordinates in a line that looks something like this: code:
code:
The point of this is, how would you go about translating hundreds of these SVG files into the new, absolute coordinates needed for the bezier() equation? How would you find and parse the relevant portion of the SVG file into the usable variables? I'm looking for a general direction. lord funk fucked around with this message at 01:14 on Oct 23, 2009 |
# ? Oct 23, 2009 01:05 |
|
|
# ? May 15, 2024 00:37 |
|
I need a batch file to be able to tell tomorrow's date. If there is a more straightforward way I would like to hear it, but best I can tell I have to set the PC's time to a fraction-of-a-second to midnight, let it tick over, read the new date and revert it:code:
I would rather not skew the system clock significantly over time, so I don't want to have to stall it for too long in the wrong time before I set it back.
|
# ? Oct 23, 2009 15:26 |
|
BizarroAzrael posted:I need a batch file You have a lot batch files that run headfirst into issues like these, can you just do Perl scripts instead? All you need is to install the interpreter and you're pretty much good to go. The benefit being that there are a million Perl libraries that do things like what you need.
|
# ? Oct 23, 2009 17:32 |
|
BizarroAzrael posted:I need a batch file to be able to tell tomorrow's date. If there is a more straightforward way I would like to hear it, but best I can tell I have to set the PC's time to a fraction-of-a-second to midnight, let it tick over, read the new date and revert it: http://www.robvanderwoude.com/datetimentmath.php Also, I think this is at least the second time I've sent you to that site. I do it because that is the best batch file reference site I've ever seen. So make sure you check there to answer any questions.
|
# ? Oct 23, 2009 17:38 |
|
Jethro posted:http://www.robvanderwoude.com/datetimentmath.php The content on it is good, but I have a hard time navigating it. Looks like I can get what I want out of that, none of the sites I found on Google even mentioned using Julian dating, mucking around with %date% seemed to be the best they could offer.
|
# ? Oct 23, 2009 18:18 |
|
I'm trying to create a regular expression in use with split in perl that will grab the base site from ARGV, but I have yet to find one that will work. Example: When the user enters http://www.google.ca I want to be able to extract google from the variable. Any ideas?
|
# ? Oct 23, 2009 21:52 |
|
dyn posted:I'm trying to create a regular expression in use with split in perl that will grab the base site from ARGV, but I have yet to find one that will work. Example: When the user enters http://www.google.ca I want to be able to extract google from the variable. Any ideas? s!https?://(\w+\.)*(\w+)\.\w+/.*!g and then get the value of $2
|
# ? Oct 23, 2009 22:10 |
dyn posted:I'm trying to create a regular expression in use with split in perl that will grab the base site from ARGV, but I have yet to find one that will work. Example: When the user enters http://www.google.ca I want to be able to extract google from the variable. Any ideas? You could do it with a regex but most languages have a URL class to assist with something like this, you may want to look for one.
|
|
# ? Oct 24, 2009 00:57 |
|
fletcher posted:You could do it with a regex but most languages have a URL class to assist with something like this, you may want to look for one. Any built-in is going to have a hard time with this notion of a "base site" being some substring of the domain/host. edit: using it at least getting down to to the hostname with a URL class makes perfect sense, didn't intend to criticise your specific followup. covener fucked around with this message at 02:10 on Oct 24, 2009 |
# ? Oct 24, 2009 02:06 |
|
lord funk posted:I have a pile of SVG files. It shouldn't take long to write an app to read, parse, and spit out a directory full of files in the format that bezier() requires. Better than that, just write it into your Processing program. It's is a very fast language and SVG is designed to be a very easy format to work with, so I'm not sure what part you're hung up on. If you want some less general advice, I'm happy to help.
|
# ? Oct 24, 2009 07:36 |
|
ante posted:I'm actually writing some code that will eventually incorporate the ability to read and work with SVG files in Processing. I haven't started this portion yet so I'm not intimately familiar with SVG, but it's essentially XML, isn't it? You can read and display SVG files (with display functions like scale and rotate) in Processing already using PShape. My real hang up is this: there is a function bezierPoint() that calculates x y coordinates along a Bezier curve. I need to use that, but there is no equivalent tool for SVG files. Edit: found a library (Geomerative) for Processing that works with SVG files. Solves that. lord funk fucked around with this message at 18:43 on Oct 24, 2009 |
# ? Oct 24, 2009 14:41 |
|
Hey guys, I guess this is more of a maths question, but what the hell. At the moment, we're testing the randomness of numbers found from a scientific spectrometer's background noise. As part of the work, we're using dice outcomes in large scales to see if it eventually tends towards equal probability. As an aside, we need to test the scenario using biased dice. At the moment, the background noise is "converted" into a number between 1-1000. A 3-sided dice is simulated, and if the value falls between 1-333, 334-666, 667-100 then sides 1,2,3 are chosen respectively. The code needs to cater for bias. This would involve a 4-sided dice simulation with the input code:
Why use this input, I hear you ask? Well, for future work, it's important to express the outcomes as "1 in 4" times this will happen "1 in 3" times this will happen, and to avoid "25% of the time" (mathematically, I know they're the same, but they are different) Any help on solving this seemingly impossible problem would be greatly received.
|
# ? Oct 26, 2009 22:36 |
|
There are exactly three ways to resolve this. 1) The input probabilities are only meant to be valid relative to other each and should be uniformly scaled so that they sum to 1. i.e. divide each probability by the sum of all the original probabilities. 2) Unlike the sides of a die, the events are not disjoint, so your model is totally wrong. 3) The input is ill-formed and you should bitch about it, possibly recovering with method 1.
|
# ? Oct 26, 2009 23:02 |
|
rjmccall posted:There are exactly three ways to resolve this. Yes I know that the 0.25 should scale to 0.223, but the idea is the long-term statistics give 25/100, 25/100, 25/100, 33/100. This means getting over their relativity and somehow finding a way of finding a way to bias it differently. I thought it was impossible. I can't even think of an easy way to trick the system into changing the stats.
|
# ? Oct 26, 2009 23:08 |
|
Legitimate empirical data will never give you probabilities of disjoint events that add to greater than 1. Can you actually explain this in some way that makes sense, or are you just looking for someone to hold your hand and tell you it's impossible?
|
# ? Oct 26, 2009 23:40 |
|
rjmccall posted:Legitimate empirical data will never give you probabilities of disjoint events that add to greater than 1. Can you actually explain this in some way that makes sense, or are you just looking for someone to hold your hand and tell you it's impossible? I know it's impossible. Assuming the probabilities are expressed exactly in a 100-data run, it would be impossible to have 25:25:25:33, because that would require 108 runs. What I wanted to do, was to make the algorithm that calculated the boundaries work on the input aforementioned. Recalculating the probabilities is the only way to make that input work, even if the inputs will not be expressed.
|
# ? Oct 26, 2009 23:54 |
|
Fruit Smoothies posted:Yes I know that the 0.25 should scale to 0.223, but the idea is the long-term statistics give 25/100, 25/100, 25/100, 33/100. They're asking you to change the laws of mathematics such that percentage works completely differently than it should. If they insist on giving you input in such a ridiculous way, then you should figure out the percents from the numbers they give you. Sum the total, and take the percentage of each of the sides so that the numbers they're giving you coalesce into a valid percentage. Then modify your dice side windows accordingly so that: 3(0.25) + 0.33 = 1.08 Side 1: 0.25/1.08, 0.231, 1-231 Side 2: 0.25/1.08, 0.231, 232-462 Side 3: 0.25/1.08, 0.231, 463-693 Side 4: 0.33/1.08, 0.307, 694-1000 You can't violate the laws of math in this project unless there's some piece of this you're not understanding. This is also going to make your simulations fuzzier than they would probably like. You should meet with them to sort this issue out, and make sure they're okay with the fuzziness introduced by you reframing their numbers into valid percents for real probability. ErIog fucked around with this message at 00:21 on Oct 27, 2009 |
# ? Oct 27, 2009 00:14 |
|
ErIog posted:They're asking you to change the laws of mathematics such that percentage works completely differently than it should. If they insist on giving you input in such a ridiculous way, then you should figure out the percents from the numbers they give you. I think they thought I could make it so "roughly every 1/4 is this, but also every 1/4 is that" To be honest, I was so focused on trying to obtain their boundaries - even though I knew I couldn't - I completely forgot that 0.231 is approx 25% anyway.
|
# ? Oct 27, 2009 00:28 |
|
I'm writing a parallel cellular automata library, and I need to divide my simulation space more or less equally according to the number of processors that the program gets assigned. My constraint is that subgrids should be more or less square, since I'd like to maximize the amount of surface area they have (so as to minimize their perimeter, which will cost me in interprocess communication). Obviously this is trivial if p is a square number, but I can't see a good way of doing it in other cases. Of course, an actual optimal solution strikes me as Hard-With-A-Capital-H since it seems like it involves integer factorization, but I can't think of a good approximation to this problem which is "good enough". Anybody have any ideas?
|
# ? Oct 27, 2009 01:29 |
|
Dijkstracula posted:I'm writing a parallel cellular automata library, and I need to divide my simulation space more or less equally according to the number of processors that the program gets assigned. Why do you need synchronization? Isn't cellular automata simulation pretty much taking the previous grid and computing next value for each point? The previous grid doesn't change and for the next grid points only depend on previous grid values. Why do you need interprocess communication, can't you just use threads? One optimization I can think of is padding a grid so that when you divide it between N threads, there is no false sharing going on. That is if one thread works on a chunk of grid, then all of its contents should fit separately in cache. If they dont then if thread 1 modifies some point in grid, and its on same cache line as points belonging to different thread, then it will cause cache invalidation and will have big performance hit.
|
# ? Oct 27, 2009 01:37 |
|
RussianManiac posted:Why do you need synchronization? Isn't cellular automata simulation pretty much taking the previous grid and computing next value for each point? The previous grid doesn't change and for the next grid points only depend on previous grid values. RussianManiac posted:One optimization I can think of is padding a grid so that when you divide it between N threads, there is no false sharing going on. That is if one thread works on a chunk of grid, then all of its contents should fit separately in cache. If they dont then if thread 1 modifies some point in grid, and its on same cache line as points belonging to different thread, then it will cause cache invalidation and will have big performance hit. Dijkstracula fucked around with this message at 01:51 on Oct 27, 2009 |
# ? Oct 27, 2009 01:47 |
|
RussianManiac posted:Why do you need synchronization? Isn't cellular automata simulation pretty much taking the previous grid and computing next value for each point? The previous grid doesn't change and for the next grid points only depend on previous grid values. How is this complicated? He wants partition space among processors and needs to be able to share data at the edges. I really can't fathom why you'd think he doesn't need some kind of synchronization method for that.
|
# ? Oct 27, 2009 01:54 |
|
Avenging Dentist posted:How is this complicated? He wants partition space among processors and needs to be able to share data at the edges. I really can't fathom why you'd think he doesn't need some kind of synchronization method for that. Maybe I am missing something but can't you implement cell automata with 2 grids that you interchange. One being previous state and the second one being the next state? when you are computing the next state you are just using the first grid, which is not modified until it becomes the next state in next iteration? Hmm, I am not sure how false-sharing comes into play in distributed computing, but it certainly is a significant point if you are talking about sharing data on single machine but between multiple cores/processors.
|
# ? Oct 27, 2009 02:01 |
|
RussianManiac posted:Maybe I am missing something but can't you implement cell automata with 2 grids that you interchange. One being previous state and the second one being the next state? when you are computing the next state you are just using the first grid, which is not modified until it becomes the next state in next iteration? Uh, at the very least you need to put barriers in so that one processor doesn't get ahead of the others. And as mentioned, this is MPI anyway, which is a shared-nothing system.
|
# ? Oct 27, 2009 02:02 |
|
Avenging Dentist posted:Uh, at the very least you need to put barriers in so that one processor doesn't get ahead of the others. And as mentioned, this is MPI anyway, which is a shared-nothing system. do you mean block synchronization? yea that is true. False sharing occurs when you don't mean to share data but it is shared anyway because the division between thread's data falls somewhere in middle of cache line, so when one thread modifies its value, it causes all other processors to invalidate their cache and do memory look up, even though the data that those threads are concerned with didn't change.
|
# ? Oct 27, 2009 02:04 |
|
Uh, yeah, I'm not really concerned about cache consistency since everything is replicated by virtue of it being written in MPI. (I'm not really sure how we got on talking about cache) It's really the grid partition problem that I'm stuck on.
|
# ? Oct 27, 2009 02:18 |
|
Dijkstracula posted:Uh, yeah, I'm not really concerned about cache consistency since everything is replicated by virtue of it being written in MPI. (I'm not really sure how we got on talking about cache) It's really the grid partition problem that I'm stuck on. Divide the simulation space into an irregular grid of c columns where each column has either r or r+1 rows; we want cr ≤ p < c(r+1). If the simulation space is w x h, you want to pick c and r such that c/r ≈ w/h (or vice-versa; the point is that the aspect ratios should approximately match, or else the cells won't be very square). So pick c := floor(sqrt(ph/w)), r := floor(p/c), and go from there.
|
# ? Oct 27, 2009 02:41 |
|
Dijkstracula posted:Uh, yeah, I'm not really concerned about cache consistency since everything is replicated by virtue of it being written in MPI. (I'm not really sure how we got on talking about cache) It's really the grid partition problem that I'm stuck on. I still don't really understand why you care how the grid is partitioned. Once a node has the list of cells it should calculate, it can advance those cells without any syncronization with other nodes; it just has to arrange to broadcast its results when it completes. As long as you always broadcast results, every node will be updated with the results for every cell, so each node can always keep its own copy of the whole grid for the previous timestep. Or is the grid so incredibly large that you want to avoid keeping a complete copy on every node? Or are broadcasts really expensive on your architecture?
|
# ? Oct 27, 2009 02:43 |
|
rjmccall posted:So pick c := floor(sqrt(ph/w)), r := floor(p/c), and go from there. ShoulderDaemon posted:Or is the grid so incredibly large that you want to avoid keeping a complete copy on every node? Or are broadcasts really expensive on your architecture? Thanks everybody.
|
# ? Oct 27, 2009 04:05 |
|
I've got some code optimizing to do, and I was wondering if there is a good resource / list of operations ordered by how expensive they are to run. As in, if multiplying values together is more computationally expensive than adding, or if running if(this == that) 10,000 times is more expensive than multiplying something four times? Is there a good place to learn this? My Google-fu is poo poo today.
|
# ? Oct 28, 2009 16:10 |
|
lord funk posted:I've got some code optimizing to do, and I was wondering if there is a good resource / list of operations ordered by how expensive they are to run. With pipelining and branch prediction, it's not as simple as listing a cycle count for each instruction anymore. The profiler is your friend.
|
# ? Oct 28, 2009 17:56 |
|
Your first step in optimizing should never be micro-optimization of instructions. Better to reduce algorithmic complexity first.
|
# ? Oct 28, 2009 19:06 |
|
I'm taking online classes for a major in software development, which means a lot of programming classes with no actual class, and terribly terse textbooks to slog through on my own. I'm almost down with the first class, which is java, and I'm having a terribly hard time finishing the last few assignments. The next class is supposed to be "object oriented programming," and I guess we are going to be doing c#. Does anyone have any tips on how to teach myself this stuff? I used "beginning programming with java for dummies" which really helped, but after I finished and it got into harder stuff, I got totally lost. I'm afraid I'm not going to be able to get through this program on my own. Any tips?
|
# ? Oct 28, 2009 22:34 |
|
Here is a book called "Learning C#": http://www.amazon.com/Learning-C-3-0-Jesse-Liberty/dp/0596521065/ I have no idea if it is good or not, but it's linked on the first post of the C# thread. Here is the C# thread: http://forums.somethingawful.com/showthread.php?threadid=2262300 I don't know what's available in your area, but if you're having trouble teaching yourself programming I'd suggest trying a community college programming class. There is a lot you can get from having a two-way face-to-face conversation with someone who (more or less) understands the material than from just watching lectures or reading books.
|
# ? Oct 29, 2009 07:53 |
|
Doghouse posted:I'm taking online classes for a major in software development, which means a lot of programming classes with no actual class, and terribly terse textbooks to slog through on my own. I'm almost down with the first class, which is java, and I'm having a terribly hard time finishing the last few assignments. The next class is supposed to be "object oriented programming," and I guess we are going to be doing c#. Does anyone have any tips on how to teach myself this stuff? I used "beginning programming with java for dummies" which really helped, but after I finished and it got into harder stuff, I got totally lost. I'm afraid I'm not going to be able to get through this program on my own. Any tips? Are you having trouble with the syntax or wrapping your head around overarching concepts like OOP?
|
# ? Oct 29, 2009 13:57 |
|
ErIog posted:Are you having trouble with the syntax or wrapping your head around overarching concepts like OOP? The concepts I understand, pretty much, it's the details and how to implement the ideas that I have trouble with. I read through "programming with java for dummies" and I understood it for the most part, and for the first 7 weeks of the 9-week class I did pretty well. But then I had an assignment to use the bubble sort method, and now we are doing methods and objects and classes and strings and I'm pretty hopelessly lost. The textbook we are using is almost incomprehensible.
|
# ? Oct 30, 2009 00:19 |
|
http://pastebin.com/m17ac43a2 (java) Why are exceptions being thrown for every input when an exception is caught for just one? I mean, say I enter, "h" instead of a double for the first prompt. The program rushes through the rest and acts like I had entered a non-double for all of them, by executing the relevant "catch" block for each try block.
|
# ? Oct 31, 2009 04:14 |
|
Safe and Secure! posted:http://pastebin.com/m17ac43a2 (java) Because that's how java.util.Scanner works: it only advances if the current input matches the request. This is easily discoverable in the documentation.
|
# ? Oct 31, 2009 04:21 |
|
Thanks, I hadn't even considered that the scanner was what was giving me trouble. I thought it was some sort of crazy property of catch blocks and the API wasn't helping there. Problem solved: http://pastebin.com/m153c03b9 Would it be a better idea to just use code:
code:
|
# ? Oct 31, 2009 05:06 |
|
|
# ? May 15, 2024 00:37 |
|
code:
|
# ? Oct 31, 2009 16:34 |