/// <summary> /// Matrix Division /// </summary> public static Matrix operator /(double left, Matrix right) { if (null == right) { throw new ArgumentNullException(nameof(right)); } if (right.ColumnCount != right.LineCount) { throw new ArgumentException("Divisor must be a square matrix.", nameof(right)); } double[][] result = MatrixLowLevel.Inverse(right.m_Items); for (int i = result.Length - 1; i >= 0; --i) { double[] line = result[i]; for (int j = line.Length - 1; j >= 0; --j) { line[j] = left * line[j]; } } return(new Matrix(result)); }
/// <summary> /// Pseudo Inverse /// </summary> public Matrix PseudoInverse() { double[][] tran = MatrixLowLevel.Transpose(m_Items); double[][] result = MatrixLowLevel.Multiply(MatrixLowLevel.Inverse(MatrixLowLevel.Multiply(tran, m_Items)), tran); return(new Matrix(result)); }
/// <summary> /// Inverse /// </summary> public Matrix Inverse() { if (ColumnCount != LineCount) { throw new InvalidOperationException("Only square matrix can be inversed."); } try { return(new Matrix(MatrixLowLevel.Inverse(m_Items))); } catch (ArgumentException) { throw new InvalidOperationException("Degenerated matrix can't be inversed."); } }
/// <summary> /// Matrix Division /// </summary> public static Matrix operator /(Matrix left, Matrix right) { if (null == left) { throw new ArgumentNullException(nameof(left)); } else if (null == right) { throw new ArgumentNullException(nameof(right)); } if (left.ColumnCount != right.LineCount) { throw new ArgumentException($"Right matrix must have {left.ColumnCount} liness, actual {right.LineCount}", nameof(right)); } else if (right.ColumnCount != right.LineCount) { throw new ArgumentException("Divisor must be a square matrix.", nameof(right)); } return(new Matrix(MatrixLowLevel.Multiply(left.m_Items, MatrixLowLevel.Inverse(right.m_Items)))); }