Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to make my program faster?

Status
Not open for further replies.

helenfish

Newbie level 3
Newbie level 3
Joined
Mar 20, 2006
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,306
hello everyone:)
i have a problem to simplify my programming codes. i need some help! i need to shorten the execution time of my program and convert it to mips. i have the program codes below. pl try to check for me. thanks ya!

#include <stdio.h>
main()
{
double Norm = 0.05;

const int N=127 ;
int Iter, i, j;
float OldValue, TotalError;
// float A[N + 1][N + 1];
float A[128][128];

// for (i = 0; i <= N; i++)
// for (j = 0; j <= N; j++)

for (i = 0; i <= 127; i++)
for (j = 0; j <= 127; j++)

A[j] = 0.0;

i=0;
j=0;
// while (i <= N && j <= N)

while (i <= 127 && j <= 127)
{ A[0] = 100.0;
A[0][j] = 100.0;
i++;
j++;
}

// for (i = 0; i <= N; i++)
// A[0] = 100.0;
// for (j = 0; j <= N; j++)
// A[0][j] = 100.0;

Iter = 0;
do {
TotalError = 0.0;
for (j = 1; j < N; j++) {
for (i = 1; i < N; i++) {
OldValue = A[j];





A[j] = A[j] * 0.5 + (A[i - 1][j] + A[i + 1][j] + A[j - 1] + A[j + 1]) * 0.125;
TotalError += (OldValue - A[j]) * (OldValue - A[j]);
}
}
Iter++;
}
while (TotalError >= Norm);
printf("%10ld%10.6f\n",Iter);
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top