Questions tagged [c++]

For questions about writing C++ computational code or utilizing libraries written with C++.

Filter by
Sorted by
Tagged with
15 votes
5 answers
2k views

Ensuring IEEE 754 Compliance and Numerical Precision in C++ HPC Projects

I'm currently engaged in a large-scale C++ HPC project focused on numerical simulation, particularly Finite Element Method (FEM) simulations. Our project spans various Linux-based platforms and ...
René Chenard's user avatar
7 votes
1 answer
176 views

Unexpected result when summing sorted (and unsorted) positive floating point numbers

I am exploring Higham's excellent Accuracy and Stability of Numerical Algorithms and chapter 4 is dedicated to summation. So I decided to test the most basic thing. Summing positive random numbers ...
lucmobz's user avatar
  • 71
1 vote
1 answer
56 views

How to calculate the force of solid applied by fluid? Using finite difference method, DNS, staggered grid, SIMPLE algorithm, immersive boundary

Problem I am using finite difference method to solve classic problem of flow around cylinder, for validation of my group's immersive boundary method. The common way to validate numerical method is ...
CheapMeow's user avatar
2 votes
1 answer
279 views

Why do my satellites fall out of orbit?

I have set up Newtonian Gravity in my Game Engine, allowing me to simulate the gravitational attraction between celestial bodies. I have the following variables defined: ...
ZeunO8's user avatar
  • 121
1 vote
1 answer
120 views

c++ software packages to solve linear systems subject to constraints

I have a finite element project based on deal.II and cmake/make as build system. I am aware of popular libraries such as deal.II, trilinos, petsc, mumps, superlu_dist,... to solve large sparse linear ...
Simon's user avatar
  • 165
2 votes
1 answer
191 views

Speeding up 3 body problem acceleration calculation

I want to find optimizations to my code for the 3BP, and more specifically computing accelerations. I'm using a data-driven approach, so I have a bodies structure ...
Remeraze's user avatar
3 votes
2 answers
719 views

C++ Run-time parameter constants

I am developing a code to simulate a Non-Volatile Memory (NVM). For that, I need several constants (memory dimensions, feature size, temperature etc.). Until then, all my constants were defined at ...
VIlaX's user avatar
  • 33
2 votes
0 answers
67 views

Efficiently retrieiving indices from lattice with periodic boundary conditions

This is something I've never thought too much about because it seemed like an unnecessary micro-optimization, but I've come across a situation where this computation is actually the primary bottleneck ...
Henry Shackleton's user avatar
0 votes
0 answers
63 views

Where should we compute `Energy` and `Trajectory` in this listing?

Suppose, I have the following listing for a barebone MD simulation: ...
user366312's user avatar
1 vote
1 answer
69 views

Computing LJ force from LJ potential, or not?

Lennard-Jones force can be computed in two different ways: Version #1: Here, the force computation is a self-contained routine. ...
user366312's user avatar
1 vote
1 answer
104 views

How can I write a unit test for this routine?

The first routine instantiates numAtoms number of atoms and distributes them in a 6*6*6 grid. The second routine populates the ...
user366312's user avatar
2 votes
2 answers
1k views

Understanding leapfrog integration algorithm

The leapfrog.cpp is an implementation of leapfrog integration algorithm where f() function is being integrated: leapfrog.cpp <...
user366312's user avatar
0 votes
1 answer
188 views

How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?

Considering the following COO sparse matrix format, with repeated indices: ...
Riobaldo Tatarana's user avatar
0 votes
0 answers
94 views

How to use a surface mesh parameterization?

I'm currently playing with the surface mesh parameterizations of the C++ library CGAL. For a mesh with a boundary, the computed uv-space (parameterization domain) is either a disk or a square, and so ...
Stéphane Laurent's user avatar
1 vote
1 answer
156 views

Can Spectra find eigenvectors and eigenvalues of complex-valued matrices?

I am using Spectra to iteratively solve large-scale eigenvalue problems. I like it because it readily works on windows, and is header-only. I would like to know if it supports complex-valued matrices. ...
DJames's user avatar
  • 417
1 vote
0 answers
66 views

How can I optimize the solution of linear systems in my Finite Element Method code for solving nonlinear computational mechanics problems?

