Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public _nMatrix ReturnInverseOfUpperTriangularMatrix(_nMatrix UpperTriangularMatrix)
        {
            var dimN = UpperTriangularMatrix.n;
            var D    = ReturnDiagonalInverseMatrix(UpperTriangularMatrix);
            var copy = CreateCopy(UpperTriangularMatrix);

            copy.ReplaceDiagonalEntriesWithZero(copy);
            copy = D.MultiplyByAnotherMatrix(copy);
            var identityClass = new nIdentityMatrix();
            var identity      = identityClass.ReturnNIdentityMatrix(dimN);

            var temp = copy.MultiplyByScalar(-1);

            for (int i = 2; i < dimN; i++)
            {
                AddNextPowerTermToMatrixSeries(copy, ref temp, i);
            }

            var inverse = identity.AddAnotherMatrix(temp);

            var copyPlus1 = identity.AddAnotherMatrix(copy);
            var Test      = inverse.MultiplyByAnotherMatrix(copyPlus1);

            //var realTest = D.ReturnDiagonalInverseMatrix(D).MultiplyByAnotherMatrix(D).MultiplyByAnotherMatrix(Test);
            return(inverse);
        }
        public _nMatrix ReturnGivensMatrix(double a, double b, int position, int n)
        {
            AssignCS(a, b);
            var identityMatrix = new nIdentityMatrix();
            var matrix         = identityMatrix.ReturnNIdentityMatrix(n);

            //matrix.SetValueAt(position, position, c);
            //matrix.SetValueAt(position + 1, position, s_0);
            //matrix.SetValueAt(position + 1, position + 1, c);
            //matrix.SetValueAt(position, position + 1, s);
            return(matrix);
        }
Пример #5
0
        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);
        }
Пример #6
0
        public _nMatrix ReturnDiagonalInverseMatrix(_nMatrix matrix)
        {
            int dim = matrix.n;
            var identityMatrixClass = new nIdentityMatrix();
            var inverseMatrix       = identityMatrixClass.ReturnNIdentityMatrix(dim);

            for (int i = 0; i < dim; i++)
            {
                inverseMatrix.SetValueAt(i + 1, i + 1, (1 / matrix.rows[i].vector[i]));
            }

            return(inverseMatrix);
        }