You are here: Symbol Reference > Toeplitz Namespace > Functions > Toeplitz.ToeplitzSolve Function
MtxVec VCL
ContentsIndex
PreviousUpNext
Toeplitz.ToeplitzSolve Function

Solve a toepltiz system of linear equations.

Pascal
procedure ToeplitzSolve(FirstRow: TVec; FirstCol: TVec; B: TVec; X: TVec); overload;
Parameters 
Description 
FirstRow 
Defines the first row R(0)..R(N-1) in the equation below. Vector can be real or complex. 
FirstCol 
Defines the first column C(0)..C(N-2) in the equation below. FirstCol.Length must be equal to FirstRow.Length-1. Vector can be real or complex. 
Defines B vector in equation below. 
Returns X vector as solution in the equation below. 

The procedures solves Toeplitz system of linear equations defined as: 

 

[ R(0) R(1) ... R(N-1) ] [ X(0) ] = [ -B(0) ] [ C(0) R(0) ... R(N-2) ] [ X(1) ] = [ -B(1) ] [ .... . . ] x [ . ] = [ . ] [ C(N-1) C(N-2) ... R(1) ] [ X(N-2)] = [ -B(N-2) ] [ C(N-2) C(N-1) ... R(0) ] [ X(N-1)] = [ -B(N-1) ]

 

The computational complexity of the algorithm is O(n2) as oposed to at least O(n3) for solving a general matrix.

uses MtxExpr, Math387, MtxVec, MtxVecTee, MtxVecEdit, Toeplitz; procedure TForm1.Button1Click(Sender: TObject); var FirstRow,FirstCol,X1,X2,B,R: Vector; A: Matrix; begin FirstRow.Size(4,False); FirstCol.Size(3,False); B.Size(4,false); FirstRow[0] := 1; FirstRow[1] := 2; FirstRow[2] := 3; FirstRow[3] := 4; FirstCol[0] := 2; FirstCol[1] := 3; FirstCol[2] := 4; A.Toeplitz(FirstRow,FirstCol); B[0] := -2; B[1] := -3; B[2] := -4; B[3] := -5; R.Copy(FirstRow); R.Resize(5); R[4] := 5; ToeplitzSolve(FirstRow,FirstCol,B,X1); A.LUSolve(B,X2,mtGeneral); if not X2.Equal(X1,EPS,cmpAbsolute) then Eraise('Not equal!'); ViewValues(X1,'Real X1',true); Levinson(R,X2); ViewValues(X2,'Real X2',true); // Complex FirstRow.Size(4,True); FirstCol.Size(3,True); B.Size(4,True); FirstRow.CValues[0] := Cplx(1,0); FirstRow.CValues[1] := Cplx(2,0); FirstRow.CValues[2] := Cplx(3,-1); FirstRow.CValues[3] := Cplx(4,0); FirstCol.CValues[0] := Cplx(2,0); FirstCol.CValues[1] := Cplx(3,1); FirstCol.CValues[2] := Cplx(4,0); A.Toeplitz(FirstRow,FirstCol); B.CValues[0] := Cplx(-2,0); B.CValues[1] := Cplx(-3,-1); B.CValues[2] := Cplx(-4,0); B.CValues[3] := Cplx(-5,0); R.Copy(FirstRow); R.Resize(5); R.CValues[4] := Cplx(5,0); ToeplitzSolve(FirstRow,FirstCol,B,X1); A.LUSolve(B,X2,mtGeneral); if not X2.Equal(X1,EPS*50,cmpAbsolute) then Eraise('Not equal!'); ViewValues(X1,'Complex X1',true); Levinson(R,X2); ViewValues(X2,'Complex X2',true); end;

 

#include "MtxExpr.hpp" #include "MtxVecEdit.hpp" #include "MtxVecTee.hpp" #include "Toeplitz.hpp" void __fastcall TForm1::BitBtn1Click(TObject *Sender) { sVector FirstRow,FirstCol,X1,X2,B,R; sMatrix A; FirstRow.Size(4,false); FirstCol.Size(3,false); B.Size(4,false); FirstRow[0] = 1; FirstRow[1] = 2; FirstRow[2] = 3; FirstRow[3] = 4; FirstCol[0] = 2; FirstCol[1] = 3; FirstCol[2] = 4; A.Toeplitz(FirstRow,FirstCol); B[0] = -2; B[1] = -3; B[2] = -4; B[3] = -5; R.Copy(FirstRow); R.Resize(5); R[4] = 5; ToeplitzSolve(FirstRow,FirstCol,B,X1); A.LUSolve(B,X2,mtGeneral); if ((X2.Equal(X1,10*EPS,cmpAbsolute)) == false) { throw "Not equal"; } ViewValues(X1,"Real X1",true); Levinson(R,X2); ViewValues(X2,"Real X2",true); // Complex FirstRow.Size(4,true); FirstCol.Size(3,true); B.Size(4,True); FirstRow.CValues(0) = Cplx(1,0); FirstRow.CValues(1) = Cplx(2,0); FirstRow.CValues(2) = Cplx(3,-1); FirstRow.CValues(3) = Cplx(4,0); FirstCol.CValues(0) = Cplx(2,0); FirstCol.CValues(1) = Cplx(3,1); FirstCol.CValues(2) = Cplx(4,0); A.Toeplitz(FirstRow,FirstCol); B.CValues(0) = Cplx(-2,0); B.CValues(1) = Cplx(-3,-1); B.CValues(2) = Cplx(-4,0); B.CValues(3) = Cplx(-5,0); R.Copy(FirstRow); R.Resize(5); R.CValues(4) = Cplx(5,0); ToeplitzSolve(FirstRow,FirstCol,B,X1); A.LUSolve(B,X2,mtGeneral); if (!X2.Equal(X1,EPS*50,cmpAbsolute)) { throw "Not equal!"; } ViewValues(X1,"Complex X1",true); Levinson(R,X2); ViewValues(X2,"Complex X2",true); }
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!