What Is Diagonal Matrix in Data Structure?

//

Heather Bennett

A diagonal matrix is a special type of square matrix where all the elements outside the main diagonal are zero. The main diagonal of a matrix consists of elements that have the same row and column index. In other words, a diagonal matrix has non-zero elements only on its main diagonal, and all other elements are zero.

Properties of Diagonal Matrix

A diagonal matrix has several interesting properties:

  • 1. Scalar Multiplication: When you multiply a scalar value by a diagonal matrix, each element on the main diagonal is multiplied by the scalar, while all other elements remain zero.
  • 2.

    Addition and Subtraction: Adding or subtracting two diagonal matrices is as simple as adding or subtracting their corresponding elements on the main diagonals.

  • 3. Matrix Multiplication: Multiplying two diagonal matrices results in another diagonal matrix, where each element on the main diagonal is obtained by multiplying the corresponding elements from both matrices.

Example

To understand better, let’s consider an example of a 3×3 diagonal matrix:

1   0   0
0   4   0
0   0   -2

In this example, the first element (1) corresponds to row 1 and column 1, second element (4) corresponds to row 2 and column 2, and so on. All other elements outside the main diagonal are zero.

Scalar Multiplication Example

If we multiply this matrix by a scalar value of 3:

3 * (1   0   0)
    (0   4   0)
    (0   0   -2)

The resulting matrix will be:

3   0   0
0   12  0
0   0   -6

Addition Example

Let’s consider another example where we add two diagonal matrices:

(1   0   0) + (2   0   0) = (3   0   0)
(0   4   0) + (0   -1  0) = (3   -1  0)
(0   2   -2) + (1    -1 -2) = (1    -1 -4)

Matrix Multiplication Example

Lastly, let’s multiply two diagonal matrices:

(1    0    ) * (4    5 ) = (4    5 )
(     )     * (    -2) = (     )
(      )      * (-6    ) = (-6     )

The resulting matrix will also be a diagonal matrix:

4

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy