Technical ReportPDF Available

Heterogeneous Dimensional Analysis for Vector and Matrix Operations

Authors:

Abstract

While dimensional analysis is known to be useful in discovering potential logical inconsistency in scalar equations, there has not been significant effort to extend this analysis to vectors and matrices that use units. When vectors and matrices operate on measurements that contain units, dimensional analysis can uncover logical problems not just in the equations, but in individual operations within the equations, as operations that might be logically consistent when operating on dimensionless quantities are not necessarily logically consistent when operating on quantities describing real-world measurements. This paper discusses some applied research in dimensional analysis in common vector and matrix operations.
Tech. Rep. DC-2020-01 Approved for Public Release: Distribution Unlimited (Case Number: AFRL-2021-0082) 1
Heterogeneous Dimensional Analysis for Vector and Matrix
Operations
Ashlie B. Hocking
Dependable Computing
Charlottesville, VA, USA
ben.hocking@dependablecomputing.com
Will Hawkins
Dependable Computing
Charlottesville, VA, USA
will.hawkins@dependablecomputing.com
AbstractWhile dimensional analysis is known to be
useful in discovering potential logical inconsistency in
scalar equations, there has not been significant effort to
extend this analysis to vectors and matrices that use
units. When vectors and matrices operate on
measurements that contain units, dimensional analysis
can uncover logical problems not just in the equations,
but in individual operations within the equations, as
operations that might be logically consistent when
operating on dimensionless quantities are not
necessarily logically consistent when operating on
quantities describing real-world measurements. This
paper discusses some applied research in dimensional
analysis in common vector and matrix operations.
Keywords: dimensional analysis; Kalman filters
Introduction
While dimensional analysis is known to be useful in
discovering potential logical inconsistency in scalar
equations, there has not been significant effort to
extend this analysis to vectors and matrices that use
units. When operators act on vector and matrix
measurements that contain units, dimensional analysis
can discover logical problems not just in the
equations, but in individual operations within the
equations, as operations that might be logically
consistent when operating on dimensionless quantities
are not necessarily logically consistent when
operating on quantities describing real-world
measurements. This paper discusses applied research
in dimensional analysis in common vector and matrix
operations. Vectors and matrices can either have
elements that all have the same units (homogenous),
or different elements can have different units
(heterogeneous).
Convention
While dimensional analysis primarily focuses on base
quantities such as length, mass, and time, rather than
units such as meters, kilograms, and seconds, we will
commonly be referring to the units of elements of
vectors and matrices rather than the dimensions of
those elements. The rationale for this convention here
is twofold: first, when modelling software such as
Simulink ignores units, there is an implicit assumption
that units for different measurements have identical
scaling factors (Hocking and Aiello 2017), and
second, the word dimensions when dealing with
matrices can be confused with the size of the matrices.
In this paper, we will follow the notation used by
Palanthandalam-Madapusi et al. (2007) of using
square brackets around terms to refer to the physical
dimensions of the term, so that  can either
refer to the units m/s or to the dimensions ,
depending on context. We will also use bold to
indicate a term is a matrix (), and an arrow to indicate
a term is a vector (
). Finally, when variable
subscripts appear in an equation, an implicit universal
quantifier exists unless otherwise specified, so that
is equivalent to 

Motivating Example
A motivating example for vectors and matrices
composed of differing units is a Kalman filter
(Meinhold and Singpurwalla 1983). Kalman filters
take a state estimate vector (), an actuator vector (
),
a state transition matrix (), a matrix describing the
effect of the actuators on the state (), an estimate of
error covariance (), and a process noise matrix ()
to generate a new state estimate vector. A Kalman
filter computes exact quantities for the conditional
mean vector for linear systems with additive
Gaussian noise governed by the dynamic equations:

(1)
(2)
Tech. Rep. DC-2020-01 Approved for Public Release: Distribution Unlimited (Case Number: AFRL-2021-0082) 2
The quantities , , and are matrices that can
change over time. The process noise
is assumed to
have zero mean and covariance , and the
measurement noise is assumed to have zero mean and
covariance . Kalman filters have two stages,
predict and update.
The prediction stage of a Kalman filter produces
the a priori estimate of the state
 

(3)
based on the system dynamics in equation (1) and the
a priori estimate of the covariance:
 
.
(4)
The update stage produces the Kalman gain ,
which is a function of both the a priori state
covariance matrix () and the measurement
error covariance matrix ():


.
(5)
The update stage also produces the a posteriori
state estimate , which is updated based on the
difference between the predicted and measured state
values and the a posteriori covariance matrix estimate
:
  
(6)
 
