Ejemplo n.º 1
0
static void randomizeGen(
   const Unsigned genListLength,        /* The length of the list genList. */
   const Permutation *const genList[],  /* The list of (generating) perms. */
   const Unsigned count1,               /* The minimum word length, as above. */
   const Unsigned count2,               /* The maximum word length, as above. */
   Permutation *const randGen)          /* The old and new quasi-random elt. */
{
   Unsigned i,
       wordLength = count1 +
                    ( (count2 > count1) ? randInteger( 0, count2-count1) : 0);
   for ( i = 1 ; i <= wordLength ; ++i )
      rightMultiply( randGen, genList[ randInteger(1,genListLength) ]);
}
Ejemplo n.º 2
0
Word *randGroupWord(
   const PermGroup *const G,
   Unsigned atLevel)
{
   Word *w = newTrivialWord();
   Unsigned  level, pt;
   Permutation **svec;

   for ( level = atLevel ; level <= G->baseSize ; ++level ) {
      pt = G->basicOrbit[level][ randInteger(1,G->basicOrbLen[level]) ];
      svec = G->schreierVec[level];
      while ( svec[pt] != FIRST_IN_ORBIT ) {
         w->position[++w->length] = svec[pt];
         pt = svec[pt]->invImage[pt];
      }
   }
   w->position[++w->length] = NULL;
   return w;
}
Ejemplo n.º 3
0
Permutation *randGroupPerm(
   const PermGroup *const G,
   Unsigned atLevel)
{
   Permutation *randPerm = newIdentityPerm( G->degree);
   Unsigned  level, pt, i;
   Permutation **svec;

   for ( level = atLevel ; level <= G->baseSize ; ++level ) {
      pt = G->basicOrbit[level][ randInteger(1,G->basicOrbLen[level]) ];
      svec = G->schreierVec[level];
      while ( svec[pt] != FIRST_IN_ORBIT ) {
         for ( i = 1 ; i <= G->degree ; ++i )
            randPerm->image[i] = svec[pt]->invImage[ randPerm->image[i] ];
         pt = svec[pt]->invImage[pt];
      }
   }
   randPerm->invImage = NULL;
   adjoinInvImage( randPerm);

   return randPerm;
}
Ejemplo n.º 4
0
void SplitFunctionImgPatch<BaseType, BaseTypeIntegral, AppContext>::SetRandomValues()
{
	// some initializations
	int min_w, min_h, max_w, max_h;
	int min_x, min_y, max_x, max_y;

    // if set, draw a random split function from the list
    // and set the member of SplitFunctionImgPatch
    if (m_appcontext->use_random_split_function){
        int num_available_split_functions = m_appcontext->split_function_type_list.size();
        this->m_splitfunction_type = m_appcontext->split_function_type_list[randInteger(0, num_available_split_functions-1)];
    } else {
        // use the default implementation
        this->m_splitfunction_type = m_appcontext->split_function_type;
    }

	// get some patch sub-regions
    switch (this->m_splitfunction_type){
	case SPLITFUNCTION_TYPE::SINGLEPIXELTEST:
		this->px1.x = randInteger(0, m_appcontext->patch_size[1]-1);
		this->px1.y = randInteger(0, m_appcontext->patch_size[0]-1);
		break;
	case SPLITFUNCTION_TYPE::PIXELPAIRTEST:
		this->px1.x = randInteger(0, m_appcontext->patch_size[1]-1);
		this->px1.y = randInteger(0, m_appcontext->patch_size[0]-1);
		this->px2.x = randInteger(0, m_appcontext->patch_size[1]-1);
		this->px2.y = randInteger(0, m_appcontext->patch_size[0]-1);
		break;
	case SPLITFUNCTION_TYPE::PIXELPAIRTESTCONDITIONED:
		this->px1.x = randInteger(0, m_appcontext->patch_size[1]-1);
		this->px1.y = randInteger(0, m_appcontext->patch_size[0]-1);
		int min_x, max_x, min_y, max_y;
		max_w = 10;
		min_x = max(0, px1.x - max_w);
		max_x = min(m_appcontext->patch_size[1]-1, px1.x + max_w);
		min_y = max(0, px1.y - max_w);
		max_y = min(m_appcontext->patch_size[0]-1, px1.y + max_w);
		this->px2.x = randInteger(min_x, max_x);
		this->px2.y = randInteger(min_y, max_y);
		break;
	case SPLITFUNCTION_TYPE::HAAR_LIKE:
		min_w = 1;
		min_h = 1;
		//max_w = static_cast<int>((double)m_appcontext->patch_size[1]*0.5);
		//max_h = static_cast<int>((double)m_appcontext->patch_size[0]*0.5);
		max_w = static_cast<int>((double)m_appcontext->patch_size[1]*0.90);
		max_h = static_cast<int>((double)m_appcontext->patch_size[0]*0.90);
		this->re1.width = randInteger(min_w, max_w);
		this->re1.height = randInteger(min_w, max_w);
		this->re1.x = randInteger(0, m_appcontext->patch_size[1]-re1.width);
		this->re1.y = randInteger(0, m_appcontext->patch_size[0]-re1.height);
		this->re2.width = randInteger(min_w, max_w);
		this->re2.height = randInteger(min_w, max_w);
		this->re2.x = randInteger(0, m_appcontext->patch_size[1]-re2.width);
		this->re2.y = randInteger(0, m_appcontext->patch_size[0]-re2.height);
		break;
	case SPLITFUNCTION_TYPE::ORDINAL:
//		this->pxs.resize(m_appcontext->ordinal_split_k);
//		for (size_t k = 0; k < pxs.size(); k++)
//		{
//			pxs[k].x = randInteger(0, m_appcontext->patch_size[1]-1);
//			pxs[k].y = randInteger(0, m_appcontext->patch_size[0]-1);
//		}
        // ORDINAL IS IMPLEMENTED HERE, BUT NOT IN GETRESPONSE?????
        throw std::logic_error("SplitFunction (set random value): Ordinal split functions not implemented yet!");
		break;
	default:
		throw std::runtime_error("SplitFunction: unknown split-type not implemented");
	}

	// define the feature channels
	this->ch1 = randInteger(0, m_appcontext->num_feature_channels-1);
	if (m_appcontext->split_channel_selection == 0)
		// use the same channel
		this->ch2 = this->ch1;
	else if (m_appcontext->split_channel_selection == 1)
		// use 2 random channels
		this->ch2 = randInteger(0, m_appcontext->num_feature_channels-1);
	else if (m_appcontext->split_channel_selection == 2)
	{
		// 50/50 chance of using same channel or using 2 random channels.
		if (randDouble() > 0.5)
			this->ch2 = this->ch1;
		else
			this->ch2 = randInteger(0, m_appcontext->num_feature_channels-1);
	}
	else
		throw std::runtime_error("SplitFunction: unknown channel-selection type");
}