Exemplo n.º 1
0
int solver_inv(void *A)
{ if(dim2(A) == dim1(A)) 
    if(siz(A) == sizeof(float)){ static float **a,**e;
#include "solver/inv.c"    
    }else if(siz(A) == sizeof(double)){ static double **a,**e;
#include "solver/inv.c"    
    }else{ fprintf(stderr,"solver_inv: not supported\n"); exit(1);}
  return 0;
}
Exemplo n.º 2
0
static int *LU(void *A)
{ if(dim2(A) == dim1(A))
    if(siz(A) == sizeof(float)){ float nrm,**a,aik,*apk,*ai,apkk;
#include "solver/LU.c"
    }else if(siz(A) == sizeof(double)){ double nrm,**a,aik,*apk,*ai,apkk;
#include "solver/LU.c"
    }
  return NULL;
}
Exemplo n.º 3
0
int solver_gauss(void *A, void *B)
{ void *X;

  if(dim1(A) != dim1(B)) return 0;
  { static int **Y;
    if(-1 == dim2(B)){
      ary2(Y,2,1);
      if(NULL == Y) return 0;
      cp(B,Y[1]); cp(Y,X);
    }else cp(B,X);
  }
  if(siz(A) == sizeof(float) && siz(B) == sizeof(float)){
    float **a,*api,s,**x,*b,bpi;
#include "solver/fb.c"
  }else if(siz(A) == sizeof(float) && siz(B) == sizeof(double)){
    float **a,*api;double s,**x,*b,bpi;
#include "solver/fb.c"
  }else if(siz(A) == sizeof(double) && siz(B) == sizeof(float)){
    double **a,*api,s;float **x,*b,bpi;
#include "solver/fb.c"
  }else	if(siz(A) == sizeof(double) && siz(B) == sizeof(double)){
    double **a,*api,s,**x,*b,bpi;
#include "solver/fb.c"
  }else{ fprintf(stderr,"solver_gauss: not supported\n"); exit(1);}
  return 0;
}
Exemplo n.º 4
0
int matprop_halfbw(void *A)
{ 
  if(dim2(A) != dim1(A)||dim2(A) < 1||dim1(A) < 1||siz(A) < 1) return 0;
  
  if(siz(A) == sizeof(float)){
    static float **a; 
    a = (float **)A;
#include "matprop/halfbw.c"
  }
  if(siz(A) == sizeof(double)){
    static double **a; 
    a = (double **)A;
#include "matprop/halfbw.c"
  }
  return 0;
}
Exemplo n.º 5
0
 bool xst(
    void const * pkey, size_t const ksize
    )
 {
    size_t size; /// Unused
    return siz(pkey, ksize, size) > 0;
 }
Exemplo n.º 6
0
      bool all(
         void const * pkey, size_t const ksize,
         void * pval, size_t & vsize
         )
      {
         assert_data_store_open();

         bool found = false;
         size_t esize = 0;

         if(siz(pkey, ksize, esize))
         {
            if(esize <= vsize)
            {
               found = get(
                  pkey, ksize,
                  pval, esize
                  );
            }

            vsize = esize;
         }
         else { vsize = 0; }


         return found;
      }
