# Tag Info

Accepted

### How to document math formulations in scientific computing codes?

I prefer using doxygen that supports C++ and LaTeX comments, both inline and as separate equations. This way, you will keep your comments, including, say, the rigorous mathematical formulation of the ...
• 8,701
Accepted

### Memory Management - Why certain initializations order are faster?

Such an effect happens because of how the data of the int** a is stored in memory (as per C/C++). This question on StackOverflow has answers with some more details (...
• 8,701
Accepted

### Numerical evaluation of the Exponential Integral Ei by rational Chebyshev approximations fails

There is a prime missing both in your code and in the expression in your question. In the original paper, the expression is:  \log(x/x_0) + (x-x_0) \frac{\sum^\prime_{0\leq j\leq n}p_j T_j^*(x/6)}{\...
• 11.5k
Accepted

### C standard for computational science

In theory, as the original authors, you're free to pick and name a standard, then expect others to follow it. In practise, if you're supporting an HPC system, then your choice is likely to be ...
• 2,269
Accepted

### Suming up the series $1+1/2+...+1/n$ in C

I see several problems with your code: type error in scanf (n is an integer, not a float) i=0 and not i==0 in the for loop ...
• 196

### C standard for computational science

You should definitely jump to C99, or newer(!). The C99 standard introduced the restrict keyword. Loosely speaking, with this keyword you can inform the compiler ...
• 571

### Numerical integration giving incorrect sign

This might be an accuracy problem in computing the second term, because of those large exponentials when $x \gg 1$. I would first work on that term: gather $e^x$ out from numerator and denominator and ...
• 11.8k

### Looking for Runge-Kutta 8th order in C/C++

summarizing some points: If it's a long-term integration of a non-dissapative model, a symplectic integrator is what you're looking for. Otherwise, since it's an equation of motion, Runge-Kutta ...
• 12.4k
Accepted

### Using GSL for basic operations

Of course it makes sense to use the GSL (or another library for that matter) for several reasons: Don't reinvent the wheel. The work has been done, you can spend your time on more useful things. If ...
• 6,159

### I've developed a derivative-free optimization method, looking for comments

I would like to hear comments from users that have some practical models (e.g. black-box hyperparameter optimization) which are still needed to be solved acceptably - whether this method works or not ...
• 2,216
Accepted

### What language are best for creating data compression algorithms except for C/C++?

In my general experience, the following are required in order to get "reasonable" performance from a programming language: The ability to specify static types. It's OK if the language also ...
• 2,814
Accepted

### How to deal with big numbers in intermediate calculations?

I think there's a simple way to do this. You have a rational function of identical cosh/sinh terms, where every expression is a homogeneous polynomial in cosh/sinh, and the only problem is that these ...
• 11.5k
Accepted

### Recommendations for ODE solvers for stiff equations

This is a huge open ended question, but I'll copy the recommendation section from the current release of DifferentialEquations.jl: Stiff Problems For stiff problems at high tolerances (>1e-2?) it ...
• 12.4k

• 407
Accepted

### C or fortran library to solve linear 2D/3D elliptic PDE

Most of the widely used finite element libraries are written in C++. If all you really care for -- and if all you will ever care for -- is solving an elliptic PDE on a rectangle, then it's probably ...
• 56.1k
Accepted

### Number of decimal of float and double in C

Prof. Bangerth's comment is completely correct. To add more detail, we can refer to IEEE754 standard which defines the floats as ...
• 2,821

### Efficient eigen-decomposition of covariance matrix

TL;DR: I don't think you will be able to beat any real/vendor eigensolver, but it's fun to think about. Deeper cut: One classic algorithm for symmetric eigendecomposition is tridiagonalizing A=QTQ' ...
• 4,946
Accepted

### Simple open-source Quantum chemistry or DFT code in C/C++

Quantum Chemistry codes can get very complicated very fast. Even if you limit yourself to DFT, there are many functionals to support. There's going to be a trade off here for you. You can get a simple,...
• 181
Accepted

### How to deal with very low numerical values in C?

The best thing to do would be to re-scale your problem so that way you don't have such small values. If you can, do this and call it a day. If every number is small, then you can still be fine ...
• 12.4k

### Decrease execution time using openMP

The algorithm you are using spawns extremely cheap tasks, especially at small $n$. As you don't have a luxury of changing the algorithm, the only reasonable (relatively) way to avoid the overhead of ...
• 8,701

### Potential gain - Matlab vs C/C++ - assembly and eigenvalues

It is unlikely that you can benefit a lot from rewriting this particular code in C++. Main reasons: you are already assembling a sparse matrix using Matlab-specific framework for sparse matrices ...
• 8,701
Accepted

### Linear solve using CHLOMOD in C

Here is how I call CHOLMOD from a C program. It uses as input my own C++ structure for a sparse matrix (in standard Compressed Row Storage format). There are several gotchas: understanding the ...
• 2,325

### Looking for Runge-Kutta 8th order in C/C++

I would like to add that while what Geoff Oxberry suggests for long-term integration (using symplectic integrators) is true, in some cases it won't work. More specifically, if you have dissipative ...
• 45
Accepted

### Implementing velocity verlet for harmonic oscillator in C gives error wrt conservation of energy

Your second acceleration ao in the else statement does not make sense. Since it assumes that the calculated position and ...
• 470

### MPI data broadcast or not in C

The question I think you're asking, based on your code, is: A. Better to have each node do redundant work B. Better to have one node do the work distribute the results. The answer is usually A. To ...
• 4,001

### How good are current implementations of rand() in C?

But these seem pretty old criticisms of the rand function This may be a nitpick, but I want to point out what I think is a flaw in this logic. Compilers are often extremely conservative about ...
• 11.5k
Accepted

### Wrong result of 'ddot' from BLAS

The strange thing in your code is ddot_ being declared as extern C int, while it is actually a ...
• 8,701