/* * Routine: * Purpose: * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ void dump_dist(char *name) { d_idx_t *pIndex; int i, j; char *pCharVal = NULL; int nVal; pIndex = find_dist(name); if (pIndex == NULL) ReportErrorNoLine(QERR_BAD_NAME, name, 1); printf("create %s;\n", pIndex->name); printf("set types = ("); for (i=0; i < pIndex->v_width; i++) { if (i > 0) printf(", "); printf("%s", dist_type(name, i + 1) == 7?"int":"varchar"); } printf(");\n"); printf("set weights = %d;\n", pIndex->w_width); for (i=0; i < pIndex->length; i++) { printf("add("); for (j=0; j < pIndex->v_width; j++) { if (j) printf(", "); if (dist_type(name, j + 1) != 7) { dist_member(&pCharVal, name, i + 1, j + 1); printf("\"%s\"", pCharVal); } else { dist_member(&nVal, name, i + 1, j + 1); printf("%d", nVal); } } printf("; "); for (j=0; j < pIndex->w_width; j++) { if (j) printf(", "); printf("%d", dist_weight(NULL, name, i + 1, j + 1)); } printf(");\n"); } return; }
/** * \fun LocaLization Constructor function * Initializes the Localization class * * * */ Localization::Localization(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : RobotBrainComponent(mgr, descrName, tagName), itsOfs(new OutputFrameSeries(mgr)), itsRunning(true), itsNumParticles(1000), itsKeepParticles(1000), generator(42u), generate_drift(generator, dist_type(M_DRIFT,SIGMA_DRIFT)), generate_trans(generator, dist_type(M_TRANS,SIGMA_TRANS)) { //// The images used for plotting the particles iMap = Image<float > (2000,2000,ZEROS); originalMap = Image<float > (2000,2000,ZEROS); addSubComponent(itsOfs); initPoints(itsNumParticles); }
/* * Routine: EvalDistopExpr(expr_t *pExpr, StringBuffer_t *pBuf); * Purpose: set the values to be used to replace a given tag for this query generation * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: */ int EvalDistExpr(expr_t *pExpr, Expr_Val_t *pBuf, Expr_Val_t *pParams, int bIsParam) { char *szName, *pChar = NULL; int nRow, nCol, nDataType, nOffset, nModifierArg, i, nTemp; szName = GetBuffer(pParams->pBuf); if (pParams[1].bUseInt) nRow = (int)pParams[1].nValue; else nRow = DistNameIndex(szName, VALUE_NAME, GetBuffer(pParams[1].pBuf)); if (pParams[2].bUseInt) nCol = (int)pParams[2].nValue; else nCol = DistNameIndex(szName, WEIGHT_NAME, GetBuffer(pParams[2].pBuf)); switch(pExpr->Value.nValue) { case KW_DISTMEMBER: nDataType = (dist_type(szName, nCol) == TKN_INT)?DT_INT:DT_STR; if (nDataType == DT_STR) { dist_member(&pChar, szName, nRow, nCol); AddBuffer(pBuf->pBuf, pChar); } else { dist_member(&nTemp, szName, nRow, nCol); pBuf->nValue = nTemp; pBuf->bUseInt = 1; } break; case KW_DISTWEIGHT: dist_weight(&nTemp, szName, nRow, nCol); pBuf->nValue = nTemp; pBuf->bUseInt = 1; nDataType = DT_INT; break; default: /* regular call to DIST() */ nDataType = (dist_type(szName, nRow) == TKN_INT)?DT_INT:DT_STR; switch (pExpr->nFlags & (EXPR_FL_RANGE | EXPR_FL_LIST)) { case EXPR_FL_RANGE: if (bIsParam) ReportError(QERR_MODIFIED_PARAM, NULL, 1); nModifierArg = (int)pParams[3].nValue; i = pick_distribution(NULL, szName, nRow, nCol, 0); nOffset = IntegrateDist(szName, nModifierArg, i, nCol); if (nDataType == DT_INT) { pBuf->bUseInt = 1; dist_member(&nTemp, szName, i, nRow); pBuf->nValue = nTemp; dist_member(&nTemp, szName, nOffset, nRow); pBuf[1].nValue = nTemp; } else { dist_member(pChar, szName, i, nRow); AddBuffer(pBuf->pBuf, pChar); dist_member(pChar, szName, nOffset, nRow); AddBuffer(pBuf[1].pBuf, pChar); } break; case EXPR_FL_LIST: if (bIsParam) ReportError(QERR_MODIFIED_PARAM, NULL, 1); nModifierArg = (int)pParams[3].nValue; /* permute it */ if (nModifierArg > distsize(szName)) ReportError(QERR_RANGE_ERROR, "", 1); if (!(pExpr->pPermute = makePermutation(pExpr->pPermute, distsize(szName), 0))) ReportError(QERR_RANGE_ERROR, NULL, 1); /* take the first n entries */ for (i=1; i <= nModifierArg; i++) { if (nDataType == DT_INT) { pBuf[i - 1].bUseInt = 1; dist_member(&pBuf[i - 1].nValue, szName, getPermutationEntry(pExpr->pPermute, i), nRow); } else { dist_member(&pChar, szName, getPermutationEntry(pExpr->pPermute, i), nRow); AddBuffer(pBuf[i - 1].pBuf, pChar); } } break; case EXPR_FL_LIST | EXPR_FL_RANGE: ReportError(QERR_RANGE_LIST, NULL, 1); break; default: if (nDataType == DT_STR) { pick_distribution(&pChar, szName, nRow, nCol, 0); AddBuffer(pBuf->pBuf, pChar); } else { pick_distribution(&nTemp, szName, nRow, nCol, 0); pBuf->nValue = nTemp; pBuf->bUseInt = 1; } break; } /* end of generic DIST() switch case */ break; } return(nDataType); }