Currently, I use Eigen3 for linear algebra operations on sparse matrices and either UMFPACK or CHOLMOD from SuiteSparse to solve sparse linear systems. However, as my model grows larger and the need ...
Riobaldo Tatarana's user avatar
0 votes
0 answers
60 views

How best to iterate over three dimensional grid?

My problem is to iterate through $[0.95,1] \times [0.95,1] \times[0.95,1] \in \mathbb{R}^{3}$. Is there a generic way to do this? I was considering rolling it all out and effectively vectorising the ...
KeynesCoeFen's user avatar
1 vote
0 answers
89 views

Resource to learn assembly code

I'm a PhD student in mechanical engineering and I have to perform a lot of simulations for my project. In my lab we use several well-known libraries, from FEM to machine learning. As we're doing ...
FEGirl's user avatar
  • 333
0 votes
0 answers
155 views

Numerical integration library interfacing with eigen

I am looking for a numerical integration library like this one. The examples look very appealing but I see that all test functions use very barebones C arrays. Do you have any recommendations of ...
KeynesCoeFen's user avatar
1 vote
3 answers
187 views

Inefficient comparisons of custom data type C++

I've got some code that I need to squeeze every bit of both time and space out of. I'm looking for a better solution to the following problem. For reasons outside of the scope of this question, I ...
Michael Jarret's user avatar
0 votes
1 answer
183 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. ...
Riobaldo Tatarana's user avatar
1 vote
1 answer
281 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
1 vote
0 answers
125 views

Does cblas_dgemm mutate my input matrices?

I have written a matrix class Matrix<T> for which I have implemented a wrapper function for cblas_dgemm. ...
Urwald's user avatar
  • 111
-1 votes
1 answer
674 views

How to initialize Eigen C++ parameters within for-loop? [closed]

I am new to Eigen C++ programming. I am trying to create an Rcpp function to call from R. The function takes a list of matrices (Xlst), and two lists of vectors (ylst and smwlst). In each for-loop ...
Shakil's user avatar
  • 1
0 votes
0 answers
100 views

Recursion relations for integrating Gaussian functions

I'm trying to implement a numerical method used in quantum chemistry from scratch. I'm using this paper as a reference. It's also available on Sci-Hub. So, the method requires calculating integrals of ...
Dmitry Govorov's user avatar
0 votes
0 answers
87 views

Book recommendation request: A good C++ based software development book for a computational mathematician

I'm hoping that this type of question is on-topic, and I have put in a little hunting to make sure it isn't a flat out repeat. If it is either of the above, I apologize in advance. I'm an early career ...
Chessnerd321's user avatar
3 votes
0 answers
187 views

How can I improve this matrix product calculation in OpenCL?

I am trying to compute a matrix-matrix product of N stacked complex double N x N matrices. For simplicity, I assume N = 512. I have written code in C++ parallelized with OMP and using OpenBLAS for the ...
sqrt6's user avatar
  • 31
-1 votes
1 answer
265 views

Armadillo BLAS Matrix Multiplication with it transpose. Blas is too slow?

Does someone knows another trick or solution how can I perform matrix multiplication by its transpose? The current code for 1000 iterations takes too much time for me. ...
Furch Radeon's user avatar
0 votes
1 answer
3k views

Dynamic Sized Identity Matrix in Eigen

I am aware of creating an identity matrix in Eigen if the number of rows and columns are known. How do we create them dynamically when the size is not known? An example would be useful. Thanks.
user1408865's user avatar
2 votes
1 answer
679 views

How to use an adaptive step size in boost::odeint

This is a combination of these two previous questions: How to get ODE solution at specified time points? Stop integration in odeint with stiff ode I need to solve the following differential equation ...
surrutiaquir's user avatar
0 votes
1 answer
1k views

C++ compilation error on Mac OSX: gsl library not found [closed]

I'm new to C++ programming. This seems a common error but I can't seem to solve: I'm trying to use the gsl library, with no luck: using ...
Sofia's user avatar
  • 11
1 vote
0 answers
991 views

Symmetric Matrix in Eigen C++

I am aware of a symmetric matrix type in uBLAS as ublas::symmetric_matrix matrix. Is there an equivalent for this in Eigen library that can be used to construct one or do we need to explicitly check ...
user1408865's user avatar
-1 votes
1 answer
272 views

Delaunay triangulation libraries for sets of 3D points CGAL

