C is a general purpose programming language. Originally intended for implementing system software, C and its close relatives are the principle languages used in most modern operating systems. Due to its thin layer of abstraction and low overhead, C allows efficient coding of algorithms and data ...

learn more… | top users | synonyms

0
votes
0answers
24 views

private register variable | OpenMP [on hold]

Consider, register int a; Does program allocate private register variables to each thread at the clause, ...
1
vote
3answers
124 views

Searching solution for solving huge linear system in MATLAB or C

I am encountering a problem that my MATLAB code ran and an error occurs and shows that it is out of memory. My code is using finite element method to solve some complicated kind of integral equation ...
0
votes
0answers
39 views

Complex Numbers in C Resulting in Unstable Calculation

I'm trying to perform a calculation which involves the following C-function: ...
0
votes
0answers
59 views

Eigen-unsupported: Levenberg - Marquardt algorithm

I am using Eigen-unsupported: LevenbergMarquardt algorithm. I use this algorithm inside my model. I wrote the minimization code both in MATLAB (using fsolve) and C++ and both gave the similar results ...
-2
votes
1answer
49 views

Solving electron density function for Hydrogen and drawing in 3D

I recently stumbled upon interesting site that has interactive 3D representation of radial electron distribution (atomic orbital). here is the url: ...
7
votes
1answer
131 views

Performance of adding eight numbers sequentially vs. in a tree

The simplest way to add 8 numbers would be something like this, sum = one + two + three + four + five + six + seven + eight; This (in C) would add ...
0
votes
0answers
14 views

Double integrals and parameters in GSL

I'm trying to calculate a numerical integral in C. I have a function that depends on several variables, two of which I want to integrate over while leaving rest of them as parameters. I was going to ...
4
votes
2answers
193 views

Should I pass command line arguments to MPI_Init or not?

When writing MPI 3.0 code, should I pass argc and argv to the MPI_Init call or not, and why? ...
0
votes
1answer
95 views

Fastest linear solver for sparse positive semidefinite, striclty diagonally dominant matrix

What is the state of the art for fastest linear solver for sparse, positive semi definite and strictly diagonally dominant matrix with N varies from ~700 to ~3000, and about a 1/16 of the matrix is ...
1
vote
1answer
46 views

How can DFT of a two dimensional array be found using program for one dimensional DFT in C?

I have the program four1.c from Numerical Recipes in C to calculate the Discrete Fourier Transform (DFT) of a one dimensional array. I want to calculate the DFT of ...
0
votes
1answer
66 views

Beginning Computer Programming [closed]

I was 7 years old when I learnt BASIC. Then I learnt C and Visual Basic till the age of 13. I stopped programming for 4 years continuously, and don't remember much about it now. I have lost the skill, ...
3
votes
2answers
182 views

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

I would like to use Runge-Kutta 8th order method (89) in a celestial mechanics / astrodynamics application, written in C++, using a Windows machine. Therefore I wonder if anyone knows a good library / ...
3
votes
2answers
158 views

C - OpenMP, MPI, Serial Program

I'm part of a Computational Science course and come from a non-programming background, so please forgive me my ignorance. I'm working on a set of code in C to numerically solve the Navier Stokes ...
0
votes
1answer
109 views

C - OpenMP, MPI, Serial Program [duplicate]

I'm part of a Computational Science course and come from a non-programming background, so please forgive me my ignorance. I'm working on a set of code in C to numerically solve the Navier Stokes ...
0
votes
1answer
131 views

PyOpenGL/OpenGL Generating Cosmic NBodys

I am working on a Universe Simulator. I'm stuck on creating the dark matters webs of the universe that look like this: http://www.mpa-garching.mpg.de/galform/data_vis/sim3dnew-highres.png I am ...
2
votes
0answers
85 views

Accurate implementation of the logarithm of the incomplete Beta function in C++?

I need an accurate implementation (for use in C/C++) of the logarithm of the incomplete Beta function: $$\log \mathrm{B}(x,y;\alpha,\beta) = \log \int_x^y t^{\alpha-1}(1-t)^{\beta-1}\mathrm{d}t$$ ...
1
vote
1answer
76 views

Appell function implementation in C++?

Is there a C++/C implementation of the Appell series? GSL and Boost do not seem to have this function.
0
votes
1answer
61 views