Exemplo n.º 7
0
int ScriptManager::LaddToScene(lua_State* L){
    int n=lua_gettop(L);
    if(n<1){
        lua_pushstring(L,"Error in lua add to scene");
        lua_error(L);
    }
    string dir=lua_tostring(L,1);
    Vector3 pos, siz(1,1,1);
    Quaternion rot(0,0,0,1);
    if(n>3){
        pos.x = lua_tonumber(L,2);
        pos.y = lua_tonumber(L,3);
        pos.z = lua_tonumber(L,4);
    }
    
    if(n>6){
        rot.x = lua_tonumber(L,5);
        rot.y = lua_tonumber(L,6);
        rot.z = lua_tonumber(L,7);
        rot.w = lua_tonumber(L,8);
    }
    
    if(n>10){
        siz.x = lua_tonumber(L,9);
        siz.y = lua_tonumber(L,10);
        siz.z = lua_tonumber(L,11);
    }
    
    active->state->addElement(new Tile(active->state, pos, siz, rot, dir));
    return 0;
}
Exemplo n.º 8
0
// Calculate the current max legend label length in pixels.
int MyGraph::GetMaxLegendLabelLength(CDC& dc) const
{
	VALIDATE;
	ASSERT_VALID(&dc);

	CString sMax;
	int nMaxChars(-1);
	CSize siz(-1,-1);

	// First get max number of characters.
	for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup) {
		int nLabelLength(m_saLegendLabels.GetAt(nGroup).GetLength());

		if (nMaxChars < nLabelLength) {
			nMaxChars = nLabelLength;
			sMax = m_saLegendLabels.GetAt(nGroup);
		}
	}

	// Now calculate the pixels.
	siz = dc.GetTextExtent(sMax);

	_ASSERTE(-1 < siz.cx);

	return siz.cx;
}
Exemplo n.º 9
0
		ParametersMap PDFImageService::run(
			std::ostream& stream,
			const Request& request
		) const {

			// Get the pdf
			PDF& pdf(PDFCMSModule::GetRequestPDF(request));

			// Get or create image
			HPDF_Image image(pdf.getImage(_key));
			if(!image)
			{
				string content(_image->get<WebpageContent>().getCMSScript().eval());
				image = pdf.embedPNGImage(_key, content);
			}

			// Width and Height
			float width(_width);
			float height(_height);
			if(!width && height)
			{
				HPDF_Point siz(HPDF_Image_GetSize(image));
				width = _height * (siz.x / siz.y);
			}
			else if(!height && width)
			{
				HPDF_Point siz(HPDF_Image_GetSize(image));
				height = _width * (siz.y / siz.x);
			}

			// Draw the image
			pdf.drawImage(
				image,
				PDF::GetPixelsFromMM(_x),
				PDF::GetPixelsFromMM(_y),
				width ? PDF::GetPixelsFromMM(width) : HPDF_Image_GetWidth(image),
				height ? PDF::GetPixelsFromMM(height) : HPDF_Image_GetHeight(image)
			);

			// Return nothing
			ParametersMap map;
			return map;
		}
