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
1answer
37 views

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

I'm attempting to implement velocity Verlet with a harmonic oscillator in C, but I have some errors: Energy is not being conserved Energy oscillates much more than I would expect I believe the ...
0
votes
0answers
18 views

Simulation of Parabolic Cylinder Function $U(a,x)$ for complex arguments

According to Wolfram Mathworld $U(a,x) = D_{-a-1/2} (x),$ and $D_v(z) = 2^{v/2}e^{-z^2/4}U(-\frac{1}{2}v, \frac{1}{2}, \frac{1}{2}z^2)$, Using the GNU Scientific Library (GSL) it seems possible ...
0
votes
0answers
48 views

Pivoting in Crout algorithm

Consider the following code, found on wikipedia, that implements the Crout decomposition algorithm: ...
1
vote
1answer
95 views

What PRNG function is this?

This is a 16-bit PRNG function, transcribed from assembly to C for easier reading: ...
0
votes
0answers
32 views

PETSc - difference between PetscNew and PetscMalloc

I wonder what is the difference between both functions. In C++, the difference between new and malloc is easier: new allocates memory by calling the constructor. What about PETSc ? In the example, ...
1
vote
1answer
45 views

PETCs - How should one initialize PetscRandom?

The documentation of PETSc shows an example of usage: ...
5
votes
0answers
54 views

Implementing std::nextafter: Should denormals-are-zero mode affect it? If so, how?

This might be the wrong stackexchange site for this question. math.SE, cs.SE, programmers.SE, and of course stackoverflow are all possibilities. I'm hoping to reach an audience that might actually ...
0
votes
1answer
76 views

Indexing Nested Loops in C [closed]

I am having trouble indexing correctly the below statement in C inside a function and then returning it as a pointer. The returning part should not be confusing - hopefully - however the indexing is a ...
1
vote
2answers
138 views

Programming language for HPC [closed]

I'm planning on building a program that will carry out HPC. I'm aware that C/C++ is significantly better than Python in terms of the speed of computation. However, I'm not yet proficient in C/C++, so ...
0
votes
0answers
64 views

How to build a regression tree in C++

I want to build a random forest that estimates facial landmarks. A random forest is a set of regression trees, built in a certain way. The problem is that I am new to machine learning, yes I ...
1
vote
2answers
48 views

Maintain Uniform Distribution across Subranges

Note: this is a continuation of Generate Random Number outside Bounds. I have a function (thanks to the previous question) with the following prototype which returns an integer in the range $[0,b]$, $...
6
votes
3answers
285 views

What do C, C++ and Java have that Fortran 2003 don't? [closed]

As you may know, Fortran is widely and longly (?) used in science. I've heard a lot of people saying that we natural scientists should all migrate to C++ or Java. I've seen people increasingly ...
6
votes
0answers
70 views

Library with polylogarithm function

I am looking for a reliable library where I can find polylogarithm function and newton/secant method for solving non-linear equations. Basically I have something like this: ...
6
votes
2answers
87 views

Sum over very small exponentials: Underflow

