(Article) C# Boolean Matrix
Article : C# Boolean Matrix
Boolean Matrix
A Boolean Matrix in C# (also known as a logical matrix) is a useful mathematical tool for complex math operations. A boolean matrix is a number matrix that consists of only 1's and 0's (or true and false). They are useful in a wide range of mathematics.Since .NET Framework does not come with built-in support for matrix math, our boolean matrix C# math library is going to be written from scratch.
Representing the Matrix
The C# matrix will be represented using a multi-dimensional array. Multi-dimensional arrays in C# are denoted by a comma between brackets, such as [,]. There are advantages and disadvantages of using multi-dimensional arrays vs jagged arrays ([][] for example). In our case, multi-dimensional arrays make the C# programming a bit simpler.
Matrix Operations
Our C# Boolean Matrix supports three operations: Meet, Join, and Product. Meet and Join are the simplest matrix operations since they only work between matrices of the same dimensions. Meet "and's" each element between the matrices while Join "or's" them.
Product is a bit more complicated. The product operation is regular matrix multiplication. In a nutshell, only boolean matrices where the number of columns in one is the same as the number of rows in the other can be multiplied.
Matrix Closures
Closures in a boolean matrix as used if the matrix represents a relation. This is something pretty mathy, but C# makes it very simple to program. The closure algorithms included are Reflexive, Symmetric, and Transitive. Transitive closure is the most complex and it uses Warshall's Algorithm to calculate the transitive closure of any boolean matrix...
Courtesy:- vcskicks.com
- guru's blog
- Login or register to post comments

