TVecInt::Diag Method

TVecInt *Diag(TMtxInt *Mtx, int k);

Copies the k-th diagonal from the TMtxInt object.

#NameTypeDescription
1MtxTMtxInt *
2kint
Remarks:

Copies the k-th diagonal from the TMtxInt object. If k = 0 then the main diagonal is copied, if k < 0 then the subdiagonal is copied and if k > 0 then the k-th super diagonal is copied to the calling vector.

Examples
#include "MtxVecInt.h"
#include "Units.MtxVecInt.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVecInt;

void Example()
{
    TVecInt* a;
    TMtxInt* d;

    CreateIt(a);
    CreateIt(d);
    // setup matrix
    d->SetIt(2, 2, DewArray<int>{1, -2, 3, 4});
    // get main diagonal from matrix
    a->Diag(d, 0); // a now containes [1,4];
    FreeIt(a);
    FreeIt(d);
}
See Also: TMtx::Diag
Declared in Dew::Math::TVecInt · Dew.Math/MtxVecInt.h · Cross-compiler