Exemple #1
0
        private _nVector HHStep1_2R(_mnMatrix matrix)
        {
            var resultAfterStep1 = HHStep1_1R(matrix);

            var scalar = (1 / resultAfterStep1.Norm(resultAfterStep1));
            var result = resultAfterStep1.MultiplyByScalar((1 / resultAfterStep1.Norm(resultAfterStep1)));

            return(result);
        }
Exemple #2
0
        private _nVector HHStep1_1R(_mnMatrix matrix)
        {
            var m           = matrix.m;
            var firstRow    = matrix.GetRow(0);
            var coefficient = Sign(firstRow.V(1)) * firstRow.Norm(firstRow);
            var coefficientTimesUnitVector = iComponentVector(m).MultiplyByScalar(coefficient);
            var resultAfterAdd             = coefficientTimesUnitVector.Add(firstRow);

            return(resultAfterAdd);
        }
Exemple #3
0
        public _mnMatrix HouseholderRightSideResult(_mnMatrix mnMatrix, int i, int dim)
        {
            var U      = HHStep1_2R(mnMatrix);
            var result = mnMatrix.MultiplyByVector(U);
            var multiplicationResult = result.mnMatrixTypeMultiplyWithAnotherVector(U);
            var resultTimes2         = multiplicationResult.MultiplyByScalar(2);
            var subtractionResult    = mnMatrix.SubtractAnotherMatrix(resultTimes2);

            if (i > 1)
            {
                AddToVHouseholder(U, subtractionResult, i, dim);
            }
            return(subtractionResult);
        }
Exemple #4
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);
        }
        public static _mnMatrix GetQuadratureMatrix(int steps, double ds, double dt)
        {
            var rows = new List <_nVector>();

            for (int t = 1; t <= steps; t++)
            {
                var doubleList = new List <double>();
                for (int r = 0; r < steps; r++)
                {
                    var temp = ds * Math.Pow(Math.E, (-1) * (ds * r) * (dt * t)); // At a specific time constant.
                    doubleList.Add(temp);
                }
                rows.Add(new _nVector(doubleList));
            }
            var matrix = new _mnMatrix(rows, steps, steps);

            return(matrix);
        }