/// <summary> /// The algebra remain determinant of this square. /// </summary> /// <param name="row">the row index of the sub.</param> /// <param name="col">the col index of the sub.</param> /// <returns>the algebra remain determinant of this square.</returns> public double AlgebraRemainDeterminant(int row, int col) { if (row < 0 || col < 0 || row >= Row || col >= Col) { throw (new ArgumentException()); } SquaredMatrix s = (SquaredMatrix)this.RemainMatrix(row, col); return(Math.Pow(-1, row + col) * s.Determinant); }
public LinearSystem(SquaredMatrix coe, Vector v) { if (coe.Size != v.Dimension) { throw (new ArgumentException()); } Vector[] vectors = new Vector[coe.Size + 1]; for (int i = 0; i < coe.Size; i++) { vectors[i] = coe.Cols[i]; } vectors[coe.Size] = v; this.LMatrix = new Matrix(vectors); this.size = this.LMatrix.Col - 1; }
/// <summary> /// The inversal matrix of this. /// </summary> /// <returns>the inversal matrix.</returns> public SquaredMatrix Inverse() { double determinant = this.Determinant; if (determinant == 0) { throw new InvalidOperationException("Cannot invert a singular matrix."); } SquaredMatrix s = new SquaredMatrix(Size); for (int i = 0; i < Row; i++) { for (int j = 0; j < Col; j++) { s[j][i] = this.AlgebraRemainDeterminant(i, j); } } return(s / Determinant); }
public SquaredMatrix(SquaredMatrix m) : base(m) { }
/// <summary> /// The inversal matrix of this. /// </summary> /// <returns>the inversal matrix.</returns> public SquaredMatrix Inverse() { double determinant = this.Determinant; if (determinant == 0) { throw new InvalidOperationException("Cannot invert a singular matrix."); } SquaredMatrix s = new SquaredMatrix(Size); for (int i = 0; i < Row; i++) { for (int j = 0; j < Col; j++) { s[j][i] = this.AlgebraRemainDeterminant(i, j); } } return s/Determinant; }