# Questions tagged [matrix]

In mathematics, a matrix (plural matrices) is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. The individual items in a matrix are called its elements or entries.

573 questions
Filter by
Sorted by
Tagged with
116 views

I have written a code in Haskell that calculates the determinant of a matrix using the laplace expansion. As I have just started learning Haskell, I would like some opinions on how well (structured) ...
3k views

### Calculate co-occurrences of some words in documents dataset

It's a function to calculate the co-occurrences of some words in a news dataset, such as Techcrunch, Wired. The words list could be locations, products or people names. Words list example: ["New ...
138 views

### Competition - Qualifications - E - Matrix distance

2 types of query: add value to x y output the sum of $value*(|a - x|+|b-y|)$ for every pair(a, b, v). In the start you are given $n$ (number of querys), $m$ (maximal dimension for square ...
309 views

### Recursive matrix multiplication

I've just written a recursive matrix multiplication and I want to know my mistakes or problems. Is there a better way doing this? ...
334 views

### Matrix inverse by elimination

Because I had trouble in finding a reliable source on the internet for the matrix inverse algorithm using Gaussian elimination, I wrote one myself. Matrix.h ...
2k views

### Extending numpy array by replacing each element with a matrix

Suppose I have a H*W numpy array like this (H=3 and W=2): ...
67 views

### Calculating the connectance of a matrix iteratively

I have a performance issue in R. I have a function that iterates over a dataframe for different levels of "site" and "method". The function samples 1:1000 interactions (rows), converts these to ...
185 views

### C++ template functions to partially implement Python numpy ndarray limited to 1d and 2d

I just read a book on creating a neural network. The book uses Python. I wanted to port this to C++. In order to do that I had to create template functions to implement some of the ...
306 views

### Encryption/decryption by matrix multiplication in C

I need to encrypt and decrypt text, image and video with a program in C with a matrix. My program is working but it's really slow, how can I improve its speed ? specially for the decrypt part. Each ...
1k views

### Triangle area computation and linear transformations

I have a task to learn how to write clear and understandable documentation of written code in python. Please, can you give me a feedback to attached code below? I need to know if the code and comments ...
128 views

### Performing FFTW double on images of type cv::Mat

I've two different types of variables: cv::Mat and array of type double so I do quite lot of copying between the two types. I ...
365 views

### class for Block Compressed sparse Row storage

Here my Block Compressed sparse Row storage class, I have some doubt about the constructor that use a std::vector<std::vector> for store the initializer list ...
363 views

### Fast affine transformations of many 3D points by one 3×4 matrix

I wrote a function to batch-transform 3D vectors by a single 3x4 matrix using SSE2: ...
79 views

### Computing Nth element of a series

I am computing Nth element of the the sequence: $a_n=-2a_{n-1}+a_{n-2}+2a_{n-3}$ Initial values are $a_1=-2$ $a_2=6$ $a_3=-8$ Code ...
863 views

### Modified compressed sparse row matrix code

I've implemented a Modified Compressed Sparse Row matrix class! The class works, but I think that some part of the code is quite crap. There are two passages and the whole code became too expansive ......
166 views

### Propagation solver in C++ using discrete Hankel transform

I wrote a small program which propagates light pulses using a discrete hankel transformation (based on A quasi-discrete Hankel transform for nonlinear beam propagation, You Kai-Ming et al., 2009. It ...
54 views

### product member of CSC matrix class

I'm implementing a CSR and CSC class! I found a lot of algorithms for computing a CSC * vector product but I didn't find any routine for the CsC * CsC matrix product, in order to save time when the ...
2k views

### Matrix multiplication project using multithreading in java

Below is my code of matrix multiplication in Java. It has both implementation of matrix multiplication- one without multi-threading and another one using multi-threading. For multi-threading ...
2k views

### Parallel matrix multiplication in Java with streams

This StackOverflow post highlights how to do matrix multiplication using Java's stream. With Java streams, there is a new way to enable concurrent threading with the Java's parallel stream. ...
2k views

### Matrix Implementation using struct in C

Follow up on this post. I have refactored my code and created a matrix_t struct and implemented various functions to create, delete, modify and perform arithmetic on them. ...
8k views

### Matrix multiplication using functions in C

This exercise surprised me a little bit. I did not expect that gcc (GCC 6.3.0 in the MinGW suite) would use the C11 standard by default, which I realised after I ...
1k views

### numpy performance of norm calculation using variable dimension

I am looking for advice to see if the following code performance could be further improved. This is and example using a 4x3 numpy 2d array: ...
274 views

### Map square coordinates in matrix to flat array indices without hurting performance

I'm more like playing and the problem I'm going to demonstrate is a learning task, so to speak, not something I really need to solve. Imagine having a matrix of data. You chose square in it and ...
4k views

### AVX SIMD in matrix multiplication

I have coded the following C function for multiplying two NxN matrices and using AVX vectors to speed up the calculation. It works but the speedup is not what is to be expected(some scalar code is ...
287 views

### Normalization, division and reshaping processes on an HDF5 file

I performing a set of division operations and reshaping on a HDF5 file. As my datapoints is around 4000 in number it takes around a minute. I will be adding more data, which will further slow my ...
301 views

### Array transposition

The task: take a byte[][] and transpose it. The complication: the original array is a result of a partition operation that might not be even, so the last subarray ...
527 views

### Portable multithreaded matrix multiplication in C

I essentially took this progam, and made it compile and run on Windows too. Also, I incorporated some nice points made by Toby Speight. matrix.h ...
1k views

### Multithreaded matrix multiplication on Unix in C

I have this program for comparing serial and parallel matrix multiplication algorithms: matrix.h ...
896 views

### Improving the manipulation of 2D Arrays for an easy challenge on HackerRank with Python 3

I am practicing some exercises on HackerRank in order to improve my skills on Python3. I am doing the 30 days challenge. There is one challenge involving matrices. I was able to pass the test cases ...
218 views

### Cor.test inside for loop is very slow for large matrix processing

I have a matrix of 36,000 genes measurements for 60 samples. For calculating most correlated genes of the first gene in the matrix, my following program gives the result. However processing time is ...
721 views

...
2k views

### Counting neighbor cells of a matrix

I was given this problem to solve inside a Swift playground. I was vaguely told my answer is correct but not good enough. ...
3k views

### Implementation of the Householder Transformation

I implemented the Householder transformation in Python, so that I can later use it in a QR decomposition. Unfortunately I haven't found a good concise source for reading up on the algorithm. I am not ...
139 views

### Small calibration script for xinput

I've written this as an alternative to xinput_calibrator when it wasn't working for me. It's my first crack at several things: ...
779 views

...
1k views

### Generic matrices implementation

I am implementing a litte generic math library. What I have done is to write my generic matrix and vector class. I'm curious if I have it done right so far (implementation wise not totally ...
742 views

### Minimum number of moves to solve “game of fifteen”

I read about this game and tried to make my own algorithm to solve this. I asked it on StackOverflow for the appropriate algorithm and logic to solve this problem. With the help of answers over ...
3k views

### Matrix multiplication with OpenMP parallel for loop

I tried implementing matrix multiplication with parallel for loop in OpenMP as follows. It runs correctly but I want to make sure if I'm missing anything. How does this determine the number of threads ...
245 views

### How to make a matrix factorization system recommander faster?

I used and modified a matrix factorization function for a system recommender from quuxlabs.com. It works well for small sized input but when we get to large matrix it takes too much time. I was ...
2k views

### Computing sum on column + sum on row + sum on each diagonal

I have the following problem: I read from a file the dimension(n) of the matrix(which is n * n) and the matrix. For each element ...
83 views

### Make each element equal to its neighbouring element which is maximum in a matrix

I have a matrix and I want to make each of its element equal to the maximum of its neighbouring element and each time I increase number of counts till all the elements in the matrix becomes equal to ...
201 views

### Multidimensional matrix exponentiation

Is there a more efficient way of exponentiating a multidimensional matrix? This is how I am currently doing it: ...
69 views

### Backward transformation implementation for a barrel eye lens aberration in c++ 14 (using opencv)

I've made the following backwards transformation from a "transformed" source x,y point, to the resulting index of the actual image that I have, so I can avoid black spots appearing in my barrel eye ...
211 views

This program is used to solve Challenge #140 [Intermediate] on /r/dailyprogrammer. The challenge is, given a input set of directed edges, print the corresponding ...
432 views

### Counting Islands In Matrix Of Boolean

Code objective: Read a txt file, parse it into a matrix and count (and also print) the number of unique "islands" in the map formed by the matrix. 0 = Sea; 1 = Land; Islands are orthogonal groups of ...
2k views

### Matrix transpose algorithm

If I have a List<List<T> like the following : Name City Id Anna NY 1 Joe NJ 2 How can I ...
49 views

### Blurring an image using matrices

Suppose there is a very big matrix and and a small window is moving on the matrix. The small window will move right and down, step by step (means each time move one step right, or move one step down). ...
713 views

### GPU and CPU templated matrix classes

I'm learning CUDA C++ (and C++). Can you guys give me some feedback on my basic templated matrix implementation? A brief explanation of my decisions: First things first: I can't use STL classes/...