Visual BasicTM Routine for In-Place Matrix Inversion

A modified version of the Gauss-Jordan algorithm for performing In-Place matrix inversion without using an augmenting unit matrix was described in a previous article by the author. He had also developed several Structural Engineering softwares during his career using that method as their analysis engine. He chose matrix inversion because it was suitable for in-core solution of large numbers of vectors for the same set of equations as encountered in structural analysis of moving, dynamic and seismic loadings. The purpose of this article is to provide its readers with its theoretical background and detailed computations of an In-Place matrix inversion task as well as a Visual Basic routine of the algorithm for direct incorporation into Visual Basic 6 softwares and Visual Basic for Applications macros in MS-Excel spreadsheets to save them time and effort of software development.


Introduction
Gauss-Jordan is a standard matrix inversion procedure developed in 1887 [1].It requires the original matrix to be appended by a unit (identity) matrix and after the inversion operation is completed the original matrix is transformed into a unit matrix while the appended unit matrix becomes the inverse.
A detailed description of the original Gauss-Jordan method as well as its comparison with the author's In-Place version which does not require the aug-D.DasGupta DOI: 10.4236/am.2018.93018241 Applied Mathematics menting matrix and the reason for its development were previously published by him in another article [2].
This paper reproduces relevant parts of that article appended by the computational details of an example and a Visual Basic routine.

Mathematics
The author has used certain terms in the following discussion which are defined as follows: Normalization is dividing an entire row by its pivotal element to transform the pivotal element to unity; Virtualization is replicating an element or a vector of the current augmenting matrix within the original matrix space without creating the real unit matrix; the Complementary of a component of the original matrix is its corresponding component in the virtual augmenting matrix and the Reduction of a row is the modification of the pivotal row by the ratio of the row element on the pivotal column and the pivotal element and then subtracting it from the row, thereby reducing the row element on the pivotal column to zero.
Unlike the classical Gauss-Jordan method, the author's In-Place Inversion algorithm does not require augmenting with and performing operations on an identity matrix and the procedure is described below: Just as with Gauss-Jordan, the following two operations are iterated on all rows to obtain the inverse.
Operation 1: The unpivoted row with the largest absolute diagonal element is selected as the pivotal row p and the value of its pivotal element  This procedure implicitly duplicates the functionality of the unit matrix of the Gauss-Jordan method within the original matrix.After performing these two operations on every row, treating each row once as a pivotal row, the original matrix is replaced by its inverse.
The sequence of operations 1 and 2 can be reversed but in that case the pivotal element , p p

A
will not be unity during operation 2 and the explicit formula will have to be used, thereby substantially increasing the amount of computation.
Solutions of the same example by both Gauss-Jordan and In-Place algorithms are given in the Author's original article for comparison purposes and hence are not reproduced here.
Computational details of a 3 × 3 matrix [3] as well as a Visual Basic subroutine with a sample calling routine are given below.It is equally useful for VB6 programs as well as a VBA routine in MS-Excel TM spreadsheets.Conversion of the routine into other languages is also quite simple.

Computational Details of In-Place Inversion of a 3 × 3 Matrix [3]
Initialization

Conclusion
During the early years of his career the author had developed a number of Structural Engineering softwares in India using his In-Place Inversion method as their analysis engine in FORTRAN language for mainframe applications.He later developed Microsoft TM QuickBasic, Compiled Basic, Visual Basic 6 (VB6) [4] [5] and Visual Basic for Applications (VBA) [6] versions of the inversion routine in the USA for PC-based engineering applications [7] [8] and spreadsheets, the last one of which has been presented here.The purpose of this article is to provide its readers with a ready-to-incorporate subroutine for VB6 softwares and MS-Excel TM spreadsheets and even if Visual Basic is phased out in future [9], it may still remain useful as a template for scientific and engineering software developers to create equivalent routines in other languages.
the original matrix after normalization of the pivotal row.
of active row with highest diagonal has been determined ' and the value of its diagonal element has been stored as Pivot ' Reset Index of the row with highest diagonal to Processed and its ' diagonal element to Unity to reduce truncation error.blnRowProcessed(iBig) = True dPivot = arrMatrix(iBig, iBig) arrMatrix(iBig, iBig) = 1! ' Divide the entire Pivotal row with Pivot For jCol = 1 To iNmat arrMatrix(iBig, jCol) = arrMatrix(iBig, jCol)