Matrix Flashcards

1
Q

Matrix multiplication

A

| t11 |
t21
| t32 | =

| M11 |
| M12 |

M11 = r11× t11  +  r12× t21  +   r13×t31
M12 = r21× t11  +  r22× t21   +  r23×t31

r11 r12 r13 |
| r21 r22 r23 | X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Matrix Addition

A

Two matrices can be added only if they have the same dimensions. The elements at similar positions get added.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Transpose of Matrix

A

Swap the elements at position i, j with j, i. But, for every row traversal, j should start 1 cell ahead of i.

1 1 1 1 1234 1234
2222 -> 1222 -> 1234
3333 1333 1234
4444 1444 1234

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Rotate by 90 degrees (anti-clock)

A
def rotateby90(a, n):
    # Your code here
    # T: a[i][j]
    # L: a[n-j-1][i]
    # B: a[n-i-1][n-j-1]
    # R: a[j][n-i-1]
    # No of layers in the matrix
    for i in range(0,n//2): 
        # go upto to last element in the square-1
        for j in range(i,n-i-1):
        t = a[i][j]
        a[i][j] = a[j][n-i-1]
        a[j][n-i-1] = a[n-i-1][n-j-1]
        a[n-i-1][n-j-1] = a[n-j-1][i]
        a[n-j-1][i] = t
How well did you know this?
1
Not at all
2
3
4
5
Perfectly