Skip to content

JamesMenetrey/Matrix.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matrix.NET

A .NET implementation of matrices and their operations.

Mathematical definition

In mathematics, a matrix (plural matrices) is a rectangular array of numbers, symbols, or expressions. The numbers, symbols or expressions in the matrix are called its entries or its elements. The horizontal and vertical lines of entries in a matrix are called rows and columns, respectively.

From Wikipedia.

Matrices are commonly written in box brackets or large parentheses:

matrix definition image

API usage

Matrices creation

Using static elements

A matrix can be created using a multidimentional array of elements.

var elements = new[,]
{
    {1, 0, 0},
    {0, 1, 0},
    {0, 0, 1}
};

matrix = new Matrix<int>(elements);

This creates an identity matrix of size 3.

Using a builder method

A matrix can be created using a builder method, delegating the process of creating the set of elements to another object.

Func<int, int, int> delegateBuilder = (i, j) => i == j ? 1 : 0;

matrix = new Matrix<int>(3, 3, delegateBuilder);

This creates an identity matrix of size 3.

Interacting with elements

Retrieving

The elements can be reteieved using the indexer of the matrix object.

var i = 0, j = 0;

var firstElement = matrix[i, j];

Number of columns/rows

var ith = matrix.NumberOfRows;
var jth = matrix.NumberOfColumns;

Basic operations

Addition

var sum = matrix1 + matrix2;

Multiplication by a scalar value

var product = matrix * scalarValue;

Multiplication by matrices

var matrixResult = matrixLeft * matrixRight;

Code convention

The project is written in respect of the rules normalized by Microsoft for C# programming and ReSharper convention. Please, be compliant to those rules when contributing.

Testing

The project is written in respect of the principles of Test Driven Development. Please, think to add unit tests for your code when contributing.

Author

The code is written Jämes Ménétrey (aka ZenLulz) in the context of mathematics courses teached in the University of Applied Sciences Western Switzerland.

About

A .NET implementation of matrices and their operations in linear algebra.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages