Ejemplo n.º 1
0
/*-------------------------------------------------------
	nClass 클래스의 확장 가능한 것 중 membership value가 가장 큰 박스를 찾는 함수

	nClass(입력) : 클래스 번호(0부터 시작)
	return : 찾았으면 해당 박스 번호, 못 찾았으면 -1
-------------------------------------------------------*/
int CFMMNN::FindMaxMembershipBox(int nClass)
{
	register float max = -1.0;
	register int nMax = -1;
	for(register int i = 0; i < m_nBox[nClass]; i ++)
	{
		register MINMAX* pBox = &m_pBox[nClass][i];
		register float t = GetMembership(pBox);
		if(t > max && IsExpandable(pBox))
		{
			max = t;
			nMax = i;
		}
	}

	return nMax;
}
Ejemplo n.º 2
0
/*-------------------------------------------------------
	입력벡터에 대해 membership value가 가장 큰 클래스를 찾는 함수

	return : membership value가 가장 큰 클래스(0부터 시작)
-------------------------------------------------------*/
int CFMMNN::FindMaxMembershipClass()
{
	memset(m_pOutput, 0, sizeof(float) * m_nClass);

	register float max = -1.0;
	int nClass = -1;
	for(register int i = 0; i < m_nClass; i ++)
	{
		for(register int j = 0; j < m_nBox[i]; j ++)
		{
			register float t = GetMembership(&m_pBox[i][j]);
			if(t > m_pOutput[i])
				m_pOutput[i] = t;
		}
		if(m_pOutput[i] > max)
		{
			max = m_pOutput[i];
			nClass = i;
		}
	}

	return nClass;
}
Ejemplo n.º 3
0
void CChannel::SetModes ( const CString& szModes, const std::vector < CString >& vecModeParams )
{
    unsigned int uiParamIndex = 0;
    enum { ADD, DEL } eDirection = ADD;
    CServer& me = CProtocol::GetSingleton ().GetMe ();

    const char* p = szModes.c_str ();
    while ( *p != '\0' )
    {
        switch ( *p )
        {
        case '+':
        {
            eDirection = ADD;
            break;
        }
        case '-':
        {
            eDirection = DEL;
            break;
        }
        default:
        {
            unsigned long ulMode = ms_ulChannelModes [ (unsigned char)*p ];
            if ( ulMode != 0 )
            {
                if ( ulMode < CMODE_PARAMSMAX )
                {
                    if ( eDirection == ADD )
                        m_ulModes |= ulMode;
                    else
                        m_ulModes &= ~ulMode;

                    if ( ulMode >= CMODE_MAX )
                    {
                        // El modo lleva parámetros
                        switch ( ulMode )
                        {
                        case CMODE_KEY:
                            if ( eDirection == ADD )
                                SetKey ( vecModeParams [ uiParamIndex ] );
                            else
                                SetKey ( "" );
                            ++uiParamIndex;
                            break;
                        case CMODE_LIMIT:
                            if ( eDirection == ADD )
                            {
                                SetLimit ( atoi ( vecModeParams [ uiParamIndex ] ) );
                                ++uiParamIndex;
                            }
                            else
                                SetLimit ( 0 );
                            break;
                        }
                    }
                }
                else
                {
                    // Cambiamos flags de usuarios o bans
                    if ( ulMode == CFLAG_BAN )
                    {
                        if ( eDirection == ADD )
                            AddBan ( vecModeParams [ uiParamIndex ] );
                        else
                            RemoveBan ( vecModeParams [ uiParamIndex ] );
                        ++uiParamIndex;
                    }
                    else
                    {
                        CUser* pUser = me.GetUserAnywhere ( base64toint ( vecModeParams [ uiParamIndex ] ) );
                        ++uiParamIndex;

                        if ( pUser )
                        {
                            CMembership* pMembership = GetMembership ( pUser );
                            if ( pMembership )
                            {
                                unsigned long ulCurFlags = pMembership->GetFlags ();
                                if ( eDirection == ADD )
                                    pMembership->SetFlags ( ulCurFlags | ulMode );
                                else
                                    pMembership->SetFlags ( ulCurFlags & ~ulMode );
                            }
                        }
                    }
                }
            }
        }
        }
        ++p;
    }
}