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
2 votes
1 answer
314 views

Quadratic Eigenvalue Problem

Is SLEPc really the only C/C++ package that provides a solver for the Quadratic Eigenvalue Problem (QEP) out of the box, using sparse matrices?
Ponyboy Curtis's user avatar
0 votes
0 answers
55 views

What techniques are there to take averages and errors in a Monte Carlo simulation in C? Can my code be improved?

I'm trying to perform a Monte Carlo simulation in C and these are the steps I'm following: We assume an infinite reservoir compound of CO and NO molecules with partial pressures 𝑦CO and 𝑦NO(= 1 − 𝑦...
Auyk's user avatar
  • 1
0 votes
0 answers
66 views

Absence of discontinuity in Specific Heat in liquid-gas transition (Based on the Ising Model)

I'm trying to do a model for the transition liquid-gas based on the Ising model and the metropolis algorithm, instead of using values of spins, I'm saying that a cell is occupied by a particle or not. ...
madcreatorfr's user avatar
0 votes
1 answer
415 views

How can I convert a C program into a CUDA program?

Suppose I already have a C program that solves a specific computational problem. I want to convert that into a CUDA program. What steps should I follow to do that? For instance, can I think as follows?...
user366312's user avatar
0 votes
1 answer
242 views

Assign and print the results of CHOLMOD package

I am trying to solve a simple working example, a linear system $Ax=b$, where $A$ is sparse SPD and $b$ is dense, using CHOLMOD. ...
Ponyboy Curtis's user avatar
1 vote
1 answer
403 views

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

I've been trying to implement data compression algorithms in python, but I just can't get mine as fast as the other algorithms other have made. So I've decided on using C since I've asked people about ...
gushkash's user avatar
  • 153
0 votes
1 answer
109 views

Suming up the series $1+1/2+...+1/n$ in C [closed]

...
Quiet_waters's user avatar
0 votes
2 answers
479 views

float in C: Size of the exponent

This question is very related to the question Number of decimal of float and double in C. In the second table we may see that the exponent of the float are from -38 to +38. But the IEEE754 standard ...
yemino's user avatar
  • 527
0 votes
1 answer
238 views

Number of decimal of float and double in C

I'm reading the following table (from https://www.tutorialspoint.com/cprogramming/c_data_types.htm ) Why the precision of the float is 6 decimal places, but I see that the float are in the interval [...
yemino's user avatar
  • 527
1 vote
1 answer
73 views

Integration in 3D

So the question was to use a nested loop to solve a 3D integral with the function conditions (written below in the code) to find $$\int dxdydz $$ and the x and y coordinate of the centre of mass of ...
Phy's user avatar
  • 13
1 vote
0 answers
98 views

Poisson equation fast solver on large grids

Below is kind of a broad question. Was given Poisson equation with BC, on meshgrid of NxM. Rewrote as system of N*M linear equations, Converted to sparse format (CSR/CRS/Yale), solved using Conj Grad ...
2Napasa's user avatar
  • 362
1 vote
1 answer
87 views

Memory issues with iterative solvers

Was trying to implement a poisson 2d solver using Conjugate Gradient Method, so from 10x10 grid the matrix becomes 100x100 (since we have 100 nodes to find the values at), 100x100 grid goes to ...
2Napasa's user avatar
  • 362
0 votes
1 answer
44 views

Identical .so shared libraries (with no symbols) are generated when compiling different C source files [closed]

At the institution I work for we have a User Exit made in Pro*C (SQL embedded in C language). We are having some troubles because identical shared libraries are generated when compiling different ...
el_senior_x's user avatar
6 votes
3 answers
287 views

Numerical integration giving incorrect sign

For my research, I need to integrate the following function: $$ W(z)=\int_0^{\infty}dx\ w(x,z)\\ =\int_0^{\infty}dx\frac{e^x}{(e^x+1)^2}\log{\left(\frac{e^{z^2/4x+x}+1}{e^{z^2/4x+x}-e^x}\right)}\\ =\...
surrutiaquir's user avatar
1 vote
2 answers
2k views

Recommendations for ODE solvers for stiff equations

I'm continuing the research of a former Ph.D. student in my group requiring the solution of a system of ODEs. On a technical note, they wrote: The system of Boltzmann equations behaves numerically ...
surrutiaquir's user avatar
3 votes
0 answers
102 views

Numerical Soultion to Background equations of cosmology

I am trying to solve the background equations of cosmology numerically using Runge-Kutta Dormand Prince method with simplified assumption $8\pi G=1$ and $c=1$. The equations are $$\ddot a = - \frac{1}{...
Dori's user avatar
  • 39
3 votes
2 answers
458 views

OpenMP: parallelizing calculation of pair interaction forces

I recently started to learn OpenMP. Albeit I have developed some intuition I still have some doubts on how to proceed under certain circumstances that are very useful for computational physicists. My ...
CLP's user avatar
  • 68
4 votes
2 answers
663 views

Evaluation of real-valued confluent hypergeometric function with specific complex arguments

In my C++ code, I need to evaluate the confluent hypergeometric function ${}_1F_1(a,b;z)$ with complex arguments in a special case. More precisely, I have to compute $$ e^{-i\phi}{}_1F_1(\ell+1+iZ,2(\...
user157765's user avatar
1 vote
2 answers
185 views

Need software for generating self-avoiding random walks on a tetrahedral lattice

I am looking for FOSS code that can generate self-avoiding random walk trajectories on a tetrahedral lattice. The purpose of the exercise is to create random conformations of model polymer chains that ...
András Aszódi's user avatar
2 votes
1 answer
351 views

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

I am looking for a general purpose library which can solve a 2D or 3D linear elliptic PDE on a rectangular domain with mixed/Robin boundary conditions. I am a C programmer, so I would prefer a C ...
vibe's user avatar
  • 1,078
1 vote
1 answer
97 views

Heineken Virus C program ( how to simplify and discard else if in my code) [closed]

So I have a question about simplifying my C code , This is the question : A pandemic of the Heineken virus is underway in Croatia and around the world. The National Civil Protection Headquarters plans ...
Aster Nash's user avatar
10 votes
1 answer
1k views

How to document math formulations in scientific computing codes?

I am writing the code relate to math. There is some complicated math formulation in the project. Directly writing the calculation code leads to hard understanding; thus I want to comment on the ...
Xu Hui's user avatar
  • 323
3 votes
1 answer
302 views

Augmented arithmetic operations (IEEE-754-2019): output definition and implementation

In the new version of IEEE-754-2019: IEEE Standard for floating-point arithmetic, the augmented arithmetic operations were introduced. These operations can be particularly useful in certain numerical ...
Anton Menshov's user avatar
  • 8,742
4 votes
1 answer
2k views

Performing 2d numerical integration with Boost Cpp

I've been learning to use the numerical quadrature of the Boost library for Cpp. In the documentation, I've found an example for 1D Gauss-Kronrod Quadrature using Boost. ...
Galilean's user avatar
  • 151
-1 votes
2 answers
589 views

2d Schrodinger Equation via matrix diagonalization in C

I am trying to solve the time-independent Schrodinger equation in two dimensions via discrete matrix diagonalization. I want the energy eigenvalues and the corresponding eigenfunctions for a given ...
user8384493's user avatar
2 votes
0 answers
81 views

Alternatives to breadth-first-search in 3D grid cluster detection?

I've got a question about a good way to find the quickest algorithm for my problem: problem: I've got a 3D cubical grid containing voxels that are either 1 or 0. It is stored as a flattened array. If ...
SumakuTension's user avatar
2 votes
1 answer
410 views

Best way to check if SOR solution has converged for 2d matrix

I have written a SOR algorithm to solve the Laplace equation on a 2d grid. The outside of the grid is fixed at 0 and the central square is fixed at 10. I can obtain the fully converged solution for ...
user8384493's user avatar
4 votes
2 answers
2k views

Memory Management - Why certain initializations order are faster?

...
TVSuchty's user avatar
  • 151
4 votes
3 answers
236 views

GPGPU computing, software selection

I am using an existing GCC C++ x86 Qt application that filters, displays and stores results computed by some C code. Since the computation by now got too complex for CPUs I intend to port the small C ...
Silicomancer's user avatar
5 votes
0 answers
68 views

Evaluate Nth root of a rational to a correctly rounded float

Excuse my lack of vocabulary for I have no formal training in this field, which is also why I ask this question - it may be trivial or it may be impossible. I want to evaluate an expression in the ...
pipe's user avatar
  • 153
0 votes
0 answers
88 views

Reducing run time of a numerical calculation using a mex file in Matlab

I wrote a Matlab code that involves doing a numeric calculation (relaxation), but it is quite slow. I learned of the possibility of using a mex file to run a C code and integrate it into Matlab, so I ...
TensoR's user avatar
  • 163
2 votes
1 answer
450 views

Solving nonlinear PDE with finite difference based on Newton-Krylov

I am now working on solving MHD equations with finite difference method, which include nonlinear equations: $$ \frac{\partial\rho}{\partial t}+\nabla\cdot\left[\left(\rho_0+\rho\right){v}\right]-\...
Nothingts's user avatar
0 votes
1 answer
329 views

Finding a shortest path in a graph

If each edge of a graph $G$ is unweighted or has equal weights, then the shortest path between two nodes in that graph is the path that contains the fewest number of edges. Such a path can be obtained ...
gete's user avatar
  • 1
2 votes
3 answers
269 views

C standard for computational science

Which C standard should be used for computational science code ? Should we keep compatibility with C89/90/ANSI or jump to C99 or C11 ? Context: Code will use third-party : BLAS, LAPACK, MKL, ...
Johann MARTINET's user avatar
1 vote
1 answer
276 views

Wrong result of 'ddot' from BLAS

I am having trouble with a C/C++ program that uses the BLAS routine ddot. I am running Linux and so far LAPACK routines worked without any problems. I get a wrong ...
Blablablu's user avatar
6 votes
3 answers
2k views

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

There is a lot of literature that indicates using rand() for simulations might be harmful. A couple of them are as follows: https://www.sciencedirect.com/science/...
physkets's user avatar
1 vote
2 answers
229 views

MPI data broadcast or not in C

I have two slightly different but getting the same results MPI code. The first one is from an open-source package having several data exchange steps in between: ...
user28208's user avatar
1 vote
1 answer
167 views

Problem with 'dsysv' from LAPACK

I am having trouble with a C program that uses the function dsysv from LAPACK. Everything compiles and works without any errors, my only problem is, that the ...
Blablablu's user avatar
6 votes
4 answers
3k views

Efficient eigen-decomposition of covariance matrix

I am looking for an C/C++/Python algorithm implementation that calculates eigenvalues and eigenvectors of a symmetric, positive semidefinite covariance matrix. A general-purpose eigen-decomposition ...
aleksv's user avatar
  • 201
0 votes
1 answer
258 views

Looking for a converter of AMPL/GAMS models into C code

I've done an extensive web search, but could not find an option. Conversion between model formats is available, but conversion of objective function and constraint equations into C code seems absent. ...
aleksv's user avatar
  • 201
1 vote
1 answer
519 views

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

Here is the URL: https://github.com/avaneev/biteopt I've tested it on numerous global optimization benchmarking functions (included), and on real-world hyperparameter optimization problems I have. ...
aleksv's user avatar
  • 201
2 votes
0 answers
92 views

Looking for a version of DSDP that is less prone to integer overflows than the original

I am working on a problem that involves semidefinite programming (constrained optimization of fairly large positive definite matrices). The software is written in C++ and calls DSDP 5.8 to solve the ...
András Aszódi's user avatar
2 votes
0 answers
354 views

Use of multidimensional FFTW and normalisation factor

I am using the FFTW MPI in C. I have a simple question. Quoting from fftw.org The multi-dimensional transforms of FFTW, in general, compute simply the separable product of the given 1d ...
GMV871's user avatar
  • 35
2 votes
1 answer
524 views

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

I have a Matlab code computing the solution to an eigenvalue PDE. It consists of two parts: assembly of the stiffness/rigidity matrices and solving a generalized eigenvalue problem. I mention that the ...
Beni Bogosel's user avatar
  • 1,077
0 votes
1 answer
479 views

High precision Discrete Fourier Transform in c

I'm trying to do a high precision discrete fourier transform on a signal. To examine the precision, I use a gaussian function as the signal, because the fourier transform is also a gaussian function. ...
Roy Liao's user avatar
2 votes
0 answers
844 views

Using C/C++ for Markov chain Monte Carlo (MCMC) methods

I'm working on optimizing the parameters of a mathematical model to fit experimental data, using an existing formula for the likelihood of observing the data given a set of parameter values. At the ...
Keith Fraser's user avatar
4 votes
1 answer
186 views

Using GSL for basic operations

I am learning C/C++ for Scientific Computing and I have a question regarding the usage of scientific libraries for basic operations. Suppose I have to write a small program in C for a bioinformatics ...
wrong_path's user avatar
1 vote
2 answers
174 views

How to deal with big numbers in intermediate calculations?

I have a rather long expression (https://pastebin.com/jUsxdCCs) that is an analytical solution of a set of differential equations generated symbolically from Maple. I need to solve a set of equations ...
Chintan Pathak's user avatar
2 votes
0 answers
219 views

lightweight implementation of semiempirical quantum chemistry (e.g. MNDO,AM-1,PM3)

I'm searching for semi-empirical quantum chemistry solver which would be easy to integrate into my own software. I found a few implementations which can be in principle used e.g. MOPAC, ORCA, SQM some ...
Prokop Hapala's user avatar
2 votes
0 answers
318 views

minimalistic library for classical molecular mechanics force-field in C/C++/Python

I would like some classical molecular mechanics forcefield library or super-simple program which does not have any external dependences, so that I can plug it into my software without worry of "...
Prokop Hapala's user avatar