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

1
vote
1answer
90 views

What PRNG function is this?

This is a 16-bit PRNG function, transcribed from assembly to C for easier reading: ...
0
votes
0answers
29 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
43 views

PETCs - How should one initialize PetscRandom?

The documentation of PETSc shows an example of usage: ...
3
votes
0answers
31 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
137 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
44 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
261 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
57 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
85 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 = ...
1
vote
1answer
113 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
54 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
89 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
41 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
115 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
89 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
128 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
130 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
332 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
116 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
92 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
46 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
111 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? ...
2
votes
1answer
196 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
903 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
352 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
588 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
136 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
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
1k 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
169 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
60 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
74 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
556 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
235 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
292 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
273 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
267 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
179 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
76 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
1k 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
1k 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 ...
7
votes
1answer
162 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
226 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
118 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
103 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 ...