Пример #1
0
// Find an EGLConfig that is an exact match for the specified attributes. EGL_FALSE is returned if
// the EGLConfig is found.  This indicates that the EGLConfig is not supported.
EGLBoolean EGLWindow::FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config)
{
    EGLint numConfigs = 0;
    eglGetConfigs(dpy, nullptr, 0, &numConfigs);
    std::vector<EGLConfig> allConfigs(numConfigs);
    eglGetConfigs(dpy, allConfigs.data(), allConfigs.size(), &numConfigs);

    for (size_t i = 0; i < allConfigs.size(); i++)
    {
        bool matchFound = true;
        for (const EGLint *curAttrib = attrib_list; curAttrib[0] != EGL_NONE; curAttrib += 2)
        {
            EGLint actualValue = EGL_DONT_CARE;
            eglGetConfigAttrib(dpy, allConfigs[i], curAttrib[0], &actualValue);
            if (curAttrib[1] != actualValue)
            {
                matchFound = false;
                break;
            }
        }

        if (matchFound)
        {
            *config = allConfigs[i];
            return EGL_TRUE;
        }
    }

    return EGL_FALSE;
}
Пример #2
0
void PMN::fillConfigs(){

	for(int i=0; i < (order/2); i++){

		int kappa = (i+1)*2;
		
		//First initialise all configurations, and add them to a vector. As there must be an equal number of p's and m's
		//there are binominal(n,n/2) of these.
		int validConfigs = Utility::BinomialCoefficients<int>(kappa, kappa/2);
		std::vector<PMConfig> allConfigs(validConfigs,PMConfig(kappa));

		//The configurations are filled using a recursive function fillAllConfigs, which is explained in more detail later.
		//After this the vector allConfigs should be filled. At e.q. k^4 it is filled with ppmm, pmpm, pmmp, mpmp, mmpp, mppm
		fillAllConfigs(0,(kappa/2+1),kappa/2,allConfigs,0);

		//Do a superficial ordering of all elements so that they all start with a p and end with an m
		for(auto &conf : allConfigs){
			conf.ordering();
		}

		//Add an emply std::vector<PMPair> to the back of the configurations-list
		//configurations.emplace_back;

		for(int j=0; j<validConfigs; j++){

			bool incr = false;
			//Check through the vector of PMPairs and see if the configuration is already present or not
			for(auto &conf : configurations[i]){

				//If it is present, add to the count and move on. The overloaded equality operator
				//also checks all permutations
				if(allConfigs[j] == conf){
					conf++;
					incr=true;
					break;
				}
			}

			//If it wasn't found, add it
			if(!incr){
				configurations[i].push_back(allConfigs[j]);
				configurations[i].back().finalise();
			}
		}

		//Then add its exponential combinatoric factor: -2/order, the 2 from the gamma-trace
		for(auto &conf : configurations[i]){
			conf *= (PM::pref_type)-2;
			conf /= kappa;
		}
	}

	//At order kappa^2 there are no multi-trace configurations
	if(order == 2){
		return;
	}

	int first_multi_trace = configurations.back().size(); //The number of single trace configurations

	//Here we use the subset_sum function defined in std_libs/std_funcs.h. It takes a list of positive integers to 
	//sum and a target, then it finds all possible ways to sum the numbers in the subset so that the result is the target.
	//E.g. {2,4} to 6 gives 2 lists: {2,2,2},{2,4}
	std::vector<int> subset(order/2 - 1);

	for(int i=0; i < (order/2-1); i++){
		subset[i] = (i+1)*2;
	}

	SubsetSum<> sumCreator(order, subset);
	std::list< std::vector<int> > combinations = sumCreator.calculate();

	//A comb is now a list of which PMConfig's we want to construct the multi-trace contrib
	for(auto &comb : combinations){
		configurations.back().emplace_back(order);
		
		std::list< std::vector<int> > send_set;    //This is a parameter sent between the recursive calls to calculate 
		fill_multi_config(comb,0,0,send_set); 		//the combinatoric factor in the end
	}

	//An iterator which starts at the first multi trace
	multi_trace_begin = configurations.back().begin();
	std::advance(multi_trace_begin, first_multi_trace);

	multi_trace_begin_const = multi_trace_begin;
}