Most Popular

1500 questions
12
votes
2 answers

Danger of complex arithmetic in scientific computing

The complex inner product $\langle u,v\rangle$ has two different definitions decided by conventions: $\bar{u}^Tv$ or $u^T\bar{v}$. In BLAS, I found the routines cdotu, zdotu, and cdotc, zdotc. The former two routines actually compute $u^Tv$ (a fake…
Hui Zhang
  • 1,319
  • 7
  • 16
12
votes
4 answers

Finding the square root of a Laplacian matrix

Suppose the following matrix $A$ is given $$ \left[\begin{array}{ccc} 0.500 & -0.333 & -0.167\\ -0.500 & 0.667 & -0.167\\ -0.500 & -0.333 & 0.833\end{array}\right]$$ with its transpose $A^T$. The product $A^TA=G$ yields $$…
usero
  • 1,663
  • 2
  • 14
  • 27
12
votes
5 answers

Dynamically ending ODE integration in SciPy

I have a light ray moving through space-time, i.e. a curve in $\mathbb{R}^4$, parametrized by some variable λ. The exact trajectory, i.e. the coordinate functions $x^μ(λ)$ of the curve are given by some ODE $\frac{dx^μ}{dλ} = f(λ)$. Now, I've got…
balu
  • 243
  • 1
  • 2
  • 8
12
votes
3 answers

How to write integration tests for numeric simulation software?

Just to be more precise, I'll put a worthy example of my typical use case. Let's say I'm developing a FEM software that produces several temporal solutions and inserts them in an HDF5 file, along with a bunch of correlated data. If I use a naive…
12
votes
2 answers

Octave: calculate distance between two matrices of vectors

Suppose I have two matrices Nx2, Mx2 representing N, M 2d vectors respectively. Is there a simple and good way to calculate distances between each vector pair (n, m)? The easy but inefficient way is of course: d = zeros(N, M); for i = 1:N, for j =…
Kelley van Evert
  • 221
  • 1
  • 2
  • 3
12
votes
3 answers

Testing if a matrix is positive semi-definite

I have a list ${\cal L}$ of symmetric matrices that I need to check for positive semi-definiteness (i.e their eigenvalues are non-negative.) The comment above implies that one could do it by computing the respective eigenvalues and checking if they…
Jernej
  • 458
  • 3
  • 11
12
votes
3 answers

Efficient tridiagonal matrix algorithm implementation

I am solving a physical problem using implicit numerical scheme. This leads me to solving a linear equation with tridiagonal matrix. I've coded this algorithm from Wikipedia. I wonder if there is an efficient library which allows to solve this type…
gmk
  • 455
  • 4
  • 8
12
votes
5 answers

Mathematical optimization software free/openSource

I want to write mathematical optimization software. At university, they taught me how to use AMPL+CPLEX/SCIP/MINOS/Couenne etc.. and that was good enough. But I cannot afford the cost of AMPL for my personal use and I don't want to have any…
HAL9000
  • 257
  • 2
  • 8
12
votes
5 answers

Numerical derivative and finite difference coefficients: any update of the Fornberg method?

When one want to compute numerical derivatives, the method presented by Bengt Fornberg here (and reported here) is very convenient (both precise and simple to implement). As the original paper date from 1988, I would like to know whether there is a…
Vincent
  • 343
  • 1
  • 8
12
votes
3 answers

Correct statistics for reporting speedup results

Say I have slow and fast versions of some code, and want to report a speedup number comparing the two. I run the slow version $n$ times and the fast version $m$ times, producing times $(s_1, \ldots, s_n)$ and $(f_1, \ldots, f_m)$. The simplest way…
Geoffrey Irving
  • 3,969
  • 18
  • 41
12
votes
2 answers

numerical integration in many variables

Let $\vec{x} = (x_1, x_2, \dots, x_n) \in [0,1]^n$ and $f(\vec{x}): [0,1]^n \to \mathbb{C}$ be a function in these variables. Is there a recursive scheme for this iterated integral? $$\int_{[0,1]^n} \prod dx_i \;f(\vec{x}) $$ If $n = 10$ and I…
john mangual
  • 947
  • 3
  • 9
  • 19
11
votes
2 answers

How to set double precision values in Fortran

Recently, I've encountered a bizarre problem with FORTRAN95. I initialized variables X and Y as follows: X=1.0 Y=0.1 Later I add them together and print the result: 1.10000000149012 After examining the variables, it seems as though 0.1 is not…
Paul
  • 12,045
  • 7
  • 56
  • 129
11
votes
6 answers

Is there a reference-level implementation of BLAS in C/C++?

The netlib BLAS implementation is an excellent reference, being mostly un-optimized and well documented (e.g. zgemm). However, it is in Fortran 77, making it somewhat inaccessible to those with a more modern programming education. Is there a…
Max Hutchinson
  • 3,051
  • 16
  • 29
11
votes
2 answers

Solid mechanics with finite differences: How to handle "corner nodes"?

I have a question concerning coding boundary conditions for solid mechanics (linear elasticity). In the special case I have to use finite differences (3D). I am very new to this topic, so perhaps some of the following questions may be very basic. To…
Felix Schwab
  • 111
  • 3
11
votes
1 answer

Why SVD is talk about less than QR and LU for sparse matrix?

For example the C++ sparse matrix libraries I used -- Eigen and SuiteSparse, they seem not to have any SVD funcitionality for sparse matrix. So just curious, is SVD more difficult than QR/LU for sparse matrix?
user5302
  • 211
  • 1
  • 4