YouTubeModel::YouTubeModel() {
  if(!db.open("youtube.db", true)) {
    RX_ERROR("Cannot open database");
    ::exit(EXIT_FAILURE);
  }

  {
    QueryResult qr(db);
    db.query("CREATE TABLE IF NOT EXISTS videos ("
             "    id INTEGER PRIMARY KEY AUTOINCREMENT,"
             "    filename TEXT, "
             "    title TEXT, "                              // title for the video as it appears on youtube
             "    description TEXT, "                        // description for the video as it appears on youtube 
             "    tags TEXT, "                               // tags for the youtube video
             "    privacy_status TEXT DEFAULT \"private\", " // private status for youtube 
             "    bytes_uploaded INTEGER DEFAULT 0,"         // - not used atm -
             "    bytes_total INTEGER DEFAULT 0,"            // total bytes of the file 
             "    state INTEGER DEFAULT 0,"                  // used to upload only videos which haven't been uploaded yet
             "    datapath INTEGER DEFAULT 0,"               // is the filename relative to the datapase of the runtime, 0 = no, 1 = yes
             "    video_resource_json TEXT,"                 // the json that we post as body when uploading 
             "    category INTEGER DEFAULT 2,"              // the category for the video on youtube
             "    retries INTEGER DEFAULT 0,"                // number of times we retried to upload the video after receiving an upload error
             "    upload_url TEXT )").execute(qr);
    qr.finish();
  }

  {
    QueryResult qr(db);
    db.query("CREATE TABLE IF NOT EXISTS state("
             "   name TEXT UNIQUE, "
             "   value TEXT)").execute(qr);
    qr.finish();
  }

}
Exemple #2
0
int query(int i)
{
  if (i > _n || i < 1)
    exit (1);
  _q++;
  if (_q == _li)
  {
    _l = true;
    return qr (i, (_v <= i ? 0 : 1));
  }
  return qr (i, (_v <= i ? 1 : 0));
}
Exemple #3
0
int query(int i)
{
  if (i > _n || i < 1)
    exit (1);
  _q++;
  if (_l == false && (rand () % _p) == 0)
  {
    _l = true;
    return qr (i, (_v <= i ? 0 : 1));
  }
  return qr (i, (_v <= i ? 1 : 0));
}
Exemple #4
0
/**
 * Randomized SVD based on
 *
 * Halko, Nathan, Per-Gunnar Martinsson, and Joel A. Tropp.
 * "Finding structure with randomness: Probabilistic algorithms for
 * constructing approximate matrix decompositions."
 * SIAM review 53.2 (2011): 217-288.
 */