Calculation of isotropic-nematic phase transition

In this paper, the theory behind the isotropic-nematic phase transition is discussed. Furthermore, an algorithm is given to calculate some properties of this phase transition. I have written a ...
3
votes
5answers
593 views

Optimization of prime factorization in C

I am trying to teach myself some programming in C by doing the problems of project Euler. I am trying to find the largest prime factor of the number 600851475143 (Euler problem 3). I have written a ...
3
votes
1answer
685 views

Free open source C/C++ library to solve 2d Poisson equation using the finite difference method

I have been writing some code in C for particle-in-cell simulation. One of the steps of the PIC algorithm requires to solve (numerically) Poisson's equation $$ \Delta \varphi = - 4 \pi \rho. $$ ...
3
votes
2answers
594 views

Developing finite volume (FVM) code in C . General advice

I need to develop a FVM code in C (The multiscale FVM method for heterogeneous media). I know that: Only uniform rectangular grids will be considered (2d now, later 3d) Sparse systems will be large ...
7
votes
1answer
121 views

WELL pseudo-random number generations

I've used MT19937 in a test harness to generate uniformly (unsigned) 32-bit [0, $2^{32}$- 1] values, based on the original Authors' mt19937.c implementation, to ...
5
votes
3answers
216 views

A clean way to compute exp(-1/x^2) near x=0 in C?

I am looking for a clean way to compute preciseley, when $x$ is very close to zero: $$\exp(-1/x^2)$$ using C. What is the best way (speed, precision, etc.) ?
3
votes
0answers
107 views

The traveling salesman problem - Using Space Renormalization

Image attached is where I am at the moment. Blue dots=points/cities, Black x's represent central points in each box that contains at least one city, and pink dots represent the midpoint of these ...
5
votes
2answers
91 views

Odd accuracy barrier in C/PETSc regarding finite elements

I’m implementing a finite element code (translating from a working MATLAB version, so I have results to compare to) and for some odd reason, some of my computations are only accurate to around 6 ...
4
votes
1answer
187 views

PETSc input format for linear solvers

I’m going through some considerable effort to translate one of my codes from MATLAB. It’s a type of finite element code and I haven’t implemented the solver yet but comparing CPU times for simply ...
2
votes
1answer
145 views

Sparse linear solvers in C?

I'm working on translating a discontinuous Galerkin code from MATLAB to C and I'm at the final point where I need to solve a sparse system. I've taken a course in C before but I'm very rusty and ...
3
votes
0answers
86 views

N-body simulation for particles

I would like use N-body simulation for measure a torque on an object in a liquid (helium). It's a 2D study. On the site : http://www.browndeertechnology.com/docs/BDT_OpenCL_Tutorial_NBody-rev3.html I ...
3
votes
4answers
180 views

Finding a molecular dynamics visualization library for C

I asked this question over at stackoverflow, and got blasted for it. I am currently working with legacy MD code written in C that my university uses, and haven't moved to a more modern library like ...
9
votes
4answers
327 views

Compute $(e^x-1)/x$ near $x = 0$

The function $f \colon x \mapsto (e^x-1)/x$ has singularity near $x = 0$. That singularity can be lifted, though: for $x = 1$, one should have $f(x) = 1$, since $$ e^x = \sum_{k=0} \frac{x^k}{k!} $$ ...
2
votes
3answers
962 views

When is MPI_Wait necessary for non-blocking calls?

