|
Rocko Bonaparte posted:Without knowing the language, I'd generally recommend getting a book up front for learning a language despite a multitude of sources online. I like to get a book that is in some way definitive of the language that I examine in isolation of a computer so that I can generally grok the nature of the language and the style of programming in it. Fortran is not like most modern languages. It is very balkanized, and your individual code base greatly influences "best practices". The general case "best practice" for Fortran is to not use it.
|
# ? Sep 1, 2010 08:10 |
|
|
# ? Jun 8, 2024 04:24 |
|
I thought Fortran was still pretty rockin' for computationally intensive numeric programming?
|
# ? Sep 1, 2010 09:07 |
|
I just have to share my physicists-wielding-Fortran story. Shortly after finishing a CS undergrad degree I went to work at a large research lab. I was put in an office with a physicist who was in charge of maintaining some fortran models. The first piece of his code I had to acquaint myself was a single function, sixteen thousand lines long. Mind you, it was the same 2000-line block of code, copy and pasted eight times, with all the variable names changed slightly in each copy. He as unrolling the loop, you see.
|
# ? Sep 1, 2010 15:24 |
|
GrumpyDoctor posted:I thought Fortran was still pretty rockin' for computationally intensive numeric programming? litghost posted:But why would you write NEW code in Fortran?
|
# ? Sep 1, 2010 15:35 |
|
Our database is in ASCII, and our client is sending us text in Unicode. We can't/won't convert our database to Unicode, and the client can't/won't clean up their text before sending it to us. I have to make an effort at converting whatever can be converted, e.g. converting Unicode smart quotes into ASCII dumb quotes, and converting letters with diacritics into letters without diacritics. Here's what I've got so far, in C# 3.5. The ascii array contains ASCII characters in the appropriate indexes, with empty strings in place of unprintable characters. The punct array contains ASCII punctuation for the appropriate Unicode values, for example the Unicode for 8211 is a double-dash and so punct[0] contains an ASCII single-dash.code:
My question is, what Unicode characters have a reasonable ASCII counterpart that I'm ignoring.
|
# ? Sep 1, 2010 15:56 |
|
loinburger posted:I have to make an effort at converting whatever can be converted, e.g. converting Unicode smart quotes into ASCII dumb quotes, and converting letters with diacritics into letters without diacritics. So, obviously, you aren't going to be doing that on your own and will just simply call out to iconv to do the transliteration for you, right?
|
# ? Sep 1, 2010 17:25 |
|
Yes, it looks like that's what I'll be doing. Gracias.
|
# ? Sep 1, 2010 18:44 |
|
I'm dumb with Matlab, can anybody show me if I can vectorize this central difference loop I have?code:
|
# ? Sep 2, 2010 04:42 |
|
SimpleCoax posted:I'm dumb with Matlab, can anybody show me if I can vectorize this central difference loop I have? As you wrote it, it would be: code:
code:
|
# ? Sep 2, 2010 04:54 |
|
litghost posted:As you wrote it, it would be: That was quick, thanks I'll try it out. I have the i+1 and i-1 reversed because I want the derivative negative, but good catch.
|
# ? Sep 2, 2010 05:22 |
|
litghost posted:Fortran is not like most modern languages. It is very balkanized, and your individual code base greatly influences "best practices". The general case "best practice" for Fortran is to not use it. If they learn Fortran in the context of a code base, then they've just learned it to that specific application, and arguably they haven't learned much Fortran at all.
|
# ? Sep 2, 2010 05:33 |
|
Rocko Bonaparte posted:Well yeah, down with the Fortran. I still want to insist if it's going to be learned, it should be learned right. Languages that have been around awhile have had plenty of time to be used terribly, so an existing code base could be a terrible example of how the language could be used well. Learning "correct" Fortran is kinda not helpful. You will come across parts of the language that ought not be taught (arithmetic GOTO, arithmetic IF are great examples). You want to avoid these, but your code base may love them (I have seen them in production code used frequently). Lemme give you a concrete example. When I learned Fortran in a class, we always used IMPLICIT NONE, the awesome statements that prevents mind-numbingly stupid errors that should be caught by the compile expect that the retard language in the interest of saving ONE LINE per variable (the WASTE! OH NO MY PERFORMANCE!!!) elides. Anyways, IMPLICIT NONE is great and all, but when your code base has >50 COMMON blocks with ~100 variables each, and +50000 lines of other code, IMPLICIT NONE is not an option. Chances are you not writing new subroutines, you are doing maintenance and glue code in existing ones, IMPLICIT NONE is a huge ball of work. BTW, if you ever written new Fortran, for the love of god please use IMPLICIT NONE if you can. Quiz Part a, what is wrong with this code: code:
code:
These might not really trip a compiler, but the core idea is present. In cases where widths are different, this can cause big problems (I*4 vs R*8 as an example). Compile time implicit variable typing without compile time or runtime checks is a terrible policy. litghost fucked around with this message at 05:56 on Sep 2, 2010 |
# ? Sep 2, 2010 05:50 |
|
Help me pick a math modelling and solving language. What should I be using to find the maximum and minimum of an equation given a bunch of constraints on the variables that make it up. Once the user has these limits, they should be able to solve the equations for a valid value. I have a problem like this but a bit more complicated: Imagine stitching together a long linear image from a number of smaller pictures taken from a car. I can't drive too close to the curb, the buildings would be cut off. I can't drive too far away, the pictures wouldn't have enough detail. I can't drive too fast, the pictures would blur and the police would pull me over. I can drive slow, but it's a waste of time. The camera can take pictures at a limited range of frame rates and exposure lengths. There's a bunch more constraints to take care of, like multiple cameras, or cameras pointing at an angle, etc. so it gets more and more complicated to do by hand as I consider more constraints to check. I want to present the user with a range of speeds and distances from the buildings they can drive at, then when they pick something they feel comfortable with it solves the equations to figure out the camera frame rate and any other parameters. Sounds like a linear programming solver would work from some googling, but I have NO CLUE about any of this stuff. I write python and C and most of my formal training was embedded hardware. The individual equations could all be modeled with functionality available in the standard math library: basic trig, log and power operations. Some of the variables to be integers and some to be floating point. It'd be nice if it was free and had a C API, but I'm open to ideas. yippee cahier fucked around with this message at 06:45 on Sep 2, 2010 |
# ? Sep 2, 2010 06:41 |
|
sund posted:I have a problem like this but a bit more complicated: Honestly, unless you need this to be a standalone or online thing, I would use Mathematica. If not, though I don't fully understand what your problem is here or what sort of use the answer (camera frame rate?) would be... Any modern language will be fine though unless you need insane scientific precision. If you want local maxima/minima, look up Euler's method, or derivate and solve for zero.
|
# ? Sep 2, 2010 07:36 |
|
baquerd posted:Honestly, unless you need this to be a standalone or online thing, I would use Mathematica. Thanks for the response. I'll give Mathematica a look. Essentially there are two problems: 1) Find the range of possible car speeds and distances from the target. 2) Given a speed and distance, find frame rate for the camera to hit some target amount of overlap. I know this is just basic trig and can all be done by hand, but it gets more complicated as I add more cameras or other devices with all sorts of other requirements that potentially share parameters with the camera model. I just got this feeling that tools for solving this sort of problem probably already exist and didn't want to find my utility in the "code horrors" thread down the road.
|
# ? Sep 2, 2010 08:06 |
|
sund posted:1) Find the range of possible car speeds and distances from the target. Specific tools may already exist, I'm not sure, but if there's anything Mathematica is good at, it's solving problems just like yours. All the basic solution functionality is completely done for you, all you need to do is model your problem in equation form with inequalities for bounds and good to go.
|
# ? Sep 2, 2010 08:22 |
|
Not really a programming question, but hopefully the people reading this thread will have useful answers. If I want to learn about how computers work "from the ground up", what are good books/other sources to read? I'd like to start with how basic logic gates are physically implemented and be able to work all the way up from that to applications running on operating systems. Edit: just noticed "The elements of computing systems" being mentioned in the books thread (which I hadn't seen when I asked this question). That looks like it should be perfect for what I'm after. Grey_Area fucked around with this message at 01:03 on Sep 3, 2010 |
# ? Sep 2, 2010 22:03 |
|
Just posting to say thanks for the help earlier, shrughes, Orzo, and MEAT TREAT. I feel like I just leveled up in programming ability.
|
# ? Sep 3, 2010 06:40 |
|
Orzo posted:I know you provided a link to the API but I don't really have time to read all of that right now, perhaps someone who is already familiar with it can illustrate what I'm trying to say better. The link you've provided doesn't seem to show which inherited methods are public and which aren't, so I'm having trouble seeing the actual interface of each level. It looks completely bloated though, classes should not be doing anywhere near as much as PageRank appears to be. Alright I'll take another swing at explaining myself. Say I've got a bunch of iterative algorithms for graph scoring. They each take a graph and produce a score for each vertex. They all follow the same pattern: 1. Set the score of each node to some starting value or another 2. Perform one step of the process 3. Calculate the change in scores 4. If the change is too large and we haven't performed too many steps, GOTO #2. Additionally, there's probably some stuff like maintaining a mapping from vertices to scores that is likely equivalent or identical across algorithms. Now my goal is to build some construct that allows me to have one implementation of this loop and allow different algorithms to slot in their own ways of doing 1, 2, and 3. In the example I gave, the first descendant fills #3. It chooses the value of the scores to be doubles, and enumerates each vertex and adds up the differences between old and new scores (and probably other stuff, I'm using my imagination to some degree starting now). The grandchild (PageRankWithPriors) in the chain fills #2. It performs the PageRank update on the graph. The great-grandchild in the chain, PageRank, fills #1. It sets the value of each vertex at the start equal to 1/N, where N is the number of vertices. I claim that using inheritance is the best way to fulfill this goal (in Java or C# or similar). In these cases, it's very straghtforward: I create a base class with some DoIt() method that performs the above loop, calling abstract methods SetInitialScores() and CalculateOneUpdate() and CalculateDelta(). Each algorithm then can inherit from the base class and fill in those methods as appropriate. The typical downsides to inheritance won't apply here. Algorithms are fixed: one doesn't typically decide that algorithm behavior needs to change. You could decide that you needed a different algorithm, certainly, but all my negative experiences regarding inheritance have been caused by needing to change the way certain derived objects function and being unable to make that happen in the restrictive world created by a fixed base class and a set-in-stone inheritance hierarchy. I just don't see that happening when it comes to this sort of development. I see two ways of using object composition to meet the same goal. The first is to have your PageRank class hold a reference to a private PageRankWithPriors object. The reference would require you to pass in #1 as a parameter. Passing methods around in Java is real annoying as everyone knows. You'd wind up having to create interfaces for every(-ish) method you wanted to be able to plug into. C# has function pointers so it would not be as painful there. Even still, you'd wind up having to write loads of boilerplate methods just to pass the message down the chain: PageRank.DoIt() just calls WrappedMember.Doit() and so on. The second way, which you alluded to, is to have a public IterativeAlgorithm base class as the one you call all the methods on. You'd have to instantiate it like new IterativeAlgorithm(new IterativeScorer(new PageRankWithPriors(new PageRank()))). Ugly. The benefit to using to this structure is that you can mix-and-match stuff at runtime. I cannot imagine how that could ever be useful. From a readability and discoverability, it's definitely the worst option. When you're checking for a PageRank implementation, you definitely aren't going to be thinking "I wonder what I can plug into this IterativeAlgorithm thing." When you want PageRank, you want PageRank. There's no reason to expose the implementation chain. In summary: you'll write more code for no benefit by using composition. (imo) Please don't think I actually like inheritance in Java.
|
# ? Sep 3, 2010 22:40 |
|
Smugdog Millionaire posted:Alright I'll take another swing at explaining myself. yeah, and what if I have a square class and want to make a rectangle class, it makes more sense to just inherit from the square and add another diameter or whatever
|
# ? Sep 3, 2010 22:49 |
|
Look at all those freakin words
|
# ? Sep 3, 2010 23:12 |
|
Does anyone know how good computer Stratego AI is? Can it beat the best human players?
|
# ? Sep 9, 2010 02:40 |
|
tractor fanatic posted:Does anyone know how good computer Stratego AI is? Can it beat the best human players? As of 2008 the answer is no. quote:Stratego AI programs are capable of playing at a high level, although none is able to compete equally against a moderately skilled human opponent. Source: http://www.strategousa.org/wiki/index.php/2008_Computer_Stratego_World_Championship
|
# ? Sep 9, 2010 03:41 |
|
I'm working on a pretty exciting project right now, a lunar rover for Google's LunarX prize, and am personally assigned to an apparently simple computer vision task although one that I've never worked with. On the top of the rover is a camera with a directional high-gain antenna pointing in the same direction as the camera. The entire head can pan and tilt to cover the whole sky above it. The object is to locate the Earth and keep it centered in the camera, so as to maintain a line of transmission for the antenna. I don't yet know the specifics of the language or operating environment, but I still want to work out the pseudo code for doing this. I was hoping someone could suggest some algorithms for this kind of thing. As far as computer vision goes, this is pretty simple. Take a mostly-black picture, try to locate the single large blue blob, determine its rough center, and align the camera to it. Where should I begin?
|
# ? Sep 9, 2010 03:50 |
|
One neat way you can do quick and dirty comparisons of images is by comparing their Fourier transforms by running e.g. fast Fourier. Presumably this will actually be enough for you. Your camera has to tell the difference between "dot surrounded by blackness" and "ground". (You could wipe any stars out by not using enough resolution on the image or the transform.) I've never done any image processing online though, I have no idea if this is fast enough. Remember that you might have to be a bit clever. Earth seen from the moon has phases (so it's not just a big ball) and the moon has pretty deep shadows. So some detection schemes might decide the bright top of a crater was the earth. If you have color and you can rely on Earth being blue enough (I'm thinking clouds) you could honestly just do a histogram of colors for the image and decide Earth! if it's over a certain threshold of blueness. EDIT: I'm only addressing identifying Earth compared to sky or moonscape. The below is basically what you need once you have. illves fucked around with this message at 04:10 on Sep 9, 2010 |
# ? Sep 9, 2010 04:05 |
|
Butt Cord posted:I'm working on a pretty exciting project right now, a lunar rover for Google's LunarX prize, and am personally assigned to an apparently simple computer vision task although one that I've never worked with. It's an interesting and deceptively difficult problem. Here's a tutorial thats relevant: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut9.html
|
# ? Sep 9, 2010 04:06 |
|
I've been using scons for a little bit now for my home pet project, but I know I am not using it well. I have various components to which I've created different SConstruct files in each directory. Everything builds in the same directory I'm working, and I get a huge mess that way. I was hoping to get away from this. Part of what I know I need involves SConscript files, but I'm not sure how to use these when I'm dealing with different test programs and such pulling in different components all over the place. Conceptually I'm not even quite clear how I'd want to approach building that stuff with scons. At the least I know I want to build in separate directory so I'm not polluting my working directory with object files and binaries. But is there anything I can do to help myself with how I've modularized everything?
|
# ? Sep 9, 2010 05:33 |
|
IlluminatusVespucci posted:One neat way you can do quick and dirty comparisons of images is by comparing their Fourier transforms by running e.g. fast Fourier. Presumably this will actually be enough for you. Your camera has to tell the difference between "dot surrounded by blackness" and "ground". (You could wipe any stars out by not using enough resolution on the image or the transform.) I've never done any image processing online though, I have no idea if this is fast enough. I'm not entirely sure what you mean by image comparison. The rover itself will move very slow, about 5cm/second, so it's not like the Earth is going to be going all over the place. The antenna has a transmit cone of about 30 degrees, but the more I can tighten that up the better. More than likely, once the Earth is in sight adjustments will only be necessary every few minutes. quote:Remember that you might have to be a bit clever. Earth seen from the moon has phases (so it's not just a big ball) and the moon has pretty deep shadows. So some detection schemes might decide the bright top of a crater was the earth. I was going to look into this as well. I get "bonus points" (greater chance at scoring admission for the PHD program) if I can target a specific quandrant of the Earth's face. I will have access to an Earth-time clock, so I'll also need to look into figuring out the phase as well as the position of mission control to determine optimal centering. quote:If you have color and you can rely on Earth being blue enough (I'm thinking clouds) you could honestly just do a histogram of colors for the image and decide Earth! if it's over a certain threshold of blueness. The color approach, and even the histogram method, was my first intuition. I'm also a bit unsure of how effective "Find the blue" will be, so it might be helpful to double-check it against the predicted shape (phase) of the Earth. We'll be using an color zoom camera with a resolution of about 800x600. quote:EDIT: I'm only addressing identifying Earth compared to sky or moonscape. The below is basically what you need once you have. Appreciated nonetheless. I wont even have access to the mounted camera for two months (I'll be doubling as a mechanical engineer until then developing the head unit itself), with a testable result expected a month later, and launch isn't for two years, so I have generous time to brainstorm and tinker and all pontificating is helpful tripwire posted:With opencv Bookmarking to look at tomorrow morning. I always grasp the math of these things better from code rather than dry equations, thanks!! Butt Cord fucked around with this message at 07:16 on Sep 9, 2010 |
# ? Sep 9, 2010 07:13 |
|
I learned Python on a Windows based install (Running IDLE, opening and saving a shell as a python file). I installed Python on two Linux systems (openSUSE and Ubuntu) but it seems neither of these has the same interactive compiler things that I am familiar with. I wrote a simple program in Konsole/Terminal akin to Hello World, but I am not sure how I would attempt something more sophisticated. Any help?
|
# ? Sep 9, 2010 11:16 |
|
ScaerCroe posted:I learned Python on a Windows based install (Running IDLE, opening and saving a shell as a python file). Most distributions include IDLE along with Python. Have you tried running 'idle' from the terminal?
|
# ? Sep 9, 2010 12:23 |
|
As it happens, I have both of those distros installed and neither includes idle with python. They do, however, have it in the repos, and you should probably have tried searching for it in there first. Specifically, in Ubuntu/Mint it's called "idle3" for the default version and "idle-python3.0" for the Python 3 version; in SUSE it's "python-idle" and "python3-idle". Incidentally, the way you develop more sophisticated stuff in general is by writing it in a seperate editor (ideally one with some language awareness, like jedit) and testing it in the REPL; trying to write everything in the REPL and then saving it when it works gets unwieldy fast. (nb. I have not used IDLE but this seems to be what you're talking about concerning "writing a simple program in Terminal")
|
# ? Sep 9, 2010 15:22 |
|
ToxicFrog posted:As it happens, I have both of those distros installed and neither includes idle with python. They do, however, have it in the repos, and you should probably have tried searching for it in there first. Shows what I know. It's part of the package in Arch, I assumed other distros would include it as well.
|
# ? Sep 9, 2010 16:31 |
|
ToxicFrog posted:As it happens, I have both of those distros installed and neither includes idle with python. They do, however, have it in the repos, and you should probably have tried searching for it in there first. Two questions: What is the REPL and how do I test any program in it? What are the repos?
|
# ? Sep 9, 2010 18:53 |
|
I'm pretty new to coding so I don't really understand how http://www.reddwarfserver.org/ works with programs - but does using something like this licensed under GPL mean that the entire program (such as a game) would also have to be licensed under GPL? edit: and to add to this, how can people tell if someone is using copyrighted code in a non-open source program? hayden. fucked around with this message at 19:58 on Sep 9, 2010 |
# ? Sep 9, 2010 19:51 |
|
Yes. The GPL states that derivatives of a work licensed under the GPL must also be licensed under the GPL, and it is commonly believed that simply using a GPLed library is sufficient to be a derivative work*. But ask your lawyer. * The exception to this would be a GPLed work that implements an unoriginal library interface, in which case your work could just as easily use a different implementation of the same interface and thus isn't tied enough to the GPLed work to be a derivative. But ask your lawyer. As to your second question, if the thief is smart enough, you generally can't, but people dumb enough to use code without obeying the license generally aren't smart enough to remove easily recognizable strings like the SCM keywords and assertion failure messages and whatnot. pseudorandom name fucked around with this message at 20:02 on Sep 9, 2010 |
# ? Sep 9, 2010 20:00 |
|
ScaerCroe posted:Two questions: What is the REPL and how do I test any program in it? What are the repos? REPL: Read-Evaluate-Print Loop. Type 'python' at the command line and this is what you get - as you enter code, it reads what you entered, evaluates it and prints the results. It's good for trying out small snippets of code on their own or using as a desk calculator; it can also be used for testing larger programs by loading them from disk and then calling/examining parts of them. Repo: short for "package repository" or "software repository". Most linux distros have one (or several), along with a program (the package manager) that interacts with them and can automatically download, install, update, and remove any piece of software in the repos. This should generally be the first place you check when installing software in linux; sometimes what you need isn't in the repos (either absent entirely, or you need a specific version not available), but most of the time, it is. Ubuntu has the graphical package manager 'synaptic' and command line 'apt-get' and 'apt-cache'; SUSE has graphical 'yast2' and command line 'zypper'. For example, in SUSE, here's how I might go about installing python 2.x and IDLE from the command line: code:
The Ubuntu version is similar; it uses 'apt-get update' instead of 'zypper refresh', 'apt-cache search' instead of 'zypper search -s', and 'apt-get install' instead of 'zypper install'. And on either OS, using the graphical interface is just a matter of starting it from the menu, entering 'python' or 'idle' into the search box and choosing it from the list that results.
|
# ? Sep 9, 2010 20:18 |
|
Does anyone know how to get cmake 2.8.2 to work with Visual Studio 2010? Googling around I've found some bug where cmake won't find 2010 Express, but I have the real deal and it's simply not in the generators list. edit: Whoops, never mind, my path variable was messed up and the wrong version of cmake was getting launched. raminasi fucked around with this message at 21:19 on Sep 9, 2010 |
# ? Sep 9, 2010 21:16 |
|
hayden. posted:I'm pretty new to coding so I don't really understand how http://www.reddwarfserver.org/ works with programs - but does using something like this licensed under GPL mean that the entire program (such as a game) would also have to be licensed under GPL? The supplied client libraries are BSD licensed, so you don't have GPL the game client.
|
# ? Sep 9, 2010 21:35 |
|
Butt Cord posted:I'm not entirely sure what you mean by image comparison. The rover itself will move very slow, about 5cm/second, so it's not like the Earth is going to be going all over the place. The antenna has a transmit cone of about 30 degrees, but the more I can tighten that up the better. More than likely, once the Earth is in sight adjustments will only be necessary every few minutes. I was just talking about getting the Earth in sight. I was thinking the sort of naive strategy of "pan around in intervals of your angle of view until you see something that looks like Earth, then keep pointing at it". So you'd need a way of knowing something "looked like Earth"—comparing each segment of sky to a reference image or images (or image signatures) would be one way. If the rover happens to know it's within a certain lunar latitude or longitude I guess you could just calculate where Earth is, but maybe there's a better way to do even the panning. My insight is obviously not profound.
|
# ? Sep 9, 2010 23:42 |
|
|
# ? Jun 8, 2024 04:24 |
|
Butt Cord posted:I'm working on a pretty exciting project right now, a lunar rover for Google's LunarX prize, and am personally assigned to an apparently simple computer vision task although one that I've never worked with. I did something like this once to make and auto-alignment system for a laser beam traveling through some lenses and eventually hitting a CCD camera. It may not be the greatest method but it located the center of a bright spot on a dark background pretty well. Generally the steps were 1) For the first few image frames, adjust the electronic shutter time on the camera to maximize the dynamic range of the image. 2) If you have a color image, convert it to greyscale and then find the center of mass of the resulting picture. This is a rough first estimate of the center of the bright area. 3) Get a greyscale 'mask' image which looks like the shape you are trying to find. In my case it was a pre-calculated picture of what we expected the laser beam to look like, in your case you might generate a bright circle representing the earth as seen from the moon with a dark circle representing the moon's shadow overlaid on top of it. 4) Center your mask image at the location found in the center of mass calculation and then calculate its overlap integral with the greyscale camera image. 5) Move the mask image slightly, re-calculate the overlap, and iterate a few times to find the mask location that maximizes the overlap integral. That should be the position where the mask and camera images are best aligned. 6) Adjust your camera orientation to move the center of the mask image to the center of the camera image on the next frame, keep on repeating to track the target as it moves. Iterating through a lot of 2D overlap integrals sounds bad, but since you generally get integer color values out of the camera its not too terrible in practice. Also, if the earth takes up a decent amount of your camera's image you can sub-sample every 10th or so row/col to drop the calculation load by a factor of 100 without degrading the result too badly. e: Also, if you have time to dick around with it now, just download some still images of the earth-from-moon view off of NASA's website and use those as trial samples to work on the problem today. It sounds like your video stream is going to be pretty slow moving and essentially a still image anyway. PDP-1 fucked around with this message at 00:28 on Sep 10, 2010 |
# ? Sep 10, 2010 00:22 |