// COPYRIGHT 2020 Claudius Zibrowius
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
#ifndef BNALGEBRA_TPP
#define BNALGEBRA_TPP
#ifndef BNALGEBRA_H
#include "BNAlgebra.h"
#endif
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// BNObj
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BNObj::BNObj(bool idem,int h, int q) :
idem(idem),
h(h),
q(q)
{
}
// //
// output and sanity checks //
// //
void BNObj::print() const
{
std::cout << this->to_string() <<"\n";
}
std::string BNObj::to_string(bool with_grading) const{
std::string output;
if (idem){output+="●";}
else {output+="○";};
if (with_grading){
output+= (" h^"+std::to_string(h));
output+= (" q^"+std::to_string(q));
output+= (" δ^"+std::to_string(this->get_delta2()/2));
};
return output;
}
std::string BNObj::to_TeX() const{
std::string output;
if (idem){output+="\\DotB";}
else {output+="\\DotC";};
output+= ("h^{"+std::to_string(h)+"}");
output+= ("q^{"+std::to_string(q)+"}");
output+= ("\\delta^{"+std::to_string(this->get_delta2()/2)+"}");
return output;
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Label
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template
Label::Label(int type, Coeff coeff) :
type(type),
coeff(coeff){
};
// //
// output //
// //
template
std::string Label::to_string(bool with_coeff) const {
std::string output;
if (with_coeff){
output+=coeff_to_string(coeff);
output+=".";
};
if (type>0){
output+=("D^"+std::to_string(type));
}
else if (type==0){
output+=("id");
}
else{
output+=("S^"+std::to_string(-type));
};
return output;
};
// //
// main methods //
// //
template
bool label_is_zero(const Label &label){
// this function is used in BNMor::simplify().
return coeff_is_0(label.coeff);
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// BNMor
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template
BNMor::BNMor(int i) :
front(BNObj()),
back(BNObj()),
labels({}){
}
template
BNMor::BNMor() :
front(BNObj()),
back(BNObj()),
labels({}){
}
template
BNMor::BNMor(BNObj front, BNObj back, std::list