public void TestGetDpxAdjGraph() { var testInput = new List<Tuple<RankedMetadataTokenAsm, RankedMetadataTokenAsm[]>>(); var testControl = new[,] { {0, 1, 0, 0}, {1, 0, 1, 0}, {0, 1, 0, 0}, {1, 0, 0, 0} }; const string ASM_NM_PREFIX = "ASM NAME "; for (var i = 0; i < testControl.GetLongLength(0); i++) { var tt = new RankedMetadataTokenAsm { AssemblyName = $"{ASM_NM_PREFIX} {i:00}"}; var ttList = new List<RankedMetadataTokenAsm>(); for (var j = 0; j < testControl.GetLongLength(1); j++) { if (testControl[i, j] == 1) { ttList.Add(new RankedMetadataTokenAsm { AssemblyName = $"{ASM_NM_PREFIX} {j:00}" }); } } testInput.Add(new Tuple<RankedMetadataTokenAsm, RankedMetadataTokenAsm[]>(tt, ttList.ToArray())); } var testResult = NoFuture.Util.Binary.Dpx.GetDpxAdjGraph(testInput); Assert.IsNotNull(testResult); Assert.AreNotEqual(MetadataTokenStatus.Error, testResult.St); Assert.IsNotNull(testResult.Graph); Assert.IsNotNull(testResult.Asms); var trGraph = testResult.Graph; Assert.AreEqual(testResult.Asms.Length, trGraph.GetLongLength(0)); Assert.AreEqual(testControl.GetLongLength(0), trGraph.GetLongLength(0)); Assert.AreEqual(testControl.GetLongLength(1), trGraph.GetLongLength(1)); for (var i = 0; i < testControl.GetLongLength(0); i++) { for (var j = 0; j < testControl.GetLongLength(1); j++) { Assert.AreEqual(testControl[i,j], trGraph[i,j]); } } }
public void TestEigenVectors() { var typicalMatrix = new[,] { {0.8D, 0.3D}, {0.2D, 0.7D} }; var eigenval00 = 1D; //var eigenval01 = 0.5D; //pg 326 Dx = rx (where 'x' is a nX1 matrix, 'n' being dim's of D so for a 3x3 matrix the eigenvector is 3x1) //(D -rI)x = 0 //so all the eigenvalues do is get you closer to guessing what 'x' is //this is the property of eigenvectors that is being sought //https://www.khanacademy.org/math/linear-algebra/alternate_bases/eigen_everything/v/linear-algebra-introduction-to-eigenvalues-and-eigenvectors // " the line that they span will not change" its just extended in the same direction var really = Matrix.Product(typicalMatrix, new double[,] {{0.6D}, {0.4D}}); System.Diagnostics.Debug.WriteLine(really.Print());//yep, this really is the {{0.6D}, {0.4D}} typicalMatrix = new[,] { {2D, 2D}, {2D, -1D} }; eigenval00 = 3D; //eigenval01 = -2D; //so you get this matrix var usedToGuessEigenVector = Matrix.Difference(typicalMatrix, Matrix.Product(Matrix.GetIdentity(typicalMatrix.GetLongLength(0)), eigenval00)); //then you simply have to try various 2x1 matricies which when taken time 'usedToGuessEigenVector' // result in a 2x1 matrix of zeros }