Recent content by nmtim
-
N
C/C++ C++ Storage Class: Definition & Examples
Do you mean like volatile, automatic, static? Tim- nmtim
- Post #2
- Forum: Programming and Computer Science
-
N
What is the difference between #define and declaring a variable and more
A preprocessor macro is just a text substitution: the right hand part gets substituted for the left hand part before the code gets to the compiler. So any occurrence of the characters "twofiftysix" downstream of "#define twofiftysix 256" gets replaced with the characters 256. It's basically...- nmtim
- Post #3
- Forum: Programming and Computer Science
-
N
The Debate on Code Simplification: What's the Verdict?
Exception propagation in C++ does stack unwinding. I didn't think goto did that. Real programmers use "comefrom".- nmtim
- Post #17
- Forum: Programming and Computer Science
-
N
Fortran Double precision computation time in fortran
... double result( init_val); gettimeofday( &t_begin, &tz); for(size_t i = 0; i < maxit; ++i) { result = result/(result+c); } gettimeofday( &t_end, &tz); // The next line prevents the compiler from eliminating the above loop. // It does not contribute to the measured time...- nmtim
- Post #14
- Forum: Programming and Computer Science
-
N
Fortran Double precision computation time in fortran
You can prevent that by using the result of the calculation in a way that the optimizer must honor. The easiest way to do that is to print it; the second easiest, though less certain as inter-procedural optimizers improve, is to insert the loop into a function.- nmtim
- Post #11
- Forum: Programming and Computer Science
-
N
Fortran Double precision computation time in fortran
As Jeff and AlephZero point out, performance depends on hardware, compiler, code, and the algorithm. If you write your program to run on a relatively recent x86/x86-64 machine using vector (packed) SSE, you might see a sharp difference between 32 and 64 bit FP. This is because there are two...- nmtim
- Post #4
- Forum: Programming and Computer Science
-
N
Fortran Troubleshooting a Fortran 77 Program with OpenMP
I was able to build using GCC 4.2. As far as I understand, GCC did not support openmp prior to 4.2 (although some people built it into 4.1 on a provisional basis, e.g. fedora core 5/6). I built GCC 4.2, than ran /my/gcc4.2dir/gfortran -fopenmp hello_f77.f with GCC 4.2 directories...- nmtim
- Post #5
- Forum: Programming and Computer Science
-
N
Fortran Troubleshooting a Fortran 77 Program with OpenMP
What version of GCC are you using? (i.e. g77 -v)- nmtim
- Post #3
- Forum: Programming and Computer Science
-
N
C/C++ GCC & C++: Allocating Large Arrays in Windows
I hadn't compared a vector-of-vectors matrix to a matrix in a flat vector in several years, so I just wrote an integer matrix-vector multiply both ways. I was surprised by the results: the difference in run time was <~ 1%. Run 1000 times for a 1000x2000 matrix, the flat vector matrix took 3.68...- nmtim
- Post #12
- Forum: Programming and Computer Science
-
N
Numerical solutions to diffusion equations
Strikwerda's "Finite Difference Schemes and Partial Differential Equations" is a general introduction to finite difference methods, with a lot of coverage of convergence, stability, etc.- nmtim
- Post #3
- Forum: Programming and Computer Science
-
N
What are the best languages for creating a website and how do I get started?
w3schools.com has tutorials for beginners on HTML & XHTML, writing web pages, etc. They also have tutorials on scripting for both the browser and server sides.- nmtim
- Post #2
- Forum: Programming and Computer Science
-
N
Efficient Set Membership Testing with Hashtable?
What language are you using? C++ for example provides set data structures. Have you tried whatever your language provides? How did it perform?- nmtim
- Post #4
- Forum: Programming and Computer Science
-
N
C Book Recommendations for High School Students
I learned from "C The Complete Reference" by Herb Schildt. You might also look at "Teach Yourself C" by the same author. And I learned a lot of basic C++ from "C++ Primer Plus", so I can recommend the author Prata (same as C Primer Plus).- nmtim
- Post #18
- Forum: Programming and Computer Science
-
N
Java Java and other high level languages for computational science
Java doesn't seem to be used much in physics/astrophysics HPC. I suspect Java does not have much to offer that C++ or the newer Fortran flavors don't have already. The thinking may be, with a lot of existing code already written in those languages, why use Java? Reading the IBM paper you...- nmtim
- Post #5
- Forum: Programming and Computer Science
-
N
Why is f1 not equal to zero in this C code for a six spring mass simulation?
Floating point math is non-associative. More aggressive optimization levels permit the compiler to reorder operations, thus leading to different results. You're counting on two numbers being identical except for sign and thus perfectly cancelling. That's not happening, indicating that...- nmtim
- Post #6
- Forum: Programming and Computer Science