function Diag(const Mtx: TMtxInt; k: Integer): VectorInt;
Copies the k-th diagonal from the TMtxInt object.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Mtx | TMtxInt | |
| 2 | k | Integer |
Returns: VectorInt
Examples
var a: TVecInt;
d: TMtxInt;
begin
CreateIt(a);
CreateIt(d);
try
// setup matrix
d.SetIt(2,2,[1,-2,
3, 4]);
// get main diagonal from matrix
a.Diag(d,0); // a now containes [1,4];
finally
FreeIt(a);
FreeIt(d);
end;
end;