I am working on a matrix on Gate Level Delay Computing-Commom Subexpression Elimination (GLDC-CSE)
Ältere Kommentare anzeigen
my matrix is
mat=[0 0 0 0 0;0 0 -1 0 0;0 0 -1 -1 -1;0 0 -1 0 -1;-1 -1 0 -1 -1]
I have written code for CSE, I have to apply GLDC now. It consist of an algorithm in which suppose the row is ar=[0 0 -1 0 0]
- I have to sort the row after sorting [-1 0 0 0 0]
- then have to take two positive delay values here it is d1=0 and d2=0
- The initial delay will be di=-1 and finaldelay=max(d1,d2)+1.
- then repeat repeat steps 2 to 4 till u get one positive value.
Explation: after sorting [-1 0 0 0 0]; d1=0 and d2=0; so di=-1 and finaldelay=max(0,0)+1=1.row[-1 -1 1 0 0]
Again sorting [-1 -1 0 0 1]; d1=0 and d2=0; di=-1 finaldelay=max(0,0)+1=1.so[-1 -1 -1 1 0]
again sorting [-1 -1 -1 0 1];d1= 0 and d2=1; di=-1 finaldelay=max(0,1)+1=2 so [-1 -1 -1 -1 2].
I am not able to extract two positive elements and replace it with -1.
Any kind of help will help me.
Thanks!!!
6 Kommentare
Rutika Titre
am 6 Nov. 2015
Rutika Titre
am 9 Nov. 2015
Bearbeitet: Walter Roberson
am 12 Nov. 2015
Walter Roberson
am 9 Nov. 2015
0 is not a positive value.
Rutika Titre
am 12 Nov. 2015
Walter Roberson
am 12 Nov. 2015
"2. then have to take two positive delay values here it is d1=0 and d2=0"
But 0 is never a positive delay value.
Rutika Titre
am 22 Nov. 2015
Antworten (1)
Walter Roberson
am 12 Nov. 2015
Your code has
d1=ar(ar(j:j+1)>=0);
You are examining two positions, out of which 0, 1, or 2 values will be >= 0. You are selecting those elements into d1.
You take d3=max(d1) . If the vector is length 1 or 2 then that is okay, you would get a scalar that contained the maximum. But if the vector was of length 0, then max() of the empty vector will be empty. And then you do difi=d3+1 . If none of the d1 values were >= 0 then d3 came out empty, and empty + 1 is empty. You then try to go around storing that emptiness into real locations...
1 Kommentar
Rutika Titre
am 14 Nov. 2015
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!