Beispiel #1
0
        public override bool Equals(object obj)
        {
            QMatrix ComparableMatrix = obj as QMatrix;

            if (ComparableMatrix == (object)null)
            {
                throw new ArgumentNullException("The object is null. Initialize the matrix");
            }
            return(this == ComparableMatrix ? true : false);
        }
Beispiel #2
0
        private static QMatrix PlusOrMinusMatrix(QMatrix a, QMatrix b, PlusOrMinus Calculation)
        {
            if ((object)a == null || (object)b == null)
            {
                throw new NullReferenceException("The object is null. Initialize the matrix");
            }
            if (a.columns != b.columns || a.rows != b.rows)
            {
                throw new MatrixException("Matrices must have the same number of columns and rows");
            }
            QMatrix matrix = new QMatrix(a.rows, a.columns);

            for (int i = 0; i < matrix.rows; i++)
            {
                for (int j = 0; j < matrix.columns; j++)
                {
                    matrix[i, j] = Calculation(a[i, j], b[i, j]);
                }
            }
            return(matrix);
        }
Beispiel #3
0
        public static QMatrix operator *(QMatrix a, QMatrix b)
        {
            if (a == (object)null || b == (object)null)
            {
                throw new ArgumentNullException("The object is null. Initialize the matrix");
            }
            if (a.columns != b.rows)
            {
                throw new MatrixException("Matrices must have the same number of columns and rows");
            }
            QMatrix multy = new QMatrix(a.rows, b.columns);

            for (int i = 0; i < a.rows; i++)
            {
                for (int j = 0; j < b.columns; j++)
                {
                    for (int k = 0; k < b.rows; k++)
                    {
                        multy[i, j] += a[i, k] * b[k, j];
                    }
                }
            }
            return(multy);
        }