Exemplo n.º 1
0
        public static QuadraticMatrix <T> Add <T>(this QuadraticMatrix <T> leftMatrix, DiagonalMatrix <T> rightMatrix)
        {
            QuadraticMatrix <T> result = leftMatrix.Clone();

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

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create clone of quadratic matrix.
        /// </summary>
        /// <returns>Clone of quadratic matrix.</returns>
        public QuadraticMatrix <T> Clone()
        {
            QuadraticMatrix <T> quadraticMatrix = new QuadraticMatrix <T>(this.Height);

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

            return(quadraticMatrix);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add quadratic matrix to quadratic matrix
        /// </summary>
        /// <typeparam name="T">type of elements in matrix</typeparam>
        /// <param name="leftMatrix">left matrix</param>
        /// <param name="rightMatrix">right matrix</param>
        /// <returns>Result quadratic matrix.</returns>
        public static QuadraticMatrix <T> Add <T>(this QuadraticMatrix <T> leftMatrix, QuadraticMatrix <T> rightMatrix)
        {
            QuadraticMatrix <T> result = leftMatrix.Clone();

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

            return(result);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Add quadratic matrix to symmetric matrix.
 /// </summary>
 /// <typeparam name="T">type of elements</typeparam>
 /// <param name="leftMatrix">left matrix</param>
 /// <param name="rightMatrix">right matrix</param>
 /// <returns>Result quadratic matrix</returns>
 public static QuadraticMatrix <T> Add <T>(this QuadraticMatrix <T> leftMatrix, SymmetricMatrix <T> rightMatrix)
 {
     return(leftMatrix.Add((QuadraticMatrix <T>)rightMatrix));
 }