void
svd_topk (const float *a, size_t m, size_t n, size_t k, float **ou)
{
  const size_t l = 2 * k;       // top2k approximation
  const size_t p = 2;           // power iterations
  size_t i;

  float *b = NULL;
  float *q = NULL;
  float *s = NULL;
  float *u = NULL;
  float *v = NULL;
  float *y = NULL;

  if (l >= min (m, n))
    goto error;

  b = mem_alloc (l * n, sizeof (float));
  q = mem_alloc (l * max (m, n), sizeof (float));
  y = mem_alloc (l * max (m, n), sizeof (float));
  if (b == NULL || q == NULL || y == NULL)
    goto error;

  for (i = 0; i < n * l; i++)
    b[i] = rnorm ();

  dotnn (a, b, m, n, l, y);
  qr (y, m, l, q);
  for (i = 0; i < p; i++) {
    dottn (a, q, m, n, l, y);
    qr (y, n, l, q);
    dotnn (a, q, m, n, l, y);
    qr (y, m, l, q);
  }
  dottn (q, a, m, l, n, b);
  transpose (b, l, n);
  svd_full (b, n, l, &u, &s, &v);
  trim (v, s, l, l, k, b);
  dotnn (q, b, m, l, k, y);
  goto done;
error:
  mem_freenull (y);
done:
  *ou = y;
  mem_free (u);
  mem_free (s);
  mem_free (v);
  mem_free (b);
  mem_free (q);
}
Exemple #5
0
Vector<value_type> lin_solve(Matrix<value_type> const & A, Vector<value_type> const & bin) {
	
	//Create A=QR 
	
	if(A.dimension().first > A.dimension().second)
		return lin_solve(A.trans()*A,A.trans()*bin);
	Matrix<value_type> Ac(std::max(A.dimension().first,A.dimension().second),A.dimension().second);
	Ac = A;
	QR_Givens<value_type> qr(Ac);
	/*std::cout << "A:\n " << A << " b: " << bin << "\n\n" ;
	std::cout << "Q: " << qr.get_q() << " R: " << qr.get_r() << "\n";
	std::cout << "a=QR: " << qr.get_q() * qr.get_r() << "\n";*/

	// calc b=QT*bin
	Vector<value_type> b = qr.get_q().trans()*bin;

	//std::cout << "Qb: \n" << b << "\n\n";

	// backtrack Rx=b
	Vector<value_type> x(A.dimension().second);
		// If check if zerolines for overdefined
	size_type dim1 = A.dimension().first, dim2 = A.dimension().second;
			
	for(size_type i=dim1-1;i!=0;--i)
		if(qr.get_r().is_zero(i))
		{
			x[i] = 1.0;
			//std::cout << "found zeroline\n";
		}
		else
		{
			dim1 = i+1;
			break;
		}
	

	if(dim1 < dim2)
	{
		//=> extend R to nxn and set k xs to 1 and beging at n-k line in backtracking
		for(size_type i = dim1; i<dim2;++i)
		{
			x[i] = 1.0;
		}
	}

	// real backtracking:
	for(size_type i = dim1-1;;--i)
	{
		x[i] = b[i];
		for(size_type j = i+1;j<dim2;++j)
		{
			x[i] -= qr.get_r()[i][j]*x[j];
		}
		x[i]/= qr.get_r()[i][i];
		if(i==0)
			break;
	}
	//std::cout << "x: \n" << x << "\n";
	return x;
}
bool YouTubeModel::incrementVideoBytesUploaded(int id, size_t nbytes) {
  std::stringstream ss;
  ss << "update videos set bytes_uploaded += " << nbytes << " where id = \"" << id << "\"";
  QueryResult qr(db);
  db.query(ss.str()).execute(qr);
  return qr.finish();
}
Exemple #7
0
int main( int argc , char *argv[] )
{
	Matrix mat = Matrix::random(m,m);
	// Eigen::MatrixXd mm(m,m);
	// for (int i = 0 ; i < m ; ++ i )
	// 	for ( int j = 0 ; j < m ; ++ j )
	// 		mm(i,j) = mat(i,j);
	Vector v = Vector::random(m);
	// Eigen::VectorXd vec(m);
	// for ( int i = 0 ; i < m ; ++ i )
		// vec(i) = v(i);
	Matrix rhb = Matrix::random(m,n);
	// std::cout<<"matrix is "<<std::endl<<mat<<std::endl;
	LU lu(mat);
	Matrix mtm;
	mat.mtm(mtm);
	Cholesky cho(mtm);
	QR qr(mat);
	std::cout<<lu.solve(rhb)<<std::endl;
	lu.compute(mtm);
	std::cout<<lu.solve(mat.transpose()*rhb)<<std::endl;
	std::cout<<qr.solve(mat.transpose()*rhb)<<std::endl;
	// std::cout<<lu.inverse()<<std::endl;
	std::cout<<"solving result"<<std::endl;
	std::cout<<cho.solve(mat.transpose()*rhb)<<std::endl;

	// LU lu2(mtm);
	// std::cout<<"result of eigen"<<std::endl<<mm.inverse()<<std::endl;
	// std::cout<<lu2.inverse()<<std::endl;
	// std::cout<<lu2.inverse()*mtm<<std::endl;

	// std::cout<<"inverse is "<<std::endl<<cho.inverse()<<std::endl;
	// std::cout<<cho.inverse()*mtm<<std::endl; 
	// std::cout<<Eigen::PartialPivLU<Eigen::MatrixXd>(mm).solve(vec)<<std::endl;
}
Exemple #8
0
void TpsRegistration::PrepareBasisKernel() {
  // TODO(bing-jian): detect singularity of the data
  vnl_matrix<double> K, U;
  ComputeTPSKernel(model_, ctrl_pts_, U, K);
  m_ = model_.rows();
  vnl_matrix<double> Pm;
  Pm.set_size(m_, d_ + 1);
  Pm.set_column(0, 1);
  Pm.update(model_, 0, 1);

  vnl_matrix<double> Pn;
  Pn.set_size(n_, d_ + 1);
  Pn.set_column(0, 1);
  Pn.update(ctrl_pts_, 0, 1);
  /* should use SVD(Pn), but vnl's SVD is an ``economy-size'' SVD  */

  /* vnl_svd<double> SVD(Pn.transpose());
  vnl_matrix<double> VV = SVD.V();
  std::cout << VV.rows() << " " << VV.cols() << std::endl;
  SaveMatrixToAsciiFile("./VV.txt", VV);
  */

  vnl_qr<double> qr(Pn);
  vnl_matrix<double> V = qr.Q();
  vnl_matrix<double> PP = V.extract(n_, n_ - d_ - 1, 0, d_ + 1);
  basis_.set_size(m_, n_);
  basis_.update(Pm);
  basis_.update(U * PP, 0, d_ + 1);
  kernel_ = PP.transpose() * K * PP;
}
Exemple #9
0
void AddTaskDialog::addTask()
{
    QSqlQuery qr(mydb);

    qr.prepare("SELECT count(*) FROM tasks WHERE url=:url AND (arch IS NULL OR arch<>'1');");
    qr.bindValue("url", gui->urlBox->currentText());
    if(!qr.exec())
    {
        //тут запись в журнал ошибок
        qDebug()<<"void AddTaskDialog::addTask(1):"<<qr.executedQuery()<<" Error: "<<qr.lastError().text();
        close();
        return;
    }
    qr.next();

    if(qr.value(0).toInt() > 0)
    {
        EMessageBox *question = new EMessageBox(this);
        question->setIcon(QMessageBox::Question);
        question->setWindowTitle(tr("URL уже существует"));
        question->addButton(tr("Перезакачать"), EMessageBox::YesRole);
        QPushButton *btn = question->addButton(tr("Отмена"),EMessageBox::RejectRole);
        question->setDefaultButton(btn);
        question->setText(tr("Этот URL <a href=\"%1\">%1</a> уже присутствует в списке заданий.").arg(gui->urlBox->currentText()));
        question->setInformativeText(tr("Нажмите <b>\"Перезакачать\"</b> для продолжения или <b>\"Отмена\"</b> для отмены действия."));
        question->setActionType(EMessageBox::AT_REDOWNLOAD);

        connect(question,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(acceptQAction(QAbstractButton*)));
        question->show();
        return;
    }
Exemple #10
0
void AddTaskDialog::loadDatabaseData()
{
    QSqlQuery qr(mydb);
    qr.exec("SELECT id,url FROM tasks ORDER BY id DESC LIMIT 99");

    while(qr.next())
        gui->urlBox->addItem(qr.value(1).toString());
    gui->urlBox->setCurrentIndex(-1);

    qr.clear();
    qr.exec("SELECT * FROM categories");
    int otherId = 0;

    while(qr.next())
    {
        QString cattitle;
        if(qr.value(1).toString() == "#downloads")continue;
        else if(qr.value(1).toString() == "#archives"){cattitle = tr("Архивы"); dirs.insert(qr.value(0).toInt(),downDir+"/"+cattitle);}
        else if(qr.value(1).toString() == "#apps"){cattitle = tr("Приложения"); dirs.insert(qr.value(0).toInt(),downDir+"/"+cattitle);}
        else if(qr.value(1).toString() == "#audio"){cattitle = tr("Аудио"); dirs.insert(qr.value(0).toInt(),downDir+"/"+cattitle);}
        else if(qr.value(1).toString() == "#video"){cattitle = tr("Видео"); dirs.insert(qr.value(0).toInt(),downDir+"/"+cattitle);}
        else if(qr.value(1).toString() == "#other"){cattitle = tr("Другое"); otherId = qr.value(0).toInt();dirs.insert(qr.value(0).toInt(),downDir);}
        else {cattitle = qr.value(1).toString(); dirs.insert(qr.value(0).toInt(),qr.value(2).toString());}

        gui->categoryBox->addItem(cattitle, qr.value(0).toInt());
    }
    gui->categoryBox->setCurrentIndex(gui->categoryBox->findData(QVariant(otherId)));

}
BOOL QT_WIN_CALLBACK enumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM)
{
    QDesktopWidgetPrivate::screenCount++;
    QDesktopWidgetPrivate::rects->resize(QDesktopWidgetPrivate::screenCount);
    QDesktopWidgetPrivate::workrects->resize(QDesktopWidgetPrivate::screenCount);
    // Get the MONITORINFO block
    QDesktopWidgetPrivate::MONITORINFO info;
    memset(&info, 0, sizeof(QDesktopWidgetPrivate::MONITORINFO));
    info.cbSize = sizeof(QDesktopWidgetPrivate::MONITORINFO);
    BOOL res = QDesktopWidgetPrivate::getMonitorInfo(hMonitor, &info);
    if (!res) {
        (*QDesktopWidgetPrivate::rects)[screen_number] = QRect();
        (*QDesktopWidgetPrivate::workrects)[screen_number] = QRect();
        return true;
    }

    // Fill list of rects
    RECT r = info.rcMonitor;
    QRect qr(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
    (*QDesktopWidgetPrivate::rects)[screen_number] = qr;

    r = info.rcWork;
    qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
    (*QDesktopWidgetPrivate::workrects)[screen_number] = qr;

    if (info.dwFlags & 0x00000001) //MONITORINFOF_PRIMARY
        QDesktopWidgetPrivate::primaryScreen = screen_number;

    ++screen_number;
    // Stop the enumeration if we have them all
    return true;
}
TEST(QueryRequestTest, AsFindCommandWithUuidNoAvailableNamespace) {
    BSONObj cmdObj =
        fromjson("{find: { \"$binary\" : \"ASNFZ4mrze/ty6mHZUMhAQ==\", \"$type\" : \"04\" }}");
    QueryRequest qr(NamespaceStringOrUUID(
        "test", UUID::parse("01234567-89ab-cdef-edcb-a98765432101").getValue()));
    ASSERT_BSONOBJ_EQ(cmdObj, qr.asFindCommandWithUuid());
}
 GLColorBuffer GLLensDustFilter::GaussianBlur(GLColorBuffer tex, bool vertical) {
     SPADES_MARK_FUNCTION();
     GLProgram *program = gauss1d;
     IGLDevice *dev = renderer->GetGLDevice();
     GLQuadRenderer qr(dev);
     int w = tex.GetWidth();
     int h = tex.GetHeight();
     
     static GLProgramAttribute blur_positionAttribute("positionAttribute");
     static GLProgramUniform blur_textureUniform("mainTexture");
     static GLProgramUniform blur_unitShift("unitShift");
     program->Use();
     blur_positionAttribute(program);
     
     blur_textureUniform(program);
     blur_textureUniform.SetValue(0);
     dev->ActiveTexture(0);
     dev->BindTexture(IGLDevice::Texture2D, tex.GetTexture());
     
     blur_unitShift(program);
     blur_unitShift.SetValue(vertical ? 0.f : 1.f / w,
                             vertical ? 1.f / h : 0.f);
     
     qr.SetCoordAttributeIndex(blur_positionAttribute());
     dev->Enable(IGLDevice::Blend, false);
     
     GLColorBuffer buf2 = renderer->GetFramebufferManager()->CreateBufferHandle(w, h, false);
     dev->Viewport(0, 0, buf2.GetWidth(), buf2.GetHeight());
     dev->BindFramebuffer(IGLDevice::Framebuffer, buf2.GetFramebuffer());
     qr.Draw();
     return buf2;
 }
TEST(QueryRequestTest, ParseFromCommandAllFlagsTrue) {
    BSONObj cmdObj = fromjson(
        "{find: 'testns',"
        "tailable: true,"
        "oplogReplay: true,"
        "noCursorTimeout: true,"
        "awaitData: true,"
        "allowPartialResults: true,"
        "readOnce: true,"
        "allowSpeculativeMajorityRead: true}");
    const NamespaceString nss("test.testns");
    bool isExplain = false;
    unique_ptr<QueryRequest> qr(
        assertGet(QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain)));

    // Test that all the flags got set to true.
    ASSERT(qr->isTailable());
    ASSERT(!qr->isSlaveOk());
    ASSERT(qr->isOplogReplay());
    ASSERT(qr->isNoCursorTimeout());
    ASSERT(qr->isTailableAndAwaitData());
    ASSERT(qr->isAllowPartialResults());
    ASSERT(qr->isReadOnce());
    ASSERT(qr->allowSpeculativeMajorityRead());
}
TEST(QueryRequestTest, ParseFromLegacyQuery) {
    const auto kSkip = 1;
    const auto kNToReturn = 2;

    BSONObj queryObj = fromjson(R"({
            query: {query: 1},
            orderby: {sort: 1},
            $hint: {hint: 1},
            $explain: false,
            $min: {x: 'min'},
            $max: {x: 'max'}
         })");
    const NamespaceString nss("test.testns");
    unique_ptr<QueryRequest> qr(assertGet(QueryRequest::fromLegacyQuery(
        nss, queryObj, BSON("proj" << 1), kSkip, kNToReturn, QueryOption_Exhaust)));

    ASSERT_EQ(qr->nss(), nss);
    ASSERT_BSONOBJ_EQ(qr->getFilter(), fromjson("{query: 1}"));
    ASSERT_BSONOBJ_EQ(qr->getProj(), fromjson("{proj: 1}"));
    ASSERT_BSONOBJ_EQ(qr->getSort(), fromjson("{sort: 1}"));
    ASSERT_BSONOBJ_EQ(qr->getHint(), fromjson("{hint: 1}"));
    ASSERT_BSONOBJ_EQ(qr->getMin(), fromjson("{x: 'min'}"));
    ASSERT_BSONOBJ_EQ(qr->getMax(), fromjson("{x: 'max'}"));
    ASSERT_EQ(qr->getSkip(), boost::optional<long long>(kSkip));
    ASSERT_EQ(qr->getNToReturn(), boost::optional<long long>(kNToReturn));
    ASSERT_EQ(qr->wantMore(), true);
    ASSERT_EQ(qr->isExplain(), false);
    ASSERT_EQ(qr->isSlaveOk(), false);
    ASSERT_EQ(qr->isOplogReplay(), false);
    ASSERT_EQ(qr->isNoCursorTimeout(), false);
    ASSERT_EQ(qr->isTailable(), false);
    ASSERT_EQ(qr->isExhaust(), true);
    ASSERT_EQ(qr->isAllowPartialResults(), false);
    ASSERT_EQ(qr->getOptions(), QueryOption_Exhaust);
}
    vector_type solve(const matrix_type& A, const vector_type& y)
    {
        typedef typename matrix_type::size_type size_type;
        typedef typename matrix_type::value_type value_type;

        namespace ublas = boost::numeric::ublas;

        matrix_type Q(A.size1(), A.size2()), R(A.size1(), A.size2());

        qr (A, Q, R);

        vector_type b = prod(trans(Q), y);

        vector_type result;
        if (R.size1() > R.size2())
        {
            size_type min = (R.size1() < R.size2() ? R.size1() : R.size2());

            result = ublas::solve(subrange(R, 0, min, 0, min),
                                  subrange(b, 0, min),
                                  ublas::upper_tag());
        }
        else
        {
            result = ublas::solve(R, b, ublas::upper_tag());
        }
        return result;
    }
