예제 #1
0
파일: pub3xdr.C 프로젝트: Keloran/okws
zstr
xdr_to_zstr (const xpub3_zstr_t &x)
{
  str zs (x.zs.base (), x.zs.size ()); 
  str ss (x.s.base (), x.s.size ());
  return zstr (ss, zs, x.clev);
}
예제 #2
0
double
GreensFunction1DRadAbs::drawR_f (double z, void *p)
{
    // casts p to type 'struct drawR_params *'
    struct drawR_params *params = (struct drawR_params *)p;
    Real v2D 		= params->H[0];	// = v2D = v/(2D)
    Real costerm 	= params->H[1];	// = k/D
    Real sinterm 	= params->H[2];	// = h*v2D
    Real sigma 		= params->H[3];	// = sigma
    int  terms = params->terms;

    Real expsigma(exp(sigma*v2D));
    Real zs(z-sigma);
    
    Real sum = 0, term = 0, prev_term = 0;
    Real root_n, S_Cn_root_n;
    
    int n = 0;
    do
    {
	if ( n >= terms )
	{
	    std::cerr << "GF1DRad: Too many terms needed for DrawR. N: "
	              << n << std::endl;
	    break;
	}
	prev_term = term;

	S_Cn_root_n = params->S_Cn_root_n[n];
	root_n  = params->root_n[n];
	term = S_Cn_root_n * ( expsigma*costerm - exp(v2D*z)*( costerm*cos(root_n*zs) - (root_n+sinterm/root_n)*sin(root_n*zs) ));

	sum += term;
	n++;
    }
    while (fabs(term/sum) > EPSILON*1.0 ||
	fabs(prev_term/sum) > EPSILON*1.0 ||
	n <= MIN_TERMS );

    // Find the intersection with the random number
    return sum - params->rnd;
}
void QgsZonalStatisticsPlugin::run()
{
  QgsZonalStatisticsDialog d( mIface );
  if ( d.exec() == QDialog::Rejected )
  {
    return;
  }

  QString rasterFile = d.rasterFilePath();
  QgsVectorLayer* vl = d.polygonLayer();
  if ( !vl )
  {
    return;
  }

  QgsZonalStatistics zs( vl, rasterFile, d.attributePrefix(), 1 ); //atm hardcode first band
  QProgressDialog p( tr( "Calculating zonal statistics..." ), tr( "Abort..." ), 0, 0 );
  p.setWindowModality( Qt::WindowModal );
  zs.calculateStatistics( &p );
}
예제 #4
0
NumericMatrix dgemm_blas(NumericMatrix xs, NumericMatrix ys) {
    double alpha = 1.0;
    double beta  = 0.0;
    bool tx = false;
    bool ty = false;
    // get row and col of xs and ys
    int xrow = tx ? xs.ncol() : xs.nrow();
    int xcol = tx ? xs.nrow() : xs.ncol();
    int yrow = ty ? ys.ncol() : ys.nrow();
    int ycol = ty ? ys.nrow() : ys.ncol();

    NumericMatrix zs(xrow, ycol);

    double * X = as<double*>(xs);
    double * Y = as<double*>(ys);
    double * Z = as<double*>(zs);

    cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, xrow, ycol, xcol, alpha, X, xcol, Y, yrow, beta, Z, xrow);

    NumericMatrix zz = wrap(Z, xrow, ycol);

    return zz;
}
예제 #5
0
파일: PNG.cpp 프로젝트: freanux/francis
void PNG::read_png_from_zip(const std::string& filename, ZipReader *zip) throw (PNGException) {
    PNGZipStream zs(zip);
    ZipSinkMemory sink;

    try {
        zip->extract(filename, sink);
        zs.data = zs.ptr = static_cast<const char *>(sink.get_data());
    } catch (const ZipReaderException& e) {
        throw PNGException(e.what());
    }

    png_bytep pdta = reinterpret_cast<png_bytep>(const_cast<char *>(zs.data));
    png_structp png_ptr;
    png_infop info_ptr;

    /* check header */
    if (png_sig_cmp(pdta, 0, 8)) {
        throw PNGException("File is not recognized as PNG file: " + filename);
    }
    //pdta += 8;

    /* initialize png */
    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
    if (!png_ptr) {
        throw PNGException("png_create_read_struct() failed");
    }

    info_ptr = png_create_info_struct(png_ptr);
    if (!info_ptr) {
        png_destroy_read_struct(&png_ptr, 0, 0);
        throw PNGException("png_create_info_struct() failed");
    }

    /* setup error handler */
    if (setjmp(png_jmpbuf(png_ptr))) {
        png_destroy_read_struct(&png_ptr, &info_ptr, 0);
        throw PNGException("setjmp of png_jmpbuf() failed");
    }

    /* read header informations */
    png_set_read_fn(png_ptr, &zs, user_data_read);
    //png_set_sig_bytes(png_ptr, 8);
    png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_EXPAND, 0);

    png_uint_32 _width;
    png_uint_32 _height;
    int color_type;
    png_get_IHDR(png_ptr, info_ptr, &_width, &_height, &bit_depth, &color_type,
        0, 0, 0);

    width = static_cast<unsigned int>(_width);
    height = static_cast<unsigned int>(_height);

    switch (color_type) {
        case PNG_COLOR_TYPE_RGB:
            color_format = ColorFormatRGB;
            break;

        case PNG_COLOR_TYPE_RGBA:
            color_format = ColorFormatRGBA;
            break;

        default:
            png_destroy_read_struct(&png_ptr, &info_ptr, 0);
            throw PNGException("Unrecognized PNG color type: " + filename);
            break;
    }

    if (bit_depth != 8) {
        png_destroy_read_struct(&png_ptr, &info_ptr, 0);
        throw PNGException("Invalid PNG bit depth, must be 8: " + filename);
    }

    /* read data stream */
    unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr);
    pic = new unsigned char[row_bytes * height];
    png_bytepp rows = png_get_rows(png_ptr, info_ptr);

    unsigned char *dest = pic;
    for (unsigned int i = 0; i < height; i++) {
        memcpy(dest, rows[i], row_bytes);
        dest += row_bytes;
    }

    /* clean up and close file */
    png_destroy_read_struct(&png_ptr, &info_ptr, 0);
}
예제 #6
0
bool xaeBlockScene::update(float fDT)
{
    g_BGMPlayer.update(fDT);

#ifdef __DEBUG
    if(xae::Instance().keyup(HGEK_ESCAPE))
    {
        g_bDebugStop ^= true;
    }

    if(g_bDebugStop) return false;

    /** 彩旦:直接赢了 */
    if(xae::Instance().keystate(HGEK_CTRL) && xae::Instance().keystate(HGEK_E))
    {
        xaeAVGScene* scene = (xaeAVGScene*)(xaeSceneMgr::Instance().get_scene("AVG"));

        /** 若死过了而且是PreBoss关 */
        if(scene->getRevived() && m_szLevelName == g_Setting.Block.m_szPreBoss)
        {
            xaeSceneMgr::Instance().del_scene("AVG");
            xaeSceneObject* sceneo = xaeSceneMgr::Instance().create_scene("Welcome", "Welcome");
            xaeSceneMgr::Instance().add_scene("Welcome", sceneo);
            xaeSceneMgr::Instance().set_current_scene("Welcome");

            return false;
        }

        /** 否则跳到AVG画面 */
        scene->parseNextPause();
        xaeSceneMgr::Instance().set_current_scene("AVG");

        /** Pre Boss干翻了 */
        if(m_szLevelName == g_Setting.Block.m_szPreBoss)
        {
            scene->setPreBossed();
        }

        return false;
    }
#endif


    /** 暂停 */
    if(xae::Instance().keyup(HGEK_ENTER))
    {
        if(m_emStatus == XBPS_PLAYING)
        {
            m_emStatus = XBPS_PAUSE;
            return false;
        }
        else
        if(m_emStatus == XBPS_PAUSE)
        {
            m_emStatus = XBPS_PLAYING;
        }
    }
    if(m_emStatus == XBPS_PAUSE) return false;

    /** GUI */
    float mousex, mousey;
    m_pHGE->Input_GetMousePos(&mousex, &mousey);
    m_pGUI->update(fDT, mousex, mousey);

    /** 挡板左右转 */
    float dx = fDT * g_Setting.Block.m_fFlapSpeed;
    if(xae::Instance().keystate(HGEK_RIGHT))
    {
        if(m_fFlapX + dx + g_Setting.Block.m_nFlapLength * m_dwFlapNum <= 600.0f)
        {
            m_fFlapX += dx;
            if(m_emStatus == XBPS_READY)
            {
                m_fBallX += dx;
            }
        }
        else
        {
            m_fFlapX = 600.0f - g_Setting.Block.m_nFlapLength * m_dwFlapNum;
            if(m_emStatus == XBPS_READY)
            {
                m_fBallX = 600.0f - (g_Setting.Block.m_nFlapLength * m_dwFlapNum) / 2.0f;
            }
        }
    }
    if(xae::Instance().keystate(HGEK_LEFT))
    {
        if(m_fFlapX - dx >= 0)
        {
            m_fFlapX -= dx;
            if(m_emStatus == XBPS_READY)
            {
                m_fBallX -= dx;
            }
        }
        else
        {
            m_fFlapX = 0.0f;
            if(m_emStatus == XBPS_READY)
            {
                m_fBallX = (g_Setting.Block.m_nFlapLength * m_dwFlapNum) / 2.0f;
            }
        }
    }

    /** 道具更新 */
    m_Treasure.update(fDT, m_fFlapX, m_fFlapY);
    /** 挡板长度 */
    float fFlapCenterX = m_fFlapX + (m_dwFlapNum * g_Setting.Block.m_nFlapLength) / 2.0f;
    m_dwFlapNum = m_Treasure.getFlapNum();
    m_fFlapX = fFlapCenterX - (m_dwFlapNum * g_Setting.Block.m_nFlapLength) / 2;
    if(m_fFlapX < 0) m_fFlapX = 0;
    else
    if(m_fFlapX + m_dwFlapNum * g_Setting.Block.m_nFlapLength > 600.0f) m_fFlapX = 600.0f - m_dwFlapNum * g_Setting.Block.m_nFlapLength;

    /** 空格或者回车 */
    if(xae::Instance().keyup(HGEK_SPACE) || xae::Instance().keyup(HGEK_ENTER))
    {
        /** 变成开始状态 */
        if(m_emStatus == XBPS_READY)
        {
            m_emStatus =XBPS_PLAYING;
        }
        else
        /** 赢了按回车回到AVG画面 */
        if(m_emStatus == XBPS_WIN)
        {
            xaeAVGScene* scene = (xaeAVGScene*)(xaeSceneMgr::Instance().get_scene("AVG"));

            /** 若死过了而且是PreBoss关 */
            if(scene->getRevived() && m_szLevelName == g_Setting.Block.m_szPreBoss)
            {
                xaeSceneMgr::Instance().del_scene("AVG");
                xaeSceneObject* sceneo = xaeSceneMgr::Instance().create_scene("Welcome", "Welcome");
                xaeSceneMgr::Instance().add_scene("Welcome", sceneo);
                xaeSceneMgr::Instance().set_current_scene("Welcome");

                return false;
            }

            /** 否则跳到AVG画面 */
            scene->parseNextPause();
            xaeSceneMgr::Instance().set_current_scene("AVG");

            /** Pre Boss干翻了 */
            if(m_szLevelName == g_Setting.Block.m_szPreBoss)
            {
                scene->setPreBossed();
            }

            return false;
        }
    }

    /** 游戏在玩的状态 */
    if(m_emStatus == XBPS_PLAYING)
    {
        /** 球飞啦! */
        float fbdx = m_fBallSpeedX * fDT, fbdy = m_fBallSpeedY * fDT;
        fbdx *= m_Treasure.getSpeedScale();
        fbdy *= m_Treasure.getSpeedScale();

        /** 横向飞 */
        if(m_fBallX + fbdx - g_Setting.Block.m_nBallLength / 2 >= 0.0f && m_fBallX + fbdx + g_Setting.Block.m_nBallLength / 2 <= 600.0f)
        {
            m_fBallX += fbdx;
        }
        else
        if(m_fBallX + fbdx - g_Setting.Block.m_nBallLength / 2 < 0.0f) m_fBallX = g_Setting.Block.m_nBallLength / 2, m_fBallSpeedX = -m_fBallSpeedX;
        else m_fBallX = 600 - g_Setting.Block.m_nBallLength / 2, m_fBallSpeedX = -m_fBallSpeedX;

        /** 纵向飞 */
        if(m_fBallY + fbdy - g_Setting.Block.m_nBallLength / 2 >= 0.0f)
        {
            m_fBallY += fbdy;
        }
        else
        if(m_fBallY + fbdy - g_Setting.Block.m_nBallLength / 2 < 0.0f) m_fBallY = g_Setting.Block.m_nBallLength / 2, m_fBallSpeedY = - m_fBallSpeedY;
        //else m_fBallY = 590.0f, m_fBallSpeedY = - m_fBallSpeedY;

        /** 碰到挡板:往上弹 */
        if(m_fBallY >= g_Setting.Block.m_fFlapY - g_Setting.Block.m_nBallLength / 2 && m_fBallY <= g_Setting.Block.m_fFlapY + 15.0f - g_Setting.Block.m_nBallLength / 2)
        {
            /** x轴在挡板范围内 */
            if(m_fBallX >= m_fFlapX && m_fBallX <= m_fFlapX + m_dwFlapNum * g_Setting.Block.m_nFlapLength)
            {
                /** 根据小球在挡板的位置确定x速度 */
                m_fBallSpeedX = (m_fBallX - (m_fFlapX + m_dwFlapNum * g_Setting.Block.m_nFlapLength / 2)) / (m_dwFlapNum * (g_Setting.Block.m_nFlapLength) / 2);
                m_fBallSpeedX *= g_Setting.Block.m_fMaxHorizontalRate;
                m_fBallSpeedX *= g_Setting.Block.m_fBallSpeed;

                /** 确定y轴速度:保证x和y的合速度为g_Setting.Block.m_fBallSpeed */
                m_fBallSpeedY = -sqrt(g_Setting.Block.m_fBallSpeed * g_Setting.Block.m_fBallSpeed - m_fBallSpeedX * m_fBallSpeedX);
            }
        }

        /** 飞丢了 */
        if(m_fBallY >= 600.0f)
        {
            /** 如果已经干翻了Pre Boss,则直接到welcome */
            xaeAVGScene* scenea = (xaeAVGScene*)xaeSceneMgr::Instance().get_scene("AVG");
            if(scenea->getPreBossed())
            {
                xaeSceneObject* sceneo = xaeSceneMgr::Instance().create_scene("Welcome", "Welcome");
                xaeSceneMgr::Instance().add_scene("Welcome", sceneo);
                xaeSceneMgr::Instance().del_scene("AVG");

                xaeSceneMgr::Instance().set_current_scene("Welcome");
                return false;
            }

            xaeSceneObject* scene = xaeSceneMgr::Instance().create_scene("Revive", "Revive");
            if(NULL != scene)
            {
                xaeSceneMgr::Instance().add_scene("Revive", scene);
            }
            xaeSceneMgr::Instance().set_current_scene("Revive");

            ((xaeReviveScene*)scene)->setLevel(m_szLevelName);

            /** 设置AVG为死过了 */
            ((xaeAVGScene*)xaeSceneMgr::Instance().get_scene("AVG"))->setRevived();

            return false;
        }

        /** 得到小球区域四个角的坐标 */
        coor zs(m_fBallX, m_fBallY), zx(m_fBallX, m_fBallY), ys(m_fBallX, m_fBallY), yx(m_fBallX, m_fBallY);
        zs.x -= (g_Setting.Block.m_nBallLength / 2), zs.y -= (g_Setting.Block.m_nBallLength / 2);
        ys.x += (g_Setting.Block.m_nBallLength / 2), ys.y -= (g_Setting.Block.m_nBallLength / 2);
        zx.x -= (g_Setting.Block.m_nBallLength / 2), zx.y += (g_Setting.Block.m_nBallLength / 2);
        yx.x -= (g_Setting.Block.m_nBallLength / 2), yx.y -= (g_Setting.Block.m_nBallLength / 2);

        /** 求四个角所在的各方块的下标 */
        int zsi = ((int)zs.y) / g_Setting.Block.m_nBlockHeight, zsj = ((int)zs.x) / g_Setting.Block.m_nBlockWidth;
        int ysi = ((int)ys.y) / g_Setting.Block.m_nBlockHeight, ysj = ((int)ys.x) / g_Setting.Block.m_nBlockWidth;
        int zxi = ((int)zx.y) / g_Setting.Block.m_nBlockHeight, zxj = ((int)zx.x) / g_Setting.Block.m_nBlockWidth;
        int yxi = ((int)yx.y) / g_Setting.Block.m_nBlockHeight, yxj = ((int)yx.x) / g_Setting.Block.m_nBlockWidth;

        /** 碰撞检测 */
        coor zspz = collisionCheck(m_hTexClothHot, zsj * g_Setting.Block.m_nBlockWidth, zsi * g_Setting.Block.m_nBlockHeight, g_Setting.Block.m_nBlockWidth, g_Setting.Block.m_nBlockHeight);
        coor zxpz = collisionCheck(m_hTexClothHot, zxj * g_Setting.Block.m_nBlockWidth, zxi * g_Setting.Block.m_nBlockHeight, g_Setting.Block.m_nBlockWidth, g_Setting.Block.m_nBlockHeight);
        coor yspz = collisionCheck(m_hTexClothHot, ysj * g_Setting.Block.m_nBlockWidth, ysi * g_Setting.Block.m_nBlockHeight, g_Setting.Block.m_nBlockWidth, g_Setting.Block.m_nBlockHeight);
        coor yxpz = collisionCheck(m_hTexClothHot, yxj * g_Setting.Block.m_nBlockWidth, yxi * g_Setting.Block.m_nBlockHeight, g_Setting.Block.m_nBlockWidth, g_Setting.Block.m_nBlockHeight);

        /** 处理碰撞 */
        if(zspz.x >= 0.0f && zspz.y >= 0.0f)
        {
            /** 这个方块消失 */
            m_bClothes[zsi][zsj] = false;
            
            /** 方块数减少 */
            m_dwBlockLeft--;

            m_Treasure.generateTreasure(zsj * g_Setting.Block.m_nBlockWidth + g_Setting.Block.m_nBlockWidth / 2,
                zsi * g_Setting.Block.m_nBlockHeight + g_Setting.Block.m_nBlockHeight / 2);

            /** 下同 */
        }

        if(zxpz.x >= 0.0f && zxpz.y >= 0.0f && (zsi != zxi || zsj != zxj))
        {
            m_bClothes[zxi][zxj] = false;
            m_dwBlockLeft--;
            m_Treasure.generateTreasure(zxj * g_Setting.Block.m_nBlockWidth + g_Setting.Block.m_nBlockWidth / 2,
                zxi * g_Setting.Block.m_nBlockHeight + g_Setting.Block.m_nBlockHeight / 2);
        }

        if(yspz.x >= 0.0f && yspz.y >= 0.0f && (zxi != ysi || zxj != ysj) && (zsi != ysi || zsj != ysj))
        {
            m_bClothes[ysi][ysj] = false;
            m_dwBlockLeft--;
            m_Treasure.generateTreasure(ysj * g_Setting.Block.m_nBlockWidth + g_Setting.Block.m_nBlockWidth / 2,
                ysi * g_Setting.Block.m_nBlockHeight + g_Setting.Block.m_nBlockHeight / 2);
        }

        if(yxpz.x >= 0.0f && yxpz.y >= 0.0f && (zxi != yxi || zxj != yxj) && (ysi != yxi || ysj != yxj) && (zsi != yxi || zsj != yxj))
        {
            m_bClothes[yxi][yxj] = false;
            m_dwBlockLeft--;
            m_Treasure.generateTreasure(yxj * g_Setting.Block.m_nBlockWidth + g_Setting.Block.m_nBlockWidth / 2,
                yxi * g_Setting.Block.m_nBlockHeight + g_Setting.Block.m_nBlockHeight / 2);
        }

        /** 重新设置速度 */
        if(!m_Treasure.getHits())
        {
            if(zspz.x >= 0.0f && zspz.y >= 0.0f) setRebound(zspz);
            else
            if(yspz.x >= 0.0f && yspz.y >= 0.0f) setRebound(yspz);
            else
            if(zxpz.x >= 0.0f && zxpz.y >= 0.0f) setRebound(zxpz);
            else
            if(yxpz.x >= 0.0f && yxpz.y >= 0.0f) setRebound(yxpz);
        }

        /** 所有方块打完了就赢了 */
        if(m_dwBlockLeft == 0) m_emStatus = XBPS_WIN;
    }
    
    return false;
}
예제 #7
0
bool FeTextureContainer::try_to_load(
	const std::string &path,
	const std::string &filename,
	bool is_image )
{
	std::string loaded_name;

#ifndef NO_SWF
	if ( !is_image && tail_compare( filename, FE_SWF_EXT ) )
	{

		if ( is_supported_archive( path ) )
		{
			loaded_name = path + "|" + filename;
			if ( loaded_name.compare( m_file_name ) == 0 )
				return true;

			m_swf = new FeSwf();

			if (!m_swf->open_from_archive( path, filename ))
			{
				std::cout << " ! ERROR loading SWF from archive: "
					<< path << " (" << filename << ")" << std::endl;

				delete m_swf;
				m_swf = NULL;
				return false;
			}
		}
		else
		{
			loaded_name = path + filename;
			if ( loaded_name.compare( m_file_name ) == 0 )
				return true;

			m_swf = new FeSwf();
			if (!m_swf->open_from_file( loaded_name ))
			{
				std::cout << " ! ERROR loading SWF: "
					<< loaded_name << std::endl;

				delete m_swf;
				m_swf = NULL;
				return false;
			}
		}

		m_file_name = loaded_name;
		return true;
	}
#endif

#ifndef NO_MOVIE
	if ( !is_image && FeMedia::is_supported_media_file( filename ) )
		return load_with_ffmpeg( path, filename, false );
#endif

	if ( is_supported_archive( path ) )
	{
		loaded_name = path + "|" + filename;
		if ( loaded_name.compare( m_file_name ) == 0 )
			return true;

		clear();
		FeZipStream zs( path );
		if ( !zs.open( filename ) )
		{
			// Error opening specified filename.  Try to correct
			// in case filename is in a subdir of the archive
			std::string temp;
			if ( get_archive_filename_with_base(
					temp, path, filename ) )
			{
				zs.open( temp );
				loaded_name = path + "|" + temp;
			}
		}

		if ( m_texture.loadFromStream( zs ) )
		{
			m_file_name = loaded_name;
			return true;
		}
	}
	else
	{
		loaded_name = path + filename;
		if ( loaded_name.compare( m_file_name ) == 0 )
			return true;

		clear();
		if ( m_texture.loadFromFile( loaded_name ) )
		{
			m_file_name = loaded_name;
			return true;
		}
	}

#ifndef NO_MOVIE
	//
	// we should only get here if we failed to load an image with SFML
	// try loading it with ffmpeg instead, which can handle more image
	// formats...
	//
	return load_with_ffmpeg( path, filename, is_image );
#else
	return false;
#endif
}
예제 #8
0
// [[Rcpp::export]]
List btm_gibbs(NumericVector token_ids, NumericVector doc_ids, int K, 
         double alpha, double eta, int iter) {
  NumericVector docs = unique(doc_ids);
  int D = docs.size();
  int V = unique(token_ids).size();
  
  std::vector<Biterm> bs;
  for (int d = 0; d < D; d++) {
    NumericVector doc_words = token_ids[doc_ids == docs[d]];
    for (int i = 0; i < doc_words.size(); i++) {
      for (int j = i+1; j < doc_words.size(); j++) {
        bs.push_back(Biterm(doc_words[i], doc_words[j], K));
      }
    }
  }
  
  Btm btm = Btm(V, K, alpha, eta, bs);
  
  int B = bs.size();
  arma::mat theta_trace(iter, K);
  theta_trace.zeros();
  arma::cube beta_trace(V, K, iter);
  
  for (int j = 0; j < iter; j++) {
    NumericVector u = runif(B);
    if ((j+1) % 100 == 0)
      Rcout << "Iteration: " << j << std::endl;
    
    // sample latent topic assignments
    for (int i = 0; i < B; i++) {
      // Rcout << "Biterm " << i << std::endl;
      NumericVector Q = btm.sample_prob(bs[i]);
      // Rcout << "----" << std::endl;
      for (int k = 0; k < K; k++) {
        if (u[i] < (Q[k] / Q[K-1])) {
          // Rcout << "assigned topic: " << k << std::endl;
          btm.update_counts(bs[i], k);
          break;
        }
      }
    }
    
    theta_trace.row(j) = btm.calc_theta();
    beta_trace.slice(j) = btm.calc_beta();
  }
  
  NumericVector zs(B);
  for (int b = 0; b < B; b++) 
    zs[b] = bs[b].get_z();
  
  List result;
  result["beta_trace"] = beta_trace;
  result["theta_trace"] = theta_trace;
  result["word_topic_count"] = btm.get_word_topic_count();
  result["topic_count_wd"] = btm.get_topic_count_wd();
  result["topic_count_bt"] = btm.get_topic_count_bt();
  result["z"] = zs;
  CharacterVector class_names(2); 
  class_names[0] = "btm"; 
  class_names[1] = "lda";
  result.attr("class") = class_names;
  
  return result;
}
예제 #9
0
void AsiMS2000::selectCommand(int commandNum)
{
  switch(commandNum)
  {
      case 0:
          accel();
          break;
      case 1:
          aalign();
          break;
      case 2:
          afcont();
          break;
      case 3:
          aflim();
          break;
      case 4:
          afocus();
          break;
      case 5:
          afset();
          break;
      case 6:
          afmove();
          break;
      case 7:
          ahome();
          break;
      case 8:
          aij();
          break;
      case 9:
          array();
          break;
      case 10:
          azero();
          break;
      case 11:
          backlash();
          break;
      case 12:
          bcustom();
          break;
      case 13:
          benable();
          break;
      case 14:
          build();
          break;
      case 15:
          cdate();
          break;
      case 16:
          cnts();
          break;
      case 17:
          customa();
          break;
      case 18:
          customb();
          break;
      case 19:
          dack();
          break;
      case 20:
          dump();
          break;
      case 21:
          ensync();
          break;
      case 22:
          epolarity();
          break;
      case 23:
          error();
          break;
      case 24:
          halt();
          break;
      case 25:
          here();
          break;
      case 26:
          home();
          break;
      case 27:
          info();
          break;
      case 28:
          joystick();
          break;
      case 29:
          jsspd();
          break;
      case 30:
          kadc();
          break;
      case 31:
          kd();
          break;
      case 32:
          ki();
          break;
      case 33:
          kp();
          break;
      case 34:
          lcd();
          break;
      case 35:
          led();
          break;
      case 36:
          lladdr();
          break;
      case 37:
          load();
          break;
      case 38:
          lock();
          break;
      case 39:
          lockrg();
          break;
      case 40:
          lockset();
          break;
      case 41:
          maintain();
          break;
      case 42:
          motctrl();
          break;
      case 43:
          move();
          break;
      case 44:
          movrel();
          break;
      case 45:
          pcros();
          break;
      case 46:
          pedal();
          break;
      case 47:
          rbmode();
          break;
      case 48:
          rdadc();
          break;
      case 49:
          rdsbyte();
          break;
      case 50:
          rdstat();
          break;
      case 51:
          relock();
          break;
      case 52:
          reset();
          break;
      case 53:
          rt();
          break;
      case 54:
          runaway();
          break;
      case 55:
          saveset();
          break;
      case 56:
          savepos();
          break;
      case 57:
          scan();
          break;
      case 58:
          scanr();
          break;
      case 59:
          scanv();
          break;
      case 60:
          secure();
          break;
      case 61:
          sethome();
          break;
      case 62:
          setlow();
          break;
      case 63:
          setup();
          break;
      case 64:
          si();
          break;
      case 65:
          speed();
          break;
      case 66:
          spin();
          break;
      case 67:
          status();
          break;
      case 68:
          stopbits();
          break;
      case 69:
          ttl();
          break;
      case 70:
          um();
          break;
      case 71:
          units();
          break;
      case 72:
          unlock();
          break;
      case 73:
          vb();
          break;
      case 74:
          vector();
          break;
      case 75:
          version();
          break;
      case 76:
          wait();
          break;
      case 77:
          where();
          break;
      case 78:
          who();
          break;
      case 79:
          wrdac();
          break;
      case 80:
          zero();
          break;
      case 81:
          z2b();
          break;
      case 82:
          zs();
          break;
      case 83:
          overshoot();
          break;
  }
}
예제 #10
0
FeShader *FePresent::add_shader( FeShader::Type type, const char *shader1, const char *shader2 )
{
    std::string path;
    m_feSettings->get_path( FeSettings::Current, path );

    std::string s1 = clean_path( shader1 );

    m_scriptShaders.push_back( new FeShader() );
    FeShader *sh = m_scriptShaders.back();

    if ( !is_relative_path( s1 ) )
        path.clear();

    switch ( type )
    {
    case FeShader::VertexAndFragment:
        if ( is_supported_archive( path ) )
        {
            //
            // Known Issue: We don't properly handle the
            // situation where one shader is specified as a
            // relative path and is in a zip, while the other
            // is specified as an absolute path.  If the first
            // is in a zip, the second is assumed to be in the
            // same zip as well.
            //
            FeZipStream zs1( path );
            zs1.open( shader1 );

            FeZipStream zs2( path );
            zs2.open( shader2 );

            sh->load( zs1, zs2 );
        }
        else
        {
            std::string path2 = path;
            std::string s2 = clean_path( shader2 );
            if ( !is_relative_path( s2 ) )
                path2.clear();

            sh->load( path + s1, path2 + s2 );
        }
        break;

    case FeShader::Vertex:
    case FeShader::Fragment:
        if ( is_supported_archive( path ) )
        {
            FeZipStream zs( path );
            zs.open( shader1 );

            sh->load( zs, type );
        }
        else
        {
            sh->load( path + s1, type );
        }
        break;

    case FeShader::Empty:
    default:
        break;
    }

    return sh;
}
예제 #11
0
Transformation Boonas:: parseParams(int start, int argc, char** argv, Transformation matrix) 
{
	QString currIn;
	
	for(int i = start; i < (argc - 1); i += 2) // iterate through parameters skiping every other
	{
		if(strcmp(argv[i], "XT") == 0)
		{
			currIn = argv[i + 1];
			matrix = xt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YT") == 0)
		{
			currIn = argv[i + 1];
			matrix = yt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZT") == 0)
		{
			currIn = argv[i + 1];
			matrix = zt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XS") == 0)
		{
			currIn = argv[i + 1];
			matrix = xs(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YS") == 0)
		{
			currIn = argv[i + 1];
			matrix = ys(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZS") == 0)
		{
			currIn = argv[i + 1];
			matrix = zs(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "US") == 0)
		{
			currIn = argv[i + 1];
			matrix = us(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XD") == 0)
		{
			currIn = argv[i + 1];
			matrix = xd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YD") == 0)
		{
			currIn = argv[i + 1];
			matrix = yd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZD") == 0)
		{
			currIn = argv[i + 1];
			matrix = zd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XR") == 0)
		{
			currIn = argv[i + 1];
			matrix = xr(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YR") == 0)
		{
			currIn = argv[i + 1];
			matrix = yr(currIn.toFloat(), matrix);
		}
		else // MUST BE ZR
		{
			currIn = argv[i + 1];
			matrix = zr(currIn.toFloat(), matrix);
		}
	}
	
	return matrix;
}