Questions tagged [c++]

A powerful object oriented programming language.

Filter by
Sorted by
Tagged with
3
votes
3answers
110 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 ...
8
votes
1answer
97 views

Is using std::valarray considered good practice?

C++ has had the std::valarray class since the C++98 standard. It is meant to facilitate numerical computations, providing the sort of operations one would expect of ...
1
vote
0answers
37 views

How to deal with a huge system of ODEs in Boost ODEINT?

I am using the C++ library ODEint, which is part of Boost, to solve an extremely large system of coupled ODEs - in particular 1975 equations with large rational functions in the coefficients. In the ...
3
votes
1answer
45 views

PETSc - Manipulate BAIJ matrix locally

My program loads a parallel PETSc matrix $A$ on several MPI processes, each holding a block submatrix $A_i$. I would like to retrieve the local submatrix $A_i$, the one corresponding to the current ...
2
votes
0answers
33 views

Algorithm to join hexahedra and obtain outline volume

I would like to join several hexahedra and obtain an outline volume. First, I started with 2D implementation. In 2D, there are non-intersecting quadrangles which always touch each other as shown in ...
0
votes
0answers
67 views

How to read data from simply formatted text file (c++)?

Mesh information like points, faces and cells is to be stored into separate files: e.g. for points file: # points data: x y z N_Points 100 x1 y1 z1 x2 y2 z2 ... cell file: # cells data: ...
3
votes
0answers
38 views

Derivative of Whittaker-Shannon interpolant

Last time we looked at how to improve the accuracy of Whittaker-Shannon interpolation, where user njuffa demonstrated that judicious use of sin_pi could greatly ...
0
votes
1answer
47 views

Computing excited states using itensor (with DMRG)

I am trying to compute first few excited states of some Hamiltonian (I am using itensor and its DMRG algorithm). To do so, I am ...
2
votes
2answers
175 views

Compiled c++ code runs much faster with double than float. Explanation?

I am still rather new on here and I hope question is suitable for this forum otherwise please help me migrate it to greener pastures. I am an electrical engineer specializing in applying mathematics ...
2
votes
1answer
75 views

Automatic differentiation via ADOL-C and the Heaviside Function

I am writting a c++ program in which I define a function $$\displaystyle F(t) = \sum_{i}r_i\,H(t-t_i)$$ where $H$ is the heaviside function, $t_i$ are optimal parameters which are mutable. The ...
1
vote
0answers
30 views

Metis: how to use and tutorial recommendation

I am new to METIS and trying to use it in my fortran code. I read the manual online. But still, I am not sure about how to implement it my code. I tried the test cases in the graphs directory. For ...
2
votes
1answer
70 views

How to justify using available code (in different language) for comparing algorithms

I have proposed an algorithm for a scheduling problem in a submitting paper. In the revision, the reviewer asked us to compare with another algorithm from the literature. Our algorithm is in MATLAB, ...
1
vote
0answers
45 views

How to integrate the contents of a vector using an adaptive quadrature routine [duplicate]

I have a function which requires the return type to be a container. The problem is that I need to integrate the contents of the container as efficiently as possible and was hoping to use adaptive ...
0
votes
1answer
83 views

Good C, C++ library for efficient grid search / tuples, ideally with bindings to Eigen

I have a $q$-dimensional grid, known at run, not compile-time, that has $50$ points in each direction and hence $50^3$ combinations that I would like to first build and then call a function with each ...
5
votes
1answer
123 views

Whittaker-Shannon interpolation: Accuracy dies with speedup; can it be fixed?

With a truncated Whitaker-Shannon series (cardinal series) $$ f(t) = \sum_{j = 0}^{n-1} y_{j} \frac{\sin\left(\pi( \frac{t-t_0}{h} -j)\right)}{\pi\left(\frac{t-t_0}{h}-j\right)} $$ we can naively ...
1
vote
1answer
157 views

LAPACK equivalent on c++ , which is the best one? [duplicate]

I am following a course of computational material physics. The professor uses fortran to code and uses lapack to solve eigenvalue problems. So far I just know c++. There is an equivalent library that ...
2
votes
3answers
137 views

Find a solution of large system of inequalities

I have a large system of homogenous inequalities involving 33 real unknowns of the form $$ \vec{F}(z_i)^T \cdot \vec{X}>0\, $$ where $\vec{X} = \left(x_1,...,x_{24}\right)^T$ are the unknowns and ...
3
votes
0answers
59 views

Structural Analysis Library

Can anyone recommend a structural analysis library that satisfies the following requirements: C++ API Simulate both beam elements and shell (slab) elements Both static and dynamic analysis Free and/...
0
votes
0answers
218 views

OpenCV: How to get the “rectified” fundamental matrix?

