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.

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.

Matrices with the same number of rows and columns can be added or subtracted element by element. But the rule for matrix multiplication is that two matrices can be multiplied only when the number of columns in the first equals the number of rows in the second.

Types of matrices

A matrix can be represented as a 2-d (two dimensional) array in any programming language, where one of the two dimensions defines row elements of a matrix, and other dimension defines column elements of the matrix.

Tag usage

The tag can contain programming related problems in implementing matrices. Questions in this tag will be related to a multidimensional array, so these questions can also be tagged with . Please avoid mathematical problems on stackoverflow (use the Mathematics Stack Exchange site instead).

Also note these related tags:

Read more

36680 questions
6
votes
1 answer

How can I make this R matrix filling function faster?

A while back I wrote a function to fill time series matrices that had NA values up according to the specifications needed and it's had occational uses on a few matrices that are about 50000 rows, 350 columns. The matrix can contain either numeric or…
Hansi
  • 2,176
  • 1
  • 13
  • 19
6
votes
4 answers

Fast Java matrix library suitable for JOGL + generic matrix math?

I'm interested in writing an OpenGL app in JOGL 2, using shaders instead of the fixed-function pipeline. I'll need to do a fair bit of 4x4 double-precision matrix math CPU-side, to replace the fixed function pipeline's push/pop/transform business. …
Alterscape
  • 1,465
  • 1
  • 16
  • 33
6
votes
2 answers

MATLAB - Merge submatrices

I'm working on an image processing project in MATLAB. In order to preprocess the image more easily, I've divided it in rows and columns, so from a original image (a 2D uint8 matrix), now I have a 3D matrix, like a stack. After processing each…
José Tomás Tocino
  • 8,637
  • 5
  • 40
  • 71
6
votes
1 answer

Mutual Information of MATLAB Matrix

I have a square matrix that represents the frequency counts of co-occurrences in a data set. In other words, the rows represent all possible observations of feature 1, and the columns are the possible observations of feature 2. The number in cell…
Colin
  • 8,627
  • 10
  • 42
  • 50
6
votes
3 answers

opengl oblique projection

I want to create a oblique (cavalier) projection in OpenGL. I know this operation is not default supported and instead I need a Shear Matrix and then make an Orthogonal Projection. Can you tell me what are the OpenGl steps / functions that I have to…
Alina Danila
  • 1,623
  • 1
  • 21
  • 51
6
votes
4 answers

Compressing a binary matrix

We were asked to find a way to compress a square binary matrix as much as possible, and if possible, to add redundancy bits to check and maybe correct errors. The redundancy thing is easy to implement in my opinion. The complicated part is…
anniesboobs
  • 61
  • 1
  • 4
6
votes
3 answers

Find the highest value in the Matrix to maximize the score

Question: I would like to find the highest value in the Matrix per teacher and group to maximize the ratio of which group should go with which teacher. Teacher A Teacher B Teacher C Teacher D Group 1 50 40 20 …
colourtheweb
  • 657
  • 2
  • 12
  • 25
6
votes
1 answer

What is the mathematical explanation of adding 2d Array and 1d Array?

I can't seem to replicate this numpy arithmetic. I'm using Julia, but want to know the mathematical explanation for this code. It seems to break what I know about Linear Algebra. X = np.arange(-5, 5, 0.2).reshape(-1, 1) X.shape ## (50, 1) test =…
dylanjm
  • 1,756
  • 5
  • 17
6
votes
4 answers

Matrices as function parameters in C89

For most of my undergrad C programming course, we studied C99 and our lecturer never bothered to teach us the main differences between C99 and previous versions. We have recently been informed that there's a possibility we'll be asked to implement…
Samuele B.
  • 364
  • 3
  • 10
6
votes
3 answers

In-place matrix rotation

An interesting question I found, asked that an NxN matrix be rotated, in-place by 90 degrees. My recursive solution, in C, is below. However when I looked up other solutions, most used a nested for loop to accomplish the task (which seems to work…
J. Andrew Laughlin
  • 1,526
  • 2
  • 18
  • 31
6
votes
1 answer

Julia: delete rows and columns from an array or matix

How can I delete one or more rows and/or columns from an array?
Jeffrey Sarnoff
  • 1,297
  • 7
  • 8
6
votes
3 answers

Applying a matrix to a function

Trying to apply a matrix to a function, using mapply without success I'm trying to solve a set of equations for different parameters. In a more simplistic form of the set of functions, I'm trying to pass a function to a matrix - constants - a…
Amidavid
  • 147
  • 7
6
votes
3 answers

Decreasing the time necessary to enter the coefficients of a matrix

Using Python, I want to build a square matrix whose coefficients are functions evaluated at some given points. The matrix is lower triangular, yet it takes more than 200 seconds to enter all the coefficients when the size is 1000. This is quite…
Nicolas
  • 65
  • 6
6
votes
3 answers

Looking for actively maintained matrix math library for php

Does anyone know where I might find a PHP matrix math library which is still actively maintained? I need to be able to do the basic matrix operations like reduce, transpose (including non-square matrices), invert, determinant, etc. This question was…
Mnebuerquo
  • 5,370
  • 4
  • 41
  • 48
6
votes
2 answers

Ruby- Adding/subtracting elements from one array with another array

I do this: a = [1,2,3,4] b = [2,3,4,5] c = b - a put c I get this answer -> [1] I want this answer -> [1,1,1,1] (like matrix addition/subtraction) I tried this: c.each {|e| c[e] = b[e] - a[e]} but I get this answer: [1,0,0,0] Can someone…
subyman
  • 63
  • 1
  • 3