(7)
Of interest to this paper is that each of the vectors
and matrices in a Kalman filter will typically be
composed of elements with heterogeneous units. To
check unit consistency in equations using Kalman
filters means understanding how vectors and matrices
of varying units interact. In addition to the simple
addition and multiplication rules covering vectors and
matrices, Kalman filters rely on transition matrices,
transformation matrices, and matrix inversion.
Dimensional Analysis of Vectors Operations
Measurement vectors can either be all of the same unit
(e.g., a vector describing a location in 3-space) or can
contain a combination of units (e.g., a vector
describing the state of a complex system). For
example, consider the velocity vector v:



(8)
With this homogeneous vector, one can apply the
magnitude operator on , yielding .
However, consider a hypothetical measurement with
heterogenous units:



(9)
With this heterogenous vector, applying the
magnitude operator to is invalid, yet this vector
could legitimately describe a state vector. For the
magnitude operation to be valid, it must be true
that all elements have the same dimensions:
.
(10)
Rules for mathematical operations on vectors of
measurements follow from the rules of operations on
their components, and whether these operations are
valid follow as well. For addition or subtraction of two
vectors, the rule is simple: the vectors must be of the
same size, and each element in one vector must match
the units of the corresponding element in the other
vector. For example, a two element vector whose first
element is measured in meters and whose second
element is measured in seconds can only be added to
another vector whose first element is measured in
meters (or other length unit) and whose second
element is measured in seconds. Formally, for the sum
to be valid,



.
(11)
For dot products, the rule is a little more
interesting: while the vectors elements do not need to
correspond, all pair-wise products must have the same
units. For example, consider the two vectors and
below:


 



(12)
For these two vectors,
 
, but and
are invalid operations. Formally, for the dot
product
to be valid,

.
(13)
Dimensional Analysis of Matrix Operations
As with vectors, the rule for addition is straight-
forward: the matrices must be of the same size in both
dimensions, and each element in one matrix must
match the units of the corresponding element in the
second matrix. For multiplication, the rules are more
complicated. For multiplication between matrix and
Tech. Rep. DC-2020-01 Approved for Public Release: Distribution Unlimited (Case Number: AFRL-2021-0082) 3
matrix to be valid, the following properties of the
two matrices must hold:
(1) The number of columns in must equal the
number of rows in (as with regular
matrices).
(2) The matrices must have elements such that, when
multiplied, the terms being added to form the
resultant matrix have the same units. This means:
(a) For matrix to be multipliable by (cf. Eq.
3 from (Palanthandalam-Madapusi, Bernstein
and Venugopal 2007)), it must be the case that
.
(14)
(b) From (14), by solving for   and
recognizing freedom of choice for , one can
show that for matrix to be multipliable by
any matrix,
.
(15)
Note that equation (15) applies to both
matrices being multiplied, as one can
determine by solving equation (14) for
 
 
Note that in the analysis of whether the matrix
multiplication  is valid, equation (15) only
refers to properties of matrix , and equation (14)
refers to properties of matrix and matrix .
While the commutative property does not hold for
matrix multiplication in general, it is true that with
square unitless matrices if  is a valid operation,
then so is . When considering square matrices with
heterogenous units, however, validity is not
commutative. For example, consider the following
two matrices:
 
 
 


.
(16)
The product  is well defined:
 
 .
(17)
However, the product  violates dimensional
analysis:

  

 .
(18)
Also note that while one can use the following
equivalence when proving properties with unitless
matrices, the equivalence is not valid when
 for some and :
  

 

 .
(19)
One important property of matrix multiplication
that does still hold for matrix measurements is that of
associativity:
.
(20)
Transition Matrices
Transition matrices are matrices that when
multiplied by a vector of size will yield another
vector of size with the same units as the original
vector. Transition matrices must have the following
properties:
(1) Transition matrices must be square matrices.
(2) For transition matrix and state vector ,

,
(21)
Thus, the units of the vector upon which a
transition matrix operates uniquely defines
the units of the transition matrix itself.
(3) From equation (21),

(22)
(4) From equation (22), diagonal elements must be
dimensionless.
(5) Equation (21) also yields

(23)
(6) From equation (23), the units of elements ,
for  uniquely defines the units
of the remaining elements of A. Without
reference to , the units of these elements cannot
be further inferred. Thus, the number of elements
in the matrix that define the units for the
Tech. Rep. DC-2020-01 Approved for Public Release: Distribution Unlimited (Case Number: AFRL-2021-0082) 4
remaining elements in the matrix is
.
(7) From equation (21), if transition matrix can
operate on vector , then can also operate on