Exemplo n.º 10
0
LRESULT iMinimapView::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
	iSize siz(LOWORD(lParam),HIWORD(lParam));
	iSize ns( iMAX<uint32>(200,iALIGN(siz.w,32)), iMAX<uint32>(200,iALIGN(siz.h,32)));
	if (ns != m_outBuff.GetSize()) {
		m_outBuff.Resize(ns);
		OnMapContentChanged();
	}
	return 0;
}
Exemplo n.º 11
0
/////////////////////////////// Helpers to build compound-descriptors //////////
cv::Mat resizeImageProportional(const cv::Mat &img, int maxSize) {
    cv::Size siz(-1,-1);
    if(img.cols>=img.rows) {
        siz.width   = maxSize;
        siz.height  = (maxSize*img.rows)/img.cols;
    } else {
        siz.width   = (maxSize*img.cols)/img.rows;
        siz.height  = maxSize;
    }
    cv::Mat ret;
    cv::resize(img, ret, siz, 0,0, CV_INTER_CUBIC);
    return ret;
}
Exemplo n.º 12
0
int ScriptManager::Lload(lua_State *L){
    int n= lua_gettop(L);
    if(n<1){
        lua_pushstring(L,"Error in lua load");
        lua_error(L);
    }
    
    int ind = lua_tointeger(L,1);
    string dir;
    if(n>1){
      dir=lua_tostring(L,2);
    }
    Vector3 pos, siz(1,1,1);
    Quaternion rot(0,0,0,1);
    Scripted * tmp=active->list.find(ind)->second;
    if(tmp)
    {
      if(!dir.empty()){
	tmp->setResource(dir);
      }
      
      if(n>3){
	  pos.x = lua_tonumber(L,3);
	  pos.y = lua_tonumber(L,4);
	  pos.z = lua_tonumber(L,5);
	  tmp->setPos(pos);
      }
      
      if(n>6){
	  rot.x = lua_tonumber(L,6);
	  rot.y = lua_tonumber(L,7);
	  rot.z = lua_tonumber(L,8);
	  rot.w = lua_tonumber(L,9);
	  tmp->setRot(rot);
      }
      
      if(n>10){
	  siz.x = lua_tonumber(L,10);
	  siz.y = lua_tonumber(L,11);
	  siz.z = lua_tonumber(L,12);
	  tmp->setSize(siz);
      }
      lua_pushnumber(L,0);
    }
    return 1;
}
Exemplo n.º 13
0
bool GameState::update(sf::Time dt)
{
    mWorld.updateWorld();
    b2Vec2 pos(mWorld.getPlayerBody()->GetPosition());
    sf::Vector2f siz(mPlayerShape.getSize());
    mPlayerShape.setPosition(100*pos.x-siz.x/2., 100*pos.y-siz.y/2.);
    if (pos.x<0)
    {
        sf::Vector2f POS(mPlayer->getPos());
        b2Vec2 vel(mPlayer->getBody()->GetLinearVelocity());
        int X = POS.x-1;
        int Y = POS.y;
        std::stringstream sh;
        sh << X;
        std::string hor = sh.str();
        std::stringstream sv;
        sv << Y;
        std::string ver = sv.str();
        mWorld.createWorld(hor+ver+".txt");
        *mContext.player = Player(mWorld.getWorld(), pos.x+7.95, pos.y, sf::Vector2f(X,Y));
        mPlayer->getBody()->SetLinearVelocity(vel);
    }
    if (pos.x>8)
    {
        sf::Vector2f POS(mPlayer->getPos());
        b2Vec2 vel(mPlayer->getBody()->GetLinearVelocity());
        int X = POS.x+1;
        int Y = POS.y;
        std::stringstream sh;
        sh << X;
        std::string hor = sh.str();
        std::stringstream sv;
        sv << Y;
        std::string ver = sv.str();
        mWorld.createWorld(hor+ver+".txt");
        *mContext.player = Player(mWorld.getWorld(), pos.x-7.95, pos.y, sf::Vector2f(X,Y));
        mPlayer->getBody()->SetLinearVelocity(vel);
    }
    if (pos.y<0)
    {
        sf::Vector2f POS(mPlayer->getPos());
        b2Vec2 vel(mPlayer->getBody()->GetLinearVelocity());
        int X = POS.x;
        int Y = POS.y+1;
        std::stringstream sh;
        sh << X;
        std::string hor = sh.str();
        std::stringstream sv;
        sv << Y;
        std::string ver = sv.str();
        mWorld.createWorld(hor+ver+".txt");
        *mContext.player = Player(mWorld.getWorld(), pos.x, pos.y+6.45, sf::Vector2f(X,Y));
        mPlayer->getBody()->SetLinearVelocity(vel);
    }
    if (pos.y>6.5)
    {
        sf::Vector2f POS(mPlayer->getPos());
        b2Vec2 vel(mPlayer->getBody()->GetLinearVelocity());
        int X = POS.x;
        int Y = POS.y-1;
        std::stringstream sh;
        sh << X;
        std::string hor = sh.str();
        std::stringstream sv;
        sv << Y;
        std::string ver = sv.str();
        mWorld.createWorld(hor+ver+".txt");
        *mContext.player = Player(mWorld.getWorld(), pos.x, pos.y-6.45, sf::Vector2f(X,Y));
        mPlayer->getBody()->SetLinearVelocity(vel);
    }
    return true;
}