# Teach me matrix multiplication!

Right now I am just using like 10+ variables for my AI and like its kind of getting me annoyed cause (dont repeat yourself) but I don’t understand how I can in a sense program a sigma (array in math) to roblox. I’ll give an example. Suppose we have an array of weights ```Lua
local weights = {
0,1,1,0,1,0
}

`````````Lua
local inputs = {
1,0.5
}
``````

I have no idea how to assign the components to be multiplied or divided and im too lazy for khan academy (yet if you guys dont respond fast lol)

1 Like

Something like matrix multiplication I think you could implement with nested for-loops. There are plenty of algorithms online you could use

Sorry I should have also mentioned how are you suppose to get the inverse of a matrix (division)?

I’ve had this bookmark since my junior year. It explains the typical procedures for doing row operations on matrices.

Before multiplying a matrix you need to know if it is conformable wich means you need to check if the column of the first matrix is equal to the row of the second matrix

A = (0,1,1,0,1,0)
and
B = (1,0,5)

A = 1 * 6 (one row 6 columns)
B = 1 * 3 (one row 3 columns)

so its not conformable, a conformable matrix is for example:
A= (2,1
2,1)
B = (2,
2)

so
A = 2*2 (two rows and two columns)
B = 2,1 (two rows and one column)

If you want to learn that and a lot more:

(its in spanish sorry xd)