Questions tagged [c++]

A powerful object oriented programming language.

Filter by
Sorted by
Tagged with
4
votes
1answer
136 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
586 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 ...
1
vote
2answers
160 views

Sign of integer determinant 4 by 4

I'm in the context of this publication: http://www.gilbertbernstein.com/resources/booleans2009.pdf I applied quantization to my point coordinates: All coordinates are integer lying in [0, 2 power 20]....
4
votes
1answer
126 views

Using GSL for basic operations

I am learning C/C++ for Scientific Computing and I have a question regarding the usage of scientific libraries for basic operations. Suppose I have to write a small program in C for a bioinformatics ...
5
votes
1answer
585 views

2D numerical integration with infinite limit (C++)

In order to integrate a two dimensional function of the form $$\int_{1}^\infty \int_{-\sqrt{x^2-1}}^{\sqrt{x^2-1}} e^{-x} \rm{d}y \rm{d}x,$$ I have been attempting to use the following code (written ...
1
vote
1answer
382 views

LAPACK sorting eigenvalues differently each time

I'm using LAPACK zgeev routine to get eigenvalues and eigenvectors of a symmetric matrix in C++. Problem is zgeev is being called in a loop but it sorts eigenvalues (and eigenvectors) differently ...
1
vote
0answers
97 views

MPI_Finalize() only some processors

I want to develop a distributed algorithm with MPI which have load balancing capability. But there is a situation that I'm not very clear about, which is, when the number of tasks is less than the ...
0
votes
2answers
267 views

Matlab, Mathematica & LAPACK returning 3 different eigenvectors

(I'm not sure which of math.se / stackoverflow / scicomp.se is the right place to ask this question) I have a C++ code which generates a complex matrix and then calculates its eigenvalues and ...
1
vote
0answers
114 views

lightweight implementation of semiempirical quantum chemistry (e.g. MNDO,AM-1,PM3)

I'm searching for semi-empirical quantum chemistry solver which would be easy to integrate into my own software. I found a few implementations which can be in principle used e.g. MOPAC, ORCA, SQM some ...
0
votes
2answers
139 views

Spherical volume integral from pre-calculated points - which algorithm is best?

I need a fast and accurate method to calculate 3d spherical volume integrals. I have pre-calculated data of high precision that just needs a few trivial manipulations before each integration step - ...
0
votes
1answer
82 views

Questions about implementing an electromagnetism/photonics solver package

I am hoping to start (very slowly) on implementing some form of a computational photonics/electromagnetism package. I know things like Meep, S4, FDTD++, EMPy, and a host of other proprietary/free/...
-2
votes
1answer
4k views

C++ - Expression must be modifiable lvalue [closed]

I am new to C++. I am trying to set up a very basic TCG game (with only minion with no text). I think my issue might be linked with pointer. Below are the functions and attributes: ...
2
votes
1answer
2k views

Simple open-source Quantum chemistry or DFT code in C/C++

I know lot of density functional packages in fortran, including one which we are developing in our group (Fireball-DFT) but I don't like fortran very much and I would like something which is easier ...
4
votes
3answers
2k views

A good, simple book/resource on Parallel Programming in C++ for scientific computing

I am a Mechanical Engineering grad student, currently working on a project which will be scaled up in the new future to require quite some processing power. I am using C++ for the code that I have, ...
1
vote
0answers
87 views

Problem in analyzing the program of Gauss Jordan Inverse problem

I had to code a program which calculates Inverse of a matrix by Gauss-Jordan Inverse method , I was trying to analyse the program and then code it myself. the link http://hullooo.blogspot.in/2011/...
1
vote
0answers
65 views

Is MATLAB feasible for app deployment versus lower level languages [duplicate]

MATLAB/Octave is a pretty useful language for prototyping scientific computation use cases, however I would like to know if the sheer nature of being a high level language bottlenecks how fast the ...
1
vote
1answer
781 views

Improve numeric stability of subtraction in C++ [closed]

I'm writing a matrix library in c++. After some debugging I found that a simple double difference is not zero for two "equals" numbers. This is due how double are represented in a computer of course. ...
3
votes
1answer
225 views

SLEPc eigensolvers take long time to converge for large sparse symmetric matrices

I am leveraging the SLEPc library for solving the first $k$ (where $k = 3$ or $4$) eigenvalues and their corresponding vectors for a matrix of size 200,000. The matrix is sparse and symmetric. I ...
6
votes
3answers
2k views

Method to check for positive definite matrices

I think it's already been asked, but I still can't figure out a way to do it computationally. I had to check for positive definiteness of an $n \times n$ matrix $A$. I know that for any nonzero ...
1
vote
2answers
671 views

LU decomposition of large dense matrices

I wanted to generate LU decomposition of large size dense matrices ($N>10^7$), the LU decomposition I'm currently using is based on Adaptive Cross Approximation and is taking very long time to ...
0
votes
1answer
49 views

Passing in a vector from this particular matrix class floating around online [closed]

I am using this matrix class here to assist me in converting this Least Squares algorithm that prices American options that is written in Matlab in C++. My question is pretty simple. I want to pass in ...
0
votes
1answer
845 views

two level iterators C++ [closed]

I am trying to implement a two level iterator as I will now describe. Basically I have a "vector of vectors" and I want a single iterator that will loop over all the objects in the vector of vectors. ...
5
votes
3answers
1k views

Efficiently computing the product of a multi-dimensional matrix (or tensor) and vectors

Update: Thank you very much for all of you who answered below. I'm studying each answer now. In the long term, I'm more interested in solutions that work for sparse tensors (sorry I should have ...
4
votes
3answers
3k views

Beating typical BLAS libraries matrix multiplication performance

A dull matrix multiplication algorithm where we use the formula $$C_{ij}=\sum_{k}A_{ik}B_{kj}$$ By literally following this in 3 loops we'll get a very slow program, because we don't utilize ...
9
votes
3answers
2k views

Are there any “light-weight” FEM packages around?

Basically, FEM seems to be a problem that is pretty much "solved". There are numerous powerful frameworks existing, like Trilinos, PETSc, FEniCS, Libmesh or MOOSE. One thing they have in common: They ...
3
votes
2answers
1k views

Developing a C++ solid mechanics program

I am a beginner in computational science and programming. I am doing research in non linear solid mechanics analysis and using C++ for coding. I have been exploring various finite element open source ...
2
votes
0answers
56 views

Under what circumstances does Elemental's distributed SVD not work? [closed]

I am playing around with Elemental's distributed singular value decomposition and am running into two particular issues. Building the test at tests/lapack_like/SVD.cpp, and running with ...
2
votes
1answer
405 views

Fast C++ implementation of sparse binary matrices

I am looking for the subject. The size of matrices will be around 1000x2000 elements with linear amount of ones (say, 6000 ones in the whole matrix). The operations I will use the most: iterating ...
1
vote
0answers
417 views

Looking for C++ function for performing optimization of parameters for multivariable function

I am adapting a Java program from C++ and need a C++ function to perform the same task as the Java BOBYQAOptimizer() function. Can anyone recommend a C/C++ library with equivalent or similar functions ...
7
votes
0answers
238 views

Numerical integration using interval arithmetic, nowadays

Is there now a package for rigorous numerical integration that uses interval arithmetic and has access to a well-developed library of special functions? By "well-developed", I mean something that, at ...
1
vote
1answer
692 views

Eigen - Solving Complex Generalized Eigenvalue Problem

I've been using the Eigen C++ linear algebra library to solve various eigenvalue problems with complex matrices. I've recently had to use a generalized eigenvalue solution process, only to be ...
3
votes
1answer
790 views

Vectorize a part of a huge matrix in C++

I have a large matrix, side-length is about $n\geq 1000$. I need to do element-wise multiplication of this matrix with another matrix many, many times. I make this process by: Vectorizing (through ...
3
votes
1answer
185 views

Fastest method forfinding a solution to x*log(x)

more specifically, $C x \log_2(x)- K = 0$, where $C$ and $K$ are constants ($\log_2$ means log base 2). I was solving a topcoder problem, SortEstimate, which requires us to solve the aforementioned ...
5
votes
1answer
1k views

Why do libraries need hand-vectorized code instead of compiler auto vectorization

C++ eigen library does vectorization for different architecture, like SSE, NEON etc. In their documentation they mentioned that, Eigen vectorization is not compiler dependent. But most modern ...
2
votes
3answers
462 views

State of the art in parallel data structures [closed]

I'm currently evaluating how I could implement several algorithms on a parallel computer with a large number of nodes, each also equipped with a powerful GPU. It turns out that for many algorithms, it ...
1
vote
2answers
872 views

GSA Search Algorithm in C++

Is there any version of GSA (Gravitational Search Algorithm)[1] implemented with C++ or even C#? What I found was implemented using MATLAB which is not good for me. [1] Rashedi, Esmat, Hossein ...
0
votes
1answer
400 views

Three body problem in C++

I am in a begginers programming course and we got a little project. I chose to simulate the three body problem using the Euler method. Even though the system is chaotic there are some special cases ...
0
votes
1answer
2k views

Equation of motion by RK4 method

I would like to sole the spring mass equation of the form: $M\ddot{Y}+B\dot{Y}+KY = F_y(t)$, where $M :$ mass, $B :$ Damping, $K : $ stiffness, $F_y :$ external force and $Y :$ displacement in ...
5
votes
2answers
10k views

C++ libraries for Fast Fourier Transform in high precision

I am looking for a C++ library for Fast Fourier Transform (FFT) in high precision (e.g., using high precision real data types similar to mpfr_t in MPFR or ...
2
votes
1answer
753 views

Complex Numerical Integration using GSL

I want to program an integration routine in C++ using the GSL library but for complex functions. How should I split my integrand to apply the gsl_integration_qag function on it. Just integrate the ...
1
vote
3answers
996 views

Which C++ Multi-objective Optimization libraries allows the addition of custom problems and custom algorithms?

I'm working on a custom discrete and constrained multi-objective optimization problem and I'd like to know which libraries or platforms that implement algorithms like ...
1
vote
1answer
236 views

Efficiently rotate vector in 2D (and 3D)

I need to efficiently rotate a 2D (and 3D) vector in a CUDA kernel. I was thinking about generating random unitary rotation matrices. I don't need to know the angle, it just has to be randomly ...
3
votes
2answers
1k views

Stabilizing a 3x3 real symmetric matrix eigenvalue calculation

I have many 3x3 real symmetric matrices for which I need to determine the eigenvalues. Wikipedia gives a nice non-iterative algorithm for this case, which I have translated into C++: ...
0
votes
2answers
137 views

Adaptive numerical integration of a univariate vector integrand

Background & Problem formulation I'm trying to write a simple program in C++ that performs adaptive numerical integration of vector valued integrands (in one variable), i.e. $$\int_a^b \bar{f}(...
-2
votes
1answer
2k views

How to implement Lagrangian/Polynomial Interpolation for my C++ Code?

I have a working C++ function: ...
1
vote
2answers
449 views

How does MPI differentiate between two computers?

I am starting to dabble in MPI. I am fairly new to this area and I am currently reading the MPI standard. I would like to write my first MPI program, a simple hello world program, on a cluster that ...
0
votes
1answer
2k views

Inversion of a matrix using c++ library armadillo or eigen [closed]

I'm trying to find inverse of a matrix using c++ library armadillo or eigen. But first row of the matrix is wrong, please note that other elements are correct. I'm unable to understand what mistake I ...
3
votes
2answers
496 views

I am searching for a C++ code implementing the complex polygamma function

I googled about some code on the complex polygamma function especially C++ code, but can't find anything. Does anyone know where to find such code? The complex digamma function does exist but not the ...
0
votes
1answer
90 views

$LU$ factorization routine to solve system $Lv = f$ and $Uv = f$

I implemented an $LU$ factorization algorithm on c++ for a $n$ by $n$ matrix $A$, and I wanted to now write a routine that solves the systems $Lv = f$ and $Uv = f$. How would you recommend writing ...
-1
votes
2answers
219 views

$LU$ factorization

Our task is to implement a factorization routine that given A in a suitably efficient data structure returns the factors $L$ and $U$ where $L$ is unit lower triangular and $U$ is upper triangular. In ...