Пример #1
0
static void linearAddition(const Linear& l, vec<Formula>& out)
{
    vec<Formula> sum;
    vec<Formula> x, y;

    //reportf("linearAddition\n");
    for (int i = 0; i < l.size; i++){
        sum.moveTo(x);
        bitAdder(l(i), id(var(var(l[i])),sign(l[i])), y);
        //reportf("step %d, x = %d, y = %d\n", i, x.size(), y.size());
        rippleAdder(x,y,sum);
    }

    //reportf("size: %d\n", sum.size());

    if (l.lo != Int_MIN){
        //reportf("lower limit\n");
        bitAdder(l.lo,_1_,x);
        lte(x,sum,out);
    }
    if (l.hi != Int_MAX){
        //reportf("upper limit\n");
        bitAdder(l.lo,_1_,x);
        lte(sum,x,out);
    }
}
Пример #2
0
    TEST(ExpressionAlgoIsSubsetOf, Compare_Exists) {
        ParsedMatchExpression exists("{a: {$exists: true}}");
        ParsedMatchExpression eq("{a: 1}");
        ParsedMatchExpression gt("{a: {$gt: 4}}");
        ParsedMatchExpression lte("{a: {$lte: 7}}");

        ASSERT_TRUE(expression::isSubsetOf(eq.get(), exists.get()));
        ASSERT_TRUE(expression::isSubsetOf(gt.get(), exists.get()));
        ASSERT_TRUE(expression::isSubsetOf(lte.get(), exists.get()));

        ASSERT_FALSE(expression::isSubsetOf(exists.get(), eq.get()));
        ASSERT_FALSE(expression::isSubsetOf(exists.get(), gt.get()));
        ASSERT_FALSE(expression::isSubsetOf(exists.get(), lte.get()));
    }
Пример #3
0
void linearAddition(const Linear& l, vec<Formula>& out)
{
    vec<Formula> sum;
    vec<Formula> inp;
    vec<Int>     cs;

    for (int i = 0; i < l.size; i++){
        inp.push(id(var(var(l[i])),sign(l[i])));
        cs.push(l(i));
    }

    Int     maxlim = (l.hi != Int_MAX) ? l.hi : (l.lo - 1);
    int     bits   = 0;
    for (Int i = maxlim; i != 0; i >>= 1)
        bits++;

    int     nodes = FEnv::nodes.size();

    addPb(inp,cs,sum,bits);
    if (opt_verbosity >= 1){
        char* tmp = toString(maxlim);
        reportf("Adder-cost: %d   maxlim: %s   bits: %d/%d\n", FEnv::nodes.size() - nodes, tmp, sum.size(), bits);
        xfree(tmp); }


    if (l.lo != Int_MIN){
        //reportf("lower limit\n");
        bitAdder(l.lo,_1_,inp);
        lte(inp,sum,out);
    }
    if (l.hi != Int_MAX){
        //reportf("upper limit\n");
        bitAdder(l.hi,_1_,inp);
        lte(sum,inp,out);
    }
}
Пример #4
0
    TEST(ExpressionAlgoIsSubsetOf, Compare_NaN) {
        ParsedMatchExpression nan("{x: NaN}");
        ParsedMatchExpression lt("{x: {$lt: 5}}");
        ParsedMatchExpression lte("{x: {$lte: 5}}");
        ParsedMatchExpression gte("{x: {$gte: 5}}");
        ParsedMatchExpression gt("{x: {$gt: 5}}");

        ASSERT_TRUE(expression::isSubsetOf(nan.get(), nan.get()));
        ASSERT_FALSE(expression::isSubsetOf(nan.get(), lt.get()));
        ASSERT_FALSE(expression::isSubsetOf(lt.get(), nan.get()));
        ASSERT_FALSE(expression::isSubsetOf(nan.get(), lte.get()));
        ASSERT_FALSE(expression::isSubsetOf(lte.get(), nan.get()));
        ASSERT_FALSE(expression::isSubsetOf(nan.get(), gte.get()));
        ASSERT_FALSE(expression::isSubsetOf(gte.get(), nan.get()));
        ASSERT_FALSE(expression::isSubsetOf(nan.get(), gt.get()));
        ASSERT_FALSE(expression::isSubsetOf(gt.get(), nan.get()));
    }
