MATRICES AND MATRIX OPERATIONS: Unit 5
Dr. Wlodzislaw Kostecki
The Papua New Guinea University of Technology (PNGUT)
Department of Electrical and Communication Engineering
Lae, Morobe Province
Papua New Guinea
Copyright © 2000 by Wlodzislaw Kostecki
All rights reserved
-------------------------------------------------------------------
(5) Multiplication of row and column matrices
OBJECTIVES :
• To distinguish between two different structures in Maple : vector and row matrix .
• To provide alternative methods of defining and inputting vectors with Maple .
• To show how to convert a vector to a row matrix .
• To show how to convert a vector to a column matrix .
• To provide alternative methods of defining and inputting row matrices with Maple .
• To show how to convert a row matrix to a vector .
• To provide alternative methods of defining and inputting column matrices with Maple .
• To show how to convert a column matrix to a vector .
• To provide examples of multiplication of a row matrix and a column matrix.
• To provide examples of multiplication of a column matrix and a row matrix.
> restart : with(linalg, multiply) :
It should be noted that although the function vector belongs to the linalg package, it need not be specified under the with(linalg) command since this function is also included in Maple ’ s main library.
N.B. In textbooks, the names "row matrix" or "row vector" and "column matrix" or "column vector" are used interchangeably. In Maple , a row matrix and a vector are different objects and the name "vector" denotes in Maple a "row vector". There is no object called "column vector" in Maple . Instead, the name column matrix is used for the structure implied.
For example, consider
-
element
row and column structures of this kind.
• A (row) vector is defined and input using any of the following four methods:
> RV := array([a, b, c]) : RV = eval(RV) ;
> RV := array(1..3, [a, b, c]) : RV = eval(RV) ;
> RV := convert([a, b, c], vector) : RV = eval(RV) ;
> RV := vector(3, [a, b, c]) : RV = eval(RV) ;
N.B. Alternatively, the command RV = op(RV) may be used to display the vector.
* * *
N.B.
Application of the
convert
function together with the form name
list
and function
matrix
to the above
-element
vector
returns a
(
×
)
row matrix
, viz.
> RM := matrix(1, 3, convert(RV, list)) : RM = matrix(RM) ; type(RM, matrix) ;
The
Boolean
value
returned by the type-checking function
type
verifies that [
RM
] is a
matrix
.
* * *
N.B.
Application of the
convert
function together with the form name
matrix
to the above
-element
vector
returns a
(
×
)
column matrix
, viz.
> CM := convert(RV, matrix) : CM = matrix(CM) ; type(CM, matrix) ;
The
Boolean
value
returned by the type-checking function
type
verifies that [
CM
] is a
matrix
.
* * *
•
A
(
×
)
row matrix
is defined and input using any of the following
four
methods:
> RM := array([ [a, b, c] ]) : RM = matrix(RM) ;
> RM := convert([ [a, b, c] ], matrix) : RM = matrix(RM) ;
> RM := matrix(1, 3, [a, b, c]) : RM = matrix(RM) ;
> RM := matrix([ [a, b, c] ]) : RM = matrix(RM) ;
* * *
N.B. Triple application of the convert function together with the form names set , list , and vector to the above row matrix returns a (row) vector , e.g.
> RV := convert(convert(convert(RM, set), list), vector) : RV = eval(RV) ; type(RV, vector) ;
The
Boolean
value
returned by the type-checking function
type
verifies that [
RV
] is a (row)
vector
.
* * *
•
A
(
×
)
column matrix
is defined and input using any of the following
four
methods:
> CM := array([ [a], [b], [c] ]) : CM = matrix(CM) ;
> CM := convert([ [a], [b], [c] ], matrix) : CM = matrix(CM) ;
> CM := matrix(3, 1, [a, b, c]) : CM = matrix(CM) ;
> CM := matrix([ [a], [b], [c] ]) : CM = matrix(CM) ;
* * *
N.B. Application of the convert function together with the form name vector to the above column matrix returns a (row) vector , e.g.
> RV := convert(CM, vector) : RV = eval(RV) ; type(RV, vector) ;
The
Boolean
value
returned by the type-checking function
type
verifies that [
RV
] is a (row)
vector
.
* * *
N.B. Conversion of a row matrix to a column matrix and vice versa is simplest using the transposition operation.
[ For the transpose of a matrix, refer to Unit (10). ]
* * *
A . Multiplication of a row matrix and a column matrix
According to the multiplication conformability rule, the product of a
(
×
)
row matrix
[
RM
] and an
(
×
)
column matrix
[
CM
] is possible only, if the number of columns in the row matrix is equal to the number of rows in the column matrix, i.e.
. The result is a
scalar
(number), which is displayed in
Maple
as a
(
×
)
matrix. This special form of product is called either the
inner
product or the
scalar
product of a
row matrix
and a
column matrix
. [ Refer also to Unit (4) for the concept of inner product used in a similar sense. ]
For example, consider a
(
×
)
row matrix [
RM
] given as
> RM := matrix(1, 3, [rm[11], rm[12], rm[13]]) : RM = matrix(RM) ;
and a
(
×
)
column matrix [
CM
] given as
> CM := matrix(3, 1, [cm[11], cm[21], cm[31]]) : CM = matrix(CM) ;
The product [
RM
] [
CM
] is the following
(
×
)
matrix:
> `RM CM` := multiply(RM, CM) : RM*CM = matrix(`RM CM`) ;
To convert the resultant matrix to the corresponding scalar (number), extract the matrix element using the subscript notation:
> `RM CM` := `RM CM`[1,1] : RM*CM = `RM CM` ;
This matrix multiplication may be displayed in "like-in-a-book" form, namely
> matrix(RM) * matrix(CM) = `RM CM` ;
* * *
N.B. The product of a (row) vector and a column matrix returns a single-element vector , which is displayed by Maple in a similar way. By convention, it is also a scalar .
* * *
Numerical example of multiplication of a row matrix and a column matrix
Let a
(
×
)
row matrix [
RM
] and a
(
×
)
column matrix [
CM
] be given as
> RM := matrix(1, 3, [1, -1, 2]) : CM := matrix(3, 1, [2, 1, -3]) : RM=matrix(RM) ; CM=matrix(CM) ;
The product [
RM
] [
CM
] is the following
(
×
)
matrix:
> `RM CM` := multiply(RM, CM) : RM*CM = matrix(`RM CM`) ;
Conversion to scalar yields
> `RM CM` := `RM CM`[1,1] : RM*CM = `RM CM` ;
or, in "like-in-a-book" form,
> matrix(RM) * matrix(CM) = `RM CM` ;
B . Multiplication of a column matrix and a row matrix
According to the multiplication conformability rule, the product of an
(
×
)
column matrix
[
CM
] and a
(
×
)
row matrix
[
RM
] is possible only, if the number of rows in the column matrix is equal to the number of columns in the row matrix, i.e.
. The product matrix is a
square matrix
of order
(
×
)
or
(
×
)
.
For example, consider the same
(
×
)
column matrix [
CM
] and the
(
×
)
row matrix [
RM
] with symbolic elements, as defined in Section
A
of this Unit.
> CM := matrix(3, 1, [cm[11], cm[21], cm[31]]) : RM := matrix(1, 3, [rm[11], rm[12], rm[13]]) :
The product [
CM
] [
RM
] is the following
(
×
)
matrix:
> `CM RM` := multiply(CM, RM) : `CM RM` = matrix(`CM RM`) ;
This matrix multiplication may be displayed in "like-in-a-book" form, namely
> matrix(CM) * matrix(RM) = matrix(`CM RM`) ;
* * *
N.B. An attempt to multiply a column matrix and a (row) vector results in an error message.
* * *
Numerical example of multiplication of a column matrix and a row matrix
Let a
(
×
)
column matrix [
CM
] and a
(
×
)
row matrix [
RM
] be given as before, i.e.
> CM := matrix(3, 1, [2, 1, -3]) : RM := matrix(1, 3, [1, -1, 2]) : CM=matrix(CM) ; RM=matrix(RM) ;
The product [
CM
] [
RM
] is the following
(
×
)
matrix:
> `CM RM` := multiply(CM, RM) : `CM RM` = matrix(`CM RM`) ;
or, in "like-in-a-book" form,
> matrix(CM) * matrix(RM) = matrix(`CM RM`) ;
* * *
Proceed to Unit (6) for " Multiplication of a multi-row multi-column matrix and a column matrix ".
-------------------------------------------------------------------