, where denotes component-wise
multiplication and
is a vector with homogenous
units. I.e., the units of matrix do not uniquely
define the units of vector .
Note that equations (22) and (23) allow us to verify
whether is a valid transition matrix without
reference to .
Transformation Matrices
Transformation matrices are matrices that
when multiplied by a vector of size will yield a
vector of size with possibly different units. For
example, in a Kalman filter the product 
transforms
a vector describing actuators into a vector describing
states.
Transformation matrices must have the following
properties:
(1) A transformation matrix transposing from a
vector
of size to a vector of size must be
of size (i.e., have rows and columns).
(2) For transformation matrix , vector
to be
transformed, and vector to be transformed into,

.
(24)
(3) From equation (24),


,
(25)
allowing us to describe whether a
transformation matrix can operate on vector
, independent of .
(4) Also from equation (24),


,
(26)
allowing us to describe whether a
transformation matrix can transform a
vector into a type with units matching vector
, independent of
.
(5) Without reference to
or , equation (24) can
also be used to show that a transformation matrix
must have the property that
,
(27)
Matrix Determinant
The determinant of a square measurement matrix is
a valid operation only if
.
(28)
This is the same requirement for a matrix to be
multiplied by another matrix (cf. equation (15)) and
follows directly from the fact that each product in the
sum used to calculate the determinant
(Palanthandalam-Madapusi, Bernstein and Venugopal
2007, 105) is a permutation of another product in the
sum where two terms have their indices swapped as
shown in equation (28).
Matrix Inversion
For matrix of size to be invertible, there has
to exist a matrix  of size such that
 ,
(29)
where is the identify matrix of size .
Invertible matrices must have these properties:
(1) As with dimensionless matrices (Dennery and
Krzywicki 1996), for matrix to be invertible,
,
(30)
(2) The matrix must be able to be multiplied by
another matrix (see equation (15))
Related work
In their paper on dimensional analysis of matrices,
Palanthandalam-Madapusi, Bernstein, and Venugopal
(2007) address similar topics, but with a different
emphasis. The emphasis for their work is on
dimensional analysis of matrices in general, and while
they do address whether the result of several
operations exist (and hence whether the operations are
valid), the operations that they analyze are mostly
distinct from the operations analyzed here.
Tech. Rep. DC-2020-01 Approved for Public Release: Distribution Unlimited (Case Number: AFRL-2021-0082) 5
Additionally, we consider not just whether results for
operations exist for a pair of operands, but also
whether results for an operation can exist for a single
operand regardless of the value of the other operand
(e.g., equations (23) or (27)).
Conclusion
Dimensional analysis on heterogeneous vectors and
matrices allow researchers to identify mistakes in
models prior to using those models in extensive
simulations or to generate code. While dimensional
analysis has historically been used to determine
whether the result of an operation has the correct units,
we have shown that you can also use dimensional
analysis to determine whether the operation is even
valid for heterogeneous units. Additionally, some
dimensional analysis approaches that only analyze
one component of an operation (e.g., equations (23) or
(27)) can determine whether that component is valid
to use in that operation regardless of what the other
component might be. This approach allows us localize
mistakes in the model to where the mistakes most
likely reside.
Acknowledgment
This work was funded by USAF AFRL/RQQA
contract FA8650-17-F-2220.
References
Dennery, Philippe, and André Krzywicki. 1996.
Mathematics for physicists. Mineola, NY, USA:
Courier Corporation.
Hocking, Ashlie B., and M. Anthony Aiello. 2017.
“The Measurement Library: Representing Physical
Types in PVS.” Automated Formal Methods 78-92.
Meinhold, Richard J., and Nozer D. Singpurwalla.
1983. “Understanding the Kalman filter.” The
American Statistician 37 (2): 123-127.
Palanthandalam-Madapusi, Harish J., Dennis S.
Bernstein, and Ravinder Venugopal. 2007.
“Dimensional Analysis of Matrices State-Space
Models and Dimensionless Units [Lecture Notes].”
IEEE Control Systems Magazine 27 (6): 100-109.
ResearchGate has not been able to resolve any citations for this publication.
Article
Full-text available
This is an expository article. Here we show how the successfully used Kalman filter, popular with control engineers and other scientists, can be easily understood by statisticians if we use a Bayesian formulation and some well-known results in multivariate statistics. We also give a simple example illustrating the use of the Kalman filter for quality control work.
Article
Full-text available
Physical dimensions and units, such as mass (kg), length (m), time (s), and charge (C), provide the link between mathematics and the physical world. It is well known that careful attention to physical dimensions can provide valuable insight into relationships among physical quantities. In this regard, the Buckingham Pi theorem, which is essentially an application of the fundamental theorem of linear algebra on the sum of the rank and defect of a matrix, has been extensively applied.
The Measurement Library: Representing Physical Types in PVS
  • Ashlie B Hocking
  • M Anthony Aiello
Hocking, Ashlie B., and M. Anthony Aiello. 2017. "The Measurement Library: Representing Physical Types in PVS." Automated Formal Methods 78-92.