Questions tagged [algorithms]
A description of the specific steps needed to solve a particular problem in an unambiguous way, expressed in an abstract form.
514
questions
3
votes
1answer
34 views
Algorithm to merge two polygons (using connectivities)?
I am struggling with implementing an algorithm that does one simple thing:
Consider two polygons (one can just draw any two polygons and number their vertices), whose connectivities in a node list are:...
5
votes
2answers
103 views
Exponent log to compute reciprocal power?
A MATLAB library seems to overcomplicate a computation:
exp( (log(a) - log(b))/b )
which is mathematically equivalent (assuming real & positive ...
3
votes
1answer
55 views
Understand the need for Welford's online algorithm
I am puzzled by the Wikipedia entry discussing many online algorithms for computing the sample variance, including the Welford's online algorithm.
In particular, the sample variance $s_n^2$ can be ...
0
votes
0answers
26 views
Largest triangle that contains a point
Given the location of $n$ points on a 2D plane ($P_1, P_2, \ldots, P_n$); and the location of a special point $X$.
Find three points $P_i,P_j,P_k$ ($i \neq j \neq k$) such that point $X$ is inside the ...
0
votes
0answers
27 views
Parameter sampling from a 3D isosurface in R
Before we start, a small disclaimer: I am not a computer scientist, and the field of isosurfaces is new to me, so hopefully, the question is phrased clearly:) Otherwise, let me know, and I will (try ...
1
vote
1answer
58 views
Transition from 2D to 3D finite element code, what are the inevitable modifications to be implemented?
Imagine we have a simple 2D FEM solver (we are dealing with solid mechanics) and we would like to develop it to a 3D FEM solver (let's say for the same solid mechanics problem) in this case what are ...
0
votes
0answers
39 views
Storing and retrieving two-dimensional and three-dimensional data
I work on computational geometry.
A huge number of two-dimensional and three-dimensional data are found in my project. Coordinates of polygon and polyhedrons vertices consisted of two-dimensional and ...
-2
votes
0answers
31 views
C++ code Thomas algorithm for solving a pentadiagonal Ax=b
I am looking to solve Ax=b for x where A is pentadiagonal square matrix (elements on the upper and lower diagonals can however equal to zero) and x, b two vectors of the same size.
I used the code ...
3
votes
3answers
112 views
How to determine if 2 rays intersect?
We are given the 2D coordinates of 2 points: the first point is where the ray starts and it goes through the second point. We are given another ray in the same way. How do we determine if they have a ...
0
votes
0answers
49 views
Finding block structure of a tensor
Are there any well-known algorithms for partitioning a dense tensor into block-sparse form?
In other words, I need to find a set of non-overlapping blocks that contain all non-zero entries of the ...
4
votes
1answer
163 views
Time Reversibility of Velocity Verlet Algorithm
I'm very new to computational Physics and am finding conflicting statements on whether the velocity Verlet algorithm, defined as:
$\begin{align}
x_{n+1} &= x_n + v_n \Delta t + \frac{1}{2} a_n \...
1
vote
1answer
48 views
Asymptotic complexity of fixed-rank SVD
According to the Wikipedia article on Singular Value Decomposition, the asymptotic complexity of computing the SVD of an arbitrary mĆn matrix M with m>n by the popular Householder QR methods is O(...
2
votes
1answer
54 views
How to select initial time step in adaptive time step ODE solver (TR-BDF2)
The Problem
I am currently reconstructing a TR-BDF2 scheme which contains the following two stages:
\begin{align}
y_{n+\gamma} & = y_n + \gamma \frac{h}{2}\left( f_n + f_{n+\gamma} \right) \...
4
votes
1answer
85 views
Which algorithms(paper) should be reproduced by a student to enter the field of computational fluid-structure interaction?
We'd better not to reinvent the wheel. But without some programming, one can hardly understand computational fluid-structure interaction. And I would like to know which papers or algorithms should a ...
1
vote
0answers
28 views
Bipartite Euclidean Matching simple to implement approximate algorithm
I am looking for a simple to implement algorithm for the bipartite euclidean matching problem (or an implementation of any practical algorithm). I am aware of Agarwal's paper, but I would like to ...
1
vote
1answer
61 views
An efficient algorithm to find Nearest Neighbours
So imagine I have a $m$ vectors each of dimension $d$. Lets call them, $\vec x_{i}$, with $i = 1, 2, 3, 4, 5, \dots, m$. Now the idea is to find the neighbours of $\vec x_{i}$ (calling them $\vec x_{j}...
2
votes
3answers
237 views
On the reordering of sparse matrices
I have been reading on different techniques used to reorder sparse matrices to achieve better performance, the most popular being the Cuthill-McKee or Reverse Cuthill-McKee algorithm. Most of those ...
2
votes
0answers
78 views
Computing Singular Value Decomposition of small ($4\times 4$) matrices
I need to compute the Singular Value Decomposition (SVD) of many $4 \times 4$ matrices. I'm looking for SVD algorithms specialized for small matrices. I've read that the ...
6
votes
1answer
573 views
Cheap recalculation of eigenvalues and eigenvectors for a low-rank update of the matrix
Suppose I have a correlation matrix, $A$, and I already have the eigenvalues and eigenvectors of this matrix.
For a given vector, $\mathbf{\mathit{v}}$, I want to calculate the eigenvalues and ...
0
votes
0answers
32 views
Producing Voronoi diagram in three dimensional
A Voronoi diagram is a kind of tesselation that divided the medium into polygons in 2D and polyhedrons in 3D.
Although there are many algorithms to construct a Voronoi diagram, some of them are faster ...
3
votes
3answers
116 views
What are some algorithms to calculate the width of an arbitrary polygon when a bounding box approximation is inaccurate
What are some alternative algorithms to creating a bounding box for finding the max width of a concave, simple winding polygon, like the one in the below image? I prefer solutions that are more ...
0
votes
0answers
69 views
Derivative-free ill-conditioned non-linear least squares
I am looking for a package which can solve (non-linear) least squares problems without the use of derivatives (because of an expensive model), but which also deals with ill-conditioning well (such as ...
0
votes
0answers
67 views
Explanation of Givens rotation in Jacobi Rotation SVD
I'm trying to implement Singular Value Decomposition (homework of sorts) via the Jacobi Rotation method (more info here, pages 11 and 12).
I am stuck at the bullet saying (sorry for the picture, but I'...
3
votes
1answer
42 views
How do you construct a self-similar binary structured-tree?
Please excuse me if this question somehow looks trivial or not really interesting, but I recently have a hard time to convince someone else that my algorithm for constructing a self-similar binary ...
0
votes
0answers
20 views
Hawkes Process : recursive formula for : $R'_{m,n} (k) = \sum_{ \{i : t_i^n < t_k^m \} } (t_k^m - t_i^n) \exp ( - \beta_{m,n} ( t_k^m - t_i^n ) ) $
Following the advice of a fellow mathematician, I am asking my question here from (https://mathoverflow.net/questions/365554/hawkes-process-recursive-formula-for-r-m-n-k-sum-i-t-in-t)
I need to use a ...
0
votes
0answers
46 views
Surface mesh from labeled 3D points
I'm trying to figure out how to create a surface mesh from a set of labeled 3D points. The 3D object could be something like part of a cave system or asteroid where there would be parts of the surface ...
1
vote
0answers
22 views
Combining many probabilities, modifying, seeking general formula
CONTEXT
I need to combine the probability of occurrence of many thousands of events for millions of individuals (trees) in an agent-based/individual-based simulation model developed in NetLogo (agent-...
2
votes
1answer
52 views
Question regarding the energy computation of the Ising-Spin Model
In most of the Monte-Carlo-Algorithms I studied, I found, at the place where they compute the energy, always a line of code, where they divided by four.
For example, this code-snippet is taken from ...
1
vote
1answer
101 views
Machine Learning for Optimization
I have a function which takes 100+ coefficients and outputs $x$. I wish to optimise $x$.
Running the simulation 50 000 times will take around 15 minutes, however, this happens in parallel - and the ...
1
vote
0answers
51 views
Assume $AX = C$. How to determine which entry of $BX - D$ is non-negative?
Let $A,B$ be $n \times n$ matrices and $C,D$ be $n \times 1$ matrices. Moreover, all entries of $A,B,C,D$ are non-negative. Assume that there is a unique matrix $X$ that solves $AX = C$.
My goal is ...
0
votes
2answers
67 views
Best way to find biggest & smallest number in a random list?
Given a list of some length, containing random numbers.
What method would need the least amount of checks to find the largest & smallest number in the list?
My best guess is: (list_length)/2 ...
-1
votes
1answer
28 views
An almost surly fine-time game of coin toss where you win with probability $p$
Given a fair coin and a number $p\in(0,1)$. How do you design a game that finishes in a finite number of tosses with a probability of $1$? And further, with the probability $p$ you win the game.
I ...
0
votes
0answers
35 views
What constraints, if any, are there on constructible patterns in Conway's Game of Life?
Conway's Game of Life is Turing-complete.
Interesting demos of this:
A clock
Tetris
I note that Turing-completeness doesn't require that any specifically encoded state be reachable, does it? ...
1
vote
1answer
53 views
Newman algorithm yielding different result to what is given in his paper
Summary
I am trying to implement Newman's algorithm for community detection, outlined in this paper. I am testing my implementation against one of the datasets used in that paper to benchmark the ...
2
votes
2answers
103 views
Using MILP to place a set of primers along a genome
Define variables $p_i,u_i\in\{0,1\}^G$, for $i=1,\ldots,8$ and $G=30000$.
Let $v$ be a constant vector also in $\{0,1\}^G$, with approximately 25% of its entries equal to $1$ (randomly located).
Let ...
1
vote
0answers
26 views
Unable to achieve semi-linear running time in computation of continuant
I am trying to compute the continuant of a list of numbers $a_0, a_1,...,a_n$, defined by the recursion relation: $K_{n+1} = a_{n+1} K_n + K_{n-1}$ and $K_0 = 1$ (see Wikipedia).
I am trying to use ...
0
votes
0answers
37 views
Boundary conditions for triangular lattice in comsol
I am trying to simulate an infinite 2D triangular lattice in Comsol but I am confused that how should I use periodic floquet boundary conditions on the unit-cell.
A unit cell that I am using is given ...
3
votes
1answer
88 views
Can you compare integer part of two fractions without division?
Suppose we need to compare
$\left \lfloor{a / b}\right \rfloor $
and
$\left \lfloor{c / d}\right \rfloor $
.
One way would of course be to calculate $a/b$ and $c/d$ by division. Is their a faster way?
5
votes
2answers
162 views
Fast algorithm for computing the similarity between two arrays
Suppose there are two arrays (They have the same length), I want to give a quantitative description about the similarity between them. I define a formula like this, which means we can shuffle them ...
5
votes
1answer
76 views
Is there an efficient algorithm for calculation of continued fraction expansion from decimal digits?
Suppose to calculate the continued fraction expansion of $\pi$, the common-sense algorithm would be to take the decimal part, perform inversion, which will give the next term as integer part, and the ...
7
votes
1answer
135 views
Numerically stable and fast sum of last K elements in sequence
Suppose I have a long, possibly infinite, sequence $x := [x_1, x_2, ...]$, and I want to use it to compute another sequence $y:=[y_1, y_2, ...]$ where each element is the sum of the last K elements of ...
5
votes
0answers
76 views
Efficient way to find eigenvalues of complex symmetric matrix with real off-diagonal elements
My goal is to find all eigenvalues (and eigenvectors) in a given range of magnitudes of a complex symmetric matrix with real off-diagonal elements (only diagonal elements are complex). Currently I'm ...
3
votes
0answers
34 views
Alternatives to breadth-first-search in 3D grid cluster detection?
I've got a question about a good way to find the quickest algorithm for my problem:
problem:
I've got a 3D cubical grid containing voxels that are either 1 or 0. It is stored as a flattened array. If ...
2
votes
0answers
40 views
Evaluating integral $F(r_2) = \frac{1}{r_2^n} \int_0^{r_2} r_1^n f(r_1)\ \mathrm{d}r_1$ without growing instability
I have the following expression to be numerically integrated in a vector-based library (e.g. numpy, MATLAB, etc),
$$
F(r_2) = \frac{1}{r_2^n} \int_0^{r_2} r_1^n f(r_1)\ \mathrm{d}r_1,
$$
where $n$ is ...
1
vote
0answers
18 views
SHREC 2010 Descriptors
I will appreciate if I may find someone how can clarify for me the part regarding the quality of feature descriptor, shown in the figure below:
and this screenshot is from the article: SHREC
All my ...
3
votes
1answer
79 views
Evaluate 3D Shape Descriptor
I'm trying to create my own 3d shape descriptor, the idea is that how I may evaluate how much my descriptor is well and good?
What I checked is that they evaluate descriptors through shape matching, ...
3
votes
0answers
69 views
Computation of Troullier-Martins pseudowavefunctions
The computation of Troullier-Martins pseudowavefunctions has been
described in [1].
The pseudowavefunction $R^{\textrm{PP}}_l$ is defined by
$$
R^{\textrm{PP}}_l(r) =
\left\{
\begin{array}{ll}
R^{\...
10
votes
3answers
345 views
Should benchmarkings be done at all? What is the point?
I am reading a paper which compares algorithm A versus algorithm B.
It shows that algorithm A is faster than algorithm B via benchmarking that shows the CPU time.
What is the point of this? Any ...
1
vote
0answers
70 views
How to approach geographic data interpolation by distance?
let's say I have a set of geographic locations (lat, lng) resulting from a query. Those locations have some kind of internal ranking, my set is sorted by this number in a descending order.
Now I'm ...
3
votes
1answer
105 views
Calculate Transformation Matrix between two sensors
My question is if I can calculate the transformation matrix between two sensors.
Each sensor provides a $4\times 4$ matrix for every timestep recorded.
The sensors are moving and have some noise in ...