Beispiel #1
0
        public matrix_class Transpose()
        {
            matrix_class mReturnMartix = new matrix_class(ColumnCount, RowCount);

            for (int i = 0; i <= mRowCount - 1; i++)
            {
                for (int j = 0; j <= mColumnCount - 1; j++)
                {
                    mReturnMartix[j, i] = mInnerMatrix[i, j];
                }
            }
            return(mReturnMartix);
        }
Beispiel #2
0
        public static matrix_class operator *(double scalarValue, matrix_class pMatrix)
        {
            matrix_class returnMartix = new matrix_class(pMatrix.RowCount, pMatrix.ColumnCount);

            for (int i = 0; i <= pMatrix.RowCount - 1; i++)
            {
                for (int j = 0; j <= pMatrix.ColumnCount - 1; j++)
                {
                    returnMartix[i, j] = pMatrix[i, j] * scalarValue;
                }
            }
            return(returnMartix);
        }
Beispiel #3
0
        public bool IsSymetricMatrix()
        {
            if (!IsSquareMatrix())
            {
                return(false);
            }
            matrix_class transposeMatrix = Transpose();

            if ((this) == transposeMatrix)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        public static matrix_class operator +(matrix_class pMatrix1, matrix_class pMatrix2)
        {
            if (!(pMatrix1.RowCount == pMatrix2.RowCount && pMatrix1.ColumnCount == pMatrix2.ColumnCount))
            {
                throw new Exception("Size Mismatch");
            }
            matrix_class returnMartix = new matrix_class(pMatrix1.RowCount, pMatrix2.ColumnCount);

            for (int i = 0; i <= pMatrix1.RowCount - 1; i++)
            {
                for (int j = 0; j <= pMatrix1.ColumnCount - 1; j++)
                {
                    returnMartix[i, j] = pMatrix1[i, j] + pMatrix2[i, j];
                }
            }
            return(returnMartix);
        }
Beispiel #5
0
        // Public Shared Operator +=(pMatrix As Matrix) As Matrix

        // For i As Integer = 0 To pMatrix.RowCount - 1
        // For j As Integer = 0 To pMatrix.ColumnCount - 1
        // pMatrix(i, j) += 1
        // Next
        // Next
        // Return pMatrix
        // End Operator
        // Public Shared Operator -=(pMatrix As Matrix) As Matrix
        // For i As Integer = 0 To pMatrix.RowCount - 1
        // For j As Integer = 0 To pMatrix.ColumnCount - 1
        // pMatrix(i, j) -= 1
        // Next
        // Next
        // Return pMatrix
        // End Operator
        public static matrix_class operator *(matrix_class pMatrix1, matrix_class pMatrix2)
        {
            if (pMatrix1.ColumnCount != pMatrix2.RowCount)
            {
                throw new Exception("Size Mismatch");
            }
            matrix_class returnMatrix = new matrix_class(pMatrix1.RowCount, pMatrix2.ColumnCount);

            for (int i = 0; i <= pMatrix1.RowCount - 1; i++)
            {
                double[] rowValues = pMatrix1.GetRow(i);
                for (int j = 0; j <= pMatrix2.ColumnCount - 1; j++)
                {
                    double[] columnValues = pMatrix2.GetColumn(j);
                    double   value        = 0;
                    for (int a = 0; a <= rowValues.Length - 1; a++)
                    {
                        value += rowValues[a] * columnValues[a];
                    }
                    returnMatrix[i, j] = value;
                }
            }
            return(returnMatrix);
        }
Beispiel #6
0
 /// <summary>
 /// Function to return one dimensional matrix as double
 /// </summary>
 /// <param name="_inpt_matrix"></param>
 /// <returns></returns>
 public static double uni_dim_matrix_to_double(matrix_class _inpt_matrix)
 {
     return(Math.Round(_inpt_matrix[0, 0], 12));
 }