Example #1
0
        /// <summary>
        /// // At this point U has been calculated including the norm of U being multiplied to U. Therefore, when we multiply U by itself it is in fact the norm times itself , and amounts to VT*V
        /// </summary>
        /// <param name="matrix"></param>
        /// <returns></returns>
        public _nMatrix HouseholderResult(_nMatrix matrix, int i, int dim)
        {
            var U = HHStep1_2(matrix);

            var result = U.MultiplyByMatrix(matrix);
            var multiplicationResult = U.MatrixTypeMultiplyWithAnotherVector(result);
            var resultTimes2         = multiplicationResult.MultiplyByScalar(2);
            var subtractionResult    = matrix.SubtractAnotherMatrix(resultTimes2);

            if (i > 1)
            {
                AddToUHouseholder(U, subtractionResult, i, dim);
            }
            return(subtractionResult);
        }
Example #2
0
        private static void AddNextPowerTermToMatrixSeries(_nMatrix copy, ref _nMatrix temp, int i)
        {
            int remainder = 0;

            Math.DivRem(i, 2, out remainder);
            if (remainder == 0)
            {
                var tmp = MatrixToThePowerN(i, copy);
                //ZeroOutRightUptoI(tmp, i);
                temp = temp.AddAnotherMatrix(tmp);
            }
            else
            {
                var tmp = MatrixToThePowerN(i, copy);
                //ZeroOutRightUptoI(tmp, i);
                temp = temp.SubtractAnotherMatrix(tmp);
            }
        }