Exemplo n.º 1
0
bool CorporationDB::CreateMemberAttributeUpdate(MemberAttributeUpdate & attrib, uint32 newCorpID, uint32 charID) {
    // What are we doing here exactly?
    // Corporation gets a new member
    // it's new to it

    DBQueryResult res;
    DBResultRow row;
    if (!sDatabase.RunQuery(res,
        " SELECT "
        "   title, corporationDateTime, corporationID, "
        "   corpRole, rolesAtAll, rolesAtBase, "
        "   rolesAtHQ, rolesAtOther "
        " FROM character_ "
        " WHERE character_.characterID = %u ", charID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return false;
    }

    if (!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Cannot find character in database");
        return false;
    }

    // this could be stored in the db
#define PRN new PyNone()
#define PRI(i) new PyInt(i)
#define PRL(i) new PyLong(i)
#define PRS(s) new PyString(s)
#define PRNI(i) (row.IsNull(i) ? PRI(0) : PRI(row.GetUInt64(i)))
#define F(name, o, n) \
    attrib.name##Old = o; \
    attrib.name##New = n

    //element                   Old Value               New Value
    F(accountKey,               PRN,                    PRN);
    // i don't even know what this could refer to
    F(baseID,                   PRN,                    PRN);
    F(characterID,              PRN,                    PRI(charID));
    F(corporationID,            PRI(row.GetUInt(2)),    PRI(newCorpID));
    // these also have to be queried from the db
    F(divisionID,               PRN,                    PRN);
    F(roles,                    PRNI(3),                PRI(0));
    F(grantableRoles,           PRNI(4),                PRI(0));
    F(grantableRolesAtBase,     PRNI(5),                PRI(0));
    F(grantableRolesAtHQ,       PRNI(6),                PRI(0));
    F(grantableRolesAtOther,    PRNI(7),                PRI(0));
    F(squadronID,               PRN,                    PRN);
    F(startDateTime,            PRL(row.GetUInt64(1)),  PRL(Win32TimeNow()));
    // another one i have no idea
    F(titleMask,                PRN,                    PRI(0));
    F(baseID,                   PRS(row.GetText(0)),    PRS(""));
#undef F
#undef PRN
#undef PRI
#undef PRS
#undef PRNI

    return true;
}
Exemplo n.º 2
0
static void
medsa_print_full(netdissect_options *ndo,
		 const struct medsa_pkthdr *medsa,
		 u_int caplen)
{
	u_char tag = TAG(medsa);

	ND_PRINT((ndo, "%s",
		  tok2str(tag_values, "Unknown (%u)", tag)));

	switch (tag) {
	case TAG_TO_CPU:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
			  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		ND_PRINT((ndo, ", %s",
			  tok2str(code_values, "Unknown (%u)", CODE(medsa))));
		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	case TAG_FROM_CPU:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
			  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	case TAG_FORWARD:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		if (TRUNK(medsa))
			ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d",
				  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
		else
			ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
				  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	default:
		ND_DEFAULTPRINT((const u_char *)medsa, caplen);
		return;
	}
}
Exemplo n.º 3
0
GLOBAL void AMD_info
(
    double Info [ ]
)
{
    double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;

    if (!Info)
    {
        return ;
    }

    n = Info [AMD_N] ;
    ndiv = Info [AMD_NDIV] ;
    nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ;
    nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ;
    lnz = Info [AMD_LNZ] ;
    lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;

    /* AMD return status */
    PRINTF ((
                "\namd:  approximate minimum degree ordering, results:\n"
                "    status: ")) ;
    if (Info [AMD_STATUS] == AMD_OK)
    {
        PRINTF (("OK\n")) ;
    }
    else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY)
    {
        PRINTF (("out of memory\n")) ;
    }
    else if (Info [AMD_STATUS] == AMD_INVALID)
    {
        PRINTF (("invalid matrix\n")) ;
    }
    else
    {
        PRINTF (("unknown\n")) ;
    }

    /* statistics about the input matrix */
    PRI ("    n, dimension of A:                                  %.20g\n", n);
    PRI ("    nz, number of nonzeros in A:                        %.20g\n",
         Info [AMD_NZ]) ;
    PRI ("    symmetry of A:                                      %.4f\n",
         Info [AMD_SYMMETRY]) ;
    PRI ("    number of nonzeros on diagonal:                     %.20g\n",
         Info [AMD_NZDIAG]) ;
    PRI ("    nonzeros in pattern of A+A' (excl. diagonal):       %.20g\n",
         Info [AMD_NZ_A_PLUS_AT]) ;
    PRI ("    # dense rows/columns of A+A':                       %.20g\n",
         Info [AMD_NDENSE]) ;

    /* statistics about AMD's behavior  */
    PRI ("    memory used, in bytes:                              %.20g\n",
         Info [AMD_MEMORY]) ;
    PRI ("    # of memory compactions:                            %.20g\n",
         Info [AMD_NCMPA]) ;

    /* statistics about the ordering quality */
    PRINTF (("\n"
             "    The following approximate statistics are for a subsequent\n"
             "    factorization of A(P,P) + A(P,P)'.  They are slight upper\n"
             "    bounds if there are no dense rows/columns in A+A', and become\n"
             "    looser if dense rows/columns exist.\n\n")) ;

    PRI ("    nonzeros in L (excluding diagonal):                 %.20g\n",
         lnz) ;
    PRI ("    nonzeros in L (including diagonal):                 %.20g\n",
         lnzd) ;
    PRI ("    # divide operations for LDL' or LU:                 %.20g\n",
         ndiv) ;
    PRI ("    # multiply-subtract operations for LDL':            %.20g\n",
         nmultsubs_ldl) ;
    PRI ("    # multiply-subtract operations for LU:              %.20g\n",
         nmultsubs_lu) ;
    PRI ("    max nz. in any column of L (incl. diagonal):        %.20g\n",
         Info [AMD_DMAX]) ;

    /* total flop counts for various factorizations */

    if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
    {
        PRINTF (("\n"
                 "    chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
                 "    LDL' flop count for real A:                         %.20g\n"
                 "    LDL' flop count for complex A:                      %.20g\n"
                 "    LU flop count for real A (with no pivoting):        %.20g\n"
                 "    LU flop count for complex A (with no pivoting):     %.20g\n\n",
                 n + ndiv + 2*nmultsubs_ldl,
                 ndiv + 2*nmultsubs_ldl,
                 9*ndiv + 8*nmultsubs_ldl,
                 ndiv + 2*nmultsubs_lu,
                 9*ndiv + 8*nmultsubs_lu)) ;
    }
}
Exemplo n.º 4
0
int compute1(long double &a,string s,int angle=0)//算术综合运算
{
    if(!check_b(s))
        return 0;
    Stack<long double> ss(20);
    Stack<char> sf(20);
    int i=0,j;
    string s1,s2;
    char c;
    long double b;
    while(IsUselessChar(s[i]))
        i++;
    if(s[i]=='-')
    {
        ss.PushStack(-1);
        sf.PushStack('*');
        i++;
    }
    else if(s[i]=='+')
        i++;
    while(s[i])
    {
        s2="\0";
        if(IsUselessChar(s[i]))
            i++;
        else if(IsBracket(s[i])==1)
        {
            if(i>0&&!IsOperator1(s[i-1]))
                if(!sf.PushStack('*'))
                    return 0;
            s2=GetBracketData(s,i);
            if(!compute1(a,s2,angle)||!ss.PushStack(a))
                return 0;
        }
        else if(IsOperator1(s[i]))
        {
            if(s[i]=='!')
            {
                if(!ss.PopStack(b)||!factorial(a,(int)b)||!ss.PushStack(a))
                    return 0;
                i++;
                continue;
            }
            while(sf.GetTopData(c))
            {
                if(PRI(s[i])>PRI(c))
                    break;
                if(!ss.PopStack(b)||!ss.PopStack(a)||!sf.PopStack(c)||!Account1(a,b,c)||!ss.PushStack(a))
                    return 0;
            }
            if(!sf.PushStack(s[i++]))
                return 0;
        }
        else if(IsData(s[i])==1)
        {
            while(IsData(s[i])==1)
                s2+=s[i++];
            if(!ss.PushStack(string_double(s2)))
                return 0;
        }
        else if(s[i]=='S')
        {
            if(i>0&&!IsOperator1(s[i-1]))
                if(!sf.PushStack('*'))
                    return 0;
            s2="\0";
            for(j=0; j<4&&s[i]; j++,i++)
                s2+=s[i];
            if(s2!="Sqrt"||IsBracket(s[i])!=1)
                return 0;
            s2=GetBracketData(s,i);
            s1="\0";
            for(j=0; s2[j]; j++)
            {
                if(IsBracket(s2[j])==1)
                    s1+="("+GetBracketData(s2,j)+")";
                if(s2[j]==',')
                {
                    j++;
                    break;
                }
                else
                    s1+=s2[j];
            }
            if(!compute1(a,s1,angle))
                return 0;
            s1="\0";
            for(; s2[j]; j++)
                s1+=s2[j];
            if(!compute1(b,s1,angle)||!Sqrt(a,b)||!ss.PushStack(a))
                return 0;
        }
        else if(s[i]>='a'&&s[i]<='z'||s[i]=='L')
        {
            s1="\0";
            if(i>0&&!IsOperator1(s[i-1]))
                if(!sf.PushStack('*'))
                    return 0;
            while(s[i]>='a'&&s[i]<='z'||s[i]=='L'||s[i]=='^')
            {
                s1+=s[i++];
                if(s[i-1]=='e'&&s[i]!='^')
                    s1+='^';
            }
            if(s[i-1]=='e')
                s2="1";
            else if(IsBracket(s[i])==1)
                s2=GetBracketData(s,i);
            else if(IsData(s[i])==1)
            {
                while(s[i])
                {
                    if(IsData(s[i])==1)
                        s2+=s[i++];
                    else
                        break;
                }
            }
            else if(s[i]=='P'||s[i+1]=='i')
                s2="Pi";
            else if(s[i]=='S')
            {
                for(j=0; j<4&&s[i]; j++,i++)
                    s2+=s[i];
                if(s2!="Sqrt"||IsBracket(s[i])!=1)
                    return 0;
                s2+="("+GetBracketData(s,i)+")";
            }
            else
                return 0;
            if(!compute1(a,s2,angle)||!compute3(b,s1,a,angle)||!ss.PushStack(b))
                return 0;
        }
        else if(s[i]=='P')
        {
            if(i>0&&!IsOperator1(s[i-1])&&!sf.PushStack('*')||!ss.PushStack(P))
                return 0;
            i+=2;
        }
        else
            return 0;
    }
    while(sf.PopStack(c))
        if(!ss.PopStack(b)||!ss.PopStack(a)||!Account1(a,b,c)||!ss.PushStack(a))
            return 0;
    if(!ss.PopStack(a)||ss.State()>=0)
        return 0;
    return 1;
}
Exemplo n.º 5
0
// cannot access PRI() in prologue
// can access PRO() in prologue but not in body
ERR::ERR()
{
    0,PUB();
    0,PRO();		// BAD
    0,PRI();		// BAD
}
Exemplo n.º 6
0
// can access PRO() in prologue but not in body
OK::OK()
{
    0,PUB();
    0,PRO();		// BAD
    0,PRI();		// BAD
}