TVec *Diag(TMtx *Mtx, int k) const;
Copies the k-th diagonal from the TMtx object.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Mtx | TMtx * | |
| 2 | k | int |
Remarks:
Copies the k-th diagonal from the TMtx 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 "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Vector a;
Matrix d;
// setup matrix
d.SetIt(2, 2, false, DewArray<double>{1, -2, 3, 4});
// get main diagonal from matrix
a.Diag(d, 0); // a now containes [1,4];
}
See Also: Vector::Diag
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler