-
Notifications
You must be signed in to change notification settings - Fork 0
Matrix
Patrick S. Tawil edited this page Apr 26, 2018
·
2 revisions
There are many ways you can initialize Matrices in Stats.NET
var MultiDimArray = new double[,]
{
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
};
var testMatrix = new Matrix(MultiDimArray);var JaggedArray =
{
new double[]
{
1, 2, 3, 4, 5
},
new double[]
{
6, 7, 8, 9, 10
},
new double[]
{
11, 12, 13, 14, 15
}
};
var testMatrix = new Matrix(JaggedArray); var rowOne = new List<double>() { 1, 2, 3, 4, 5 };
var rowTwo = new List<double>() { 6, 7, 8, 9, 10 };
var rowThree = new List<double>() { 11, 12, 13, 14, 15 };
var rows = new List<List<double>>() { rowOne, rowTwo, rowThree };
var testMatrix = new Matrix(rows);All these matrices have 3 rows and 5 columns and here is their visual representation
var mat1= new double[,]
{
{1, 2},
{14, 15}
};
var mat2= new double[,]
{
{5, 7},
{13, 2}
};
var firstMatrix = new Matrix(mat1);
var secondMatrix = new Matrix(mat2);
//Addition
var addedMatrix = firstMatrix + secondMatrix;
var addedMatrix = firstMatrix.Add(secondMatrix);
//Subtraction
var subtractedMatrix = firstMatrix - secondMatrix;
var subtractedMatrix = firstMatrix.Subtract(secondMatrix);
//Multiplication (Dot Product)
var prodMatrix= firstMatrix*secondMatrix;
var prodMatrix = firstMatrix.Multiply(secondMatrix);Yet to be implemented
There are two ways to bind your matrices together, by row or by column
//Column Bind
var cbind = firstMatrix.ColumnBind(secondMatrix);Here is its visual representation
//Row Bind
var rbind = firstMatrix.RowBind(secondMatrix);Here is its visual representation


