Questions tagged [numpy]

NumPy is the fundamental package for scientific computing with Python.

26 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
180 views

fastest way to compute many small dot products

I have two n-by-3 blocks contiguous in memory ("n vectors of length 3") and I'd like to compute the dot product between each of the rows as fast as possible. In numpy, using ...
5
votes
0answers
1k views

Python - calculation time derivative and laplacien by finite differences

I would like to determine a temporal derivative and a Laplacian by the finite differences method to solve the heat equation in a 1-dimensional case. My aim is to get the sources term that is why I ...
4
votes
0answers
56 views

Solving multiple linear regression in parallel

I am working on a problem where I need to solve approximately 500 Million Linear Regressions (OLS). What would be the most efficient way to do this (e.g. using GPU or a some framework that can do this ...
3
votes
0answers
56 views

Difference between wave vector and density matrix in numerical calculation of Schrödinger equation

I solved Schrödinger equation for a following tow-level time-dependent Hamiltonian numerically in two ways: ...
3
votes
0answers
94 views

Inconsistency in optimize.minimize

I am trying to fit a time-dependent curve at each time step. I do so in minimizing along $x_c$ the quadratic error between the curve and a reference solution $ 1/(1 + \exp\left(\sqrt{S}(x-x_c)\right) $...
3
votes
0answers
2k views

Efficiently creating an adjacency matrix from a lattice in numpy

I have an $n$ by $m$ numpy array representing a rectangular lattice $L$, where each site contains a one or a zero, representing two different materials. I'm modelling heat flow across this lattice. ...
3
votes
0answers
302 views

matplotlib contourplot for $\log z$ in the Complex Plane $\mathbb{C}$

I tried using Python's matplotlib on the logarithm and here is what I got, a kind of starburst pattern. Since the angle jumps between $\theta = 0$ and $\theta = 2\pi$, contour assumes there is a ...
2
votes
0answers
347 views

What algorithm do BLAS and ATLAS use for matrix multiplication?

I have searched and what I understood was that they use the naive one with several memory and cache optimizations. However, I wanted to know whether they are using the Strassen or the Coppersmith-...
2
votes
0answers
198 views

Optimizing for loops by using Einstein summations instead

I have some Python code containing a couple of for loops, which I would like to optimize by using low-level functions. My first approach is to use ...
2
votes
0answers
97 views

Is the numerical resolution of this huge sparse polynomial system tractable?

I'd like to find numerically a solution to a sparse system of 2000000 polynomial equations of degree 3 with 50000 variables and integer coefficients (or at least to decide whether or not a solution ...
1
vote
0answers
41 views

Interpolate location based on triangular sensor array

There are 3 sensors (A, B, C) on a plane, located in the corners of a (known) equilateral triangle. I want to calculate the (2D) location of an object (X) inside that triangle. One sensor returns one ...
1
vote
0answers
59 views

Help with vectorized computation where vector multiplication would need to create an additional dimension

I want to use vectorized computation (with python and numpy) to do some calculation involving bessel functions. As is often the case, I need to calculate the sums of bessel functions of (infinit) ...
1
vote
0answers
23 views

Problem with recursive implementation of Subspace Iteration method in Numpy

I am having trouble with implementing the method of subspace iteration to find the eigenvalues and vectors of a random, symmetric matrix, A that is mxm with m = 10. ...
1
vote
0answers
103 views

Calculate integrals using numpy.fft

Good evening, I would like to understand why I do not get the correct result: I assume that I know my function on discrete data points and expand it as a discrete Fourier transform: $\text{sin}(x)=\...
1
vote
0answers
114 views

computing dual matrix trace norm and tensor gradient in python

I'm trying to write the following function in python: $$ f_\mu(\mathcal X) = f_0(\mathcal X) + \sum_{i = 1}^n \max_{||\mathcal Y_{i(i)}|| \leq1} \alpha_i\langle \mathcal X_{(i)},\mathcal Y_{i(i)} \...
1
vote
0answers
292 views

Rank filter on an nXm array using python

I would like to apply a rank filter on an nXm numpy array. Let's say I have this array: ...
1
vote
0answers
50 views

Update model parameter with new data, discarding old data

I have this dataset, and I am using y = (a * x^n) / (b + x^n) Hill function as the model, where a is the limit of the Hill curve,...
1
vote
0answers
2k views

Finding eigenvectors and eigenvalues of large matrices in Python's numpy

I am running a PCA analysis on a data set using Python's (v2.7.10) NumPy. I validated that my program works by running the PCA analysis on a smaller dataset and then confirming that I get similar ...
1
vote
0answers
217 views

Inverse quadratic method only makes one iteration - python

I'm tryin' to implement this method with python3 but i don't solve the problem. This is my code: ...
1
vote
0answers
978 views

PageRank computation as the left principal eigenvector

I'm following the book here to compute PageRank: http://nlp.stanford.edu/IR-book/html/htmledition/markov-chains-1.html I built the transition matrix P as indicated in the book. Then I computed the ...
0
votes
0answers
43 views

Plotting the motion of a positive charge in a cylindrically symmetric magnetic field

I want to plot the motion of a positive charge in a cylindrically symmetric magnetic field. I am assuming a cylinder around the z-axis, with the magnetic field going in clockwise direction. The B-...
0
votes
0answers
127 views

Getting euclidean distance between vector A and C without anyway of retrieving them when their distances with a common vector B is known

Motivation: My plan is to get the overall euclidean distance matrix for all the vectors in N number of dataset. Each dataset is basically an array of n-dimensional points. For e.g: A dataset can be ...
0
votes
0answers
55 views

how can I plot specific iterations?

I have made this code for an explicit Euler method but I want to plot only the 0,1,25,50 iterations not all of them.How can I do it? ...
0
votes
0answers
341 views

How to take convolution of two arrays in Python by using NumPy?

Generally, we know that if we have this relation between Fourier transforms of three functions in frequency domain as: $$\mathfrak{F}\{\mathsf{P}(t)\} = \mathfrak{F}\{\mathsf{Z}(t)\}\mathfrak{F}\{\...
0
votes
0answers
106 views

Smoothing FFT result

I am trying to calculate the spectrum of Bremmstrahlung, which involves calculating the Fourier transformed acceleration. I am solving a non-linear ODE to numerically calculate the acceleration in the ...
0
votes
1answer
120 views

Specifying mesh spacing for DFT in numpy

I was testing the .fft package of numpy 1.16.1 in Python 3.7.2. In particular I was trying to verify that the transform resembles the analytical one for: $$f(x) = \mathrm{exp}\left[-\left(\frac{x-5}{2}...