Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
2 votes
0 answers
43 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
34 views

Temperature of a Lennard-Jones system [closed]

...
user366312's user avatar
0 votes
0 answers
59 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
51 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
100 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
870 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
126 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: ...
Joaquim José da Silva Xavier's user avatar
0 votes
0 answers
70 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
96 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
  • 403
1 vote
0 answers
64 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 ...
Joaquim José da Silva Xavier's user avatar
0 votes
0 answers
49 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
81 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
  • 261
0 votes
0 answers
97 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
0 votes
0 answers
86 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 ...
user14717's user avatar
  • 2,125
1 vote
3 answers
182 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
147 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. ...
Joaquim José da Silva Xavier's user avatar
1 vote
1 answer
211 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
98 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
468 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
73 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
84 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
177 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
233 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
2k 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
494 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
877 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
751 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
195 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
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 ...
Robert Bassett's user avatar
0 votes
2 answers
354 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
  • 88
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
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 ...
SHdotCom's user avatar
4 votes
0 answers
83 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
  • 261
1 vote
1 answer
349 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
270 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
238 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
189 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
431 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
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....
commonys's user avatar
1 vote
0 answers
254 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
190 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
548 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
  • 261
1 vote
2 answers
164 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
165 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
270 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
2 votes
0 answers
57 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 ...
Martrin's user avatar
  • 31
3 votes
2 answers
341 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 ...
Michael B's user avatar
2 votes
1 answer
447 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 ...
Stéphane Laurent's user avatar
1 vote
1 answer
291 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. ...
Stéphane Laurent's user avatar
1 vote
0 answers
416 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++...
enco909's user avatar
  • 11

1
2 3 4 5
7