Brainlet here, how are matrices used in programming?

Brainlet here, how are matrices used in programming?

Attached: matrix.png (512x288, 20K)

to store data and access them easily

Do not use the term "matrix", but "multi dimensional array".

>how are they used

What the fuck kind of question is that anyways? They are using by using them derp

Graphics
Codes (as in linear codes)
A lot of optimization problems are expressed as matrices

As a data structure for graphs. See Adjacency matrices for example

A matrix is distinct from a multidimensional array in that it has an algebraic structure.

either unwrapped into a single array or mutli dimensional array.

Used for anything from ai, to computergraphic, to numerical operation, etc.

Don't talk about matrices ever again

Obviously no one here do real science. The matrix its used as a storage element in application as Lineal Programming and optimization. If you wonder on those themes i sujest to you to read about the TSP or optimization on the wikipedia articles.

Lots of things. For example, I'm making a tetris game and using a matrix to store the locations of pieces that have fallen.

Computer graphics rely on them heavily. For example, an object's position, rotation, and scale are represented by a matrix. Matrices are also used to project points from a 3D scene onto a 2D plane (your screen).

however you want, I usually use arrays

Misleading. Don't listen to this person.

They're everywhere. Solving equation systems is one of the primary things that come to mind.

you're an idiot but nice digits, checked

Attached: RCZ.png (645x773, 19K)

What did I say that's wrong?

matrices are used to compactly express a set a linear equations, or for expressing multi-variable linear operators.
in other words matrices and matrix-operations are super useful in maths when we are considering more than one variable.

consequently if you do programming for data science, signal processing, machine learning, etc., you will haveily depend on matrices and matrix operations.

It's literally an array into another array

In pretty much any way you can imagine using them.

>what are 2d arrays used for in programming
Gee wizz I wonder what

They're used a lot in machine learning and statistics when you have multiple variables. Look up multivariate linear regression.

As a structuring element in morphological operations such as erosion and dilation.

Matrices were made easily solvable by computers. Back in the day, using a matrix was the more difficult option to solve things. Now it's easy.

He asked for programming not science. Solving linear equations is not programming, optimization is, but unless you deal with big big problems time is not an issue or you use premade vectorisation instructions or libs.

For programming benchmarks for supercomputers:

usually with BLAS

Non-meme answer:
Transformation function in artificial neutral networks.

just take 3D modeling for example. You are modeling a 3D scene that needs to end up on your 2D screen. You'll need to transform vector spaces to make that happen.

Attached: 1493274847843.png (346x93, 3K)

more like an array OF other arrays

two-dimensional arrays

Hi!

One thing I had to use matrices for in programming recently was to calculate the maximum distance of nodes in a network

there is this thing called an "adjacency matrix", where you have a row and column for each node in your network or graph. every time a node is connected directly to another node, you put a "1" in the matrix.

this by itself only shows you which nodes are directly connected.

now if you use a little bit of linear algebra, you can figure out which nodes are connected indirectly by multiplying the adjacency matrix by itself. So A^2 tells you which nodes are connected via another node, and A^3 which nodes are connected via two other nodes, etc.

If you sum all those up, and it turns out that there are some spots that always remain zero, you have a graph where certain nodes can never be reached.

this is how matrices are still useful in some contexts.

pic related is a sum of adjacency matrices (sigma A^n - min(sigma A^n)). they were multiplied by themselves until the graph was determined to be complete (every vertex is reachable from every other vertex).

Attached: ad_div3_m3.png (276x252, 15K)

Let's say you want to rotate a bunch of points by a given angle. You need to calculate the sine and cosine of that angle (which is slow) and then add and multiply them with the coordinates of each point (which is much faster). You can speed up this operation by hoisting those values out of the loop.
Now let's say you're rotating those points around another point, and then translating them by some other distance. There are several more additions and multiplications that need to take place. You could write them all out by hand, or, to speed things up further, you could premultiply all the parts that are possible to premultiply, leave only the last few steps undone, and hoist all of those coefficients out of the loop like before.
That's what a matrix is: A bunch of coefficients from different equations, premultiplied together so you can hoist them out of a loop. A single matrix can represent an arbitraty sequence of translation and rotation operations in a form that's efficient for using repeatedly on many inputs. It's part of the magic that makes 3D graphics work, which means it's one of the most important reasons for a programmer to know some math. In the end, everything is video games.

You can use a matrix to store the directed edges of a graph with an O(1) lookup time.

Also lookup Floyd's algorithm.

Its just for storing data. You could do math with them if you want. I dont use them, its not something you would nornally use in oop

no son, that's called an array.

I use lists. I very rarelt use arrays

And yes i know lists are implementations of arrays but i wouldnt call lists matricies

But he's correct, a matrix is a thing that might be represented by an array but it could also be another data structure. What makes it a matrix are high level semantics.

The word array is actually slightly ambiguous. But most people take it to mean an indexed contiguous array of objects in memory. So lists are not implementations of arrays.

I think the List class uses arrays for its opperation is what i meant. I havent decompiled it but i would be surprised if i didnt see arrays and sorts in it

Attached: 27hywl.jpg (500x627, 106K)

machine learning, 3d graphics, image processing just to name a few

Does a matrix apply here?

Attached: Screenshot_2017-04-04_12-14-36.png (1016x578, 40K)

>he doesn't know his indexed matricial operations

Simplex method
Massive scale weather modelling

yes. load into a matrix, fill nulls with 9999 or something, and apply A*.

anything u use algebra for is probably using matrices desu

>all these fucking insufferable cs grad retards calling matrices arrays of arrays
kill yourselves

Attached: 1520890351527.png (836x1136, 297K)

I just don't want to be looked down upon, what do i need to do as a cs student for that? :(

Here's a list of a few things.
>Cryptography
>Graphics
>Supercomputing/Scientific computing
>Numerical Analysis

this all very nice and interesting but please stop putting every statement into a new line. thanks for the somewhat interesting input reddit

>Does a matrix apply here?

you could use a 2D array for the data structure, but you don't have to, and certainly not a matrix in the LinAlg sense:
- make another of triangle data structure that also stores a bool for tracking left/right
- start at the next to bottom row
- increment each cell in the row by the value of the larger of its two "children" elements below and track if bigger was on left/right side
- go to next row up, repeating till at the top
- congrats, the top element now stores the max path sum, and you have a chain of left/right values to follow to the bottom to yield that

int a[10][10];

thats a 2d array its a 10 rolls 10 columns you could do a 3d array following the same logic.

matrix math dominates low level graphics programming, specifically shaders, which is more than half of low level graphics programming.

And they also multip-

ITT: CS Brainlets think multidimensional array === Matrix

Attached: 1436495656115.jpg (570x587, 43K)

dynamic programming, no?
so you can, or you can just keep the last row, IIRC

y? are you a phoneposter?

some math problems are equivalent to solving a linear system i.e Ax=b see the finite elements method