Questions tagged [efficiency]
The efficiency tag has no usage guidance.
68 questions
0
votes
0
answers
63
views
Are there any efficient numerical methods to solve the recurrence relation of a function?
First, the recurrence relation is:
$$\pi_{k+1}(\omega)=(\omega-\alpha_k)\pi_{k}(\omega)-\beta_k\pi_{k-1}(\omega),$$
where
$$\alpha_k=\frac{\int_0^\Lambda\omega\pi_{k}^2(\omega)h^2(\omega)\text{d}\...
0
votes
0
answers
36
views
Fastest way to calculate the eigenvector with the largest eigenvalue for a 3*3 positive-definite matrix [duplicate]
As stated in the title: I have a 3 by 3 positive-definite matrix $M$. What I need is the eigenvector corresponding to the largest eigenvalue, since I am calculating the solution to maximize the value ...
2
votes
1
answer
453
views
How to leverage the GPU for parallel 3-body problem computations
I have a 3-body simulation which must run millions of times.
As far as I know, the GPU shines when it gets to preform simple operations on huge matrices/arrays. Currently I'm debugging and running my ...
5
votes
0
answers
152
views
Single precision vs double precision conjugate gradients
I tested my conjugate gradients implementation with float and double precision and contrary to my guess the double code was twice faster than the single precision code. The reason is that I need many ...
2
votes
0
answers
114
views
Efficient heat diffusion implementation with varying coefficients
I have the following heat diffusion equation:
\begin{alignat}{3}
\partial_t u(t, \vec{x}) &= g(\vec{x})\Delta u(t,\vec{x}), &\quad& \vec{x} \in\Omega, \, t\in(0,\infty],\\
\partial_n u(t,\...
2
votes
1
answer
93
views
Best approach to simulating dynamics on networks
I have been recently getting into the field of various processes on networks. For example, stochastic processes like percolation, Ising models, various statistical-physics models; or deterministic ...
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 ...
5
votes
0
answers
109
views
Dense factorization specialized for RBF-FD method
In RBF-FD methods (see Fornberg & Flyer. A Primer on Radial Basis Functions with Application to the Geosciences. SIAM, 2015. Chapter 5.), the finite-difference stencil coefficients for a set of ...
1
vote
1
answer
146
views
Computing pairwise distances in a grid efficiently
I have a spline-based model where I have a set of control points in 3D space. I want to compute pairwise distances between every point on a regular 3D grid and these control points. Is there an ...
1
vote
1
answer
168
views
Efficiency of developing PDE solvers using sparse matrices versus loops
I am new to solving PDEs, but have been looking at different implementations of finite difference and finite volume schemes. One thing I have noticed in different implementations is that some ...
4
votes
1
answer
724
views
Incomplete Cholesky preconditioner for CG efficiency
I am currently solving the harmonic equation using a P1 FEM discretisation. The resulting matrix $A$ is SPD and fairly sparse so I use a preconditioned conjugate gradients (CG) solver to find a ...
-1
votes
1
answer
98
views
How asymmetric encryption is done very fast [closed]
In any asymmetric encryption specifications, there is a step where we need to calculate data ^ public_key mod e to get ...
2
votes
1
answer
410
views
Solving stiff ODEs: Dealing with Jacobian terms which take too long to compute with finite differences
I have a system of PDEs describing atmospheric chemistry and transport. I use finite-differences to make my system of PDEs into a system of ~10,000 ODEs. I then integrate the ODEs forward in time with ...
3
votes
1
answer
540
views
How can I extract the banded or block diagonal part of a sparse matrix in MATLAB?
Given a large sparse (square) matrix in MATLAB, how can I extract the banded or the block-diagonal parts (of fixed size) of it efficiently?
These are useful operations when prototyping and testing ...
2
votes
1
answer
303
views
Methods to improve the efficiency and the memory requirement of LU factorization for complex symmetric system matrix
I want to solve a linear set of equations (Ax=b) using LU decomposition. My "A" matrix is a complex matrix which is ...
1
vote
1
answer
705
views
Effecient method for iterating over sparse dataset
Apologies if this isn't the appropriate forum for this question.
I have a set of elements that I need to iterate over as part of a modeling workflow. The elements exists over a set of dimensions (i, ...
0
votes
0
answers
69
views
How can I optimize that loop?
I need to populate a matrix $A_{kl}$, where
$$ k = (m-1)J+n$$
$$ l = (p-1)J+q$$
And
$$m,p = 1, 2, ..., I$$
$$n,q = 1, 2, ..., J$$
Its components are (mnpq). For ...
5
votes
1
answer
868
views
Fastest way to calculate the $2$-norm (or an upper bound for the $2$-norm) of the inverse of a matrix $A\in \mathbb{C}^{N\times N}$
I have a matrix $A\in \mathbb{C}^{N\times N}$ and I need to calculate $||A^{-1}||_{2}$ efficiently. Can it be done without having to evaluate the inverse explicitly?
In general, I am looking for ...
0
votes
0
answers
88
views
Reducing run time of a numerical calculation using a mex file in Matlab
I wrote a Matlab code that involves doing a numeric calculation (relaxation), but it is quite slow. I learned of the possibility of using a mex file to run a C code and integrate it into Matlab, so I ...
12
votes
2
answers
3k
views
What is the most efficient way to write 'for' loops in Matlab?
I have read that if, for example, I have a double for loop that runs over the indexes of a matrix, then putting the column running index in the outer loop is more ...
4
votes
2
answers
113
views
How to efficiently invert $K \otimes M+I_T\otimes \Sigma$?
I'm looking for a way to efficiently invert $$K \otimes M+I_T\otimes \Sigma$$ where the inverses for $M,K$ exist. $I_T$ is the identity matrix of dimension $T$, and $\Sigma$ is a diagonal matrix, with ...
3
votes
1
answer
141
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, ...
2
votes
0
answers
265
views
Why is the method of im2col with GEMM is more efficient than the method of direction implementation with SIMD in CNN
The convolutional layers are most computationally intense parts of Convolutional neural networks (CNNs).Currently the common approach to impement convolutional layers is to expand the image into a ...
8
votes
1
answer
751
views
Accurate and efficient computation of the inverse Langevin function
The Langevin function $\mathcal{L}(x) = \mathrm{coth}(x) - \frac{1}{x}$ occurs in computations related to elastomers and paramagnetic materials. It is easily computed accurately and with high ...
1
vote
0
answers
103
views
B-splines least squares with equality constraints
Can someone recommend the best way to solve a least squares fitting problem with B-splines, with additional equality constraints? I want to solve:
$$
\min_x || b - A x ||^2, \textrm{subject to: } C x =...
3
votes
1
answer
127
views
Solve $A^{-1} b$ when one column is replaced
Given square matrix $A_0$, vector $b$, vector $A_0^{-1}b$ and matrices $A_1, A_2, \dots, A_k$, in which each $A_i$ is generated from $A_{i-1}$ by replacing one single column, I would like to find an ...
4
votes
2
answers
193
views
MATLAB Matrix Multiply Efficiency
I am using MATLAB to prototype a few matrix multiply techniques and compare efficiency. Eventually, I will move the prototype codes to C. It is for a homework assignment where we need to write an ...
0
votes
1
answer
139
views
How to improve the efficiency when I need to exhaustively pairwise millions of list in Python?
I have a m*n matrix (m>1000000, n>50000). What I want to do now is to pairwise every two rows of the matrix and do some further computation (e.g computing common elements of two rows, or reveal ...
5
votes
1
answer
1k
views
Half precision in Fortran
To improve the time efficiency of my code, I'd like to test a lower precision for real number, using e.g. half precision (2 bytes).
However, I'm not sure if I can do that in Fortran.
After playing ...
0
votes
2
answers
321
views
Benefits of matrix multiply over inversion
I have two variations of an iterative algorithm. All the steps of both algorithms are equivalent except one. In this step:
Algorithm 1 needs to compute the matrix $ABA^T$ for matrices $A \in \mathbb{...
1
vote
1
answer
490
views
Why does PETSc matrix memory allocation improve performance so much?
Context
In the Portable, Extensible Toolkit for Scientific Computing (PETSc), the user often creates matrices and vectors. These objects are then used as input for other routines like iterative ...
1
vote
1
answer
909
views
Plotting the same function multiple times on the same set of axes but with different parameters [Python]
I am currently trying to plot a function which describes linear perturbation growth in cosmology for different world models. I would like to be able to have all the curves on the same set of axes, but ...
1
vote
1
answer
118
views
Declare variable to substitute one calculate only once
Frame of the question
I am currently editing an add-on module to an ocean/circulation model, which is written in Fortran. The code of the main model is quite optimized with respect to short run time (...
7
votes
3
answers
1k
views
Is there any computational efficiency to global variables?
I'm wondering specifically in regard to a recursive function such as massive a game tree. I can't specifically say how big yet, but definitely pushing the limits of a given processor or processor ...
1
vote
0
answers
67
views
Stiff ODEs coupled with PDEs (computational efficiency)
I am simulating in COMSOL a system of 3 coupled PDEs (parabolic & elliptic) along with 10 stiff ODEs. In order to have the system working, I am downsizing the time step size too much to achieve ...
2
votes
1
answer
273
views
Difference between Brent's and Alefeld-Potra-Shi for root finding
I need to find the (unique) root of a nonlinear function $f(x)$, $x \in \mathbb{R}$.
For the record, $f(x)$ is the CDF of a probability density minus a constant $0 < p < 1$ (I am inverting the ...
5
votes
4
answers
3k
views
What is "good" parallel scaling?
I often hear the phrase "good" or "bad" parallel scaling/efficiency.
What exactly do people mean when they say that?
For example, let $p = 1,\ldots 16$ be the number of processing elements, and A and ...
4
votes
1
answer
157
views
Efficient way to generate a list of possible matrices (all integer components) with a determinant $V$
I have an interesting problem from my research that I have been struggling to solve. One part of the problem involves generating all possible matrices, where each set contains three integer vectors, ...
2
votes
1
answer
184
views
Parallel efficiency
I would like to calculate efficiency of parallel alghoritm, using the number of computations instead of time computations.
In materials from my studies I have a formula like below:
$$ \eta(n,p) = \...
1
vote
1
answer
84
views
Calculate proportions of exponentially weighted factors avoiding underflow problem
I am trying to implement in Python this ratio:
$\frac{w_t(i)}{\sum w_t(j)}$ where $w_t(i) = w_{t-1}(i)\cdot\exp{(-x_{t}(i))}$, i.e. the weights are exponentially decreasing without running into ...
0
votes
1
answer
695
views
Power series regression linear fit in VBA excel
I wrote a program that calculates the best fit in VBA excel for the following model
$$
y_k=c_1x_k+c_0+c_{-1}(x_k)^{-1}
$$
solving for the best fit parameters $c_1$, $c_0$, and $c_{-1}$. However I ...
2
votes
1
answer
195
views
Performance based on the Roofline model
To somewhat follow up on the question asked here, I have been told that the Roofline model is one way of assessing the performance of any scientific code. Basically I compute the Arithmetic Intensity (...
7
votes
2
answers
369
views
Comparing various implementations/software packages for large-scale finite element simulations
I currently use FEniCS and Deal.II to solve various FEM problems. I am also writing my own implementation of these problems by directly implementing the data structures, routines, and solvers within ...
0
votes
0
answers
824
views
Efficient Implementation of the Log Sum Exp Log trick for Preventing Underflow erros
So I'm constructing a Gibbs sampler for a moderately sized graphical model, and I started encountering underflow errors (the computed relative frequencies were all very small). To get around this, I'...
0
votes
2
answers
208
views
most efficient way to calculate eigen states of a 2D or 3D potential (Matlab)
I know of several ways to calculated the eigen states of 1D potentials (i.e. DVR, Crank–Nicolson, etc). However I wonder what is the most efficient way to do the same for a N-Dimensional potential? ...
0
votes
3
answers
1k
views
Determining efficiency in MFLOPS/s of a parallel program
I am running some scientific (parallel) code and would like to obtain some performance profiling measurements. I want to obtain the "efficiency" of the code in terms of flops/s over theoretical (peak) ...
1
vote
2
answers
91
views
Help on writing sofware: general guidelines, in particular separation of computation and visualization
Although I already did some work in the intersection of theory and simulation I'm still very new to this field and I need some guidance. If anybody can give some recommendations for introductory ...
1
vote
1
answer
166
views
Comparison of the time efficiency of an optimization problem formulated as a Network Flow model and Mixed Integer Programming
In combinatorial optimization, there are many problems that can be formulated as either Network Flow model or Mixed Integer Programming (MIP), e.g. supply chains, transportation, and graph-base ...
10
votes
3
answers
874
views
Is there a complexity between $O(n)$ and $O(n \log n)$ [closed]
Is there a complexity degree that is bigger than $O(n)$ and smaller than $O(n \log n)$?
1
vote
0
answers
93
views
What's the most efficient way to calculate the Wiger quasiprobability distribution?
I want to calculate the Wigner quasiprobability distribution function of a particular wavefunction. The definition suggests a few straightforward ways of calculating it, but I was wondering if there's ...