Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

6
votes
0answers
45 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 ...
5
votes
0answers
426 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 ...
5
votes
0answers
186 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 ...
5
votes
0answers
127 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 ...
4
votes
0answers
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 ...
4
votes
0answers
505 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 ...
4
votes
0answers
224 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 ...
4
votes
0answers
197 views

Generalized NumPy reshape function to imitate einsum syntax

I often perform a lot of reshape(), transpose() or squeeze() operations on ...
4
votes
0answers
51 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 ...
3
votes
0answers
53 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. ...
3
votes
0answers
75 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 ...
3
votes
0answers
33 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. ...
3
votes
0answers
64 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 ...
3
votes
0answers
120 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 ...
3
votes
0answers
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 ...
3
votes
0answers
108 views

Haskell Laplace determinant

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) ...
3
votes
0answers
143 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 ...
3
votes
0answers
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 ...
3
votes
0answers
53 views

Calculating OpenGL view matrices

I'd like a little help here calculating the view matrix for OpenGL based on the lookat type function: ...
3
votes
0answers
86 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 ...
3
votes
0answers
143 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: ...
2
votes
0answers
30 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 ...
2
votes
0answers
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. ...
2
votes
0answers
77 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 ...
2
votes
0answers
80 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. ...
2
votes
0answers
62 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 ...
2
votes
0answers
269 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 ...
2
votes
0answers
305 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 ...
2
votes
0answers
115 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: ...
2
votes
0answers
994 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 ...
2
votes
0answers
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 ...
2
votes
0answers
340 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 ...
2
votes
0answers
62 views

Picking seats in a matrix

I'm trying to write a Python class that creates a matrix of zeros, then uses a random number generator to pick 'seats' on the matrix. It changes the zero in that seat to a one, until the matrix is all ...
2
votes
0answers
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): ...
2
votes
0answers
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 ...
2
votes
0answers
289 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 ...
2
votes
0answers
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 ...
2
votes
0answers
245 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 ...
2
votes
0answers
116 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 ...
1
vote
0answers
585 views

MIPS Assembly Program to access elements in the 4x4 matrix, row or column-major oder

This MIPS Assembly program will make you access the elements in the 4x4 matrix in either row or column-major order i.e. accessing all elements row by row or column by column. Output is posted below ...
1
vote
0answers
111 views

Performing FFTW double[2] on images of type cv::Mat

I've two different types of variables: cv::Mat and array of type double[2] so I do quite lot of copying between the two types. I ...
1
vote
0answers
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 ...
1
vote
0answers
1k 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. ...
1
vote
0answers
171 views

Haskell - Adjacency Matrix

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 ...
1
vote
0answers
47 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). ...
1
vote
0answers
2k views

Traceback in sequence alignment with affine gap penalty (Needleman-Wunsch)

I am working on an implementation of the Needleman-Wunsch sequence alignment algorithm in python, and I've already implemented the one that uses a linear gap penalty equation for scoring, but now I'm ...
1
vote
0answers
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 ...
1
vote
0answers
124 views

Cuda C Matrix Compression

I am using Cuda to learn and implement a CSR matrix compression algorithm. What can I do better relating to C's best practices? main.c: ...
1
vote
0answers
348 views

Get vertical acceleration from rotation vector and accelerometer values

My goal here is to calculate the acceleration towards the ground, which I call "vertical acceleration". This seems to be working OK for the most part, except when there is a lot of rotation going on ...
1
vote
0answers
130 views

Why does lu-factorization make my program slower?

I'm trying to calculate the smallest eigenvalue of the matrix A by using the "inverted exponentiation method" (see the code). I manage to find the smallest eigenvalue, but when I try to optimize the ...