Toeplitz matrix
defination:-
In linear algebra a Toeplitz matrix or diagonal-constant matrix is a matrix in which each desending diagonal from left to right is constant.
lets consider a example which would make it clear how a toeplitz matrix looks like.
![[a_0 a_(-1) a_(-2) ... a_(-n+1); a_1 a_0 a_(-1) ... |; a_2 a_1 a_0 ... a_(-2); | ... ... ... a_(-1); a_(n-1) ... a_2 a_1 a_0].](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_vVivt01jCPQsQOlPag6cc_TkC-YdDun-zjQ6AKlnPkiOcDO8W2WhiEvtrnbgMJrfgkS6ntj3-NtbNC4n_rS3RsYXy4HR455awZ0cmd6rokC2P1spM88hvUBK9OLSWPxGpuxO2BcITfU5xqw4DS660-Dy-PKI4=s0-d)
And its matrix equation form is:-
| 
c++ code to form this matrix and add two such matrixes |
CODING:
|
|
#include<stdio.h>
#include<stdlib.h>
int main()
{
int
b[10][10],a[10],a1[10],c[10][10],d[10][10],i,j,x=0,max; /*
initialization */
printf("Enter the maximum nos of element
you want to input \n");
scanf("%d",&max);
for(i=0;i<max;i++)
/* input to the 1st matrix
*/
{
printf("enter the
element of the fist array\n");
scanf("%d",&a[i]);
}
printf("The elements of the first
toeplitz matrix is:\n");
for(i=0;i<max;i++)
{
for(j=0;j<max;j++)
{
b[i][j]=a[x++]; /*passing up
of single dimensional array into double array*/
x=x%max;
printf("%d",b[i][j]);
}
x=max-1-i;
printf("\n");
}
for(i=0;i<max;i++)
/* input to 2nd matrix
*/
{
printf("enter the element
of the second array\n");
scanf("%d",&a1[i]);
}
printf("The element for the second
toeplitz matrix:\n");
for(i=0;i<max;i++) /* arranging the
element into the toeplitz matrix */
{
for(j=0;j<max;j++)
{
c[i][j]=a1[x++];
x=x%max;
printf("%d",c[i][j]);
}
x=max-1-i;
printf("\n");
}
printf("The addition of the two toeplitz
matrix is:\n");
for(i=0;i<max;i++) /*
addition of the two toeplitz matrix */
{
for(j=0;j<max;j++)
{
d[i][j]=b[i][j]+c[i][j];
}
}
for(i=0;i<max;i++) /* printing the addition of the two toeplitz
matrix */
{
for(j=0;j<max;j++)
{
printf("%d",d[i][j]);
}
printf("\n");
}
system("pause");
return 0;
}
********************************************************************
|
|
No comments:
Post a Comment