| Matrix and Vector Operations
An EngineersToolbox Calculation Module |
|
Background Information This module solves a number of common problems in computational linear algebra, including:
In general, the module takes a matrix A and a matrix B as input, and returns a matrix C containing the results of the specified operation. Matrix Addition and Subtraction Additions and subtractions can only be performed on matrices of the same order. The resulting matrix C will be of the same order as matrix A and matrix B.
Matrix Multiplication The multiplication of matrices A and B can only be performed if the matrices are conformable; that is, the number of columns in matrix A is equal to the number of rows in matrix B. The resulting matrix C has the same number of rows as matrix A and the same number of columns as matrix B.
Transpose of a Matrix The transpose of a matrix is obtained by interchanging the rows and columns of the matrix. The resulting matrix C will have a number of rows that is equal to the number of columns in matrix A, and a number of columns that is equal to the number of rows in A.
Determinant of a Matrix The determinant is a scalar value function of a square matrix. The resulting matrix C will contain a single element.
Matrix Inversion Only square matrices can be inverted. The resulting matrix C will have the same dimensions as the input matrix A.
LU Decomposition A square input matrix A can be represented as a product of two matrices,
where L is lower triangular (only has elements on the diagonal and below) and U is upper triangular (only has elements on the diagonal and above). For example:
The resulting matrix C contains both the elements of L and U, with the diagonal elements of L implicitly defined as 1.0. For example, assuming a 3x3 matrix:
where:
and
Solving a Linear Set of Equations The calculation of x in A·x = B assumes that A is a square matrix and B is a column vector. Additionally, A and B must be conformable; that is, the number of columns in matrix A is equal to the number of rows in vector B. The resulting column vector C contains the elements of x. For example:
Eigenvalues and Eigenvectors Calculation of the eigenvalues l and eigenvectors f of the generalized eigenproblem A·f = l·B·f requires that A and B be square matrices of the same order n. If eigenvalues are requested, the resulting matrix C will contains the n calculated eigenvalues:
If eigenvectors are requested, the resulting matrix C will contain the n calculated eigenvectors:
Dot Product The dot product is a scalar function of two vectors of equal length. The resulting matrix C will contain a single element.
Cross Product The cross product is a vector function of two vectors of length 3. The resulting matrix C will be a vector of length 3.
Module Input The Matrix and Vector Operations main input form, shown in Figure 1, provides basic instructions for using the module. The matrix worksheet looks and operates much like a conventional spreadsheet. It allows you to enter numeric data in a tabular format. To define the A matrix, simply highlight a group of cells in the worksheet and press Ctrl+A. The selected cells will be marked in blue. Any blank cells will be interpreted as zeros. To define the B matrix, highlight a group of cells press Ctrl+B. The selected cells will be marked in red. Once again, blank cells will be interpreted as zeros. To perform a matrix calculation, select a cell in an open region of the worksheet and click the Calculate button. The calculation menu shown in Figure 2 will be displayed on the screen. Select the desired calculation and click OK. The calculated result will be entered in the worksheet at the selected location as shown in Figure 3. The module will warn you if the selected location for the result matrix will overwrite data contained in Matrix A or Matrix B. The module will also warn you if there is not enough room to paste the result at the specified location.
Figure 1. Matrices A and B marked in the worksheet
Figure 2. User selects open cell on worksheet and clicks on the Calculate button
Figure 3. Results are posted at the selected cell
Module Results The results matrixis displayed using the standard ETBX results report shown in Figure 4.
Figure 3. Matrix and Vector Operations results report
References
|
| Help Contents | Module Library | Copyright © 2001-2008
Engrasp, Inc. All rights reserved. |