All Questions
48 questions
0
votes
1
answer
321
views
Approximation of the multiplicative matrix inverse (linalg.inv ())
I am trying to compute the multiplicative inverse of a large matrix (~ >40,000x40,000). This can be done with e.g. numpy.linalg.inv or ...
3
votes
1
answer
141
views
Python: Create submatrices from long/narrow table and save in HDF5
Hello dear StackExchange Community,
I have written a small program which is doing the following. In short:
it reads in a table in narrow format
creates submatrices from it
saves it in HDF5 format
...
1
vote
1
answer
3k
views
Lo Shu Magic Square (Python)
I wrote a python program to find if a matrix is a magic square or not. It works, but I can't help feeling like I may have overcomplicated the solution. I have seen other implementations that were a ...
2
votes
0
answers
58
views
Converting list of sequences into one-hot vectors
I have an array of dim 1000 x 150 where I have 1000 strings each of length 150. And the strings only contain ATCGN (these are ...
2
votes
3
answers
418
views
How can I optimize my Von Neumann neighborhood algorithm?
I am working on a small project that requires finding Von Neumann neighborhoods in a matrix. Basically, whenever there is a positive value in the array, I want to get the neighborhood for that value. ...
2
votes
1
answer
111
views
Improving performance of function to multiply vector with a matrix?
I wrote this function to multiply vector with a matrix and I was wondering if someone experienced can spot something can improved its performance.
...
2
votes
1
answer
196
views
Procedural generation of a general matrix representing a tile map
The problem is to design an structure which generates "uniformly" the next one in an initially zero matrix. Taking an arbitrary index i in the range [0,m-...
5
votes
1
answer
145
views
Naive Solver of Matrix with Periodic Boundary Conditions Feedback
I am creating an \$O(n)\$ solver for an \$Ax = b\$ system where \$A\$ has the form
\$
A = \begin{pmatrix}
a_1 & b_1 &&&d_{u}\\ c_1 & a_2 & b_2\\& \ddots & \ddots &...
4
votes
1
answer
292
views
Generating unique 2D numpy arrays with 2 adjacent row elements swapped while using BFS in Python
So I have a 12 x 6 2D numpy array for input which consists of 7 possible board objects (characters from 'abcdefg'). From a 2D numpy array I wish to generate all the possible unique 2D arrays, in whose ...
3
votes
1
answer
2k
views
Matrix Exponentiation in Python
I recently wrote a python code for matrix exponentiation.
Here's the code:
...
5
votes
2
answers
136
views
Fast execution of function which resembles matrix multiplication
I am trying to make the following function as fast as possible on large matrices. The matrices can have dimensions in the range of 10K-100K. The matrix values are always between 0 and 1. The function ...
5
votes
1
answer
926
views
Count number of unique adjacent cells in a matrix
I want to write an algorithm to count how many islands are in a given matrix. Consider for example:
...
3
votes
0
answers
194
views
Lowest cost path through elements in a matrix
I've developed a program in Python that calculates the lowest possible costing path between two points in a matrix, including the values contained in the start and finish cells. The code is below. ...
6
votes
1
answer
416
views
Reading sparse matrix from binary file
I have binary files containing sparse matrices. Their format is:
number of rows int
length of a row int
column index int
value float
Reading ...
2
votes
1
answer
5k
views
Inverse mapping with bilinear interpolation on an image
The following is my solution for an inverse mapping with bilinear interpolation on an image. The original image is img and ...