You are here: Symbol Reference > MtxExpr Namespace > Classes > Matrix Record > public > Matrix.Diag Method
MtxVec VCL
ContentsIndex
PreviousUpNext
Matrix.Diag Method

Sets the matrix diagonal to values from the vector.

Pascal
function Diag(const Vec: TVec; k: integer): TMtx; overload;

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.

Diag

var A: Matrix; D: Vector; begin A.SetIt(2,2,True,[1,1, 2,1, 1,2, 2,2]); D.SetIt(2, True,[2,2, 1,1]); A.Diag(D,0); // A becomes: // [2,2, 2,1] // [1,2, 1,1] end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!