コード例 #1
0
        private static SymmetricMatrix <T> Add <T>(DiagonalMatrix <T> lhs, SymmetricMatrix <T> rhs)
        {
            var result = new SymmetricMatrix <T>(rhs);

            for (int i = 0; i < lhs.Order; i++)
            {
                result[i, i] = (dynamic)lhs[i, i] + (dynamic)result[i, i];
            }

            return(result);
        }
コード例 #2
0
        private static DiagonalMatrix <T> Add <T>(DiagonalMatrix <T> lhs, DiagonalMatrix <T> rhs)
        {
            var resultArray = new T[lhs.Order];

            for (int i = 0; i < lhs.Order; i++)
            {
                resultArray[i] = (dynamic)lhs[i, i] + (dynamic)rhs[i, i];
            }

            return(new DiagonalMatrix <T>(resultArray));
        }
コード例 #3
0
        private static SquareMatrix <T> Add <T>(SquareMatrix <T> lhs, DiagonalMatrix <T> rhs)
        {
            var result = new SquareMatrix <T>(lhs);

            for (int i = 0; i < result.Order; i++)
            {
                result[i, i] = (dynamic)result[i, i] + (dynamic)rhs[i, i];
            }

            return(result);
        }
コード例 #4
0
        /// <summary>
        /// Create clone of diagonal matrix.
        /// </summary>
        /// <returns>Clone of diagonal matrix.</returns>
        public new DiagonalMatrix <T> Clone()
        {
            DiagonalMatrix <T> diagonalMatrix = new DiagonalMatrix <T>(this.Height);

            for (int i = 0; i < this.Height; i++)
            {
                diagonalMatrix[i, i] = this[i, i];
            }

            return(diagonalMatrix);
        }
コード例 #5
0
        public static DiagonalMatrix <T> Add <T>(this DiagonalMatrix <T> leftMatrix, DiagonalMatrix <T> rightMatrix)
        {
            DiagonalMatrix <T> result = leftMatrix.Clone();

            for (int i = 0; i < result.Width; i++)
            {
                dynamic value = rightMatrix[i, i];
                result[i, i] += value;
            }

            return(result);
        }
コード例 #6
0
        private static Matrix <T> InitializeResultMatrix <T>(Matrix <T> lhs, Matrix <T> rhs)
        {
            Matrix <T> result;

            if (lhs.GetType() == typeof(SquareMatrix <T>) || rhs.GetType() == typeof(SquareMatrix <T>))
            {
                result = new SquareMatrix <T>(lhs.Order);
            }
            else if (lhs.GetType() == typeof(SymmetricalMatrix <T>) || rhs.GetType() == typeof(SymmetricalMatrix <T>))
            {
                result = new SymmetricalMatrix <T>(lhs.Order);
            }
            else
            {
                result = new DiagonalMatrix <T>(lhs.Order);
            }

            return(result);
        }
コード例 #7
0
ファイル: Addition.cs プロジェクト: denisoda/EPAM
 /// <summary>
 /// finds sum with diagonal matrix
 /// </summary>
 /// <param name="matrix">diagonal matrix which is added to existing matrix</param>
 /// <returns>new square matrix as result of sum two matrixes</returns>
 public SquareMatrix <T> Visit(DiagonalMatrix <T> matrix) => Sum(matrix);
コード例 #8
0
 private static void Sum <T>(DiagonalMatrix <T> matrix, DiagonalMatrix <T> addedMatrix)
 {
     SumDiagonalElements <T>(matrix, addedMatrix);
 }
コード例 #9
0
 private static SquareMatrix <T> Add <T>(DiagonalMatrix <T> lhs, SquareMatrix <T> rhs) => Add(rhs, lhs);
コード例 #10
0
 private static SymmetricMatrix <T> Add <T>(SymmetricMatrix <T> lhs, DiagonalMatrix <T> rhs) => Add(rhs, lhs);