Skip to main content

Questions tagged [numpy]

NumPy is the fundamental package for scientific computing with Python.

4 votes
1 answer
102 views

How can I efficiently find an anti-symmetric generator of a special orthogonal matrix?

Given a special orthogonal matrix $O$ (i.e: $OO^T = 1$ and $\det(O) = 1$), I am trying to efficiently find a matrix $X$ such that $O = e^X$ and $X = -X^T$ using Python (NumPy & SciPy). One obvious ...
Solarflare0's user avatar
1 vote
0 answers
52 views

Converting an expression into an einsum

I have the following expression that I need to calculate for some matrices: $$ \sum_{k}c_{t,i,k}\sigma^\prime\left(w_tX_t+b_t\right)_k\left(\sum_\ell w_{t,k,\ell}\tilde{X}_t^{w,\ell}\right) $$ I could,...
Gummy bears's user avatar
0 votes
0 answers
87 views

First and second component of fft for circle approximation to periodic curve

I wanted to understand how the fast fourier transform work in numpy and for this I tried apply it on $n$ points of an ellipse $t_k = \frac{2\pi}{n-1}k$ with $k=1...n$ $$f_k = f(t_k) = (acos(t_k), bsin(...
edamondo's user avatar
  • 173
0 votes
1 answer
107 views

Solving a polynomial with NumPy

I'm trying to do something that I thought would be very straightforward but somehow I'm struggling. I have a time series and I want to extrapolate it, assuming a linear trend, to forecast when will it ...
user avatar
11 votes
1 answer
343 views

Is it possible to express an arbitrary tensor contraction in terms of BLAS routines?

I noticed that libraries like numpy and pytorch are able to perform arbitrary tensor contractions at speeds similar to comparably sized matrix multiplications. This leads me to believe that underneath ...
ilya's user avatar
  • 121
5 votes
2 answers
2k views

What algorithm(s) do numpy and scipy use to calculate matrix inverses?

I am solving differential equations that require inverting dense square matrices, and I wanted to know what algorithm(s) do numpy and scipy use to calculate matrix inverses?
kamy rez's user avatar
1 vote
1 answer
121 views

Improvement to naive gradient descent implementation for the Thomson problem

I have a Python program (available on github) that uses naive gradient descent to find approximate solutions to the Thomson Problem. It works surprisingly well, but I've been wondering if there's a ...
Martin C.'s user avatar
  • 229
3 votes
0 answers
258 views

Helmholtz decomposition of a vector field in Fourier space with Python

I have a 3D vector field and I want to extract its divergence-free part (also called transverse component), using the Helmholtz decomposition. In principle, this can be done in the Fourier space, as ...
Wil's user avatar
  • 31
1 vote
1 answer
705 views

Float equality tolerance for single and half precision

Suppose the metric is abs(a-b) <= rtol * max(abs(a), abs(b)) i.e. math.isclose with ...
OverLordGoldDragon's user avatar
0 votes
1 answer
78 views

Compute a series of matrix multiplications and matrix norms quickly in Python

I need to compute a series of matrix multiplications involving 3x3 matrices and a series of matrix norms also involving 3x3 matrices and I wonder how I can set these computations up with numpy such ...
Mantabit's user avatar
  • 121
0 votes
0 answers
106 views

About Convolution Theorem

...
Deepak Kallepalli's user avatar
3 votes
1 answer
890 views

Time and memory required to diagonalize a 18000 by 18000 matrix using numpy in python

Can someone give an estimate of the Time and memory required to diagonalize a 20000 by 20000 complex hermitian matrix using numpy in python ?
Snpr_Physics's user avatar
1 vote
0 answers
130 views

Convolution/weighted average of two arrays in Python

I have an equation that I need to calculate numerically, but I am having doubts about my approach. I am cross-posting this question from Stack Exchange, because I am not getting any responses. This is ...
theWrongAlice's user avatar
0 votes
0 answers
58 views

Eigenvalues of same operator expressed in two different orthonormal basis are coming out different

I have an operator $H$. I express $H$ as a matrix in the orthonormalized $\{ |e > \}$ basis. Then I diagonalize it to obtain eigenvalues, let's say for example $H$ is $6 \times 6$ and the ...
Snpr_Physics's user avatar
1 vote
1 answer
740 views

Beta function and integral value

I have two values $a$ and $b$ where $a \ge 0$ and $b \ge 0$ and I have to calculate the formula below. $$ \frac{1}{2}\int_0^1\text{abs}\left[\left( \frac{p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)}}{\...
Bhavana Reddy's user avatar

15 30 50 per page
1
2 3 4 5
12