Skip to main content

Questions tagged [c]

For questions related to computational software and libraries written in the C programming language

Filter by
Sorted by
Tagged with
4 votes
1 answer
3k views

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

I know lot of density functional packages in fortran, including one which we are developing in our group (Fireball-DFT) but I don't like fortran very much and I would like something which is easier ...
Prokop Hapala's user avatar
0 votes
1 answer
220 views

How to deal with very low numerical values in C?

I have to work with values such as 1e-15 in my code but I can't. Indeed, because of low precision these values are equivalent to 0. Any ideas?
T. Auerrac's user avatar
0 votes
1 answer
569 views

Decrease execution time using openMP

I have this method which computes the Fibonacci function: ...
N.Der's user avatar
  • 13
1 vote
0 answers
134 views

Problem in analyzing the program of Gauss Jordan Inverse problem

I had to code a program which calculates Inverse of a matrix by Gauss-Jordan Inverse method , I was trying to analyse the program and then code it myself. the link http://hullooo.blogspot.in/2011/...
BAYMAX's user avatar
  • 229
1 vote
0 answers
76 views

Is MATLAB feasible for app deployment versus lower level languages [duplicate]

MATLAB/Octave is a pretty useful language for prototyping scientific computation use cases, however I would like to know if the sheer nature of being a high level language bottlenecks how fast the ...
fibonachoceres's user avatar
1 vote
1 answer
967 views

Jacobi iteration for finite difference: when to stop?

I implemented a finite difference scheme to solve Poisson's equation in a 2D grid in C. I solve the system by using Jacobi iteration. Everything works fine until I use a while loop to check whether it ...
wrong_path's user avatar
2 votes
3 answers
712 views

MPI in C, all processor run outside of the MPI envir created

I am new to MPI and am trying to figure out the subtleties in it, and for that reason I am just playing around with an easy example. The question I have is that when I run the code below with 2 ...
user20973's user avatar
4 votes
1 answer
258 views

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

I am trying to evaluate the Exponential Integral $Ei(x)=-\int^{\infty}_{-x}\frac{e^{-t}}{t}dt$ for $x>0$ (interpreted as the Cauchy principal value) by using rational Chebyshev approximations, ...
jitter's user avatar
  • 155
1 vote
1 answer
295 views

fast adaptive quadrature on equispaced 2-D grid

I need to numerically evaluate 2-D integrals of the form: $$ \mathcal{I}(\theta) = \int_{0}^{1} \int_0^1 \varphi_\theta(x,y) dx dy $$ where $\varphi_\theta$ is a family of smooth functions indexed by ...
lacerbi's user avatar
  • 185
0 votes
2 answers
312 views

CHOLMOD implementation

I am working on a domain decomposition code in C that uses CHOLMOD to approximate grid values for a PDE in each sub-domain. The issue I have is that the methods use Matrix Market format, which is not ...
user20973's user avatar
1 vote
1 answer
587 views

Linear solve using CHLOMOD in C

I am using the open-source CHLOMOD (as here http://faculty.cse.tamu.edu/davis/suitesparse.html) in order to solve a linear system Ax=b (performing A/b=x) in my domain decomposition code but I am ...
user20973's user avatar
0 votes
1 answer
239 views

Open Source Linear Algebra Library

I am making a code in C that requires the equivalent of Matlab's '\' command for a linear system of the form AX=B where A is an NxN matrix and X, B are Nx1 vectors- i.e a code that performs X=A\B that ...
user20973's user avatar
-2 votes
2 answers
154 views

Array initialization in C

In this bit of code, the X and Y arrays should be identical but for some reason, that I CANNOT figure out for the life of me, X[0] is always 1 rather than 0. I have tried initializing the whole array ...
user20973's user avatar
3 votes
0 answers
363 views

Error in MD simulation with Lennard-Jones potential in C, resulting in a lack of conservation of energy

I'm working on a MD simulation using the Lennard-Jones potential and the Velocity Verlet algorithm. The code compiles and runs, but the energy for each time step is not conserved; it decreases ...
Luciano's user avatar
  • 151
1 vote
1 answer
588 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 error ...
Luciano's user avatar
  • 151
2 votes
1 answer
190 views

What PRNG function is this?

This is a 16-bit PRNG function, transcribed from assembly to C for easier reading: ...
Andrew Cheong's user avatar
1 vote
0 answers
145 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, ...
guhur's user avatar
  • 133
1 vote
1 answer
110 views

PETCs - How should one initialize PetscRandom?

The documentation of PETSc shows an example of usage: ...
guhur's user avatar
  • 133
10 votes
0 answers
895 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 ...
Peter Cordes's user avatar
0 votes
1 answer
98 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 ...
debronee101's user avatar
1 vote
2 answers
275 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 ...
J. Doe's user avatar
  • 11
1 vote
2 answers
106 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]$, $...
user19087's user avatar
  • 143
5 votes
3 answers
1k 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 ...
Leonardo Castro's user avatar
8 votes
2 answers
1k views

Library with polylogarithm function [duplicate]

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: ...
Bociek's user avatar
  • 181
8 votes
2 answers
1k 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(\...
fastfforward's user avatar
2 votes
2 answers
1k 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 ...
a06e's user avatar
  • 1,739
3 votes
2 answers
98 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 ...
kesari's user avatar
  • 287
0 votes
1 answer
129 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.
ahmed baba's user avatar
2 votes
1 answer
104 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 ...
Bob Dobalina's user avatar
2 votes
1 answer
2k views

Profiling optimized C code using gprof

I have a simple C code with many function calls, which I profiled using gprof. ...
user avatar
1 vote
1 answer
411 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 ...
Kevan's user avatar
  • 11
2 votes
1 answer
639 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 ...
Eenoku's user avatar
  • 141
4 votes
1 answer
2k 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 <...
drjrm3's user avatar
  • 2,159
3 votes
2 answers
5k 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. ...
hpc_beginner's user avatar
0 votes
1 answer
542 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 ...
Marwan's user avatar
  • 39
-2 votes
2 answers
253 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 ...
Betelgeuse's user avatar
1 vote
0 answers
105 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 ...
gsamaras's user avatar
  • 113
1 vote
1 answer
782 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 ...
Mr_Vlasov's user avatar
  • 113
3 votes
1 answer
126 views

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

Is the following a standards-conformant MPI-3 C program? ...
Patrick Sanan's user avatar
0 votes
1 answer
3k 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 ...
user12290's user avatar
  • 275
2 votes
1 answer
984 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 ...
user14765's user avatar
3 votes
4 answers
3k 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 ...
GuSuku's user avatar
  • 139
1 vote
3 answers
1k 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 ...
winterfly's user avatar
-3 votes
1 answer
446 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-...
Chem Ninjas's user avatar
7 votes
1 answer
187 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 ...
kesari's user avatar
  • 287
8 votes
3 answers
8k 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? ...
gnzlbg's user avatar
  • 1,085
0 votes
1 answer
669 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 ...
rursw1's user avatar
  • 93
1 vote
1 answer
234 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 ...
user10176's user avatar
0 votes
1 answer
106 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, ...
Prabal Gupta's user avatar
14 votes
4 answers
5k 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 / ...
James C's user avatar
  • 277