con_closed.cpp

Go to the documentation of this file.
00001 /** @file con_closed.cpp Conditionalclosedness */
00002 
00003 /*
00004  * Implementation of the conditionally clossed algorithm
00005  *
00006  * Copyright (C) 2011  Tomas Masopust
00007  *
00008  */
00009 
00010 
00011 #include "con_closed.h"
00012 #include <vector>
00013 
00014 namespace faudes {
00015 
00016 bool IsConditionalClosed(const GeneratorVector& specVect, const Generator& pk, const GeneratorVector& genVect, const Generator& gk) {
00017   FD_DF("Conditionalclosedness checking...");
00018   
00019   Idx i;
00020 
00021   // there must be the same number of parameters
00022   if (specVect.Size() != genVect.Size()) {
00023     std::stringstream errstr;
00024     errstr << "The sizes of specVect and genVect are different.";
00025     throw Exception("ConditionalClosedness", errstr.str(), 201);
00026   }
00027 
00028   // the generators must be deterministic
00029   for (i = 0; i < specVect.Size(); i++) {
00030     if (specVect.At(i).IsDeterministic() == false) {
00031       std::stringstream errstr;
00032       errstr << "Generators of specVect must be deterministic, but there is a nondeterministic one";
00033       throw Exception("ConditionalClosednes", errstr.str(), 201);
00034     }
00035   }
00036   
00037   if (pk.IsDeterministic() == false) {
00038     std::stringstream errstr;
00039     errstr << "Generator pk must be deterministic, but is nondeterministic";
00040     throw Exception("ConditionalClosedness", errstr.str(), 201);
00041   }
00042   
00043   for (i = 0; i < genVect.Size(); i++) {
00044     if (genVect.At(i).IsDeterministic() == false) {
00045       std::stringstream errstr;
00046       errstr << "Generators of genVect must be deterministic, but there is a nondeterministic one";
00047       throw Exception("ConditionalClosedness", errstr.str(), 201);
00048     }
00049   }
00050   
00051   if (gk.IsDeterministic() == false) {
00052     std::stringstream errstr;
00053     errstr << "Generator gk must be deterministic, but is nondeterministic";
00054     throw Exception("ConditionalClosedness", errstr.str(), 201);
00055   }
00056 
00057   // check if P_k(K) is Lm(G_k)-closed
00058   if (IsRelativelyPrefixClosed(gk,pk) == false) {
00059     return false;
00060   }
00061 
00062   // check if P_{i+k}(K) is Lm(G_i)||P_k(K)-closed
00063   for (i = 0; i < specVect.Size(); i++) {
00064     Generator helpPlant;
00065     Parallel(genVect.At(i),pk,helpPlant);
00066     if (IsRelativelyPrefixClosed(helpPlant,specVect.At(i)) == false) {
00067       return false;
00068     }
00069   }
00070   
00071   return true;
00072 }
00073 
00074 
00075 } // name space 
00076 
00077 
00078 

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen