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.

learn more… | top users | synonyms

2
votes
2answers
55 views

Path from source to destination, with increasing values

Given a source and destination, in an integer matrix, find path, such that the next position in the path has a greater than or equal to value than the previous position. In other words ...
0
votes
0answers
13 views

NASM - ASCII-Matrices [on hold]

I would like to print numbers in bigger ASCII-Matrices with a NASM-program. Like a dot-matrix-display but only with ASCII-Characters. In my program, I can just display one number, but I fail to ...
8
votes
2answers
50 views

Count the one islands in the matrix

What is an island? A group of connected 1s forms an island. For example, the below matrix contains 5 islands: {{1, 1, 0, 0, 0}, {0, 1, 0, 0, 1}, {1, 0, 0, 1, 1}, {0, 0, 0, 0, 0}, {1, 0, 1, 0, 1}} ...
2
votes
0answers
60 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
votes
2answers
55 views

Matrix multiplication of arbitrary sizes [closed]

This function is for multiplying two matrices together. It's kind of messed up because the result is actually supposed to overwrite the object that called it, or since it's static, it's supposed to ...
0
votes
2answers
118 views

Given N*N matrix, rotate it by 90 degree to left and right without extra memory

Looking for code review, clever optimizations, good coding practices. If question is unclear drop by a comment, I will clarify asap. Unit testing has been a visual inspection and concluded ...
3
votes
2answers
69 views

Searching a 2D matrix for a consecutive sequence

I've been solving problems on checkio (and trying to digest other's code) in order to improve my Python. My main goals are to learn to write more idiomatic Python and to explore the language more ...
3
votes
2answers
60 views

Optimizing garbage collection for local objects

I am trying to make a 3D application with OpenGL/LWJGL at the moment, but I am now already hitting some limits on the JVM, most likely due to a configuration that needs to be done. I have the ...
1
vote
1answer
40 views

MaxSum sub matrix within a matrix

