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

544 questions
Filter by
Sorted by
Tagged with
986 views

I've written a program that runs through a matrix of numbers, ranging from 0 to 2, and stores the results in a 2D vector. I'm using the values in the 2D vector as the profile for a tile map for a ...
3k views

### 4x4 matrix implementation in C++

I've been doing some 3D graphics in OpenGL lately and I needed a way to work with 4x4 matrices. My implementation supports the following operations: Matrix-matrix addition. Matrix-matrix subtraction. ...
891 views

102 views

### Profit sensitivity analysis in base R

Using base R, I've conducted a simple profit sensitivity analysis, i.e. measuring the impact on profit if there is a change in price, variable cost per sale, unit sales or fixed costs assuming that ...
325 views

### Pretty print a 2D matrix in C (numpy style)

Works for any 2D matrix represented by a 1D array. Comments and criticism welcome. Also wondering whether the code can be made shorter. It's really messy right now. ...
128 views

### Horizontally concatenating the entries of two matrices, and padding with NaNs

I have two matrices a and b that have, on each line, some values (null or not) and then a bunch of zeros at the end. I want to ...
91 views

### Extract the largest value for each day from a matrix

I have a matrix in which the right-most elements are repeated YYYYMMDD dates in descending order, for example: ...
87 views

### Predict new ratings for each user based on their pearson correlation with other users

I am new to R and programming. I have a set of ratings for 45000 users and 40 odd movies. I need to predict new ratings for each user based on their pearson correlation with other users. I also need ...
191 views

### Counting matrix elements that have “4” or “5” as a neighbor

I have a matrix (500x500) of integers. For each entry, I need to look at its surrounding neighbours (so 8 elements) and determine what the integers are, and run a function on these integers. Here ...
49 views

### Assign values to a matrix based on the location of non-zero elements in another matrix

I have a matrix, A containing ones and zeros. I want to create a new matrix B where the non-zero elements are in the same ...
121 views

### Merging two square matrices

I would like to optimize a snippet of code, which uses a multiple nested if statements. I am looking for a formula to make it as a combination of multiple arrays ...
2k views

### Java method to make a string representation of a matrix

I have coded this static method for converting a double matrix into a nifty String. It considers the width of the matrix to be ...
365 views

### Print matrix in spiral order

I have a task formulated like this Please print a matrix in spiral order, clockwise from outer rings to inner rings. I decided to implement it in Clojure. ...
78 views

### Symmetry analysis for atom arrangements in a crystal

For a while now I've been meaning to post some of my Haskell code here so that someone can tell me what parts of the language/base library I've been completely overlooking. This is the first thing I'...
350 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 ...
423 views

### Print out a Zig-Zag Matrix in Haskell

My task is to code something that prints out this: This is what I have done so far. ...
125 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: ...
341 views

### google foo.bar max path algorithm puzzle optimization [closed]

I got a programming puzzle described as follows: Save Beta Rabbit Oh no! The mad Professor Boolean has trapped Beta Rabbit in an NxN grid of rooms. In the center of each room (except for the ...