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

40841 questions
7
votes
2 answers

Matrix multiplication and inverse problems with accelerate framework

I am trying to multiply two matrices in Objective-C. I have imported the accelerate framework to my project in Xcode, everything compiles just fine. I did the matrix multiplication on my calculator and got correct values, however, when running the…
Douglas
  • 2,524
  • 3
  • 29
  • 44
7
votes
3 answers

How does 4x4 matrix work in 3d graphic?

I am learning about 3d graphics and have stumbled upon matrixes, which I don't fully understand. I have a 3d object, with topology, points in coordinate system and ECS (4x4 matrix of the object). ECS is: -1.1247455413666E-32 , 1.83690953073357E-16,…
Zaay
  • 622
  • 2
  • 8
  • 23
7
votes
3 answers

How to quickly determine if a matrix is a permutation matrix

How to quickly determine if a square logical matrix is a permutation matrix? For instance, is not a permutation matrix since the 3rd row have 2 entries 1. PS: A permutation matrix is a square binary matrix that has exactly one entry 1 in each row…
SparkAndShine
  • 17,001
  • 22
  • 90
  • 134
7
votes
5 answers

Calculate row-wise matrix cumsum from vector

Given a vector I would like to create a square matrix where elements of vector are on diagonal and there is row-wise cumsum of elements. Example vector: vec <- c(1, 2, 3, 4) Required output: [,1] [,2] [,3] [,4] [1,] 1 3 6 10 [2,] …
Tomas Greif
  • 21,685
  • 23
  • 106
  • 155
7
votes
5 answers

Summing by groups of rows in R

This is a bit of a difficult question to title, so edits welcome. The data looks like this: mat = [,1] [1,] 9.586352e-04 [2,] NA [3,] 2.605841e-03 [4,] 7.868957e-05 [5,] 1.000000e+00 [6,] NA [7,]…
wolfsatthedoor
  • 7,163
  • 18
  • 46
  • 90
7
votes
1 answer

Bash - Multiply Bidimensional Matrix

Supposing that I have bidimensional matrix n x n, and we already know n=4 and values 1 - 16 like I must multiply the parts like: Array1*Array2 = result Array3*result = result1 Array4*result1 = result2 ShowMatrix() { echo "MyMatrix…
Choletski
  • 7,074
  • 6
  • 43
  • 64
7
votes
1 answer

Getting an error "number of items to replace is not a multiple of replacement length"

I'm trying to convert a record into a date and time format using the strptime function. However, I'm not sure why I'm getting the error: number of items to replace is not a multiple of replacement length. I tried to check the length of the record…
dixi
  • 680
  • 1
  • 13
  • 27
7
votes
3 answers

Android view 3d rotate transformation on big resolution screens

I'm implementing 3d card flip animation for android (api > 14) and have an issue with big screen tablets (> 2048 dpi). During problem investigation i've come to the following basic block: Tried to just transform a view (simple ImageView) using…
Henrik
  • 73
  • 1
  • 5
7
votes
2 answers

Get position, rotation and scale from matrix in OpenGL

At the moment I'm learning OpenGL ES for Android development. Now I'm at the point where I have to deal with the ModelMatrix and the CameraMatrix but I have some questions for it: In OpenGL we always use 4x4 matrix and I understand why we do this…
Cilenco
  • 6,951
  • 17
  • 72
  • 152
7
votes
2 answers

Remove NaN row from X array and also the corresponding row in Y

I have an X array with NaN and I can remove the row with NaN as such: import numpy as np x = x[~np.isnan(x)] But I have a corresponding Y array assert len(x) == len(y) # True x = x[~np.isnan(x)] assert len(x) == len(y) # False and breaks How do I…
alvas
  • 115,346
  • 109
  • 446
  • 738
7
votes
4 answers

Is there a way to find out if A is a submatrix of B?

I give quotation mark because what I mean is for example: B = [[1,2,3,4,5], [6,7,8,9,10], [11,12,13,14,15], [16,17,18,19,20]] suppose we select row 2,4 and col 1,3, the intersections will give us A = [[6,8], [16,18]] My…
CJJ
  • 139
  • 1
  • 7
7
votes
3 answers

Sampson error for five point essential matrix estimation

I used the 5 point Method from Nister to calculate the Essential matrix . Further improved Outlier Rejection using RANSAC and Sampson Error Threshold. I randomly choose 5 point sets, estimate the essential matrix and evaluate the Sampson error for…
7
votes
5 answers

What's a good matrix manipulation library available for C?

I am doing a lot of image processing in C and I need a good, reasonably lightweight, and above all FAST matrix manipulation library with a permissive license. I am mostly focussing on affine transformations and matrix inversions, so i do not need…
horseyguy
  • 29,455
  • 20
  • 103
  • 145
7
votes
3 answers

Jacobian matrix computation for artificial neural networks

Recently I started thinking about implementing Levenberg-Marquardt algorithm for learning an Artificial Neural Network (ANN). The key to the implementation is to compute a Jacobian matrix. I spent a couple hours studying the topic, but I can't…
Andrzej Gis
  • 13,706
  • 14
  • 86
  • 130
7
votes
1 answer

Traversing a boost::ublas matrix using iterators

I simply want to traverse a matrix from start to finish touching upon every element. However, I see that there is no one iterator for boost matrix, rather there are two iterators, and I haven't been able to figure out how to make them work so that…
The Vivandiere
  • 3,059
  • 3
  • 28
  • 50
1 2 3
99
100