Code review for best practices, optimizations, code cleanup etc. Also requesting verification of the complexity: O(row*row*col). /** * Contains coordinates of the * topMost left, of matrix, ...
4
votes
2answers
70 views

Rotate an image by 90 degrees

Looking for review, good practices, optimizations, clean code tips etc. final class Pixel { private final int color; public Pixel(int color) { this.color = color; } public ...
3
votes
2answers
82 views

Find mirror image of a matrix

Looking for review, good practices, optimizations, clean code tips etc. /** * Flip the columns. * * Complexity: * O(row * col) * */ public final class Mirror { private Mirror () { } ...
4
votes
2answers
108 views

Defensive programming type-checking

I have issues with dynamically typed languages, and I tend to worry about type a lot. Numpy has different behaviour depending on if something is a matrix or a plain ndarray, or a list. I didn't ...
2
votes
1answer
104 views

Project Euler #82 - path sum: three ways

Project Euler problem 82 asks: Here's my solution: def main(): matrix = [ [131, 673, 234, 103, 18], [201, 96, 342, 965, 150], [630, 803, 746, 422, 111], ...
3
votes
1answer
91 views

Clockwise and counterclockwise spiral matrix traversal

An interviewer asked me to write clean Java code for clockwise and counterclockwise spiral matrix traversal. e.g. {{1,2,3}, {7,8,9}} becomes {1,2,3,9,8,7} and {1,7,8,9,3,2} I've tried many methods ...
2
votes
1answer
51 views

Matrix of checkboxes - only 1 allowed in a row

Task Create a matrix of checkboxes. The user must be able to select only 1 checkbox in a row or unselect all of them. Solution <!DOCTYPE html> <html> <head> <meta ...
0
votes
1answer
50 views

Computing tangent space basis vectors for an arbitrary mesh

This is more like a share and a request than a question. I converted Eric Lengyel's code, which calculates tangents of a mesh for the purpose of texturing and normal mapping, to support SIMD. For this ...
3
votes
1answer
46 views

Simplifying loop for Incidence Matrix

I had to work in the Transport Problem and we're asked to try to make the fastest code for big matrices, so we're advised to try to avoid loops. And the only one I've got and I cannot imagine how to ...
3
votes
1answer
222 views

Sudoku solver - review on anything

I'd like a review on anything including optimizations, corrections, suggestions for robustness, adherence to good coding practices, etc. I also request verification of the complexity: O(nn), where n ...
2
votes
1answer
248 views

Prolog Sudoku solver taking too long

I was wondering if there's any way I can improve this code's execution. I want to use it on a 9*9 grid, but it takes too long to solve this as 4*4. This program takes as input a 4*4 matrix ...
2
votes
1answer
52 views

Given set of cubes can we get a given word?

Given some cubes, can cubes be arranged such that an input word can be formed from the top view of the cubes? For example: assume an imaginary cube with only 3 surfaces where cube1: {a, b, c} and ...
2
votes
4answers
161 views

How can I make this code more readable and efficient?

How can I rewrite this code to make it more readable and, if possible, more efficient? The conditions are entirely necessary in this problem, but how could I rewrite those if(a != 1) and such? celula ...
3
votes
1answer
98 views

Optimize Scipy Sparse Matrix Factorization code for SGD

I'm working on implementing the stochastic gradient descent algorithm for recommender systems (see Funk) using sparse matrices with Scipy. This is how a first basic implementation looks like: N = ...
2
votes
1answer
85 views

Minesweeper, Bombcount method

I have a method which checks all of its surrounding squares and returns the number of bombs around it. The problem is it uses a long list of if statements, which is pretty ugly and probably ...
2
votes
1answer
122 views

Optimizing this matrix shifter

I need to optimize this piece of code I made because this will run in real-time mode. It's a matrix shifter that pulls downward and will neglect any transparent element. Code: void shiftDown(int ...
2
votes
2answers
338 views

Finding a route in maze matrix

Maze puzzle A 1 in input matrix means "allowed"; 0 means "blocked". Given such a matrix, find the route from the 1st quadrant to the last (n-1, n-1). I would like to get some feedback to ...
3
votes
3answers
143 views

Neighbors of a matrix element

I would like a code review to make this code better, clear, and concise. The problem it's solving is as follows: Given a matrix, print the circumference of each of the items. For example: 1 2 3 ...
5
votes
1answer
90 views

10x10 bitmapped square with bits

This program prints out a 10x10 square and uses only bit operations. It works well, but I don't like that global array. Can you tell me if the code is proper or not? #include <iostream> ...
0
votes
1answer
226 views

Is my 4x4 Matrix multiplication on a 1d float array correct?

I'm trying to develop my own Math library to use on a Voxel Engine, but I'm worried about Matrices multiplication. Everywhere I saw ppls using 4x4 Matrices on a 2d Float Array but i'm using a 1d Float ...
2
votes
2answers
80 views

How's my matrix library look?

I've written a short library for manipulating matrices for 3D drawing. I've tried to strike a balance between speed and readability. Anything to improve? %! %mat.ps %Matrix and Vector math routines ...
0
votes
3answers
546 views

Searching for an element in a 2D array

For example, given a 2D array (a matrix): {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}} What are the solutions to find a number, such as 6? Here's the code I tried using binary search method: ...
3
votes
0answers
292 views

Implementing the CutHill-McKee Algorithm

I am very much interested in the Reverse Cuthil McKee Algorithm. I have seen Fortran and C or C++ implementations of it, and I decided that it would be a nice exercise to implement it in Python. I ...
7
votes
2answers
117 views

How to increase efficiency of matrix operation in C?

I have a N*N upper triangular matrix with property such that, all its diagonal elements are a1,a2,a3,...,aN. I want that a[i][j] (for all j>i) should be (a[i][j-1] + a[i+1][j]) / 2. I have many ...
3
votes
5answers
239 views

Finding the maximum row of a 4x4 matrix

I have written a recursive function that I believe will return the 'maximum' row of the 4x4 matrix it is fed. By 'maximum' I mean that the maximum row of the matrix. 1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 ...