I have a stereo image pair and the respective intrinsics and extrinsics of both cameras. With this information, I can calculate the fundamental Matrix between the two cameras (let's call it F). I can ...
3
votes
3answers
192 views

Simple way to store/read data from file in C++

I've been running various simulations with C++, and doing so has often involved saving lots of data to file (real/complex matrices, arrays, etc) and then reading them into other programs later. ...
17
votes
3answers
2k views

C++ Best practices for dealing with many constants, variables in scientific codes

I am developing a code to simulate fluid flow with biological substances present in the flow. This involves the standard Navier-Stokes equations coupled to some additional biological models. There are ...
4
votes
3answers
254 views

Best software to do big number calculations quickly

I am trying to do some work on some math conjecture. I am testing the conjecture numbers using very large math numbers (100+ digits ). I am currently using python to test these numbers. In the ...
2
votes
0answers
1k views

Good C++ optimization library for BFGS

To implement maximum likelihood estimators, I am looking for a good C++ optimization library that plays nicely with Eigen's matrix objects. Eigen has some capability of interfacing of its own but if ...
1
vote
0answers
48 views

FFTW on subarray with MPI

With the guru interfaces of FFTW, I can apply transforms only to parts of a multidimensional array by modifying the fftw_iodim ...
1
vote
0answers
98 views

$ A * B $ computation when B is a symmetric matrix in armadillo [closed]

Is there any way to multiply a symmetric matrix by a dense one in armadillo(and use the fact that we have a symmetric matrix)? I know about DSYMM Routine in BLAS,...
0
votes
2answers
707 views

Does armadillo library slow down the execution of matrix operations?

I've converted a MATLAB code to C++ to speed it up, using the Armadillo library to handle matrix operations in C++, but surprisingly it is 10 times slower than the MATLAB code! So I test the ...
5
votes
3answers
925 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 ...
0
votes
1answer
144 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. ...
2
votes
2answers
238 views

Integration of a diverge function in c++ GSL Library

I am trying to perform an Integral of Hypergeometric function 2F1(a,b,c,x) from -1 to 1 for some good values of $a,b,c$ (lets say $a=1,b=2,c=3$) . I did it in ...
2
votes
1answer
251 views

MD Simulation: Reference for the Neighbor's List Method

With a rather basic knowledge in C++, I have written my own MD simulation code. Currently, I calculate forces in the most naive way: I go through all the atoms and account for their interactions. This ...
1
vote
0answers
54 views

Dense decomposition of very non-square matrices

I have inherited code that solves Eigen::Matrix problems using the code shown on this page: ...
0
votes
1answer
340 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. ...
2
votes
0answers
52 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 ...
1
vote
2answers
624 views

2D Ising Model, heat capacity decreases with lattice size

The problem I'm trying to make a metropolis simulation of the 2D Ising model. Basically, it's the following, for each monte-carlo step: Visit each lattice site, Compute energy required to flip ...
0
votes
1answer
61 views

Wanting an explanation of the variables in Iterative PCA algorithm

I've been trying to implement the CPU GS-PCA algorithm in this paper . The code starts on page 28 I have a program written a script in python which gives the same output as the C++ program in the ...
0
votes
1answer
28 views

combinatory exploration c++ [closed]

I have n spots with 2 possible positions each. I would like to explore all of this possibilities in C++ using loops (or something else if there is a better option). I was thinking of looping from 0 ...
1
vote
2answers
1k views

Physics Simulation in C++

OK, I know a bit of C++ (very basic syntax), and I want to do physics simulation in C++, like stuff like (also the things mentioned here): Ripples and waves over a 2-d surface Vibrating string/...
1
vote
1answer
204 views

C++: Efficient library for dense linear algebra operations (determinant & principal minors)

I usually work with Python, but my basic knowledge of c++ allows me to switch when I need to increase the speed of my code. Currently, I have a python script that (among other things) computes the ...
0
votes
1answer
132 views

How to do a Generalized Complex Schur (or QZ) Decomposition with Eigen C++? [closed]

I would like to do a Generalized Schur (or QZ) decomposition for a pair of complex matrices $A$ and $B$. I found the following class: ...
5
votes
2answers
240 views

Recommended language/environment for large scale semi-continuous biological models

We have a fairly large (maybe 1000 equations) differential-algebraic equation model written in ACSLX, an obsolete modelling environment similar to Modelica. The model represents the evolution of a ...
2
votes
0answers
145 views

What could be causing multi-dimensional numerical integration inconsistency?

I'm trying to numerically integrate a multi-dimensional expression. The integrand is complicated; for example this is the integrand for $N=4$: $$\begin{aligned}&x_1^6x_2^5x_3^3x_4^2(x_1-x_1x_2)(...
0
votes
1answer
94 views

Is the time step size of a Rosenbrock method for stiff systems iteratively calculated?

I have an ODE system of the general form y' = k(y)(x) + q(z)(x) x' = a(z)(x) + b(x)(x) where k,q,a and b are also dependent on the states x and y. The ...
6
votes
2answers
165 views

Generating set of points on a surface defined by constraint

I'm writing a differential geometry library, and one minor convenience I'd like to offer is to generate a set of points on a surface given by a constraint. For example, for a sphere, $$x^2+y^2+z^2-r^...
1
vote
0answers
258 views

Newton - Raphson method : maxima of function in 2 variables

I am computing the maximum of a function (with two-variables) using Newton-Raphson method. The function is : $e^{-(x \ - x_0)^2 - (y \ - y_0)^2}$, whose maxima exists at $(x_0,y_0)$. The Jacobian ...
1
vote
2answers
310 views

C++ template design pattern for groups (algebra)

Having both programmed my share of c++ and studied some beginners group theory some year ago, I got curious about this... Is there any particularly popular template based (object oriented) design ...
1
vote
2answers
2k views

Solving the 1D Particle-in-a-Box using C++

I've just finished learning the physics behind the problem and would like to write a program in C++ than can solve the problem. I'm actually stuck at the start. I've quite a bit of research, the ...
1
vote
2answers
178 views

Inverting big symmetric and singular matrices

In this post I found a very similar probem to the one I have, but not a satisfactory answer for my purposes. I have a set of matrices $C_\ell$. They are exactly symmetric by construction. ...
2
votes
0answers
351 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 ...
4
votes
1answer
135 views

Simple Monte Carlo in C++, result dependent from seed

I implemented as an exercise a program to sample the statistics of the escape time of a Brownian particle in a potential well. I used the Euler-Maruyama method to numerically integrate the ...
0
votes
1answer
572 views

Speeding up ODEINT stiff example [closed]

I am trying the implement the following odeint solver example but my differential equations are different. https://github.com/headmyshoulder/odeint-v2/blob/master/examples/stiff_system.cpp The ...