您的当前位置:首页【C#】 4. NumericMatrix类型(包含矩阵运算)

【C#】 4. NumericMatrix类型(包含矩阵运算)

2023-12-29 来源:乌哈旅游
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UserDefinedDataEXP
{
    class NumericMatrix<T>:Matrix<T>
    {
        // Constructors
        public NumericMatrix(): base()
        {
        }
        public NumericMatrix(int rows, int columns): base(rows, columns)
        {
        }
        public NumericMatrix(int rows, int columns, int rowstart, int columnstart) :base(rows, columns, rowstart, columnstart)
        {
        }
        public NumericMatrix(NumericMatrix<T> source): base(source)
        {
        }
        public NumericMatrix(Array<T> array, int rowstart, int columnstart) :base(array, rowstart, columnstart)
        {
        }

        // + 运算符
        #region ADD OPERATION
        //委托BinaryOperatorT<T, T, T> addTT
        private static BinaryOperatorT<T, T, T> addTT;

        //矩阵加法实现1:NumericMatrix<T> v1,NumericMatrix<T> v2
        public static NumericMatrix<T> operator +(NumericMatrix<T> v1, NumericMatrix<T> v2)
        {
            NumericMatrix<T> result = new NumericMatrix<T>(v1.Rows,v1.Columns,v1.MinRowIndex,v1.MinColumnIndex);
            int rdelta = v2.MinRowIndex - v1.MinRowIndex;
            int cdelta = v2.MinColumnIndex - v1.MinColumnIndex;
            
            if (addTT == null)
            {
                addTT = new BinaryOperatorT<T, T, T>(GenericOperatorFactory<T, T, T, NumericMatrix<T>>.Add);
            }
            for (int i = v1.MinRowIndex; i <= v1.MaxRowIndex; i++)
            {
                for (int j =  v1.MinColumnIndex; j <= v

因篇幅问题不能全部显示,请点此查看更多更全内容