TEST(QueryRequestTest, ConvertToAggregationWithPipeline) {
    QueryRequest qr(testns);
    qr.setFilter(BSON("x" << 1));
    qr.setSort(BSON("y" << -1));
    qr.setLimit(3);
    qr.setSkip(7);
    qr.setProj(BSON("z" << 0));

    auto agg = qr.asAggregationCommand();
    ASSERT_OK(agg);

    auto ar = AggregationRequest::parseFromBSON(testns, agg.getValue());
    ASSERT_OK(ar.getStatus());
    ASSERT(!ar.getValue().getExplain());
    ASSERT_EQ(ar.getValue().getBatchSize(), AggregationRequest::kDefaultBatchSize);
    ASSERT_EQ(ar.getValue().getNamespaceString(), testns);
    ASSERT_BSONOBJ_EQ(ar.getValue().getCollation(), BSONObj());

    std::vector<BSONObj> expectedPipeline{BSON("$match" << BSON("x" << 1)),
                                          BSON("$sort" << BSON("y" << -1)),
                                          BSON("$skip" << 7),
                                          BSON("$limit" << 3),
                                          BSON("$project" << BSON("z" << 0))};
    ASSERT(std::equal(expectedPipeline.begin(),
                      expectedPipeline.end(),
                      ar.getValue().getPipeline().begin(),
                      SimpleBSONObjComparator::kInstance.makeEqualTo()));
}
void testApp :: draw()
{
	
	//ofQuaternion constructor: angle, ofVec3f axis
	
	ofQuaternion qr (roll, Znormal);	// quat roll.
	ofQuaternion qp (pitch, Xnormal);	// quat pitch.
	ofQuaternion qh (heading, Ynormal);	// quat heading or yaw.
	ofQuaternion qt;					// quat total.

	
	
	// The order IS IMPORTANT. Apply roll first, then pitch, then heading.
	qt = qr * qp * qh;
	
	
		
	ofPushMatrix();
		ofTranslate( ofGetWidth() * 0.5, ofGetHeight() * 0.5, 0 );
		
		/******************************/
		
		/*
		//GYMBAL LOCK!!
		EulerRot = qt.getEuler();
		ofRotateX(EulerRot.x);
		ofRotateY(EulerRot.y);
		ofRotateZ(EulerRot.z);
		 */
		 

		ofVec3f qaxis; float qangle;
		qt.getRotate(qangle, qaxis);
	
		ofRotate(qangle, qaxis.x, qaxis.y, qaxis.z);
 
	
		ofScale( 200, 200, 200 );
		/******************************/

		
		drawCube();
		
	ofPopMatrix();
	
	
	
	
	ofSetColor( 0x000000 );
	ofDrawBitmapString
	(
	 "fps :: " + ofToString(ofGetFrameRate(), 2) + "\n\n"
	 "incDir  :: press i to change :: " + ofToString( incDir ) + "\n\n"
	 "roll    :: press 1 to change :: " + ofToString( roll ) + "\n\n"
	 "pitch   :: press 2 to change :: " + ofToString( pitch ) + "\n\n"
	 "heading :: press 3 to change :: " + ofToString( heading ) + "\n\n",
	 20,
	 20
	 );
}
TEST(QueryRequestTest, DefaultQueryParametersCorrect) {
    BSONObj cmdObj = fromjson("{find: 'testns'}");

    const NamespaceString nss("test.testns");
    std::unique_ptr<QueryRequest> qr(
        assertGet(QueryRequest::makeFromFindCommand(nss, cmdObj, false)));

    ASSERT_FALSE(qr->getSkip());
    ASSERT_FALSE(qr->getLimit());

    ASSERT_EQUALS(true, qr->wantMore());
    ASSERT_FALSE(qr->getNToReturn());
    ASSERT_EQUALS(false, qr->isExplain());
    ASSERT_EQUALS(0, qr->getMaxTimeMS());
    ASSERT_EQUALS(false, qr->returnKey());
    ASSERT_EQUALS(false, qr->showRecordId());
    ASSERT_EQUALS(false, qr->hasReadPref());
    ASSERT_EQUALS(false, qr->isTailable());
    ASSERT_EQUALS(false, qr->isSlaveOk());
    ASSERT_EQUALS(false, qr->isOplogReplay());
    ASSERT_EQUALS(false, qr->isNoCursorTimeout());
    ASSERT_EQUALS(false, qr->isTailableAndAwaitData());
    ASSERT_EQUALS(false, qr->isExhaust());
    ASSERT_EQUALS(false, qr->isAllowPartialResults());
}
TEST(QueryRequestTest, ParseFromCommandReadOnceDefaultsToFalse) {
    BSONObj cmdObj = fromjson("{find: 'testns'}");
    const NamespaceString nss("test.testns");
    bool isExplain = false;
    unique_ptr<QueryRequest> qr(
        assertGet(QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain)));
    ASSERT(!qr->isReadOnce());
}
void test_boostmultiprec()
{
  typedef Matrix<Real,Dynamic,Dynamic> Mat;
  typedef Matrix<std::complex<Real>,Dynamic,Dynamic> MatC;

  std::cout << "NumTraits<Real>::epsilon()         = " << NumTraits<Real>::epsilon() << std::endl;
  std::cout << "NumTraits<Real>::dummy_precision() = " << NumTraits<Real>::dummy_precision() << std::endl;
  std::cout << "NumTraits<Real>::lowest()          = " << NumTraits<Real>::lowest() << std::endl;
  std::cout << "NumTraits<Real>::highest()         = " << NumTraits<Real>::highest() << std::endl;
  std::cout << "NumTraits<Real>::digits10()        = " << NumTraits<Real>::digits10() << std::endl;

  // chekc stream output
  {
    Mat A(10,10);
    A.setRandom();
    std::stringstream ss;
    ss << A;
  }
  {
    MatC A(10,10);
    A.setRandom();
    std::stringstream ss;
    ss << A;
  }

  for(int i = 0; i < g_repeat; i++) {
    int s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE);

    CALL_SUBTEST_1( cholesky(Mat(s,s)) );

    CALL_SUBTEST_2( lu_non_invertible<Mat>() );
    CALL_SUBTEST_2( lu_invertible<Mat>() );
    CALL_SUBTEST_2( lu_non_invertible<MatC>() );
    CALL_SUBTEST_2( lu_invertible<MatC>() );

    CALL_SUBTEST_3( qr(Mat(internal::random<int>(1,EIGEN_TEST_MAX_SIZE),internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
    CALL_SUBTEST_3( qr_invertible<Mat>() );

    CALL_SUBTEST_4( qr<Mat>() );
    CALL_SUBTEST_4( cod<Mat>() );
    CALL_SUBTEST_4( qr_invertible<Mat>() );

    CALL_SUBTEST_5( qr<Mat>() );
    CALL_SUBTEST_5( qr_invertible<Mat>() );

    CALL_SUBTEST_6( selfadjointeigensolver(Mat(s,s)) );

    CALL_SUBTEST_7( eigensolver(Mat(s,s)) );

    CALL_SUBTEST_8( generalized_eigensolver_real(Mat(s,s)) );

    TEST_SET_BUT_UNUSED_VARIABLE(s)
  }

  CALL_SUBTEST_9(( jacobisvd(Mat(internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE), internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE/2))) ));
  CALL_SUBTEST_10(( bdcsvd(Mat(internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE), internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE/2))) ));
}
TEST(QueryRequestTest, ParseCommandIsFromFindCommand) {
    BSONObj cmdObj = fromjson("{find: 'testns'}");
    const NamespaceString nss("test.testns");
    bool isExplain = false;
    unique_ptr<QueryRequest> qr(
        assertGet(QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain)));

    ASSERT_FALSE(qr->getNToReturn());
}
Exemple #23
0
void PacketParser(SOCKET sck, const char *Packet)
{
	switch (Packet[0])
	{
	// Movement packet.
	case PacketHeaders.MovementPacket:
		{
			MOVEMENTPACKET *mp = (MOVEMENTPACKET*)Packet;
			cout << "Mov*" << "ID:" << mp->ID << "|" << "MID:" << mp->MapID << "|" << "X:" << mp->XPos << "|" << "Y:" << mp->YPos << endl;
			BroadcastPacket(Packet, sizeof(MOVEMENTPACKET));
		}
		break;

	// Chat packet
	case PacketHeaders.ChatPacket:
		{
			CHATPACKET *cp = (CHATPACKET*)Packet;
			cout << "Chat*"<< cp->ID << "||" << cp->Text << endl;
			BroadcastPacket(Packet, cp->Length);
		}
		break;

	// Login packet
	case PacketHeaders.LoginPacket:
		{
			LOGINPACKET *lp = (LOGINPACKET*)Packet;
			cout << "Login*" << lp->Username << " : " << lp->Password << endl;

			stringstream querystring;
			querystring << "SELECT * FROM (`Users`) WHERE (`Username`='" << lp->Username << "' AND `Password`='" << lp->Password << "') LIMIT 1";
			mysqlpp::Connection con;
			con.connect(0, "localhost", "root", "", 3306);
			con.select_db("moonlightfrost");
			mysqlpp::Query qry(con.query(querystring.str()));
			mysqlpp::StoreQueryResult qr(qry.store());
			con.disconnect();

			if ( qr.num_rows() == 0 )
			{
				lp->UserID = 0;
				send(sck, (char *)lp, sizeof(LOGINPACKET), 0);
			}
			else
			{
				lp->UserID = atol(qr[0]["ID"].c_str());
				send(sck, (char *)lp, sizeof(LOGINPACKET), 0);
			}
		}
		break;

	default:
		{
			printf("WARNING: Recieved packet structure not recognized. Header: %s \n", (int)((char)Packet[0]));
		}
		break;
	}
}
Exemple #24
0
void qr(cv::Mat input, cv::Mat &q, cv::Mat &r){
	Eigen::Matrix3Xd* A = toMatrix3Xd(input);
	Eigen::HouseholderQR<Eigen::MatrixXd> qr(*A);
	Eigen::MatrixXd R = qr.matrixQR().triangularView<Eigen::Upper>();
	Eigen::MatrixXd Q = qr.householderQ();

	q = toMat(Q);
	r = toMat(R);
}
TEST(QueryRequestTest, ConvertToAggregationWithCommentSucceeds) {
    QueryRequest qr(testns);
    qr.setComment("test");
    const auto aggCmd = qr.asAggregationCommand();
    ASSERT_OK(aggCmd);

    auto ar = AggregationRequest::parseFromBSON(testns, aggCmd.getValue());
    ASSERT_OK(ar.getStatus());
    ASSERT_EQ(qr.getComment(), ar.getValue().getComment());
}
Exemple #26
0
void test_qr()
{
  for(int i = 0; i < 1; i++) {
    CALL_SUBTEST( qr(Matrix2f()) );
    CALL_SUBTEST( qr(Matrix4d()) );
    CALL_SUBTEST( qr(MatrixXf(12,8)) );
    CALL_SUBTEST( qr(MatrixXcd(5,5)) );
    CALL_SUBTEST( qr(MatrixXcd(7,3)) );
  }

  // small isFullRank test
  {
    Matrix3d mat;
    mat << 1, 45, 1, 2, 2, 2, 1, 2, 3;
    VERIFY(mat.qr().isFullRank());
    mat << 1, 1, 1, 2, 2, 2, 1, 2, 3;
    VERIFY(!mat.qr().isFullRank());
  }
}
int YouTubeModel::getNumberOfRetries(int id) {
  QueryResult qr(db);
  bool r = db.select("retries").from("videos").where("id", id).execute(qr);
  if(!r) {
    RX_ERROR("Cannot retrieve the number of retries for video: %d", id);
    return -1;
  }
  qr.next();
  return qr.getInt(0);
}
Exemple #28
0
GuestPayDialog::GuestPayDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GuestPayDialog)
{
    ui->setupUi(this);
    QUrl qr("https://auth.alipay.com/login/index.htm?goto=");

    ui->webView->setUrl(qr);
    QDesktopServices::openUrl(qr);
}
TEST(QueryRequestTest, ConvertToAggregationWithHintSucceeds) {
    QueryRequest qr(testns);
    qr.setHint(fromjson("{a_1: -1}"));
    const auto aggCmd = qr.asAggregationCommand();
    ASSERT_OK(aggCmd);

    auto ar = AggregationRequest::parseFromBSON(testns, aggCmd.getValue());
    ASSERT_OK(ar.getStatus());
    ASSERT_BSONOBJ_EQ(qr.getHint(), ar.getValue().getHint());
}
TEST(QueryRequestTest, ValidSortProj) {
    QueryRequest qr(testns);
    qr.setProj(fromjson("{a: 1}"));
    qr.setSort(fromjson("{a: 1}"));
    ASSERT_OK(qr.validate());

    QueryRequest metaQR(testns);
    metaQR.setProj(fromjson("{a: {$meta: \"textScore\"}}"));
    metaQR.setSort(fromjson("{a: {$meta: \"textScore\"}}"));
    ASSERT_OK(metaQR.validate());
}