Skip to main content

All Questions

Tagged with
2 votes
1 answer
31 views

Lattice-boltzmann simulation runs over the object mask, simulating areas that should be just black

I'm trying to simulate a tesla valve using the method, starting from this code. The problem is that the mask, the boundaries, or the bounce-back are not being applied correctly. If I reverse the ...
yous's user avatar
  • 21
0 votes
1 answer
55 views

Efficient stochastic numerical integration over many trajectories

I am implementing a numerical method for solving stochastic differential equations using the Euler-Maruyama method. What I have works, but it is not efficient. The reason is that because of the ...
J.Agusti's user avatar
  • 173
0 votes
1 answer
30 views

My Python's Minesweeper function is returning different values when it should be constant values

I wrote a Minesweeper in Python using a class, the random and the Numpy modules. By choosing the difficulty, it sets up the dimension of the board and creates it, with the help of Numpy. It, then, ...
Pedddrym's user avatar
2 votes
1 answer
72 views

Optimize this Python code that involves matrix inversion

I have this line of code that involves a matrix inversion: X = A @ B @ np.linalg.pinv(S) A is an n by n matrix, B is an n by m matrix, and S is an m by m matrix. m is smaller than n but usually not ...
Taylor Fang's user avatar
1 vote
2 answers
84 views

Rotating a vector field in an efficient way in python

I need to rotate a 3D vector field by 90 degrees. I do that by first using the NumPy function rot90 (see the docs here). Then I rotate each component at each position in a very inefficient way: using ...
Alf's user avatar
  • 1,929
1 vote
0 answers
53 views

Optimal function to scan numpy matrix

I have a binary 2D numpy array that represents transactions and items. For item I (represented as columns), I want to calculate the total number of transactions (represented as rows) that purchased ...
rhamzaali's user avatar
1 vote
1 answer
71 views

Creating Matrix from Vector Entries and Deprecation Warning from NumPy

I want to create a square matrix, let say 4X4, which the entries are taken from a vector, with length 16. This vector entry will be arranged in the column of matrix. Suppose that u is a vector with ...
Margi's user avatar
  • 35
-1 votes
1 answer
42 views

numpy.dot function and by-hand calculation

I am working on calculating pcov from a Jacobian matrix by hand, and understand most of it but am struggling to understand how the .dot function works from numpy in python. I have looked at the manual ...
HAILEY RUDE's user avatar
1 vote
1 answer
70 views

Define a matrix in R in a similar fashon as with Numpy

I love the fact that using numpy in Python it is very easy to define a matrix/array in a way that is very close to the mathematical definition. Does R have a similar way of achieving this result? ...
larry77's user avatar
  • 1,461
0 votes
1 answer
64 views

bottleneck in multiprocessing in python

I have a code that uses two parameters (r,t) to create a matrix H. I then find the eigenvalues of this matrix and do some computations using the eigenvalues. Now, I need to do this for many different ...
Souroy's user avatar
  • 21
1 vote
1 answer
89 views

how to use efficiently rotation matrix in numpy to compute new coordinates along a circle (avoiding for loops)?

I would like improve the script below. The goal of the script is to compute different coordinates corresponding to several angles. This corresponds to rotate one point around x axis and for each step ...
Certes's user avatar
  • 155
3 votes
3 answers
104 views

Finding unique columns and their indices in NumPy matrix efficiently

I have a very large binary matrix (for example, shape = (210000, 5000)) and want to find unique columns and indices of this matrix. Memory is important to me, so that is why I am looking for a method ...
farid_musa's user avatar
0 votes
0 answers
46 views

Raising a Numpy Array to a large power [duplicate]

I am using Numpy to raise a 2 X 2 array (matrix), with positive elements, to an integer power. But if I use a high enough power, I get negative values in the result: A = np.array([[1, 1], [1, 0]]) B = ...
Radu Valasutean's user avatar
0 votes
1 answer
35 views

How to reorder rows of a numpy array according to another array [duplicate]

I have a matrix A whose rows have to be reordered or shuffled according to the sequence in array b. The actual size of a Matrix A is more than 100 rows. The suggested answer need to be scalable. A = ...
M.Patil's user avatar
  • 81
2 votes
2 answers
61 views

NumPy: get a matrix of distances between values

If I have a set of points: points = np.random.randint(0, 11, size=10) print(points) Output: [ 5 4 9 7 4 1 2 10 4 2] And if I want to get a matrix representing the distance from each point to ...
Mandias's user avatar
  • 844

15 30 50 per page
1
2 3 4 5
264