Skip to main content

Questions tagged [c++]

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

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
56 views

Is there a reasonably simple solution for nonlinear parameter optimization using c++ objects?

I have a problem under the form of a set of 2 ODE that includes 6 free parameters. I need to optimize these parameters based on experimental results. So far, basically, I have implemented a C++ object ...
user22744's user avatar
0 votes
0 answers
98 views

Numerically integrating photon wavelength undergoing gravitational time dilation

I am trying to integrate the wavelength of a photon that is undergoing gravitational redshift. The formula that I'm trying to emulate is: \begin{equation} \lambda_{i} = \lambda_{e} \frac{ \sqrt{...
shawn_halayka's user avatar
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
203 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
77 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
289 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
155 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 ...
SolidMechanicsFan's user avatar
2 votes
1 answer
200 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
787 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
89 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
66 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
97 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
107 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
261 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: ...
Ponyboy Curtis's user avatar
0 votes
0 answers
109 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
229 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
68 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 ...
Ponyboy Curtis's user avatar
0 votes
0 answers
96 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
99 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
  • 435
0 votes
0 answers
224 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
197 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
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
1 vote
0 answers
148 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
982 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
125 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
93 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
195 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
302 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
4k 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
842 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
2k 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
1k 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
338 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
444 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
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
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
89 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
  • 435
1 vote
1 answer
459 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
393 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
273 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
226 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
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
0 votes
1 answer
6k 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
409 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
  • 121
0 votes
1 answer
227 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
794 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
  • 435

1
2 3 4 5
7