Пример #5
0
void Conditions::Lte(const string& name, const string& value) {
    shared_ptr<Condition::Base> lte(new Condition::Lte(name, value));
    vector< shared_ptr<Condition::Base> >::push_back(lte);
}
Пример #6
0
void oneRun(char * args)
{
    Input input;
    Matrix<double> cuad(41, 2);
    Model *model = new Model();
    ModelFactory *modelFactory;
    PatternMatrix *dataSet;
    Matrix<double> *theta;
    Matrix<double> *weight;
    
    modelFactory = new SICSGeneralModel();
    dataSet = new PatternMatrix(0);
    theta = new Matrix<double>(1, 41);
    weight = new Matrix<double>(1, 41);

    input.importCSV((char *) "Cuads.csv", cuad, 1, 0);
    input.importCSV(args, *dataSet, 1, 0);
    
    model->setModel(modelFactory, ESTIMATION_MODEL);
    delete modelFactory;
    
    model->getItemModel()->setDataset(dataSet);

    for (int k = 0; k < cuad.nR(); k++)
    {
		(*theta)(0, k) = cuad(k, 0);
		(*weight)(0, k) = cuad(k, 1);
	}

	// build parameter set
	model->getParameterModel()->buildParameterSet(model->getItemModel(), model->getDimensionModel());

	// Create estimation
	EMEstimation em;
	//Here is where quadratures must be set.
	//create the quad nodes
	QuadratureNodes nodes(theta, weight);
	em.setQuadratureNodes(&nodes);
	em.setModel(model);
	em.setInitialValues(Constant::ANDRADE);
	//Pass the profiler to the estimation object so it can be used to profile each step
	//Run the estimation
	em.estimate();

	/*
	 * Now we will run the estimation of individual parameter
	 */
	//Now create the estimation
	LatentTraitEstimation lte(dataSet);
	//Pass the model
	lte.setModel(model);
	//Pass the quadrature nodes
	lte.setQuadratureNodes(&nodes);
	//Ready to estimate
	lte.estimateLatentTraitsEAP();
	//lte.estimateLatentTraitsMAP();
	//finished
	//now read the latent traits but we will do this later
	lte.getLatentTraits()->print();
	
	//Matrix<double> data(dataSet->countIndividuals(), dataSet->countItems());
	//input.importCSV(args, data, 1, 0);
	
	//double* itemsf = new double[ data.nC()];
	//itemFit(latentTraits->pm, *(latentTraits->traits), data, model->getParameterModel()->getParameterSet(), model -> type,itemsf);
	//personFit(latentTraits->pm, *(latentTraits->traits), data, model->getParameterModel()->getParameterSet(), model -> type);

	delete dataSet;
	delete model;
	delete theta;
	delete weight;
}
Пример #7
0
inline bool lte(const T1& lhs, const T2& rhs) {
  return lhs.get_head() <= rhs.get_head()  &&
          ( !(rhs.get_head() <= lhs.get_head()) ||
            lte(lhs.get_tail(), rhs.get_tail()));
}
Пример #8
0
		bool gt(double a, double b) { return !lte(a, b); }
Пример #9
0
CameraPtr Camera::init()
{
   // Create a transform to contain the location and orientation of the camera.
   mTransform = OSG::Transform::create();

   OSG::NodePtr beacon = OSG::Node::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor be(beacon, OSG::Node::CoreFieldMask);
#endif
   beacon->setCore(mTransform);

   mLeftTexture = tex_chunk_t::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor lte(mLeftTexture);
   mLeftTexture->setEnvMode(GL_MODULATE);
#else
   mLeftTexEnv = OSG::TextureEnvChunk::create();
   mLeftTexEnv->setEnvMode(GL_MODULATE);
#endif

   mRightTexture = tex_chunk_t::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor rte(mRightTexture);
   mRightTexture->setEnvMode(GL_MODULATE);
#else
   mRightTexEnv = OSG::TextureEnvChunk::create();
   mRightTexEnv->setEnvMode(GL_MODULATE);
#endif

   mCurrentTexture = mLeftTexture;
#if OSG_MAJOR_VERSION >= 2
   mCurrentTexEnv = mLeftTexEnv;
#endif

   // setup camera
   mCamera = OSG::PerspectiveCamera::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor ce(mCamera);
#endif
   mCamera->setFov(
#if OSG_MAJOR_VERSION < 2
      OSG::osgdegree2rad(60.0)
#else
      OSG::osgDegree2Rad(60.0)
#endif
   );
   mCamera->setNear(0.01);
   mCamera->setFar(10000);
   mCamera->setBeacon(beacon);

   mLeftImage = OSG::Image::create();
   mRightImage = OSG::Image::create();

   OSG::ImagePtr img;

   // Set up FBO textures.
   img = mLeftImage;
   mLeftTexture->setMinFilter(GL_LINEAR);
   mLeftTexture->setMagFilter(GL_LINEAR);
   mLeftTexture->setTarget(GL_TEXTURE_2D);
   mLeftTexture->setInternalFormat(GL_RGBA8);
   mLeftTexture->setImage(img);

   img = mRightImage;
   mRightTexture->setMinFilter(GL_LINEAR);
   mRightTexture->setMagFilter(GL_LINEAR);
   mRightTexture->setTarget(GL_TEXTURE_2D);
   mRightTexture->setInternalFormat(GL_RGBA8);
   mRightTexture->setImage(img);

   mCurrentImage = mLeftImage;

   return shared_from_this();
}