示例#1
0
void KNDdeTorusCollocation::PhaseBOTH(KNVector& ph0, KNVector& ph1, KNVector& presol)
{
  ph0.clear();
  ph1.clear();
  for (size_t i2 = 0; i2 < nint2; i2++)
  {
    for (size_t i1 = 0; i1 < nint1; i1++)
    {
      for (size_t j2 = 0; j2 < ndeg2 + 1; j2++)
      {
        for (size_t j1 = 0; j1 < ndeg1 + 1; j1++)
        {
          size_t idx1 = idxmap(j1, j2, i1, i2);
          // matrix multiplication
          for (size_t l2 = 0; l2 < ndeg2 + 1; l2++)
          {
            for (size_t l1 = 0; l1 < ndeg1 + 1; l1++)
            {
              const size_t idx2 = idxmap(l1, l2, i1, i2);
              for (size_t p = 0; p < NDIM; p++)
              {
                ph0(p + NDIM*idx1) += presol(p + NDIM * idx2) * ID1(l1, j1) * I2(l2, j2);
                ph1(p + NDIM*idx1) += presol(p + NDIM * idx2) * I1(l1, j1) * ID2(l2, j2);
              }
            }
          }
        }
      }
    }
  }
}
示例#2
0
void Generator::convert(const SPI & spi,Polynomial & result1) const {
  SPIID ID1(spi.leftID()), ID2(spi.rightID());
  const GroebnerRule & first = retrieve(ID1);
  const GroebnerRule & second = retrieve(ID2);
  Monomial tip1(first.LHS());
  Monomial tip2(second.LHS());
  Monomial right1, left2;
  int len1 = spi.overlapLength();
  MonomialIterator w1 = tip2.begin();
  for(int k=1;k<=len1;++k) { ++w1;};
  int max1 = tip2.numberOfFactors()-1;
  // The following line is for a faster run-time.
  right1.reserve(max1-len1+1);
  for(int i=len1;i<=max1;++i,++w1) {
    right1 *= (*w1);
  }
  MonomialIterator w2 = tip1.begin();
  int max2 = tip1.numberOfFactors() - len1;
  // The following line is for a faster run-time.
  left2.reserve(max2);
  for(i=0;i< max2;++i,++w2) {
    left2 *= (*w2);
  }
  helpConvert(first.RHS(),right1,left2,second.RHS(),result1);
};
  void
  OPCollisionCorrelator::output(magnet::xml::XmlStream &XML)
  {
    for (size_t ID1(0); ID1 < Sim->N; ++ID1)
      for (size_t ID2(ID1+1); ID2 < Sim->N; ++ID2)
	if (lastColl[ID1][ID2] > 100* freetimehist.getBinWidth()) freetimehist.addVal(-1.0);

    XML << magnet::xml::tag("CollisionCorrelator");
  
    freetimehist.outputHistogram(XML, 1.0/Sim->dynamics.units().unitTime());

    XML << magnet::xml::endtag("CollisionCorrelator");
  }
