This program takes a matrix as input along with a number, and calculates the matrix resulting from multiplying each element of the matrix by the given number.
- Run the program.
- Enter the number of rows and columns for the matrix.
- Enter the elements of the matrix.
- The entered matrix will be displayed.
- Enter the number to multiply the matrix.
- The resulting matrix after multiplication will be displayed.
To perform scalar multiplication, it is enough to multiply that number in each matrix and form a new matrix with the results. A number that is multiplied by a matrix is called a "scalar". Multiplication of a scalar number in a matrix is also called scalar multiplication.
Suppose we have the following matrix:
A = [[ 2 , 4 ],
[ 1 , 3 ]]
And we want to multiply it by the number 3: ===> Scalar number = 3
The calculation would be as follows:
3.A = 3. [[ 2 , 4 ], = [[ 3x2 , 3x4 ],
[ 1 , 3 ]] [ 3x1 , 3x3 ]]
The resulting matrix after multiplication would be:
Scalar matrix = [[ 6 , 12 ],
[ 3 , 9 ]]