VectorInt Diag(TMtxInt Mtx, Int32 k)
Copies the k-th diagonal from the TMtxInt object.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Mtx | TMtxInt | source TMtxInt |
| 2 | k | Int32 |
Returns: VectorInt
Examples
TVecInt a;
TMtxInt d;
MtxVec.CreateIt(out a);
MtxVec.CreateIt(out d);
try
{
// setup matrix
d.SetIt(2,2,[1,-2,
3, 4]);
// get main diagonal from matrix
a.Diag(d,0); // a now containes new double[] {1,4};
}
finally
{
MtxVec.FreeIt(ref a);
MtxVec.FreeIt(ref d);
}