示例#4
0
KNDdeTorusCollocation::KNDdeTorusCollocation(KNExprSystem& sys_, size_t ndeg1_, size_t ndeg2_, size_t nint1_, size_t nint2_) :
    sys(&sys_),
    ndim(sys_.ndim()), ntau(sys_.ntau()), npar(sys_.npar()),
    ndeg1(ndeg1_), ndeg2(ndeg2_), nint1(nint1_), nint2(nint2_),
    col1(ndeg1_),    col2(ndeg2_),
    mesh1(ndeg1_ + 1), mesh2(ndeg2_ + 1),
    lgr1(ndeg1_ + 1, ndeg1_ + 1), lgr2(ndeg2_ + 1, ndeg2_ + 1),
    dlg1(ndeg1_ + 1, ndeg1_ + 1), dlg2(ndeg2_ + 1, ndeg2_ + 1),
    I1((ndeg1_ + 1), (ndeg1_ + 1)),
    ID1((ndeg1_ + 1), (ndeg1_ + 1)),
    I2((ndeg2_ + 1), (ndeg2_ + 1)),
    ID2((ndeg2_ + 1), (ndeg2_ + 1)),
    mlg1((ndeg1_ + 1)*(ndeg1_ + 1)),
    mlg2((ndeg2_ + 1)*(ndeg2_ + 1)),
    mlgd1((ndeg1_ + 1)*(ndeg1_ + 1)),
    mlgd2((ndeg2_ + 1)*(ndeg2_ + 1)),
    ilg1((ndeg1_ + 1)*(ndeg1_ + 1) + 1),
    ilg2((ndeg2_ + 1)*(ndeg2_ + 1) + 1),
    ilgd1((ndeg1_ + 1)*(ndeg1_ + 1) + 1),
    ilgd2((ndeg2_ + 1)*(ndeg2_ + 1) + 1),
    time1(ndeg1*ndeg2*nint1*nint2), time2(ndeg1*ndeg2*nint1*nint2),
    kk((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    ee((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    rr((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    p_tau(ntau, ndeg1*ndeg2*nint1*nint2), p_dtau(ntau, ndeg1*ndeg2*nint1*nint2),
    p_xx(ndim, ntau+2*(ntau+1), ndeg1*ndeg2*nint1*nint2),
    p_fx(ndim, ndeg1*ndeg2*nint1*nint2),
    p_dfp(ndim, 1, ndeg1*ndeg2*nint1*nint2),
    p_dfx(ndim, ndim, ndeg1*ndeg2*nint1*nint2),
    p_dummy(0, 0, ndeg1*ndeg2*nint1*nint2)
{
  lobatto(mesh1);
  lobatto(mesh2);
  gauss(col1);
  gauss(col2);
  for (size_t i = 0; i < mesh1.size(); i++)
  {
    poly_coeff_lgr(lgr1(i), mesh1, i);
    poly_coeff_diff(dlg1(i), lgr1(i));
  }
  for (size_t i = 0; i < mesh2.size(); i++)
  {
    poly_coeff_lgr(lgr2(i), mesh2, i);
    poly_coeff_diff(dlg2(i), lgr2(i));
  }

  // here comes the phase condition for par(OMEGA0) and par(OMEGA1)
  // the integration in the bottom border
  // construct the diffint matrix
  for (size_t i = 0; i < ndeg1 + 1; i++)
  {
    for (size_t k = 0; k < ndeg1 + 1; k++)
    {
      mlg1.clear();
      mlgd1.clear();
      ilg1.clear();
      ilgd1.clear();
      poly_coeff_mul(mlg1,  lgr1(i), lgr1(k));
      poly_coeff_mul(mlgd1, dlg1(i), lgr1(k));
      poly_coeff_int(ilg1,  mlg1);
      poly_coeff_int(ilgd1,  mlgd1);
      I1(i, k) = (poly_eval(ilg1, 1.0)-poly_eval(ilg1, 0.0)) / nint1;
      ID1(i, k) = poly_eval(ilgd1, 1.0);
    }
  }
  for (size_t j = 0; j < ndeg2 + 1; j++)
  {
    for (size_t l = 0; l < ndeg2 + 1; l++)
    {
      mlg2.clear();
      mlgd2.clear();
      ilg2.clear();
      ilgd2.clear();
      poly_coeff_mul(mlg2,  lgr2(j), lgr2(l));
      poly_coeff_mul(mlgd2, dlg2(j), lgr2(l));
      poly_coeff_int(ilg2,  mlg2);
      poly_coeff_int(ilgd2,  mlgd2);
      I2(j, l) = (poly_eval(ilg2, 1.0) - poly_eval(ilg2, 0.0))/ nint2;
      ID2(j, l) = poly_eval(ilgd2, 1.0);
    }
  }
}
示例#5
0
void FontPage::Load( const FontPageSettings &cfg )
{
	m_sTexturePath = cfg.m_sTexturePath;

	// load texture
	RageTextureID ID1( m_sTexturePath );
	if( cfg.m_sTextureHints != "default" )
		ID1.AdditionalTextureHints = cfg.m_sTextureHints;

	m_FontPageTextures.m_pTextureMain = TEXTUREMAN->LoadTexture( ID1 );
	ASSERT( m_FontPageTextures.m_pTextureMain != NULL );

	RageTextureID ID2 = ID1;
	/* "arial 20 16x16 [main].png" => "arial 20 16x16 [main-stroke].png" */
	if( ID2.filename.find("]") != string::npos )
	{
		ID2.filename.Replace( "]", "-stroke]" );
		if( IsAFile(ID2.filename) )
		{
			m_FontPageTextures.m_pTextureStroke = TEXTUREMAN->LoadTexture( ID2 );
			ASSERT( m_FontPageTextures.m_pTextureStroke != NULL );
			ASSERT_M( m_FontPageTextures.m_pTextureMain->GetSourceFrameWidth() == m_FontPageTextures.m_pTextureStroke->GetSourceFrameWidth(), ssprintf("'%s' and '%s' must have the same frame widths", ID1.filename.c_str(), ID2.filename.c_str()) );
			ASSERT_M( m_FontPageTextures.m_pTextureMain->GetNumFrames() == m_FontPageTextures.m_pTextureStroke->GetNumFrames(), ssprintf("'%s' and '%s' must have the same frame dimensions", ID1.filename.c_str(), ID2.filename.c_str()) );
		}
	}

	// load character widths
	vector<int> aiFrameWidths;

	int default_width = m_FontPageTextures.m_pTextureMain->GetSourceFrameWidth();
	if( cfg.m_iDefaultWidth != -1 )
		default_width = cfg.m_iDefaultWidth;

	// Assume each character is the width of the frame by default.
	for( int i=0; i<m_FontPageTextures.m_pTextureMain->GetNumFrames(); i++ )
	{
		map<int,int>::const_iterator it = cfg.m_mapGlyphWidths.find(i);
		if( it != cfg.m_mapGlyphWidths.end() )
			aiFrameWidths.push_back( it->second );
		else
			aiFrameWidths.push_back( default_width );
	}

	if( cfg.m_iAddToAllWidths )
	{
		for( int i=0; i<m_FontPageTextures.m_pTextureMain->GetNumFrames(); i++ )
			aiFrameWidths[i] += cfg.m_iAddToAllWidths;
	}

	if( cfg.m_fScaleAllWidthsBy != 1 )
	{
		for( int i=0; i<m_FontPageTextures.m_pTextureMain->GetNumFrames(); i++ )
			aiFrameWidths[i] = lrintf( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy );
	}

	m_iCharToGlyphNo = cfg.CharToGlyphNo;

	m_iLineSpacing = cfg.m_iLineSpacing;
	if( m_iLineSpacing == -1 )
		m_iLineSpacing = m_FontPageTextures.m_pTextureMain->GetSourceFrameHeight();

	int iBaseline=0;
	/* If we don't have a top and/or baseline, assume we're centered in the
	 * frame, and that LineSpacing is the total height. */
	iBaseline = cfg.m_iBaseline;
	if( iBaseline == -1 )
	{
		float center = m_FontPageTextures.m_pTextureMain->GetSourceFrameHeight()/2.0f;
		iBaseline = int( center + m_iLineSpacing/2 );
	}

	int iTop = cfg.m_iTop;
	if( iTop == -1 )
	{
		float center = m_FontPageTextures.m_pTextureMain->GetSourceFrameHeight()/2.0f;
		iTop = int( center - m_iLineSpacing/2 );
	}
	m_iHeight = iBaseline - iTop;
	m_iDrawExtraPixelsLeft = cfg.m_iDrawExtraPixelsLeft;
	m_iDrawExtraPixelsRight = cfg.m_iDrawExtraPixelsRight;

	/* Shift the character up so the top will be rendered at the baseline. */
	m_fVshift = (float) -iBaseline;

	SetTextureCoords( aiFrameWidths, cfg.m_iAdvanceExtraPixels );
	SetExtraPixels( cfg.m_iDrawExtraPixelsLeft, cfg.m_iDrawExtraPixelsRight );

//	LOG->Trace("Font %s: height %i, baseline %i ( == top %i)",
//		   m_sTexturePath.c_str(), height, baseline, baseline-height);
}