Questions tagged [c++]
For questions about writing C++ computational code or utilizing libraries written with C++.
328
questions
2
votes
0
answers
52
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 ...
0
votes
0
answers
60
views
Where should we compute `Energy` and `Trajectory` in this listing?
Suppose, I have the following listing for a barebone MD simulation:
...
1
vote
1
answer
64
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.
...
1
vote
1
answer
102
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 ...
2
votes
2
answers
916
views
Understanding leapfrog integration algorithm
The leapfrog.cpp is an implementation of leapfrog integration algorithm where f() function is being integrated:
leapfrog.cpp
<...
0
votes
1
answer
148
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:
...
0
votes
0
answers
85
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 ...
1
vote
1
answer
114
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. ...
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 ...
0
votes
0
answers
52
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 ...
1
vote
0
answers
83
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 ...
0
votes
0
answers
118
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 ...
0
votes
0
answers
108
views
Solving L1 minimization problems in Eigen
I have an $m\times n$ dense matrix $\mathbf{M}$ and wish to solve $\mathbf{M}\mathbf{x} = \mathbf{b}$ via any of the "L1" methods using Eigen. By this I mean I'm happy with using basis ...
1
vote
3
answers
184
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 ...
0
votes
1
answer
156
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.
...
1
vote
1
answer
237
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 ...
1
vote
0
answers
112
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.
...
-1
votes
1
answer
555
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 ...
0
votes
0
answers
88
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 ...
0
votes
0
answers
86
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 ...
3
votes
0
answers
180
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 ...
-1
votes
1
answer
244
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.
...
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.
2
votes
1
answer
554
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 ...
0
votes
1
answer
981
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 ...
1
vote
0
answers
842
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 ...
-1
votes
1
answer
230
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!
7
votes
1
answer
2k
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 ...
0
votes
2
answers
369
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 ...
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 ...
0
votes
2
answers
1k
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 ...
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 ...
1
vote
1
answer
367
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 ...
-1
votes
1
answer
299
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 ...
1
vote
0
answers
239
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 <...
4
votes
0
answers
197
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 ...
4
votes
2
answers
476
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(\...
0
votes
1
answer
4k
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....
1
vote
0
answers
280
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 ...
0
votes
1
answer
201
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 ...
2
votes
1
answer
566
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 ...
1
vote
2
answers
166
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 ...
0
votes
1
answer
185
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-...
0
votes
1
answer
296
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 ...
2
votes
0
answers
58
views
N-body correct scaling
I realized an usual way to scale an N-body problem for an N-body simulation is by choosing units such that gravitational constant $G = 1$, but I'm probably doing it the wrong way. Suppose I simply ...
3
votes
2
answers
371
views
Using the BDF and RK4 methods to solve this coupled system of ODEs in C++
I'm trying to solve a system of ODEs using the BDF order 4 method. I find the first 3 points using RK4, then for the implicit part of the BDF, I use Newton-Raphson iteration. Unfortunately my solution ...
2
votes
1
answer
479
views
Can one safely use an OpenMP parallel loop with Armadillo?
I have a C++ code performing some Armadillo computations in a loop. I'd like to parallelize this loop with OpenMP. But Armadillo automatically uses OpenMP for some computations. So, would the OpenMP ...
1
vote
1
answer
293
views
Range of a matrix from its complete orthogonal decomposition
In this StackOverflow answer, @Gokul has shown how to get a basis of the kernel of a matrix with the help of the 'Eigen' function CompleteOrthogonalDecomposition. ...
1
vote
0
answers
432
views
Optimize speed for calculating the approximate inverse of a large matrix
I am searching for a faster method to calculate an approximate inverse of a large matrix (up to 32000x32000) resulting from a discrete non-linear system of partial differential equations. I'm using C++...
3
votes
1
answer
1k
views
'Eigen' matrices with static dimension
I noticed that 'Eigen' matrices with dynamic dimension are less efficient than the matrices with static dimension. My algorithm uses a lot of matrices which don't need to be resized, so I wanted to ...