I need help. Do you know such a library for 3D triangulation - CGAL? How to get from it the order of joining the vertices to enter into your variable? Found nothing on the official site. Thanks!
Max Panchuk's user avatar
7 votes
1 answer
3k views

Eigen C++ Library Over 4x Slower than Fortran

I am experimenting with ways to call compiled programs from Python. My primary interest is iterative optimization methods, so I'm testing an implementation of Newton's method to solve a logistic ...
Robert Bassett's user avatar
0 votes
2 answers
399 views

Searching for recent code source for "Parallel scientific computing in C++ and MPI "

I am learning C++ scientific computing with "Parallel scientific computing in C++ and MPI A Seamless Approach to Parallel Algorithms and their Implementation" since it kept coming up a lot ...
coyote's user avatar
  • 188
1 vote
2 answers
1k 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
0 votes
2 answers
2k views

Are C++ and FORTRAN low or high -level programming languages?

In this post, they mentioned that C++ and FORTRAN are low–level programming languages. However, In other references, they consderd these language as a high-level programming languages. Which one is ...
SHdotCom's user avatar
4 votes
0 answers
85 views

Global reconstruction defined elementwise in a-posteriori error estimator

This question is a follow-up of this previous one. In "Error Control for Discontinuous Galerkin Methods for First Order Hyperbolic Problems" by Georgoulis et al., an error estimator is ...
FEGirl's user avatar
  • 333
1 vote
1 answer
392 views

Compute 2D numerical double integration with Boost C++ with parameters

I am trying to compute the double Richardson and Wolf integrals for the focusing of a lens with Boost in C++ (using the Gauss Kronrod method). As a starting point, I used the example presented in this ...
Bertrand Simon's user avatar
-1 votes
1 answer
349 views

Can someone help or point me out to C++ source code for a two body orbit simulation using symplectic integration?

I've professional experience with physics simulations and C++ programming, although I don't have specific experience with astrophysics simulations. I'm trying to build a two-body evolving system ...
Simo's user avatar
  • 19
1 vote
0 answers
249 views

Efficient multidimensional numerical integration in R and C++

I'm trying to perform a 4-dimensional numerical integration in R using a function I wrote in C++ code which is then sourced in <...
CafféSospeso's user avatar
4 votes
0 answers
210 views

High quality constrained optimization C++ library with matrix free second order solver?

I'm working with large scale constrained optimization problem. Some of my constraints can be non linear. Currently i'm using IPOPT. Quality is good by my Hessian computation too slow. It seems that i ...
Daiver's user avatar
  • 225
4 votes
2 answers
551 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
0 votes
1 answer
5k views

C++ Eigen::Map class questions

The Eigen::Map documentation here (https://eigen.tuxfamily.org/dox/classEigen_1_1Map.html) mentions the following: This class represents a matrix or vector expression mapping an existing array of data....
commonys's user avatar
1 vote
0 answers
322 views

Why does Eigen allocate a temporary to evaluate A.noalias() = B.transpose()*C in parallel?

I wrote a program which iteratively transforms data using matrix multiplications. To minimize the number of large memory allocations, I use two roughly equal-sized ...
Wout12345's user avatar
0 votes
1 answer
215 views

Perturbation problem using Runge-Kutta 4

I'm trying to evaluate the perturbations magnitude between 2 body orbiting a central one in three dimensions. In order to do this I need to have an estimate of the error, which I did using Richardson ...
Zebx's user avatar
  • 101
2 votes
1 answer
630 views

Reference request: C++ and numerical analysis book

I'm a master student with a good Numerical analysis background. I'm going to do a master thesis in the same subject, but I need to use C++ since my advisor loves it, and I also believe it's the best ...
FEGirl's user avatar
  • 333
1 vote
2 answers
171 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
0 votes
1 answer
204 views

MPI_Test not progressing MPI_Isend/MPI_Irecv requests

I am running a CFD simulation with a 200,000-vertex mesh. I've decomposed the mesh into 2 load-balanced sub-domains to test my parallel implementation. In the specific function that I am time-...
niran90's user avatar
  • 233
0 votes
1 answer
329 views

Point cloud to height map in C++

With the increased popularity of 3D imaging and scanning I thought it would be easy to transform a xyz point cloud into a Height Map (xy matrix of z points), but after a couple of hours searching I ...
Pedro Ferreira's user avatar

1
2 3 4 5
7