Commit e006f43d authored by SPARSA ROYCHOWDHURY's avatar SPARSA ROYCHOWDHURY

19/7/2017:

1. Replaced all "NULL" by "nullptr" as par C++11 standard 
2. Tried to fix some memory leaks
3. Now the program is compilation error free and apparently the TPDA is implemente
4. Testing Remaining Though
5. Still more memory leaks re there.
parent 17277298
......@@ -58,7 +58,7 @@ public :
char *del; // transitions
short **w; // weight matrix
runZone* addNext(char dn, char wn); // new run after adding transition 'dn' of tsm value 'wn'
runZone* addNext(char dn, char wn); // new run after adding transition 'dn' of tsm value 'wn'
runZone* shuffle(runZone *s2); // concatenation of two partial runs
......
......@@ -35,7 +35,7 @@
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<flagsDictionary>
<element flagsID="0" commonFlags="-std=c++11"/>
<element flagsID="0" commonFlags="-mtune=generic -march=x86-64 -std=c++11"/>
</flagsDictionary>
<codeAssistance>
</codeAssistance>
......@@ -45,11 +45,6 @@
<buildCommand>${MAKE} -f makefile</buildCommand>
<cleanCommand>${MAKE} -f makefile clean</cleanCommand>
<executablePath></executablePath>
<ccTool>
<incDir>
<pElem>include</pElem>
</incDir>
</ccTool>
</makeTool>
<preBuild>
<preBuildCommandWorkingDir>.</preBuildCommandWorkingDir>
......@@ -59,12 +54,18 @@
<folder path="0/src">
<ccTool>
<incDir>
<pElem>src</pElem>
<pElem>include</pElem>
<pElem>.</pElem>
</incDir>
</ccTool>
</folder>
<item path="main.cpp" ex="false" tool="1" flavor2="8">
<ccTool flags="0">
<incDir>
<pElem>include</pElem>
<pElem>.</pElem>
</incDir>
</ccTool>
</item>
<item path="src/continuoustpda.cpp" ex="false" tool="1" flavor2="8">
......
# Automatic path mapper. CRC = 1
# Automatic path mapper. CRC = 468718686
/home/sparsa/NetBeansProjects=/home/sparsa/Programming
/home/sparsa/Programming/mtp/src/tpdaCGPP.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/tpdaCGPP.cpp -o ./obj/tpdaCGPP.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/timePushDown.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/timePushDown.cpp -o ./obj/timePushDown.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/tpda2.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/tpda2.cpp -o ./obj/tpda2.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/drawsystem.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/drawsystem.cpp -o ./obj/drawsystem.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/continuoustpda.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/continuoustpda.cpp -o ./obj/continuoustpda.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/tpdaZone.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/tpdaZone.cpp -o ./obj/tpdaZone.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/treeBitOperations.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/treeBitOperations.cpp -o ./obj/treeBitOperations.o -lm -std=c++11
/home/sparsa/Programming/mtp/src/pds.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c ./src/pds.cpp -o ./obj/pds.o -lm -std=c++11
/home/sparsa/Programming/mtp/main.cpp=/home/sparsa/Programming/mtp#-g -I ./include -c main.cpp -o main.o -lm -std=c++11
......@@ -49,7 +49,7 @@
#include <functional> // Function objects, designed for use with the standard algorithms
#include <utility> // Various utility components
#include <ctime> // C-style time/date utilites
#include <cstddef> // typedefs for types such as size_t, NULL and others
#include <cstddef> // typedefs for types such as size_t, nullptr and others
#include <new> // Low-level memory management utilities
#include <memory> // Higher level memory management utilities
#include <climits> // limits of integral types
......
......@@ -111,19 +111,19 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
// trans at L of s2 should be same as trans at R of this state
if( d4 != (s2->d2) || w4 != (s2->w2) )
return NULL;
return nullptr;
// there should be a push at L and pop at R of state s2
if( !isPush(s2->d2) || !isPop(s2->d4) )
return NULL;
return nullptr;
// push and pop symbol must be same
if( (transitions[s2->d2].as) != (transitions[s2->d4].as) )
return NULL;
return nullptr;
// push-pop edge between L and R of s2 should be added
if( ( (s2->gc) & 1 ) == 0 || ( (s2->gc) & 128 ) == 0 ) // push-pop edge not added yet
return NULL;
return nullptr;
char gcn; // flag for the new state
char d0, w0; // d1 and w1 for the new state
......@@ -144,14 +144,14 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
// if d3 of this state has a reset of clock x1
if( d3 != (-1) ) {
if( d3 != (s2->d1) || w3 != (s2->w1) ) // hanging trans and tsm should be same as d3 and w3 resp.
return NULL;
return nullptr;
// accuracy between d3->d4 and s2->d1 -> s2->d2 should be same
if( (gc & 8) == 0 && ( (s2->gc) & 2) != 0 )
return NULL;
return nullptr;
if( (gc & 8) != 0 && ( (s2->gc) & 2) == 0 )
return NULL;
return nullptr;
d0 = d1; // new hanging points comes from first state
w0 = w1;
......@@ -166,13 +166,13 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
else if(isReset(1, d2) ) {
if( d2 != (s2->d1) || w2 != (s2->w1) )
return NULL;
return nullptr;
if( ac24 && ( (s2->gc) & 2) == 0 )
return NULL;
return nullptr;
if( !ac24 && ( (s2->gc) & 2) != 0 )
return NULL;
return nullptr;
d0 = d1;
w0 = w1;
......@@ -187,15 +187,15 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
else if(d1 != (-1) ) {
if( d1 != (s2->d1) || w1 != (s2->w1) )
return NULL;
return nullptr;
ac14 = !big(1, 4); // accuracy between points d1 and d4 of first state
if( ac14 && ( (s2->gc) & 2) == 0 )
return NULL;
return nullptr;
if( !ac14 && ( (s2->gc) & 2) != 0 )
return NULL;
return nullptr;
d0 = d1;
w0 = w1;
......@@ -216,11 +216,11 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
if( (s2->gc) & 2) { // hanging distance of 2nd state is small
if(!ac24) // if distance between d2 and d4 is big for first state
return NULL;
return nullptr;
dis = mod(w1-w0, M) + d24;
if(dis >= M) // if distance between d2 and d4 is big for first state,
return NULL;
return nullptr;
gcn |= 16; // accuracy between d0 to d1 can be small
}
......@@ -1086,7 +1086,7 @@ bool isEmptyTPDA() {
xrs.right = i;
// shuffle, considering rs as left state
vs = rs->shuffle( states[i] );
if(vs != NULL) { // if new state is valid
if(vs != nullptr) { // if new state is valid
if( (vs->gc) & 16) { // if hanging distance is accurate
rs1 = vs->copyState();
......@@ -1129,7 +1129,7 @@ bool isEmptyTPDA() {
// shuffle, considering rs as right state
vs = states[i]->shuffle(rs);
if(vs != NULL) { // if new state is valid
if(vs != nullptr) { // if new state is valid
if( (vs->gc) & 16) { // if hanging distance is accurate
rs1 = vs->copyState();
......
......@@ -38,26 +38,26 @@ pds_state* pds_state::add_stack() {
// if push edge already added to left point(bit 1) or pop edge already added to right point(bit 2)
if(gc & 6) // looking at 1st and 2nd bit from right side(bit position starts from 0)
return NULL;
return nullptr;
if( !isPush(del1) || !isPop(del2) ) // there must be a push at first point and pop at 2nd point
return NULL;
return nullptr;
if(transitions[del1].as != transitions[del2].as) // push and pop stack symbol must be same
return NULL;
return nullptr;
int lb = transitions[del2].lbs[0]; // lower bound for symbol age
int ub = transitions[del2].ubs[0];// upper bound
// if distance between two points is big, but upper bound is not infinity
if( (gc & 1) == 0 && ub != INF)
return NULL;
return nullptr;
//if distance between two points is accurate
if(gc & 1) {
int dis = mod(w2-w1, M);
if(dis < lb || dis > ub) // distance must be compatible with the bounds
return NULL;
return nullptr;
}
......@@ -82,13 +82,13 @@ pds_state* pds_state::add_stack() {
pds_state* pds_state::shuffle(pds_state *s2){ // shuffle with state s2{
if( del2 != (s2->del1) || w2 != (s2->w1) )
return NULL;
return nullptr;
if( isPush(s2->del1) && ( (s2->gc) & 2 ) == 0 ) // if there is a push of first point of 2nd state, but not yet done
return NULL;
return nullptr;
if( isPop(del2) && (gc & 4) == 0 ) // if there is a pop of second point of 1st state, but not yet done
return NULL;
return nullptr;
pds_state *vs = new pds_state(); // allocate memory for new state
......@@ -290,7 +290,7 @@ bool pdsempty() {
for(w2=0; w2 < M; w2++) {
vs = atomic(d1, d2, w1, w2, 1); // atomic state with distance accurate
if(vs != NULL && identity(vs) ) {
if(vs != nullptr && identity(vs) ) {
states.push_back(vs);
vrs.push_back(xrs);
......@@ -307,7 +307,7 @@ bool pdsempty() {
}
vs = atomic(d1, d2, w1, w2, 0); // atomic state with distance big
if(vs != NULL && identity(vs) ) {
if(vs != nullptr && identity(vs) ) {
states.push_back(vs);
......@@ -342,7 +342,7 @@ bool pdsempty() {
//states[count]->print();
vs = states[count]->add_stack();
if(vs != NULL && identity(vs) ) {
if(vs != nullptr && identity(vs) ) {
xrs.type = 1; // add_stack type
xrs.left = count;
......@@ -364,7 +364,7 @@ bool pdsempty() {
xrs.type = 2; // shuffle type
vs = states[count]->shuffle(states[i]);
if(vs != NULL && identity(vs) ) {
if(vs != nullptr && identity(vs) ) {
xrs.left = count;
xrs.right = i;
......@@ -384,7 +384,7 @@ bool pdsempty() {
// shuffle i-th state with 'count'-th state
vs = states[i]->shuffle(states[count]);
if(vs != NULL && identity(vs) ) {
if(vs != nullptr && identity(vs) ) {
xrs.left = i;
xrs.right = count;
......
......@@ -29,26 +29,26 @@ stpdastate* stpdastate::shuffle(stpdastate *s2) {
// transion at L of s2 should be same as transion at R of this state, tsm values as well better be equal
if( d2 != (s2->d1) || w2 != (s2->w1) )
return NULL;
return nullptr;
// there should be a push at L and pop at R of state s2
if( !isPush(s2->d1) || !isPop(s2->d2) )
return NULL;
return nullptr;
/* ******** THIS IS A HUGE MISTAKE , IN OTHER FILES ALSO *****************, REMOVE THIS
// push and pop symbol must be same
if( (transitions[s2->d1].ps) != (transitions[s2->d2].pp) )
return NULL;
return nullptr;
*/
//cout << "ilias" << endl;
// push-pop edge between L and R of s2 should be added
if( ( (s2->gc) & 1 ) == 0 ) // push-pop edge not added yet
return NULL;
return nullptr;
char gcn; // flag for the new state
......@@ -578,7 +578,7 @@ bool isEmptySTPDA() {
xrs.right = i;
// shuffle, considering rs as left state
vs = rs->shuffle( states[i] );
if(vs != NULL) { // if new state is valid
if(vs != nullptr) { // if new state is valid
if( identity(vs) ) {
states.push_back(vs);
vrs.push_back(xrs);
......@@ -599,7 +599,7 @@ bool isEmptySTPDA() {
// shuffle, considering rs as right state
vs = states[i]->shuffle(rs);
if(vs != NULL) { // if new state is valid
if(vs != nullptr) { // if new state is valid
if( identity(vs) ) {
states.push_back(vs);
vrs.push_back(xrs);
......
......@@ -227,7 +227,7 @@ bool stateGCPP::shuffleCheck(stateGCPP *s2) {
stateGCPP* stateGCPP::shuffle(stateGCPP *s2){ // shuffle with state s2
if(! shuffleCheck(s2) )
return NULL;
return nullptr;
return reduceShuffle(s2);
}
......@@ -935,7 +935,7 @@ bool isEmptyGCPP() {
for(i=0; i < count; i++) {
// shuffle, considering rs as left state
vs = rs->shuffle( allStates[i].first );
if(vs != NULL) { // if new state is valid
if(vs != nullptr) { // if new state is valid
if( identity(vs) ) {
xrs = getTrack(2, count, i); // key for the new state
allStates.push_back( make_pair(vs, xrs) );
......@@ -968,7 +968,7 @@ bool isEmptyGCPP() {
// shuffle, considering rs as right state
vs = (allStates[i].first)->shuffle(rs);
if(vs != NULL) { // if new state is valid
if(vs != nullptr) { // if new state is valid
if( identity(vs) ) {
xrs = getTrack(2, i, count); // key for the new state
allStates.push_back( make_pair(vs, xrs) );
......
This diff is collapsed.
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment