Dew MtxVec NET
TSparseMtx.Diag Method
Summary
Sets the kk-th diagonal of TSparseMtx to the Vec object.

Class
TSparseMtx

Declaration
Procedure Diag(Vec: TVec; kk: integer = 0);

Description
Sets the kk-th diagonal of TSparseMtx to 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.

Example 1

uses MtxExpr, Sparse; procedure Example; var asp, bsp: TSparseMtx; csp, dsp: TSparseMtx; d: Vector; begin // ... // #1 : split asp into lower(bsp), upper(csp) and diagonal(d) sections bsp.LowerTriangle(asp); csp.UpperTriangle(asp); asp.Diag(d); // now combine lower(bsp), upper, and diagonal(d) back dsp.AddSplit(bsp,d,csp); // should be equal if not asp.Equal(dsp) then Eraise('Not Equal!'); end;
#include "MtxVecCpp.h" #include "Sparse.hpp" void __fastcall Example() { Vector d; TSparseMtx *asp = new TSparseMtx(); TSparseMtx *bsp = new TSparseMtx(); TSparseMtx *csp = new TSparseMtx(); TSparseMtx *dsp = new TSparseMtx(); // ... // #1 : split asp into lower(bsp), upper(csp) and diagonal(d) sections bsp->LowerTriangle(asp); csp->UpperTriangle(asp); asp->Diag(d); // now combine lower(bsp), upper, and diagonal(d) back dsp->AddSplit(bsp,d,csp); // should be equal if (!asp->Equal(dsp)) ERaise("Not Equal!"); delete asp; delete bsp; delete csp; delete dsp; }

Copyright 2008 Dew Research
http://www.dewresearch.com