Posts

Showing posts with the label matrix

Special Matrix

Image
 1. Diagonal Matrix :   For this matrix M[row, column] = 0 for all row != column We can store non zero elements in one dimensional array to avoid storing zeros  2. Lower Triangular Matrix :  M[row, column] = 0 for all row < column M[row, column] = non-zero for all row >= column Non zero element count = 1 + 2 + 3 + ..... n = n(n+1)/2 Zero element count = n^2 - n(n+1)/2 = n(n-1)/2 Row Major Formula Column Major Formula 3. Upper Triangular Matrix M[row, column] = 0 for all row > column M[row, column] = non-zero for all row <= column Non zero element count  = 1 + 2 + 3 + ..... n =  n(n+1)/2 Zero element count  = n^2 - n(n+1)/2 =  n(n-1)/2 4. Symmetric Matrix M[row, column] is Symmetric matrix if M[row, column] = M[column, row] To represent it we can either use Lower Triangular Matrix or Upper Triangular Matrix. 5. Tridiagonal Matrix Total number of elements = n + n-1 + n-1 = 3n - 2 Calculate index when represented in 1 D array   6. ...