This slideshow requires JavaScript.
Category: Computer Science
A Simple and Utilitarian C# Matrix Class by James Pate Williams, BA, BS, MSwE, PhD
We designed and implemented a simple and utilitarian C# matrix class for double precision numbers. The class has the binary matrix operators +, -, *, / which are addition, subtraction, multiplication, and division of two matrices. We also include an operator for multiplication of matrix by a scalar and an operator for dividing a matrix by a scalar. We have included functions to compute the p-norm, p, q-norm, and max norm of a matrix. We also can calculate using truncated infinite series the exponential, cosine, and sine function of a matrix. The exponential and trigonometric functions use a powering function that raises a matrix to a non-negative integral power.
Below is a screenshot of the test Windows Forms application. We execute the four binary matrix operators in the order +, -, *, / e.g. A+B, A-B, A*B, A/B. In order to divide by B, the matrix B must be square and non-singular, that is square and invertible.

The B matrix has the form of the matrix in the online discussion:
http://www.purplemath.com/modules/mtrxinvr2.htm
We create a project named MatrixExample. In this project we add a Matrix class whose code is given below:
I leave it as an exercise for the reader to test the various norms and other functions.