|
Pie Colony posted:I have a general implementation question... You're right about how to do movement at any angle (x = cos(angle)*b, y = sin(angle)*b), but you'll have to switch to floating-point coordinates to make it work well. If you can't do that, google "breshenham algorithm". haveblue fucked around with this message at 16:51 on Nov 23, 2009 |
# ? Nov 23, 2009 16:49 |
|
|
# ? Jun 5, 2024 08:36 |
|
Pie Colony posted:I have a general implementation question... Read up on vectors. It's pretty much what you're doing already (using two numbers to represent a direction and speed), but more generalized. And yeah you'll probably want to store your speeds and positions as floats, and then use some rounding to figure out which pixels should be drawn to each frame. Vinterstum fucked around with this message at 17:56 on Nov 23, 2009 |
# ? Nov 23, 2009 17:54 |
|
haveblue posted:You're right about how to do movement at any angle (x = cos(angle)*b, y = sin(angle)*b), but you'll have to switch to floating-point coordinates to make it work well. Quake 3 used integral coordinates. (Which, incidentally, is why you can trickjump in it.)
|
# ? Nov 23, 2009 18:01 |
|
I'm trying to make a batch script that reads a list of file and directory addresses in a .txt file and identifies the files.code:
|
# ? Nov 23, 2009 18:13 |
|
Hey kids! It's LAPACK time! I'm implementing block LU-factorization for a scientific computing class, and after having had less than optimal results by storing my matrix as an array of subblocks (profiling my code showed that 30% of my runtime is spent in integer division calculating offsets into the matrix ), I'm looking at re-implementing it. So I'm staring at the documentation for dgetrf and it dawned on me that perhaps the leading dimension of A need not be equal to m (otherwise, why would they insist on it being a parameter?) I'm not sure how this behaves and I don't want to get too far down the path before realizing that I'm yet again misreading the docs: is it the stride of the array (ie. for some kxk submatrix embedded in some nxn matrix, I can factor this without needing a memcpy or something?)
|
# ? Nov 23, 2009 21:41 |
|
TheWevel posted:
I figured out a better way to do what I was doing: code:
|
# ? Nov 24, 2009 00:11 |
|
MEAT TREAT posted:For writing a file check out the PrintWriter class. code:
|
# ? Nov 24, 2009 23:28 |
|
Hahahahahahahahahahahahaha
|
# ? Nov 24, 2009 23:54 |
I've got a situation where data is stored in two different RDBMS's and I need to essentially do a simple JOIN between two tables that are in the different systems. I started out by just grabbing all the info from one and doing a giant IN () clause when I query the other database, which gave me the "Packet too large" once my query got over 1MB. The biggest the query will ever be is about 2MB. Should I simply raise the max_allowed_packet variable to allow for my massive IN()? Should I load the data into a temp table and then do a JOIN? What is the fastest solution here? This is in Java and the db server I have control over is MySQL.
|
|
# ? Nov 26, 2009 03:34 |
|
I'm teaching myself Fortran because this language is so deeply rooted in my field (computational fluid dynamics) with all the legacy codes that it will never go away no matter how much it's considered dead. So, I've set up a dual boot with Ubuntu and I've installed gfortran, gnuplot and VIM to get started. I've managed to write a small program to compute the derivative of a specified function (in my case f(x) = sin(2x)) analytically and using a simple finite difference scheme. I figured out how to output the data to a .txt file and figured out how to plot it and everything is gravy EXCEPT the way my data is being outputted is like: a b c d e 1 2 3 4 5 But I need my data to be formatted like this: a 1 b 2 c 3 d 4 e 5 Because that's how gnuplot works (it plots column vs column). Is there a way I can easily transpose the row vector it gives me into a column vector? Or is there a way to just create a column vector? When I define my vector I do a "REAL x(1:5)" which is what all the tutorials I've found online tell me to do. The way I worked around this problem was basically to put a WRITE statement inside of my DO loop so that on the first iteration it'll write "a 1" and then "b 2" on the next line in the next iteration, but this really can't be memory/cost effective to access and read/write to a file after every single iteration. Plus there has to be an easier way... right? Edit: I realize that I might be using vector incorrectly. My only other programming experience is with MATLAB and as far as I know, a vector and array are the same thing but I don't think this is the case in other languages. Ziir fucked around with this message at 08:58 on Nov 26, 2009 |
# ? Nov 26, 2009 08:51 |
|
Ziir posted:The way I worked around this problem was basically to put a WRITE statement inside of my DO loop so that on the first iteration it'll write "a 1" and then "b 2" on the next line in the next iteration, but this really can't be memory/cost effective to access and read/write to a file after every single iteration. Plus there has to be an easier way... right? code:
Also, in scientific computing/HPC there's a strong desire to get carried away with "oh but is this efficient"...as you gain more experience coding in Not-Matlab (and kudos to you for trying to break out of that), you'll discover that any i/o is painfully slow, so writing out the data to disk will be the bottleneck, not walking the arrays. In general, don't worry about efficiency of code until you've run it through a profiler.
|
# ? Nov 26, 2009 09:35 |
|
Thanks. I really should have done this last year when I took my CFD course but at the time I had a pretty hectic schedule and learning another language was the last thing I wanted to do. Since I've never taking a CS course, here are some other questions: What exactly does it mean to compile a code? The Wikipedia entry says it gets translated to machine code but I'm not sure what that even means. If the CPU doesn't actually execute the code that I'm writing then why are there so many different languages? I always thought compile was synonymous to the "make" command in Linux/Unix. But well, it isn't? And lastly, what is a .out file? Why doesn't Fortran just skip this middle step and write directly to a .txt file instead of making me run the .out file first? Edit: I lied, one more. It's kind of tedious to run (compile?) my Fortran code, then run the .out file, then start gnuplot and plot my data and then set the axes and titles and such all via command line. Is it possible to just write a script to do this all for me and how? Ziir fucked around with this message at 18:25 on Nov 26, 2009 |
# ? Nov 26, 2009 18:18 |
|
Ziir posted:What exactly does it mean to compile a code? The Wikipedia entry says it gets translated to machine code but I'm not sure what that even means. If the CPU doesn't actually execute the code that I'm writing then why are there so many different languages? Ziir posted:I always thought compile was synonymous to the "make" command in Linux/Unix. But well, it isn't? Ziir posted:And lastly, what is a .out file? Why doesn't Fortran just skip this middle step and write directly to a .txt file instead of making me run the .out file first? The act of running your program has nothing to do with the compiler - you compile it once, then run all the datasets you want by executing the a.out program. [/fixed] Ziir posted:Edit: I lied, one more. It's kind of tedious to run (compile?) my Fortran code, then run the .out file, then start gnuplot and plot my data and then set the axes and titles and such all via command line. Is it possible to just write a script to do this all for me and how?
|
# ? Nov 26, 2009 19:52 |
|
Dijkstracula posted:OK, some terminology: Fortran is a compiled language, as opposed to Matlab, which is interpreted (that is, it isn't converted to machine language but instead is run inside the Matlab program). So, it's not correct to say "why doesn't Fortran...?" because Fortran is merely a language, and gfortran is the compiler that compiles your Fortran code to an executable. When you run gfortran and don't specify a filename for your program, for historical reasons it defaults to a.out. That is your program. (for fun, type file a.out and you'll see that it's an executable of the ELF type.) So that we're on the same page, my .f90 file is my code, and my a.out file is the actual program/executable? That means that I can email the a.out file to someone who doesn't have a Fortran compiler installed and they'll still be able to run it? Dijkstracula posted:The act of running your program has nothing to do with the compiler - you compile it once, then run all the datasets you want by executing the a.out program. The way I understand it is I compile my code to get my a.out program, and then I run this a.out program to generate data that I can use in gnuplot. But if I change my code I'm going to have to recompile it, so that's what I meant. So what I meant was, I want to be able to write a script that does something like this: code:
|
# ? Nov 26, 2009 20:27 |
|
Ziir posted:So that we're on the same page, my .f90 file is my code, and my a.out file is the actual program/executable? That means that I can email the a.out file to someone who doesn't have a Fortran compiler installed and they'll still be able to run it? Ziir posted:The way I understand it is I compile my code to get my a.out program, and then I run this a.out program to generate data that I can use in gnuplot. But if I change my code I'm going to have to recompile it, so that's what I meant.
|
# ? Nov 26, 2009 20:54 |
|
Dijkstracula posted:That's the idea. (So, there's a bit more to the story if, say, you write a Fortran program that uses some BLAS or LAPACK library that the other guy doesn't have, so you'd have to make sure that your colleague and you both agree on using Atlas or GOTOblas or whatever. This is where knowing about shared libraries and how they work is important, since you'll surely be linking against them.) Cool. I don't think I'll need to worry about libraries and such for a while but I'll keep that all in mind when I do.
|
# ? Nov 27, 2009 01:53 |
|
Another hopefully quick question. I'm reading this page right now on functions and I'm confused with their example. It seems like the example code calls for a function that "they haven't defined yet" because the function is defined later on down the road. Well, in MATLAB, it shits itself if you don't write your code in sequential order. Does it not matter with Fortran?
|
# ? Nov 27, 2009 03:06 |
|
Ziir posted:Well, in MATLAB, it shits itself if you don't write your code in sequential order. Does it not matter with Fortran? Actually MATLAB doesn't care about order either. Function look up happens at execution. For Fortran it depends on the compiler, but for the most compilers require functions to be resolved at link time (linking occurs after compilation). Bottom line, you can use functions in any order, but they all must be defined at some time during compilation. Missing function definitions cause errors like "undefined symbol: _FUNA@8". The @# after the function name is actually the number of bytes that are passed as arguments. So if you define a function with two arguments (_FUNA@8) and call with one or three it will not match (_FUNA@4 or _FUNA@12). Of course this will not prevent all type errors, but it will prevent the biggest mistake. Return types are a bigger problem for Fortran, so if you do not use "IMPLICIT NONE" it will not catch type mismatch errors with return types. litghost fucked around with this message at 03:23 on Nov 27, 2009 |
# ? Nov 27, 2009 03:17 |
|
edit:wrong thread!
|
# ? Nov 27, 2009 03:39 |
|
litghost posted:Actually MATLAB doesn't care about order either. Function look up happens at execution. Wow, I had no idea about the MATLAB thing. I guess I never really tried it, I just assumed things needed to be in sequential order because it always fusses about undefined variables and such. Anyway, then is there a way to save functions separately as it's own function1.f90 file so that I can call/run them only if I need to?
|
# ? Nov 27, 2009 04:15 |
|
Ziir posted:Anyway, then is there a way to save functions separately as it's own function1.f90 file so that I can call/run them only if I need to?
|
# ? Nov 27, 2009 05:00 |
|
Ziir posted:Wow, I had no idea about the MATLAB thing. I guess I never really tried it, I just assumed things needed to be in sequential order because it always fusses about undefined variables and such. Of course. As talked about there are shared libraries (.so) which you can use, but you'll mostly want to use object files (.o) and static libraries (.a). If you use the "-c" flag, the compiler will only compile your .f90 file into an object (.o) and not link it (make an executable). You can create a static library (.a) by joining several objects (.o) using ar. The f90 file with the "PROGRAM" statement is generally the last file you compile and then you include all the dependencies (.o, .so, .a) files in the argument list. This where Makefile files become handy. Here is an example Makefile code:
With this, make knows how to compile program when you start changing the 3 .f90s, and only compiles the .o's that changed (by comparing data stamps of the targets relative to their products. Basically you type make, and it will determine which files to recompile to make the end product. Read up on make, as it is your friend for any non-trival programming project. litghost fucked around with this message at 05:20 on Nov 27, 2009 |
# ? Nov 27, 2009 05:18 |
|
Can anyone tell me why this piece of batch script won't work in a particular location:code:
')' unexpected at this time repeatedly for each line of the svn.txt file. I don't see why the location of the script even matters, can anyone shed light on this? For the sake of convenience, it would be good if this script could work from this location. I don't think the fact the directory is mapped is the issue, I can move it a directory deeper and it works. It really seems to be this one location.
|
# ? Nov 27, 2009 18:54 |
|
Is it possible to take information from a Word doc and send it to multiple Excel documents? Currently, I print out a copy of the Word document (program schedule for a tv station) and hand write the episode numbers for shows that we take off a service called pathfire. This isn't the greatest since my coworkers have to read my horrid handwriting. So is it possible for either a script or maybe a VB app to parse the word document, see the second episode number for Rachel Ray, and then send that to an Excel document labeled Tuesday? Most of the shows and episode numbers are in the same place from week to week, but sometimes on the weekends the shows get shuffled due to sports.
|
# ? Nov 28, 2009 08:34 |
|
(AS 3) I just did this method that takes any number of arrays and compares them with eachother with the Function compareFunction and runs actionFunction if compareFunction returns true. Is there a name for something like this? I couldn't find anything like it for Actionscript but it seems like something that would be pretty common. php:<? package biz.hatu.utils { public function compareArrays(arrays:Array, compareFunction:Function, actionFunction:Function):void{ for each(var array:Array in arrays){ for each(var array2:Array in arrays){ for each(var value:* in array){ for each(var value2:* in array2){ if(compareFunction(value, value2)){ actionFunction(value, value2); } } } } } } } ?>
|
# ? Nov 28, 2009 17:35 |
|
diremonk posted:Is it possible to take information from a Word doc and send it to multiple Excel documents? It's going to be best to do it the other way around where you generate the word document from the CSV/Excel data. The CSV/Excel data should always be in the same spot.
|
# ? Nov 28, 2009 17:53 |
|
Not really possible to do it the other way around, the word doc is generated by another department for their use. Only reason we get a copy is to make sure that all of the lovely paid programs are in house. Thanks for the info though, guess I'll work on my handwriting.
|
# ? Nov 28, 2009 21:25 |
|
Hopefully someone can answer this one. I'm doing some fluid dynamics simulations in MATLAB, and I'm running into a weird problem where the elements of my velocity field becomes complex after a few iterations of my main timeloop. Same thing happens for temperature, density, energy, etc, basically all my variables take on complex values. The thing is, I've gone over it many times, and there's nowhere in my code where a complex number would be produced by means of taking a square root of a negative number. So I have no clue why this is happening. I'm far from an expert in computational methods, so basically, my question is this: is it possible that something like small number rounding errors could be causing this problem?
|
# ? Nov 28, 2009 23:40 |
|
Complex values can be created by other ways of simply taking the square root of a negative number. For instance, are you taking the eigenvalues of a non-symmetric matrix? But, to answer your question, no, rounding errors will never create a complex number if you're working in the reals (this is assuming that you're working in a semi-well conditioned problem) Dijkstracula fucked around with this message at 00:16 on Nov 29, 2009 |
# ? Nov 29, 2009 00:14 |
|
Dijkstracula posted:Complex values can be created by other ways of simply taking the square root of a negative number. For instance, are you taking the eigenvalues of a non-symmetric matrix? Well, of the math I'm using in this solution algorithm, square roots are the only thing I could think of that would create a complex number. I am using some matrices, but all matrix operations in my code are done elementwise - I'm definitely not doing anything like finding eigenvalues. Any other ideas?
|
# ? Nov 29, 2009 00:33 |
|
fletcher posted:I've got a situation where data is stored in two different RDBMS's and I need to essentially do a simple JOIN between two tables that are in the different systems. I was pondering the best method for this too this week, you could try feeding everything into a temporary table.
|
# ? Nov 29, 2009 01:06 |
|
Hey guys, I was directed to this subforum by a friend and told to ask for help here. I'm looking for someone to make me a basic utility that does a bulk find and replace on a directory of .txt documents. When the .txt files are written to my system, lines that should read abcdefghijk are written as abcd***. What I want to is something that allows me to enter in the characters that I want to appear in the .txt files, and then at the end of the day when I'm finished with my work I can run the utility on all the characters that I've inputted and have them replace what was written to my system. I'm willing to pay someone for this work, so if you're interested in helping me out, contact me by PM and I'll give more details.
|
# ? Nov 29, 2009 02:48 |
|
What operating system are you running? This is a one-liner in Linux or OSX. $ cat foo abcdefghijk abcdefghijk butts lmao test abcdefghijkabcdefghijk $ sed -ie 's/abcdefghijk/abcd\*\*\*/' foo $ cat foo abcd*** abcd*** butts lmao test abcd***abcdefghijk edit: to be clear, substitute \*\*\* with the letters you want to be inserted. Dijkstracula fucked around with this message at 03:26 on Nov 29, 2009 |
# ? Nov 29, 2009 03:23 |
|
fletcher posted:I've got a situation where data is stored in two different RDBMS's and I need to essentially do a simple JOIN between two tables that are in the different systems. You should probably download the data and create a temp table out of it. For fun chips, index the table afterwards.
|
# ? Nov 29, 2009 07:00 |
|
American Psychonauts posted:
Exponential Death? It's actually not that common, since there's usually far more efficient ways of solving a certain problem (like keeping stuff sorted).
|
# ? Nov 29, 2009 18:21 |
|
BizarroAzrael posted:Can anyone tell me why this piece of batch script won't work in a particular location: Can %%a ever have a space in it? I think you need to surround it in quotes when you set latest to it.
|
# ? Nov 30, 2009 16:26 |
|
What is a good language to use for a moderate - large size database site that is going to be faster than php and is compatible with postgresql? I've considered asp .net, ajax, ruby but I'm out of the loop on what is current. This is for a friend who has no cash which is why he's resorting to someone who hasn't built a website in like 5 years (me).
|
# ? Nov 30, 2009 17:34 |
|
nintendo65 posted:What is a good language to use for a moderate - large size database site that is going to be faster than php and is compatible with postgresql? I've considered asp .net, ajax, ruby but I'm out of the loop on what is current. This is for a friend who has no cash which is why he's resorting to someone who hasn't built a website in like 5 years (me). C
|
# ? Nov 30, 2009 18:34 |
|
nintendo65 posted:What is a good language to use for a moderate - large size database site that is going to be faster than php and is compatible with postgresql? I've considered asp .net, ajax, ruby but I'm out of the loop on what is current. This is for a friend who has no cash which is why he's resorting to someone who hasn't built a website in like 5 years (me). The answer is always Java! http://jdbc.postgresql.org/
|
# ? Nov 30, 2009 18:48 |
|
|
# ? Jun 5, 2024 08:36 |
|
yatagan posted:The answer is always Java! No really, it's Scala, using Lift
|
# ? Nov 30, 2009 20:43 |