I am trying to compute (in C) a sum like $S = \sum_i \exp( - a_i )$, where $10^{4} < a_i < 10^{5}$ are approximately normal distributed. So even if I do the Log-Sum-Exp trick $S = \exp(\...
1
vote
1answer
145 views

Kummer's confluent hypergeometric for complex arguments in C/C++?

I need to evaluate Kummer's confluent hypergeometric function for imaginary arguments: $$_1F_1(a,b;ix)$$ where $i$ is the imaginary unit, $a,b,x$ are real, and $a,b>0$. Is there a routine ...
3
votes
1answer
56 views

Do BLAS routines compute their respective operations with minimum error?

Do all BLAS routines compute the respective operation with minimum error ? i.e. Is the reduction in sdot computed with least error ? I need to call these ...
0
votes
1answer
90 views

solver linear system equation

I need to solve to solve a "large" symmetric sparse linear systems, with matrix size 8000? I heard about HSL, ITPACK, but I don't know how to use them, and I am working in C language.
2
votes
1answer
44 views

Use of structs in Axisymmetric Finite Volume method

This might be better somewhere else, but I'll give it a try here first. I'm implementing a finite volume scheme for an axisymmetric problem in C, and am looking for a more efficient way to handle all ...
2
votes
1answer
131 views

Profiling optimized C code using gprof

I have a simple C code with many function calls, which I profiled using gprof. ...
1
vote
1answer
97 views

Kronecker products and basis contractions (ie. B.A.Transpose[B]) in C?

I have implemented a basis transformation in C of the following form kron[A,A]*B*Transpose[kron[A,A]] where A and ...
2
votes
1answer
138 views

Recommendation for C/C++ library which offers Schur complement functions?

I need to find C/C++ libraries which offer function for computing Schur complement. I know about MUMPS and Pastix, but I need more of them to compare them in my research. Do you have any experience ...
4
votes
1answer
140 views

What is wrong with this matrix multiplication?

I am attempting to write a matrix multiplication routine because I need to do some analysis in CUDA and I want to validate it with CPU code. I am trying to use <...
3
votes
2answers
384 views

BLAS, LAPACK or ATLAS for Matrix Multiplication in C

I am trying to find the most optimized way to perform Matrix Multiplication of very large sizes in C language and under Windows 7 or Ubuntu 14.04. And searching led me to BLAS, LAPACK and ATLAS. ...
0
votes
1answer
127 views

Water Properties IAPWS-IF97 implementation on C/C++

I'm Looking for an implementation of the IAPWS-IF97 water properties on C/C++. I'm aware of the library freesteam. However freesteam does not include all the properties I'm looking for. Particularly I ...
-2
votes
2answers
94 views

Ways to solve numerically differential equations in C [closed]

I have to solve numerically a differential equation in C. The equation is: How can I write some code to solve it? Are there some numerical methods (Runge-Kutta maybe?) to solve it? A colleague ...
1
vote
0answers
48 views

Elemental vs DPLASMA

I want to use one of these two libraries into my C++ project to basically invert a dense matrix (with Cholesky). Of course, I am interested in a distributed environment. Both libraries seem nice so ...
1
vote
1answer
130 views

Find area of a polygon. In C and Obj C.

I've been given an assignment: Create a console application (using C and Obj C) that will calculate area of a random polygon. The application should process input data as a .txt file with a list of ...
3
votes
1answer
60 views

Is it valid MPI-3 to nest non-blocking collectives?

Is the following a standards-conformant MPI-3 C program? ...
0
votes
1answer
184 views

How to change one bit of a 32 bit integer in C

I have three 32 bit integers a,b,c. I want to make 10th bit of a=(23 rd bit of b) xor (4th bit of c) without disturbing other bits of a. How can I do this in C programming language? a can be zero ...
2
votes
1answer
230 views

Efficient compressed row storage Gauss Seidel C/C++

I am trying to figure out why my sparse (CRS) Gauss Seidel solver is so slow. I tried to find an implementation of the Gauss Seidel method in sparse format online but could only find implementations ...
2
votes
4answers
1k views

Use of Java or Scala in HPC?

I was looking to brush up and/or pick up some languages for a hobby project on my free Amazon EC2, and I was going through the benchmark results for Java vs C (or Scala vs C)and Fortran vs C. It seems ...
1
vote
3answers
397 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
58 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
667 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
139 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: http://winter.group.shef.ac.uk/orbitron/AOs/1s/e-...
7
votes
1answer
148 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 ...
5
votes
2answers
2k 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
178 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
61 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
75 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, ...
5
votes
2answers
590 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
241 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
304 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
279 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 ...
3
votes
1answer
284 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$$ ...
2
votes
1answer
188 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
77 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
2k 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 ...
4
votes
1answer
2k 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
1k 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 ...