TMtxInt *Diag(TVecInt *Vec, int k);
Sets the matrix diagonal to values from the vector.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec | TVecInt * | |
| 2 | k | int |
Remarks:
Sets the k-th diagonal of the calling matrix to values from from the Vec object. If k = 0 then the main diagonal matrix is set, if k < 0 then the k-th subdiagonal matrix is set and if k > 0 the then the k-th super diagonal is set. The matrix must be large enough to hold diagonal or an exception is raised.
Examples
#include "MtxVecInt.h"
#include "Units.MtxVecInt.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVecInt;
void Example()
{
TMtxInt* A;
TVecInt* D;
CreateIt(A);
CreateIt(D);
A->SetIt(2, 2, DewArray<int>{1, 1, 1, 2});
D->SetIt(DewArray<int>{3, 4});
A->Diag(D, 0);
// A becomes:
// [3,1]
// [1,4]
FreeIt(D);
FreeIt(A);
}
See Also: TVecInt::Diag
Declared in Dew::Math::TMtxInt · Dew.Math/MtxVecInt.h · Cross-compiler