# 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.

58 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
74 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 ...
75 views

I'm working on 2-D top-down graphics engine, and need a way to simulate clouds. My idea was that I could create a layer comprised of a matrix of rectangles whose alpha value would be picked from a ...
194 views

### Creation of matrix with specific attempts at the end

What I want to do is build a Slay-the-Spire-like Map. As you can see in the following image, the map is splitted in ISteps and ...
555 views

### Codewars: N-dimensional Von Neumann Neighborhood in a matrix

Task: For creating this challenge on Codewars I need a very performant function that calculates Von Neumann Neighborhood in a N-dimensional array. This function will be called about 2000 times The ...
224 views

### Cache conscious SIMD matrix multiply of unsigned integers

The goal of the code review by order of importance (i.e. What I hope to hear from you): I've verified correctness using a straightforward matrix multiply function though I am open to those who want ...
131 views

### Kernel density regression in Julia

Here is a naive implementation of a kernel density regression algorithm in Julia. The code works, but there is quite a bit of room for improvement though. First, there is not an optimal bandwidth ...
63 views

### 4×4 cofactor in SSE

The cofactor of a 4×4 matrix can be used to convert a "regular geometry" matrix into the matrix that transforms the normals. It's an alternative to the common inverse-transpose pattern. In this post I ...
160 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 ...
2k 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 ...
663 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 ...
243 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 ...
213 views

### Generalized NumPy reshape function to imitate einsum syntax

I often perform a lot of reshape(), transpose() or squeeze() operations on ...
53 views

### Basic declarative style to rotate and crop an image array

I wrote a couple of basic Clojure functions (practicing a declarative style) and I was looking to get some feedback on them. You can see all the code here. Is there anything I could improve on to ...
48 views

### Finding shortest path in matrix

Given an N x N matrix of positive integers, I need to find the shortest path from the first cell of matrix to the last cell of matrix. I can move exactly x steps from any cell, where x is the value of ...
23 views

### How would you convert this code to best take advantage of CSS transform for panning/zooming?

I am using react-flow-chart for a job project, but it doesn't implement zoom, and I would like to take the reigns and try applying it myself. I took a linear ...
55 views

### Striping a matrix concentrically, anticlockwise

Given a matrix you shall stripe the matrix, such that every number that has equal distance to the matrix border will be filled into an array. For examples see code comments. ...
206 views

### Python program to solve matrix-chain multiplication

An assignment at school required me to write a Python program for this task: In the matrix-chain multiplication problem, we are given a sequence of matrices ...
49 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. ...
97 views

### Calculate huge Fibonacci Numbers in C++ using GMP and boost::multiprecision

Problem Statement Calculate the exact value of the n-th Fibonacci number, say the one-billionth. Algorithm The algorithm is based on the idea that Fibonacci numbers can be represented as 2x2 ...
42 views

### Deriving incremental feature representations for bit flips

Given a boolean 3D matrix and a set of actions specifying bit flips at certain positions, a set of resulting matrices can be obtained, one matrix for each action, as if executing each bit flip ...
111 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) ...
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 ...
55 views

### Calculating OpenGL view matrices

I'd like a little help here calculating the view matrix for OpenGL based on the lookat type function: ...
91 views

### Project Euler #2 in Go

I just learned Go (yesterday in fact) and today I made this solution to Project Euler #2. The problem is to sum the even Fibonacci numbers. My program uses the matrix representation of the linear ...
148 views

### Computing pairwise distance covariances for a symmetric matrix

I wrote a non-vectorized, non-parallel wrapper function for computing the pairwise distance covariances (Wikipedia) (original paper) in a data frame: ...
45 views

Code Problem ...
53 views

### Compute angular distances between data points in a matrix

I am having a hard time speeding up a function that I use to compute angular distances between data points in a matrix. More precisely, I want to compute \sum_{r=1}^n|\pi - \arccos\left(\frac{(X_{i}-...
35 views

### Spiral printing elements of a matrix

As I'm learning elixir, I wrote some code for printing elements in the spiral of a matrix(2D array). I was wondering if there is any room for improvements with regards to its performance or ...
31 views

### MinMax product for large matrices

I created this program which runs with no error, but I'd like to have some comments if it is possible to optimize it, since I need to run the program with N = 3200. ...
90 views

### C++ matrix operations

Not much formal education in programming. One year in school. We did C++ classes for most user defined objects. I've written a few different class variations for matrices but wonder about how useful ...
88 views

### Dijkstra in JavaScript

I am writing the solution of Dijkstra's algorithm in JS. This is what has happened so far. I need to make it so that the choice of nodes is by recursion. Tell me how to do this better. ...
68 views

### CUDA kernel to compare matrix entries, weighted with a pattern

I wonder if it's possible to optimize this code in CUDA. Could I get any hints how to? Equivalent algorithm runs faster in Matlab for me, but there I'm doing matrix operations. Compution I'm not ...
326 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 ...
354 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 ...
130 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: ...
1k views

### Recursive matrix multiplication in C++

I'm working through CLRS, and I'm hoping to get some pointers (ha!) on my C++ coding style and the way I've implemented recursive matrix multiplication. The code right now seems a bit complex for ...
1k views

### HackerRank - Matrix Rotation

Problem statement Given a matrix (up to 300 × 300), rotate each element R steps anti-clockwise along concentric rectangular paths (R up to 109). The algorithm is rated as hard on HackerRank. On ...
108 views

### Online Principal Component Analysis with spectral bounds

I have question regarding online PCA implemented in the paper. I am interested in the Algorithm 2. I am not certain if there is a bug in my code can someone confirm if my code is correct? The ...
431 views

### Find minimum distance in matrix

Challenge URL: http://acm.scu.edu.cn/soj/problem.action?id=3330 Windy has a matrix A with size N*M which only contains 0 or 1. The distance between Axy and Apq is: |x-p| + |y-q| Can you help ...
67 views

### Analysis of TV station preferences for various demographic groups

I have a notebook here which details my code and may be more legible. I worked on a project that flattens a table that initially looked like this (this is table1): ...
176 views

### C# port of data mining algorithm much slower than reference implementation

I was trying to implement the algorithm specified in this research paper (please ignore the math, since it's irrelevant to the question). This algorithm is very basic in formal concept analysis. The ...
300 views

### A* search algorithm in Clojure

Cost of nodes are represented by a matrix (called world), heuristic cost estimate/g score/f score are all represented in matrices. The world and its size are ...
1k views

### Linear System Solver using Gauss-Jordan Elimination

I'm learning about Gauss-Jordan Elimination, and decided to write a program to automate the process to help solidify my understanding. Along with the algorithm itself, I wrote a ...
246 views

### Smoothing matrix for visual representation

I recently started playing around with R and am currently trying to plot GPS data points onto a perspective plot. I have a script that works and I get my desired results out of it and it works ok for ...
117 views

### Increasing speed of parity check matrix

The code runs fine and takes 100s to complete it for 5 iteration. I need to reduce it to take less time with the same number of iterations. h = 324 by 648 matrix The code is that of FFT Belief ...
108 views

### Fast matrix transpose

I would like to improve the naive matrix transpose algorithm by using a cache friendly algorithm. So far there are 4 variants. Iterate over the source matrix: ...
38 views

### Stochastic gradient descent - backpropagation over mini-batches in one go

I have been working through a tutorial on neural networks. I have then been translating the code to java, to help improve my understanding of what the code is doing. The book mentions a way of ...
61 views

### Extract numerics from matrix A with logical matrix B

I have a matrix A containing numeric values and a matrix B containing 0/1s: ...