Example #1
0
	InternalArgument execute(const std::vector<InternalArgument>& args) const {
		Structure* s1 = get<0>(args);
		Structure* s2 = get<1>(args);

		auto equal = true;

		if(equal){
			equal &= s1!=NULL && s2!=NULL;
		}
		if(equal){
			equal &= s1->vocabulary()==s2->vocabulary();
		}
		if(equal){
			for(auto sort2inter : s1->getSortInters()){
				auto sort = sort2inter.first;
				auto inter = sort2inter.second;
				if(sort->builtin()){
					continue;
				}
				auto inter2 = s2->inter(sort);
				equal &= checkEquality(inter, inter2);
			}
			for(auto pred2inter : s1->getPredInters()){
				auto pred = pred2inter.first;
				auto inter = pred2inter.second;
				if(pred->builtin() || pred->overloaded()){
					continue;
				}
				auto inter2 = s2->inter(pred);
				equal &= inter->ct()->approxEqual(inter2->ct()) || checkEquality(inter->ct(), inter2->ct());
				equal &= inter->cf()->approxEqual(inter2->cf()) || checkEquality(inter->ct(), inter2->ct());
			}
			for(auto func2inter : s1->getFuncInters()){
				auto func = func2inter.first;
				auto inter = func2inter.second->graphInter();
				if(func->builtin() || func->overloaded()){
					continue;
				}
				auto inter2 = s2->inter(func)->graphInter();
				equal &= inter->ct()->approxEqual(inter2->ct()) || checkEquality(inter->ct(), inter2->ct());
				equal &= inter->cf()->approxEqual(inter2->cf()) || checkEquality(inter->ct(), inter2->ct());
			}
		}

		InternalArgument ia;
		ia._type = AT_BOOLEAN;
		ia._value._boolean = equal;
		return ia;
	}
Example #2
0
/// Make sure this stencil makes sense for this mesh.
void FEM_Ghost_Stencil::check(const FEM_Mesh &mesh) const {
  const FEM_Elem &elem=mesh.elem[mesh.chkET(elType)];
  checkEquality("number of elements",
		n,"FEM_Ghost_stencil",
		elem.size(),"mesh");
  int i,prevEnd=0;
  for (i=0;i<n;i++) {
    int nElts=ends[i]-prevEnd;
    checkRange("FEM_Ghost_stencil index array",nElts,n);
    prevEnd=ends[i];
  }
  int m=ends[n-1];
  for (i=0;i<m;i++) {
    int t=adj[2*i+0];
    mesh.chkET(t);
    checkRange("FEM_Ghost_stencil neighbor array",
	       adj[2*i+1],mesh.elem[t].size());
  }
}
static bool
executeExpr(char *jqBase, int32 jqPos, int32 op, JsonbValue *jb)
{
	int32	type;
	int32	nextPos;

	check_stack_depth();

	/*
	 * read arg type 
	 */
	jqPos = readJsQueryHeader(jqBase, jqPos, &type, &nextPos);

	Assert(nextPos == 0);
	Assert(type == jqiAny || type == jqiString || type == jqiNumeric || 
		   type == jqiNull || type == jqiBool || type == jqiArray);

	switch(op)
	{
		case jqiEqual:
			if (jb->type == jbvBinary && type == jqiArray)
				return checkArrayEquality(jqBase, jqPos, type, jb);
			return checkEquality(jqBase, jqPos, type, jb);
		case jqiIn:
			return checkIn(jqBase, jqPos, type, jb);
		case jqiOverlap:
		case jqiContains:
		case jqiContained:
			return executeArrayOp(jqBase, jqPos, type, op, jb);
		case jqiLess:
		case jqiGreater:
		case jqiLessOrEqual:
		case jqiGreaterOrEqual:
			return makeCompare(jqBase, jqPos, type, op, jb);
		default:
			elog(ERROR, "Unknown operation");
	}

	return false;
}
Example #4
0
// Add a new graph to our PatternMap
void PatternMap::Add( Graph*g ) {
    PatternList_iterator i;
    Graph_iterator j;

    // if the map is empty or does not contain this size, add it 
    if ( Patterns.find(g->size()) == Patterns.end() ) 
    { 
        Label(g); // label all the nodes arbitrarily
        Patterns[g->size()].push_back( GraphList() );
        EquivalentCopies[g->size()].push_back( GraphList() );
        Patterns[g->size()].back().push_back(g);

        Graph * g_copy = new Graph;
        *(g_copy) = *g;
        Label(g_copy); // label all the nodes arbitrarily
        EquivalentCopies[g->size()].back().push_back(g_copy);
        // and also add all equivalent copies
        AddEquivalentCopies( 
            g, 
            g->GraphNodes.begin()->first, 
            &( EquivalentCopies[g->size()].back() ) 
        );    
        return;
    }

    // otherwise the size exists. Check for the graph in every GraphList of  
    // every Pattern list for this size, and if it is found then the pattern 
    // exists so increment its frequency.

    // Note this is where the EquivalentCopies GraphList is used: we need to 
    // determine if the pattern of Graph g has been found before, but it could
    // be that it was found but in a different (equivalent) form
    
    // for each GraphList in the vector
    for (    PatternList_iterator i1 = Patterns[g->size()].begin(), 
            i2 = EquivalentCopies[g->size()].begin(); 
            i1 != Patterns[g->size()].end(); 
            ++i1, ++i2
        ) 
    {
        // for each graph in the GraphList
        for (Graph_iterator j = i2->begin(); j != i2->end(); ++j) { 
            if ( checkEquality(g, *j) ) {
                // We have a match, i.e. the 2 graphs are functionally the same, 
                // but not necessarily topologically. To ensure
                CopyLabels (*j, g); 
                i1->push_back(g);   
                // The labels are consistent, i.e. label "1" always corresponds 
                // to the same add
                // Copy the labels now then add the graph
                return;
            }
        }
    }

    // the pattern has not been found, so add it as above

    Label(g);    // label all the nodes arbitrarily 
    Patterns[g->size()].push_back( GraphList() );
    EquivalentCopies[g->size()].push_back( GraphList() );
    Patterns[g->size()].back().push_back(g);

    Graph * g_copy = new Graph;
    *(g_copy) = *g;
    Label(g_copy); // label all the nodes arbitrarily 
    EquivalentCopies[g->size()].back().push_back(g_copy);
    // and also add all equivalent copies
    AddEquivalentCopies( 
        g, 
        g->GraphNodes.begin()->first, 
        &( EquivalentCopies[g->size()].back() ) 
    );    
}