Beispiel #1
0
  Graph(const vec1<vec1<VertexType> >& _points_in, int domain)
  { 
    vec1<vec1<VertexType> > _points = compressGraph(_points_in);
    if(_points.size() > domain)
      throw GAPException("Graph too large");
    edges = _points;
    edges.resize(domain);
    
    for(int i : range1(_points.size()))
    {
        int i_size = _points[i].size();
        for(int j = 1; j <= i_size; ++j)
        {
            if(_points[i][j].target() <= 0 || _points[i][j].target() > domain) {
                throw GAPException("Graph contains out-of-bounds vertex: " + toString(_points[i][j].target()));
            }
            
            if(_points[i][j].colour() < 0 ) {
                throw GAPException(" Graph contains invalid edge colour: " + toString(_points[i][j].colour()));
            }
            VertexType edge(i, _points[i][j].colour());
            if(directed)
            {
              edge = edge.flipped();
            }

            edges[_points[i][j].target()].push_back(edge);
        }
    }
    for(int i : range1(edges.size()))
    {
        std::set<VertexType> pntset(edges[i].begin(), edges[i].end());
        edges[i] = vec1<VertexType>(pntset.begin(), pntset.end());
    }
  }
Obj GAP_get_rec(Obj rec, UInt n)
{
    if(!IS_REC(rec))
        throw GAPException("Invalid attempt to read record");
    if(!ISB_REC(rec, n))
        throw GAPException(std::string("Unable to read value from rec"));
    return ELM_REC(rec, n);
}
 bool operator()(Obj recval) const
 {
     if(recval == True)
         return true;
     if(recval == False)
         return false;
     if(recval == Fail)
         throw GAPException("Got 'fail' as a Boolean");
     throw GAPException("Not a bool!");
 }
// This is a special method. It gets a boolean from a record, and assumes
// it is 'false' if not present
bool GAP_get_maybe_bool_rec(Obj rec, UInt n)
{
    if(!IS_REC(rec))
        throw GAPException("Invalid attempt to read record");
    if(!ISB_REC(rec, n))
        return false;
    Obj b = ELM_REC(rec, n);
    if(b == True)
        return true;
    if(b == False)
        return false;
    throw GAPException("Record element is not a boolean");
}
  GAPRecord operator()(Obj rec) const
  {
    if(!isa(rec))
      throw GAPException("Not a record");

    return GAPRecord(rec);
  }
Beispiel #6
0
  Obj get(const char* c)
  {
    UInt n = RNamName(c);
    if(!has(c))
      throw GAPException("field not in record");

    return ELM_REC(record, n);
  }
Obj GAP_getGlobal(const char* name)
{
    UInt i = GVarName(name);
    Obj o =  VAL_GVAR(i);
    if(!o)
        throw GAPException("Missing global : " + std::string(name));
    return o;
}
 std::pair<T,U> operator()(Obj rec) const
 {
   if(!isa(rec))
     throw GAPException("Invalid attempt to read pair");
   GAP_getter<T> get_T;
   GAP_getter<U> get_U;
   std::pair<T,U> p(get_T(ELM_LIST(rec, 1)), get_U(ELM_LIST(rec, 2)));
   return p;
 }
 sc_config_option optionFromString(std::string s) {
     if(s == "never") return never;
     if(s == "always") return always;
     if(s == "alwaysbase") return alwaysbase;
     if(s == "root") return root;
     if(s == "firstnontrivial") return firstnontrivial;
     
     throw GAPException("'" + s + "' is not a valid configuration option for ConInGroup."
                        "Valid options are never, always, alwaysbase, root, firstnontrivial");
 }
Beispiel #10
0
Con fill_container(Obj rec)
{
    if(!(IS_SMALL_LIST(rec)))
        throw GAPException("Invalid attempt to read list");
    int len = LEN_LIST(rec);

    Con v;
    typedef typename Con::value_type T;
    GAP_getter<T> getter;
    for(int i = 1; i <= len; ++i)
    {
        v.push_back(getter(ELM_LIST(rec, i)));
    }
    return v;
}
Beispiel #11
0
Con fill_optional_container(Obj rec)
{
  if(!(IS_SMALL_LIST(rec)))
      throw GAPException("Invalid attempt to read list");
  int len = LEN_LIST(rec);

  Con v;
  GAP_getter<T> getter;
  for(int i = 1; i <= len; ++i)
  {
      if(ISB_LIST(rec, i))
      { v.push_back(getter(ELM_LIST(rec, i))); }
      else
      { v.push_back(optional<T>()); }
  }
  return v;
}
Beispiel #12
0
 GAPRecord(Obj o) : record(o)
 {
   if(!IS_REC(o))
     throw GAPException("Not a record");
 }
Beispiel #13
0
 int operator()(Obj recval) const
 {
     if(!isa(recval))
         throw GAPException("Invalid attempt to read int");
     return INT_INTOBJ(recval);
 }
Beispiel #14
0
 std::string operator()(Obj recval) const
 {
     if(!isa(recval))
         throw GAPException("Invalid attempt to read string");
     return std::string((char*)CHARS_STRING(recval));
 }
Beispiel #15
0
 operator T()
 {
     if(!GAP_isa<T>(o))
         throw GAPException("Failed to map GAP object to C++");
     return GAP_get<T>(o);
 }