MtxExpr.Diag Method

Vector Diag(TMtx Mtx, Int32 k)

Returns k-th diagonal from the source matrix.

#NameTypeDescription
1MtxTMtxsource TMtx
2kInt32

Returns: Vector

Remarks:

Internally calls Dew.Math.Vector.Diag

Examples
TVec a;
TMtx d;
MtxVec.CreateIt(out a);
MtxVec.CreateIt(out d);
try
    {
        // setup matrix
        d.SetIt(2,2,false,[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);
    }