chsvlib
chsv helper source code

◆ Cofactor() [2/2]

value_type Cofactor ( size_type  iColumn,
size_type  iRow 
) const

Returns a cofactor associated with the specified element.

Parameters
iColumnis an index of a column, where the element is located.
iRowis an index of a row, where the element is located.
Returns
The cofactor of the element. If a summ of iColumn and iRow is even, the value is equal to the result of applying the Minor method with the same parameters. Otherwise the returned value is equal to the additive invertion of the Minor return value.

For any matrix \(A_{m\times n} = \left(\begin{array}{ccccccc} a_{1,1} & \cdots & a_{1,j-1} & a_{1,j} & a_{1,j+1} & \cdots & a_{1,n} \\ \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\ a_{j-1,1} & \cdots & a_{i-1,j-1} & a_{i-1,j} & a_{i-1,j+1} & \cdots & a_{i-1,n}\\ a_{j,1} & \cdots & a_{i,j-1} & a_{i,j} & a_{i,j+1} & \cdots & a_{i,n} \\ a_{j+1,1} & \cdots & a_{i+1,j-1} & a_{i+1,j} & a_{i+1,j+1} & \cdots & a_{i+1,n}\\ \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & \cdots & a_{m,j-1} & a_{m,j} & a_{m,j+1} & \cdots & a_{m,n} \end{array}\right)\)

A.Cofactor(i, j)

will calculate the determinant \({\left(-1\right)}^{i+i}\cdot \left|\begin{array}{cccccc} a_{1,1} & \cdots & a_{1,j-1} & a_{1,j+1} & \cdots & a_{1,n} \\ \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\ a_{j-1,1} & \cdots & a_{i-1,j-1} & a_{i-1,j+1} & \cdots & a_{i-1,n}\\ a_{j+1,1} & \cdots & a_{i+1,j-1} & a_{i+1,j+1} & \cdots & a_{i+1,n}\\ \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & \cdots & a_{m,j-1} & a_{m,j+1} & \cdots & a_{m,n} \end{array}\right|\).

Exceptions
Chusov::Exceptions::InvalidParameterExceptionThe current matrix is not square