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
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<rebuildPropChanged>false</rebuildPropChanged> <rebuildPropChanged>false</rebuildPropChanged>
</toolsSet> </toolsSet>
<flagsDictionary> <flagsDictionary>
<element flagsID="0" commonFlags="-std=c++11"/> <element flagsID="0" commonFlags="-mtune=generic -march=x86-64 -std=c++11"/>
</flagsDictionary> </flagsDictionary>
<codeAssistance> <codeAssistance>
</codeAssistance> </codeAssistance>
...@@ -45,11 +45,6 @@ ...@@ -45,11 +45,6 @@
<buildCommand>${MAKE} -f makefile</buildCommand> <buildCommand>${MAKE} -f makefile</buildCommand>
<cleanCommand>${MAKE} -f makefile clean</cleanCommand> <cleanCommand>${MAKE} -f makefile clean</cleanCommand>
<executablePath></executablePath> <executablePath></executablePath>
<ccTool>
<incDir>
<pElem>include</pElem>
</incDir>
</ccTool>
</makeTool> </makeTool>
<preBuild> <preBuild>
<preBuildCommandWorkingDir>.</preBuildCommandWorkingDir> <preBuildCommandWorkingDir>.</preBuildCommandWorkingDir>
...@@ -59,12 +54,18 @@ ...@@ -59,12 +54,18 @@
<folder path="0/src"> <folder path="0/src">
<ccTool> <ccTool>
<incDir> <incDir>
<pElem>src</pElem>
<pElem>include</pElem>
<pElem>.</pElem> <pElem>.</pElem>
</incDir> </incDir>
</ccTool> </ccTool>
</folder> </folder>
<item path="main.cpp" ex="false" tool="1" flavor2="8"> <item path="main.cpp" ex="false" tool="1" flavor2="8">
<ccTool flags="0"> <ccTool flags="0">
<incDir>
<pElem>include</pElem>
<pElem>.</pElem>
</incDir>
</ccTool> </ccTool>
</item> </item>
<item path="src/continuoustpda.cpp" ex="false" tool="1" flavor2="8"> <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 @@ ...@@ -49,7 +49,7 @@
#include <functional> // Function objects, designed for use with the standard algorithms #include <functional> // Function objects, designed for use with the standard algorithms
#include <utility> // Various utility components #include <utility> // Various utility components
#include <ctime> // C-style time/date utilites #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 <new> // Low-level memory management utilities
#include <memory> // Higher level memory management utilities #include <memory> // Higher level memory management utilities
#include <climits> // limits of integral types #include <climits> // limits of integral types
......
...@@ -111,19 +111,19 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) { ...@@ -111,19 +111,19 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
// trans at L of s2 should be same as trans at R of this state // trans at L of s2 should be same as trans at R of this state
if( d4 != (s2->d2) || w4 != (s2->w2) ) 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 // there should be a push at L and pop at R of state s2
if( !isPush(s2->d2) || !isPop(s2->d4) ) if( !isPush(s2->d2) || !isPop(s2->d4) )
return NULL; return nullptr;
// push and pop symbol must be same // push and pop symbol must be same
if( (transitions[s2->d2].as) != (transitions[s2->d4].as) ) 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 // 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 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 gcn; // flag for the new state
char d0, w0; // d1 and w1 for the new state char d0, w0; // d1 and w1 for the new state
...@@ -144,14 +144,14 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) { ...@@ -144,14 +144,14 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
// if d3 of this state has a reset of clock x1 // if d3 of this state has a reset of clock x1
if( d3 != (-1) ) { if( d3 != (-1) ) {
if( d3 != (s2->d1) || w3 != (s2->w1) ) // hanging trans and tsm should be same as d3 and w3 resp. 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 // accuracy between d3->d4 and s2->d1 -> s2->d2 should be same
if( (gc & 8) == 0 && ( (s2->gc) & 2) != 0 ) if( (gc & 8) == 0 && ( (s2->gc) & 2) != 0 )
return NULL; return nullptr;
if( (gc & 8) != 0 && ( (s2->gc) & 2) == 0 ) if( (gc & 8) != 0 && ( (s2->gc) & 2) == 0 )
return NULL; return nullptr;
d0 = d1; // new hanging points comes from first state d0 = d1; // new hanging points comes from first state
w0 = w1; w0 = w1;
...@@ -166,13 +166,13 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) { ...@@ -166,13 +166,13 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
else if(isReset(1, d2) ) { else if(isReset(1, d2) ) {
if( d2 != (s2->d1) || w2 != (s2->w1) ) if( d2 != (s2->d1) || w2 != (s2->w1) )
return NULL; return nullptr;
if( ac24 && ( (s2->gc) & 2) == 0 ) if( ac24 && ( (s2->gc) & 2) == 0 )
return NULL; return nullptr;
if( !ac24 && ( (s2->gc) & 2) != 0 ) if( !ac24 && ( (s2->gc) & 2) != 0 )
return NULL; return nullptr;
d0 = d1; d0 = d1;
w0 = w1; w0 = w1;
...@@ -187,15 +187,15 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) { ...@@ -187,15 +187,15 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
else if(d1 != (-1) ) { else if(d1 != (-1) ) {
if( d1 != (s2->d1) || w1 != (s2->w1) ) if( d1 != (s2->d1) || w1 != (s2->w1) )
return NULL; return nullptr;
ac14 = !big(1, 4); // accuracy between points d1 and d4 of first state ac14 = !big(1, 4); // accuracy between points d1 and d4 of first state
if( ac14 && ( (s2->gc) & 2) == 0 ) if( ac14 && ( (s2->gc) & 2) == 0 )
return NULL; return nullptr;
if( !ac14 && ( (s2->gc) & 2) != 0 ) if( !ac14 && ( (s2->gc) & 2) != 0 )
return NULL; return nullptr;
d0 = d1; d0 = d1;
w0 = w1; w0 = w1;
...@@ -216,11 +216,11 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) { ...@@ -216,11 +216,11 @@ tpdastate* tpdastate::shuffle(tpdastate *s2) {
if( (s2->gc) & 2) { // hanging distance of 2nd state is small if( (s2->gc) & 2) { // hanging distance of 2nd state is small
if(!ac24) // if distance between d2 and d4 is big for first state if(!ac24) // if distance between d2 and d4 is big for first state
return NULL; return nullptr;
dis = mod(w1-w0, M) + d24; dis = mod(w1-w0, M) + d24;
if(dis >= M) // if distance between d2 and d4 is big for first state, 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 gcn |= 16; // accuracy between d0 to d1 can be small
} }
...@@ -1086,7 +1086,7 @@ bool isEmptyTPDA() { ...@@ -1086,7 +1086,7 @@ bool isEmptyTPDA() {
xrs.right = i; xrs.right = i;
// shuffle, considering rs as left state // shuffle, considering rs as left state
vs = rs->shuffle( states[i] ); 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 if( (vs->gc) & 16) { // if hanging distance is accurate
rs1 = vs->copyState(); rs1 = vs->copyState();
...@@ -1129,7 +1129,7 @@ bool isEmptyTPDA() { ...@@ -1129,7 +1129,7 @@ bool isEmptyTPDA() {
// shuffle, considering rs as right state // shuffle, considering rs as right state
vs = states[i]->shuffle(rs); 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 if( (vs->gc) & 16) { // if hanging distance is accurate
rs1 = vs->copyState(); rs1 = vs->copyState();
......
...@@ -38,26 +38,26 @@ pds_state* pds_state::add_stack() { ...@@ -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 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) 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 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 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 lb = transitions[del2].lbs[0]; // lower bound for symbol age
int ub = transitions[del2].ubs[0];// upper bound int ub = transitions[del2].ubs[0];// upper bound
// if distance between two points is big, but upper bound is not infinity // if distance between two points is big, but upper bound is not infinity
if( (gc & 1) == 0 && ub != INF) if( (gc & 1) == 0 && ub != INF)
return NULL; return nullptr;
//if distance between two points is accurate //if distance between two points is accurate
if(gc & 1) { if(gc & 1) {
int dis = mod(w2-w1, M); int dis = mod(w2-w1, M);
if(dis < lb || dis > ub) // distance must be compatible with the bounds 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() { ...@@ -82,13 +82,13 @@ pds_state* pds_state::add_stack() {
pds_state* pds_state::shuffle(pds_state *s2){ // shuffle with state s2{ pds_state* pds_state::shuffle(pds_state *s2){ // shuffle with state s2{
if( del2 != (s2->del1) || w2 != (s2->w1) ) 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 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 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 pds_state *vs = new pds_state(); // allocate memory for new state
...@@ -290,7 +290,7 @@ bool pdsempty() { ...@@ -290,7 +290,7 @@ bool pdsempty() {
for(w2=0; w2 < M; w2++) { for(w2=0; w2 < M; w2++) {
vs = atomic(d1, d2, w1, w2, 1); // atomic state with distance accurate 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); states.push_back(vs);
vrs.push_back(xrs); vrs.push_back(xrs);
...@@ -307,7 +307,7 @@ bool pdsempty() { ...@@ -307,7 +307,7 @@ bool pdsempty() {
} }
vs = atomic(d1, d2, w1, w2, 0); // atomic state with distance big 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); states.push_back(vs);
...@@ -342,7 +342,7 @@ bool pdsempty() { ...@@ -342,7 +342,7 @@ bool pdsempty() {
//states[count]->print(); //states[count]->print();
vs = states[count]->add_stack(); vs = states[count]->add_stack();
if(vs != NULL && identity(vs) ) { if(vs != nullptr && identity(vs) ) {
xrs.type = 1; // add_stack type xrs.type = 1; // add_stack type
xrs.left = count; xrs.left = count;
...@@ -364,7 +364,7 @@ bool pdsempty() { ...@@ -364,7 +364,7 @@ bool pdsempty() {
xrs.type = 2; // shuffle type xrs.type = 2; // shuffle type
vs = states[count]->shuffle(states[i]); vs = states[count]->shuffle(states[i]);
if(vs != NULL && identity(vs) ) { if(vs != nullptr && identity(vs) ) {
xrs.left = count; xrs.left = count;
xrs.right = i; xrs.right = i;
...@@ -384,7 +384,7 @@ bool pdsempty() { ...@@ -384,7 +384,7 @@ bool pdsempty() {
// shuffle i-th state with 'count'-th state // shuffle i-th state with 'count'-th state
vs = states[i]->shuffle(states[count]); vs = states[i]->shuffle(states[count]);
if(vs != NULL && identity(vs) ) { if(vs != nullptr && identity(vs) ) {
xrs.left = i; xrs.left = i;
xrs.right = count; xrs.right = count;
......
...@@ -29,26 +29,26 @@ stpdastate* stpdastate::shuffle(stpdastate *s2) { ...@@ -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 // 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) ) 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 // there should be a push at L and pop at R of state s2
if( !isPush(s2->d1) || !isPop(s2->d2) ) if( !isPush(s2->d1) || !isPop(s2->d2) )
return NULL; return nullptr;
/* ******** THIS IS A HUGE MISTAKE , IN OTHER FILES ALSO *****************, REMOVE THIS /* ******** THIS IS A HUGE MISTAKE , IN OTHER FILES ALSO *****************, REMOVE THIS
// push and pop symbol must be same // push and pop symbol must be same
if( (transitions[s2->d1].ps) != (transitions[s2->d2].pp) ) if( (transitions[s2->d1].ps) != (transitions[s2->d2].pp) )
return NULL; return nullptr;
*/ */
//cout << "ilias" << endl; //cout << "ilias" << endl;
// push-pop edge between L and R of s2 should be added // push-pop edge between L and R of s2 should be added
if( ( (s2->gc) & 1 ) == 0 ) // push-pop edge not added yet if( ( (s2->gc) & 1 ) == 0 ) // push-pop edge not added yet
return NULL; return nullptr;
char gcn; // flag for the new state char gcn; // flag for the new state
...@@ -578,7 +578,7 @@ bool isEmptySTPDA() { ...@@ -578,7 +578,7 @@ bool isEmptySTPDA() {
xrs.right = i; xrs.right = i;
// shuffle, considering rs as left state // shuffle, considering rs as left state
vs = rs->shuffle( states[i] ); vs = rs->shuffle( states[i] );
if(vs != NULL) { // if new state is valid if(vs != nullptr) { // if new state is valid
if( identity(vs) ) { if( identity(vs) ) {
states.push_back(vs); states.push_back(vs);
vrs.push_back(xrs); vrs.push_back(xrs);
...@@ -599,7 +599,7 @@ bool isEmptySTPDA() { ...@@ -599,7 +599,7 @@ bool isEmptySTPDA() {
// shuffle, considering rs as right state // shuffle, considering rs as right state
vs = states[i]->shuffle(rs); vs = states[i]->shuffle(rs);
if(vs != NULL) { // if new state is valid if(vs != nullptr) { // if new state is valid
if( identity(vs) ) { if( identity(vs) ) {
states.push_back(vs); states.push_back(vs);
vrs.push_back(xrs); vrs.push_back(xrs);
......
...@@ -227,7 +227,7 @@ bool stateGCPP::shuffleCheck(stateGCPP *s2) { ...@@ -227,7 +227,7 @@ bool stateGCPP::shuffleCheck(stateGCPP *s2) {
stateGCPP* stateGCPP::shuffle(stateGCPP *s2){ // shuffle with state s2 stateGCPP* stateGCPP::shuffle(stateGCPP *s2){ // shuffle with state s2
if(! shuffleCheck(s2) ) if(! shuffleCheck(s2) )
return NULL; return nullptr;
return reduceShuffle(s2); return reduceShuffle(s2);
} }
...@@ -935,7 +935,7 @@ bool isEmptyGCPP() { ...@@ -935,7 +935,7 @@ bool isEmptyGCPP() {
for(i=0; i < count; i++) { for(i=0; i < count; i++) {
// shuffle, considering rs as left state // shuffle, considering rs as left state
vs = rs->shuffle( allStates[i].first ); 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) ) { if( identity(vs) ) {
xrs = getTrack(2, count, i); // key for the new state xrs = getTrack(2, count, i); // key for the new state
allStates.push_back( make_pair(vs, xrs) ); allStates.push_back( make_pair(vs, xrs) );
...@@ -968,7 +968,7 @@ bool isEmptyGCPP() { ...@@ -968,7 +968,7 @@ bool isEmptyGCPP() {
// shuffle, considering rs as right state // shuffle, considering rs as right state
vs = (allStates[i].first)->shuffle(rs); 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) ) { if( identity(vs) ) {
xrs = getTrack(2, i, count); // key for the new state xrs = getTrack(2, i, count); // key for the new state
allStates.push_back( make_pair(vs, xrs) ); 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