예제 #1
0
void doOneBeta(const EngineType& engine,
               std::vector<size_t>& ne,
               OpLibFactoryType& opLibFactory,
               size_t site,
               size_t sigma,
               RealType beta)
{
	RealType sum = 0;
	RealType sum2 = 0;
	RealType denominator = 0;
	FreeFermions::Combinations combinations(engine.size(),ne[0]);
	size_t factorToMakeItSmaller = 1;
	for (size_t i = 0; i<combinations.size(); ++i) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		EtoTheBetaHType ebh(beta,engine,0);
		DiagonalOperatorType& eibOp = opDiagonalFactory(ebh);
		
		std::vector<size_t> vTmp(engine.size(),0);
		for (size_t j=0;j<combinations(i).size();++j) vTmp[combinations(i)[j]]=1;
		std::vector<std::vector<size_t> > occupations(1,vTmp);
		HilbertStateType thisState(engine,occupations);
		HilbertStateType phi = thisState;
		eibOp.applyTo(phi);
		denominator += scalarProduct(thisState,phi)*factorToMakeItSmaller;
		LibraryOperatorType& myOp2 = opLibFactory(LibraryOperatorType::N,site,sigma);
		myOp2.applyTo(phi);
		sum += scalarProduct(thisState,phi)*factorToMakeItSmaller;
		myOp2.applyTo(phi);
		sum2 += scalarProduct(thisState,phi)*factorToMakeItSmaller;
	}
	std::cout<<beta<<" "<<sum<<" "<<denominator<<" "<<sum/denominator<<" "<<sum2/denominator<<"\n";	
}
예제 #2
0
void VUINodeImage::OnPaint(VGraphicsInfo &Graphics, const VItemRenderInfo &parentState)
{
	VItemRenderInfo thisState(parentState,this,1.f);
	//Graphics.ClippingStack.Push(GetBoundingBox(),true);
	m_Image.OnPaint(Graphics,thisState);
	//Graphics.ClippingStack.Pop();
}
예제 #3
0
void VUINodeRotator::OnPaint(VGraphicsInfo &Graphics, const VItemRenderInfo &parentState)
{
	const VRectanglef rect = GetClientRect();

	hkvVec2 vCenter = ( rect.m_vMin + rect.m_vMax ) / 2.0f;

	hkvVec2 vSize = GetSize();

	VColorRef color = VColorRef(255,128,128,255);
	Overlay2DVertex_t v[6];

	float fWidth = vSize.x / 2;
	float fHeight = vSize.y / 2;


	IVRender2DInterface::CreateQuadVertices(-fWidth,-fHeight,fWidth,fHeight,0,0,1,1,color ,v);

	for ( int i = 0 ; i < 6 ; i++ )
	{
		Overlay2DVertex_t vertex = v[i];

		float fx = v[i].screenPos.x;
		float fy = v[i].screenPos.y;

		v[i].screenPos.x = vCenter.x + (fx * hkvMath::cosDeg (m_fAngle) + fy * hkvMath::sinDeg (m_fAngle));
		v[i].screenPos.y = vCenter.y + (-fx * hkvMath::sinDeg (m_fAngle) + fy * hkvMath::cosDeg (m_fAngle));
	}

	VTextureObject *pTex = Image().m_States[VWindowBase::NORMAL].GetCurrentTexture();
	Graphics.Renderer.Draw2DBuffer(6, v, pTex, VSimpleRenderState_t(VIS_TRANSP_ALPHA,RENDERSTATEFLAG_ALWAYSVISIBLE|RENDERSTATEFLAG_DOUBLESIDED));


	VItemRenderInfo thisState(parentState,this,1.f);
	m_TextCfg.OnPaint(Graphics,thisState);
	return;
}
예제 #4
0
void VTooltip::OnPaint(VGraphicsInfo &Graphics, const VItemRenderInfo &parentState)
{
  if (m_fDelay>0.f)
    return;

  hkvVec2 vMousePos = GetContext()->GetCurrentMousePos();
  VCursor *pCursor = GetContext()->GetCurrentCursor();
  if (!pCursor)
    return;

  // offset tooltip position by cursor size
  VRectanglef rect;
  rect = pCursor->GetCursorRect();
  vMousePos += rect.m_vMax;

  const float fFullBorder = m_fBorderSize+m_fTextBorder;
  
  VRectanglef textRect;
  hkvVec2 v = m_pText->GetSize(&textRect);
  SetSize(v.x,v.y);
  m_pText->SetTextOfs(-textRect.m_vMin);

  float xpos= vMousePos.x-fFullBorder;
  float ypos= vMousePos.y-fFullBorder;

  int iSizeX, iSizeY;
  Vision::Contexts.GetCurrentContext()->GetSize(iSizeX, iSizeY);

  if((xpos + v.x) > iSizeX)
    xpos = iSizeX - v.x - fFullBorder*2;

  if((ypos + v.y) > iSizeY)
    ypos = iSizeY - v.y - fFullBorder*2;

  SetPosition(xpos,ypos);
  

  // fade in the tooltip
  float fFadeValue = hkvMath::Abs (m_fDelay)*4.f;
  if (fFadeValue>1.f) fFadeValue = 1.f;

  // render text on background
  VItemRenderInfo thisState(parentState,this,fFadeValue);
  if (m_iBackgroundColor.a>0)
  {
    VRectanglef clientRect = GetBoundingBox();
    VSimpleRenderState_t iState = VGUIManager::DefaultGUIRenderState();
    if (m_fBorderSize>0.f)
    {
      VColorRef iColor = m_iBorderColor;
      iColor.a = (int)((float)iColor.a*fFadeValue);
      hkvVec2 vb(fFullBorder,fFullBorder);
      Graphics.Renderer.DrawSolidQuad(clientRect.m_vMin-vb,clientRect.m_vMax+vb,iColor,iState);
    }
    
    VColorRef iColor = m_iBackgroundColor;
    iColor.a = (int)((float)iColor.a*fFadeValue);
    hkvVec2 vb(m_fTextBorder,m_fTextBorder);
    Graphics.Renderer.DrawSolidQuad(clientRect.m_vMin-vb,clientRect.m_vMax+vb,iColor,iState);
  }
  m_pText->OnPaint(Graphics,thisState);
}