Can any1 plz hep me out with this algorithm.I am really not getting hoe to implement in code. the problem is how to get the to zero elements from row vector and apply this algorithm. And the how to repalce it values. plz help.
I am working on a matrix on Gate Level Delay Computing-Commom Subexpression Elimination (GLDC-CSE)
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 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.
Risposte (1)
Walter Roberson
il 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...
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!