0 Up votes0 Down votes

6 views3 pagesApr 14, 2010

© Attribution Non-Commercial (BY-NC)

DOC, PDF, TXT or read online from Scribd

Attribution Non-Commercial (BY-NC)

6 views

Attribution Non-Commercial (BY-NC)

- C Lab Report
- elab
- FeedlabCh1
- hcl
- Comparación de indices multidimensionales de pobreza
- Smallest and Largest Number
- Matrix Questions for SSC Stenographer PDF
- State Space Realizations
- Lec1_Maths_3_20110919
- Matrix
- SS ,UNIX ,CD lab
- exam cap 6
- Rajat
- gfjgfjgfjfgj
- oracle_2.pdf
- Arrays
- TerminaBug_Post1
- B.B.M-New-syllabus.pdf
- Matrices
- Math Econ

You are on page 1of 3

Roll No:09EE1026

Assignment No:6 */

#include<stdio.h>

#include<math.h>

#define S 128

void add(int X[][S], int Y[][S], int add[][S],int order, int *sum, ) // function definition for Addison of two matrice two matrices

{

int i=0, j=0;

for(i=0;i<order;i++)

{

for(j=0;j<order;j++)

add[i][j]=X[i][j]+Y[i][j];

}

*sum=*sum+1;

void subtract(int X[][S], int Y[][S], int sub[][S],int order, int *diff) // function definition for subtraction of two matrices

{

int i=0, j=0;

for(i=0;i<order;i++)

{

for(j=0;j<order;j++)

sub[i][j]=X[i][j]-Y[i][j];

}

*diff=*diff+1;

}

void form(int X[][S], int Y[][S], int x, int y, int o) //taking four matrices and putting it in one matrix

{

int i,j;

for(i=x;i<x+o;i++) {

for(j=y;j<y+o;j++)

Y[i][j]=X[i-x][j-y];

}

}

void divide(int X[][S], int Y[][S], int x, int y, int order) //Dividing the function into four parts

{

int i,j;

for(i=x;i<(x+order);i++) {

for(j=y;j<y+order;j++)

Y[i-x][j-y]=X[i][j];

}

}

void multiply(int A[][S], int B[][S], int product[][S], int o, int *pro,int *sum, int *diff)

{

int A11[S][S], B11[S][S], C11[S][S], A12[S][S], B12[S][S], C12[S][S], A21[S][S], B21[S][S], C21[S][S], A22[S][S], B22[S][S], C22[S][S];

int M1[S][S],M2[S][S],M3[S][S],M4[S][S],M5[S][S],M6[S][S],M7[S][S];

int sum1[S][S], sum2[S][S], sum3[S][S], sum4[S][S], sum5[S][S], sum6[S][S], sum7[S][S], sum8[S][S], sum9[S][S], sum10[S][S],sum11[S][S],

sum12[S][S], sum13[S][S], sum14[S][S];

if (o<2)

{

product[0][0]=A[0][0]*B[0][0];

*pro=*pro+1;

}

else

{

divide(A,A11,0,0,o/2);

divide(B,B11,0,0,o/2);

divide(A,A12,0,o/2,o/2);

divide(B,B12,0,o/2,o/2); //calling function divide

divide(A,A21,o/2,0,o/2);

divide(B,B21,o/2,0,o/2);

divide(A,A22,o/2,o/2,o/2);

divide(B,B22,o/2,o/2,o/2);

add(B11,B22, sum2,o/2,sum); //calling add function

add(A21,A22,sum3,o/2,sum);

subtract(B12,B22,sum4,o/2,diff);

subtract(B21,B11,sum5,o/2,diff); //calling function subtract

add(A11,A12,sum6,o/2,sum);

subtract(A21,A11,sum7,o/2,diff);

add(B11,B12,sum8,o/2,sum);

subtract(A12,A22,sum9,o/2,diff);

add(B21,B22,sum10,o/2,sum);

multiply(sum1,sum2,M1,o/2,pro,sum,diff);

multiply(sum3,B11,M2,o/2,pro,sum,diff);

multiply(A11,sum4,M3,o/2,pro,sum,diff); //calling function multiply

multiply(A22,sum5,M4,o/2,pro,sum,diff);

multiply(sum6,B22,M5,o/2,pro,sum,diff);

multiply(sum7,sum8,M6,o/2,pro,sum,diff);

multiply(sum9,sum10, M7,o/2,pro,sum,diff);

add(M1,M4,sum11,o/2,sum);

subtract(M5,M7,sum12,o/2,diff);

subtract(M1,M2,sum13,o/2,diff);

add(M3,M6,sum14,o/2,sum);

subtract(sum11,sum12,C11,o/2,diff);

add(M3,M5,C12,o/2,sum);

add(M2,M4,C21,o/2,sum);

add(sum13,sum14,C22,o/2,sum);

form(C11,product,0,0,o/2);

form(C12,product,0,o/2,o/2); //calling form function

form(C21,product,o/2,0,o/2);

form(C22,product,o/2,o/2,o/2);

{

int i,j;

for(i=0; i<order; i++)

{

for(j=0;j<order;j++)

{

printf("%d\t", X[i][j]);

}

printf("\n");

}

}

int main()

{

int order, i=0, j=0;

int order_new, A[S][S], B[S][S], product[S][S];

int *pro, *sum, *diff, p, s, d;

sum=&s;

pro=&p;

diff=&d;

p=s=d=0;

printf("Enter the order of the square matrices A and B:");

scanf("%d", &order);

order_new=order;

for(i=1;;i*=2)

{

if(order<=i)

{

order_new=i;

break;

}

}

printf("The padded order for A and B is %d \n", order_new);

printf("Enter the contents of Matrix A: \n");

for (i=0;i<order_new;i++)

{

for(j=0;j<order_new;j++)

{

if(i<(order) && j<(order))

scanf("%d", &A[i][j]);

else

A[i][j]=0;

}

}

printf("Enter the contents of Matrix B: \n");

for (i=0;i<order_new;i++)

{

for(j=0;j<order_new;j++)

{

if(i<(order) && j<(order))

scanf("%d", &B[i][j]);

else

B[i][j]=0;

}

}

print(A, order_new);

print(B, order_new);

multiply(A,B,product,order_new,pro,sum, diff);

print(product,order_new);

printf("No. of times multiplication is done: %d \n", *pro);

getch();

}

- C Lab ReportUploaded byAhsan Ijaz
- elabUploaded byjkbkb
- FeedlabCh1Uploaded byGJ Recalde
- hclUploaded byshenbagaraman cse
- Comparación de indices multidimensionales de pobrezaUploaded byFabiana Carro
- Smallest and Largest NumberUploaded bysubramanya
- Matrix Questions for SSC Stenographer PDFUploaded bySiddhu Siddhu
- State Space RealizationsUploaded byfadymounier
- Lec1_Maths_3_20110919Uploaded bytulis88
- MatrixUploaded byamera_na
- SS ,UNIX ,CD labUploaded byAarthi Sriraman
- exam cap 6Uploaded bycameraman01
- RajatUploaded byDheerandra Pratap
- gfjgfjgfjfgjUploaded byApurba
- oracle_2.pdfUploaded byJamal Mohammed
- ArraysUploaded byDilip Naidu
- TerminaBug_Post1Uploaded byMatthew Fong
- B.B.M-New-syllabus.pdfUploaded byRajiv Mohan
- MatricesUploaded bydeuzer77
- Math EconUploaded byjennel_maquinana
- Inclusion relations between outhostochastic matrices and products of pinching matrices - Yiu-Tung Poon ; Nam-Kiu Tsing.pdfUploaded byjulianli0220
- The CalendarUploaded byJack Fielding
- FunctionsUploaded byMehboob Khokhar
- week3Uploaded byAdarsh Kumar
- Analysis of Truss StructureUploaded bydaniel
- EE Course Scilab OnlineUploaded byRaúl Zura
- New Microsoft Office Word Document (2)Uploaded bySushant Shukla
- psu254mho1Uploaded byJohn Le Tourneux
- cfaUploaded bymdorneanu
- lecture21.pdfUploaded byLuis Alejandro Gonzalez

- Friction [Compatibility Mode]Uploaded byfaizan260690
- Sqpms Science Theory x Paper2 2010Uploaded byrahul1992yadav
- Somnath Bhardwaj Lect_notesUploaded byfaizan260690
- L9-LinkedListUploaded byfaizan260690
- 5 BeamsUploaded byfaizan260690
- Equivalent Force Systems 2 [Compatibility Mode]Uploaded byfaizan260690
- Vector calculusUploaded bytakis.papadopoulos6672
- lesson31divergencetheoremslides-1209653696964461-9Uploaded byfaizan260690
- Free Body Problems With Solution 2 [Compatibility Mode]Uploaded byfaizan260690
- Lec 8 Linked ListsUploaded byfaizankhan260690
- Prob08011Uploaded byfaizan260690
- Prob08010Uploaded byfaizan260690
- Free Body Problems With Solution 1 [Compatibility Mode]Uploaded byfaizan260690
- Equivalent Force Systems 1 [Compatibility Mode]Uploaded byfaizankhan260690
- Prob08009Uploaded byfaizan260690
- Prob08008Uploaded byfaizan260690
- Lec 7 StructuresUploaded byfaizan260690
- Lec 6 PointersUploaded byfaizan260690
- Prob08007Uploaded byfaizan260690
- Prob08005Uploaded byfaizan260690
- Lec 3 Control LoopingUploaded byfaizan260690
- Super QuestionsUploaded byfaizan260690
- World ScientistsUploaded byfaizan260690

- Matrices Det(S)Uploaded bykaran
- BCA MCQUploaded byViswaprem CA
- Jacobi EigenUploaded bywaqarahmed4544
- Generalized StuffUploaded bykiplimo89
- Linear Algebraic EquationsUploaded byJonathan Budinho
- Matrix Singular Value DecompositionUploaded byHamed Nikbakht
- MatrixUploaded byJoshua Salindo
- Theory Problems of Matrices - Schaum - Frank AyresUploaded bybataneja
- Operatoria MatricialUploaded byfeliperuiz
- 1 Matrix for LmsUploaded bySaman Jayakadu
- Bahasa InggrisUploaded byvonie
- Chap0Uploaded byla
- Math 1B03 ExamUploaded byPoulaElhamyMondyBasaly
- Matrix Computation for Engineers and Scientist by JenningsUploaded byAnonymous LcR6ykPBT
- cours de matricesUploaded byabdorez
- PartI-Problem Set MatricesUploaded byAbhijit
- studmaxxUploaded byAnchit Gupta
- Quiz_01,_MTH-501Uploaded byShining_90
- Chapter 20 I Matrices Enhancement.docUploaded byadibahaz
- 3 Matrix TutorialUploaded byigogin
- Maths Term PaperUploaded byprashiq
- DissertationUploaded byHồ Công-Việt
- Gilbert Strang-The Algebra of Elimination [expository notes] (2011).pdfUploaded byTimmavajjula Venkata Karthik
- A18Uploaded byoxxid
- This Program Performs Matrix AdditionUploaded bymknatoo1963
- Operations on Matrices - Linear AlgebraUploaded bydocsdownforfree
- DSP_Lab 2Uploaded byShahid Khan
- Matix FormuleUploaded byAbhay Singh Chandel
- Linear Algebra ReviewUploaded byrd8
- floyds algorithmUploaded byYash Sharma

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.