Most Popular

1500 questions
7
votes
1 answer

computing turbulent energy spectrum from isotropic turbulence flow field in a box

I have my 3 dimensional velocity flow-field u, v and w at a given instant of time from DNS using pseudo-spectral method. I need to calculate the energy spectrum ( in Fourier space ) as a function of magnitude of wave-number, i.e. $E(k)$ as a…
user4557934
  • 105
  • 1
  • 5
7
votes
1 answer

How do I vectorize this 4-D matrix operation in Matlab?

I need to do a large number of matrix operations in Matlab, but one of the matrices is 4-D and my normal instincts for correct vectorization are failing me. Right now I'm using a loop. Maybe somebody can fix my dumb brain? for k=1:kNum for…
Colin K
  • 285
  • 1
  • 9
7
votes
4 answers

cost function: why use power of two ? abs(x - xhat) / x better?

Why do people use the classical least squares approach so often ? If I use the absolute value instead of the power, I immediately know how far away the solution is: $$ res = \frac{abs(x - x_{model})}{x}$$ What is the benefit of squaring ?
Moritz
  • 343
  • 1
  • 13
7
votes
1 answer

What are some ideas to preprocess / precondition the following linear system?

Let $A\in \mathbb{R}^{n\times n}$ symmetric and positive semidefinite, and $\omega\in \mathbb{R}\setminus\{0\}$. I am interested in solving the following linear system for a range of values of $\omega$: $$((A-\omega^2 I)(A-\omega^2 I)+\omega^2 I)x…
fred
  • 1,000
  • 6
  • 12
7
votes
2 answers

Linear interpolation in Fortran

Is there a Fortran subroutine which performs linear interpolation in one-dimenional data? I need something similar to MATLAB function interp1.
kyperros
  • 139
  • 1
  • 1
  • 5
7
votes
2 answers

Finite element library in fortran

I want to create a finite element code in fortran. There are many libraries out there on internet. Can someone suggest me a good finite element library in fortran? I am looking for Ease of use (using fortran language specifically) Well…
343_458
  • 171
  • 2
7
votes
4 answers

Fortran code for Ewald summation

I am trying to write a code to calculate the potential and forces, for the same using ewald summation.For this purpose, the formula for potential and force I have used is : $$ U = U^{(r)} + U^{(k)} + U^{(bc)} + U^{self} $$ where the k-space…
user35952
  • 201
  • 2
  • 6
7
votes
1 answer

Generalized least squares gradient of a vector field

For computing the gradient of a scalar field, one can use the weighted least squares method as described in the paper Revisiting the Least-squares Procedure for Gradient Reconstruction on Unstructured Meshes by Dimitri Mavriplis (pg. 23). My…
tmaric
  • 1,916
  • 1
  • 11
  • 22
7
votes
1 answer

Problems Implementing the Remez Algorithm

So first off: *** This code is not being used in production software. It is a personal project of mine, trying to understand approximation theory and advanced curve fitting. In other words, I'm trying to understand how it works, not trying to…
7
votes
3 answers

Does the Lanczos starting vector have to be random?

In all descriptions of the Lanczos vector, it's said that the starting vector is random. But let's say I'm only interested in the eigenvector associated with the lowest eigenvalue (as is the case when using Lanczos to find the ground-state of a…
Lagerbaer
  • 487
  • 4
  • 9
7
votes
2 answers

Classification of observations depending on its trajectory

I'm afraid the title is terrible, but I don't know how to summarize this problem in a few words. Using an instrument, we are monitoring the trajectory of several objects during a period of time. We take a lot of measurements of the position of the…
siritinga
  • 203
  • 1
  • 6
7
votes
1 answer

Convex Optimization problem with sum of absolute value constraints

How to solve the optimization problem written below? $$\begin{align} &\operatorname{argmax}\limits_{a}\; a^T b - \frac{1}{2} a^T X a\\ &\text{subject to } \sum_i |a_i|=4,\; \sum_i a_i = 0 \end{align}$$ where $a$, $b$ are $n$-vectors and $X$ is a…
Bill Z
  • 73
  • 1
  • 4
7
votes
1 answer

energy drift in molecular dynamics

I hope the following question will not be perceived as to vague. I am trying to ask the question directly, without going into too much information regarding my code. I am currently developing a molecular dynamics code for a custom application, as…
user3225087
  • 291
  • 2
  • 6
7
votes
1 answer

What is the numerical difference between abs(z)^2 and z x z*, where z is a complex number

I am doing research in electromagnetics (a branch of physics) and I deal with complex numbers in my computing tasks (I use MATLAB). Let's say $z$ is a complex number. To calculate the square of the magnitude of $z$, which is $|z|^2$, I can use two…
aesrth
  • 73
  • 4
7
votes
1 answer

How to avoid overflow error in program that computes product of two numbers, such that when one is big enough to cause overflow, other is $0$?

Let us say that I have a function like so: def f(x): return g(x)*h(x) Now, g(x) and h(x) are such that when g(x) produces a result large enough to cause overflow errors, h(x) produces a number that is approximately zero. So, the result provided…
bzm3r
  • 669
  • 5
  • 21