Skip to content

Commit

Permalink
Add LU Dekomposition to my BaseMatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWandererProductions committed Jun 5, 2024
1 parent ddd52d2 commit bb82c4c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Mathematics/BaseMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// ReSharper disable UnusedMember.Global

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using ExtendedSystemObjects;

Expand Down Expand Up @@ -182,6 +183,26 @@ public BaseMatrix Inverse()
return new BaseMatrix(result);
}

/// <summary>
/// Lus the decomposition.
/// </summary>
/// <returns>Key Value Pair of L and U Matrix</returns>
/// <exception cref="System.NotImplementedException"></exception>
public KeyValuePair<BaseMatrix, BaseMatrix> LuDecomposition()
{
if (Height != Width)
{
throw new NotImplementedException(MathResources.MatrixErrorInverseNotCubic);
}

var (l, u) = MatrixInverse.LuDecomposition(Matrix);

var lMatrix = new BaseMatrix(l);
var uMatrix = new BaseMatrix(u);

return new KeyValuePair<BaseMatrix, BaseMatrix>(lMatrix, uMatrix);
}

/// <summary>
/// Determinants this instance.
/// </summary>
Expand Down

0 comments on commit bb82c4c

Please sign in to comment.