public void AddToUHouseholder(_nVector U, _nMatrix matrix, int i, int dim) // Householder Matrices are correct and functioning { var uMatrix = U.MatrixTypeMultiplyWithMe(); var resultafterUMatrixTimes2 = uMatrix.MultiplyByScalar(2); var identity = new nIdentityMatrix(); var finalHouseholderMatrix = identity.ReturnNIdentityMatrix(i) .SubtractAnotherMatrix(resultafterUMatrixTimes2); var matrixToAdd = identity.ReturnNIdentityMatrix(dim); matrixToAdd.InsertSubMatrix(finalHouseholderMatrix, i); UHouseholderMatrices.Add(matrixToAdd); //var result = matrixToAdd.MultiplyByAnotherMatrix(matrix); }
public void AddToVHouseholder(_nVector V, _mnMatrix mnMatrix, int i, int dim) { var vMatrix = V.MatrixTypeMultiplyWithMe(); var resultafterUMatrixTimes2 = vMatrix.MultiplyByScalar(2); var identity = new nIdentityMatrix(); var finvlHouseholderMatrix = identity.ReturnNIdentityMatrix(i - 1) .SubtractAnotherMatrix(resultafterUMatrixTimes2); var matrixToAdd = identity.ReturnNIdentityMatrix(dim - 1); matrixToAdd.InsertSubMatrix(finvlHouseholderMatrix, i - 1); VHouseholderMatrices.Add(matrixToAdd); //var maybe = matrixToAdd.MultiplyByAnotherMatrix(matrixToAdd.ReturnTranspose(matrixToAdd)); //var result = mnMatrix.MultiplyMeByNMatrix(matrixToAdd); }
public _nMatrix ReturnGivensMatrix(double a, double b, int position, int n) { AssignCS(a, b); var identityMatrix = new nIdentityMatrix(); var matrix = identityMatrix.ReturnNIdentityMatrix(n); return(matrix); }
public _nMatrix Umatrix(int n) { var identity = new nIdentityMatrix(); var UU = identity.ReturnNIdentityMatrix(n); for (int i = n - 2; i >= 0; i--) { var mat = UHouseholderMatrices[i]; UU = UHouseholderMatrices[i].MultiplyByAnotherMatrix(UU); } return(UU); }
public void AssertInsertSquareSubMatrix() { var identityClass = new nIdentityMatrix(); var identity = identityClass.ReturnNIdentityMatrix(6); identity.InsertSubMatrix(subMatrix, 3); Assert.AreEqual(identity.GetValueAt(4, 4), 1); Assert.AreEqual(identity.GetValueAt(5, 5), 4); Assert.AreEqual(identity.GetValueAt(6, 6), 21); Assert.AreEqual(identity.GetValueAt(5, 4), 3); Assert.AreEqual(identity.GetValueAt(6, 4), 5); }
public void BeforeEachTest() { var lista = new List <double>() { 1, 2, 6 }; var lista2 = new List <double>() { 3, 4, 43 }; var lista3 = new List <double>() { 5, 6, 21 }; var veca1 = new _nVector(lista); var veca2 = new _nVector(lista2); var veca3 = new _nVector(lista3); var VecLista = new List <_nVector>(); VecLista.Add(veca1); VecLista.Add(veca2); VecLista.Add(veca3); subMatrix = new _nMatrix(VecLista, 3); var idendityClass = new nIdentityMatrix(); identity = idendityClass.ReturnNIdentityMatrix(6); var list = new List <double>() { 1, 2, 6, 7, 8, 3 }; var list2 = new List <double>() { 3, 4, 43, 23, 1, 22 }; var list3 = new List <double>() { 5, 6, 21, 1, 34, 2 }; var list4 = new List <double>() { 15, 46, 221, 21, 334, 32 }; var list5 = new List <double>() { 15, 46, 21, 31, 34, 12 }; var list6 = new List <double>() { 45, 26, 221, 11, 234, 2 }; var vec1 = new _nVector(list); var vec2 = new _nVector(list2); var vec3 = new _nVector(list3); var vec4 = new _nVector(list4); var vec5 = new _nVector(list5); var vec6 = new _nVector(list6); var VecList = new List <_nVector>(); VecList.Add(vec1); VecList.Add(vec2); VecList.Add(vec3); VecList.Add(vec4); VecList.Add(vec5); VecList.Add(vec6); matrix = new _nMatrix(VecList, 6); var list1 = new List <double>() { 1, 2, 6, 7, 8, 3 }; var list12 = new List <double>() { 3, 4, 43, 23, 1, 22 }; var list13 = new List <double>() { 5, 6, 21, 1, 34, 2 }; var list14 = new List <double>() { 15, 46, 221, 21, 334, 32 }; var list15 = new List <double>() { 2, 3, 4, 5, 6, 7 }; var list16 = new List <double>() { 8, 9, 10, 11, 12, 13 }; var vec11 = new _nVector(list1); var vec12 = new _nVector(list12); var vec13 = new _nVector(list13); var vec14 = new _nVector(list14); var vec15 = new _nVector(list15); var vec16 = new _nVector(list16); var VecList1 = new List <_nVector>(); VecList1.Add(vec11); VecList1.Add(vec12); VecList1.Add(vec13); VecList1.Add(vec14); VecList1.Add(vec15); VecList1.Add(vec16); matrix2 = new _nMatrix(VecList1, 6); }