I hope this is not too off-topic here -- I've asked it on SO but I'm hoping I'll get better answers here! I'm a little bit confused about when I should call MPI_Wait (or other variants such as: ...
4
votes
1answer
269 views

Libraries for distributed-memory Cholesky factorization?

What libraries can compute dense Cholesky factorizations in distributed-memory environments (preferably using MPI). I'm using C/C++, and have access to a cluster of between 1 and 40 nodes, where each ...
9
votes
2answers
364 views

Testing if two 12x12 matrices have the same determinant

I am given a $12 \times 12$ matrix $Q$ that is symmetric, invertible, positive definite and dense. I need to test if $$\det(Q) = \det(12I-Q-J) \; \; (1)$$ where $J$ is the all ones matrix. I am ...
0
votes
0answers
70 views

How to avoid over fitting? An application of GBM boosting package

I distributed my data into 90% training and 10% testing, then I build a boosting regression model using GBM boosting package in R which is very similar to the famous Adaboost regression model. There ...
1
vote
2answers
201 views

What sparse solver supports diagonal storage format

I'm writing finite-difference method program using C. The stiffness matrix is symmetrical and band. For its storage I'd like to use Sparse Diagonal Storage format. Could someone tell please, what ...
6
votes
5answers
241 views

Evaluate the sum

I want to evaluate the sum $$\sum_{k=1}^\infty \left(\frac{i+1}{\sqrt{2}}\right)^k\cdot k^{-\alpha}$$ where $i=\sqrt{-1}$ and $\alpha\in[\frac{3}{4},1]$ with 8 digits accuracy. If I am willing to ...
3
votes
2answers
100 views

Are matlab C library versions backwards compatible?

I have some C++ code that links to matlab2008b. Are matlab 2012a and 2012b backwards compatible with 2008b? If it's not trivially compatible, are there some simple steps to make it compatible?
9
votes
3answers
452 views

Recommendations for a lightweight/no-install C or C++ based dense linear algebra solver

Most of my programming is one-off research codes in C for my own use. I have never distributed any code to other than close collaborators. I have developed an algorithm that I am publishing in a ...
4
votes
2answers
409 views

Extracting a 2D matrix from a multidimensional array in C

In my c language program, I have to store multiple dense $m\times m$ matrices corresponding to gridpoints $x_i$ with $i=1,...,n$. I decided to create a three dimensional array $A\in R^{n\times ...
6
votes
1answer
613 views

Open-source, thread-safe implementation of convex optimization solvers in C/C++?

Is there an open-source, thread-safe implementation of convex optimization solvers in C/C++? Some libraries such as NLopt, Ipopt, OPT++ don't meet my requirements. OPT++ and Ipopt aren't ...
7
votes
3answers
832 views

How do I know if my code is being vectorized by the compiler?

As exemplified by Jed Brown's answer to Costs of lookups versus calculations, using vectorized vs non-vectorized floating point operations results in much faster code. Many modern compilers claim ...
13
votes
4answers
1k views

Is C slower than Fortran on the spectral norm shootout (using gcc, intel and other compilers)?

The conclusion here: How much better are Fortran compilers really? is that gfortran and gcc are as fast for simple code. So I wanted try something more complicated. I took the spectral norm shootout ...
2
votes
1answer
269 views

Implicitly casting PetscReal to the real part of PetscComplex

The version of Petsc installed on my machine has PetscScalar set to be complex. I am making a matrix which has all real entries. Something like the following code compiles: ...
15
votes
3answers
2k views

I/O Strategies for computational problems with large data sets?

My research group focuses on molecular dynamics, which obviously can generate gigabytes of data as part of a single trajectory which must then be analyzed. Several of the problems we're concerned ...
11
votes
1answer
237 views

Is there a tool out there that can generate interval extensions of Fortran (or C) functions by parsing Fortran (or C) code?

Case studies in my PhD thesis require that I have interval extensions of Fortran subroutines in CHEMKIN-II (apologies for the link; it's the best one I could find for a package no longer distributed ...
3
votes
3answers
330 views

How to obtain finite difference, which is continuous

I want to calculate a finite difference (something like this SO Post). My data is as follows: I have x-values that are powers of two (4, 8, 16, 32 and 64). Corresponding to them are y-values, such ...
46
votes
5answers
8k views

How much better are Fortran compilers really?

This question is an extension of two discussions that came up recently in the replies to "C++ vs Fortran for HPC". And it is a bit more of a challenge than a question... One of the most often-heard ...
6
votes
2answers
948 views

Which libraries have good implementations of Basis splines?

I'm looking to use the finite element method with B-splines as my function basis. Which C/C++ libraries have good B-spline support? Specifically, I'm looking for an implementation of a stable ...
3
votes
1answer
316 views

PETSc's makefile system can't find MKL

I'm learning PETSc and trying to make the examples written in C. However, when I use the provided makefile, I get the following error: ...
39
votes
14answers
2k views

Is it common not to use libraries for standard numerical algorithms, and why?

A lot of numerical algorithms (integration, differentiation, interpolation, special functions, etc.) are available in scientific computation libraries like GSL. But I often see code with "hand-rolled" ...