Ejemplo n.º 1
0
int main(int argc, char **argv)
{
  ros::init(argc, argv, "t21");

  ros::NodeHandle node;

  T21 t21(node);
  t21.run();

  return 0;
}
Ejemplo n.º 2
0
    vector<Path> au2pp(LL au_id, LL id, vector<Paper> paper_by_au, Paper paper){
        vector<Paper> paper_ref_ed; /// Papers that refers to Id
        
        vector<Paper> paper_au_af;

        thread t21(f21, paper, ref(paper_ref_ed));
        thread t22(f22, paper, ref(paper_au_af));
        t21.join();
        t22.join();
        
        vector<vector<LL> > ret;
        au2pp_1hop(au_id, id, ret, paper);
        au2pp_2hop(au_id, id, ret, paper_by_au, paper_ref_ed);
        au2pp_3hop(au_id, id, ret, paper_by_au, paper, paper_ref_ed, paper_au_af);
        return ret;
    }
Ejemplo n.º 3
0
TEST(KVEngineTestHarness, AllCommittedTimestamp) {
    unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());
    KVEngine* engine = helper->getEngine();
    if (!engine->supportsDocLocking())
        return;

    unique_ptr<RecordStore> rs;
    {
        MyOperationContext opCtx(engine);
        WriteUnitOfWork uow(&opCtx);
        CollectionOptions options;
        options.capped = true;
        options.cappedSize = 10240;
        options.cappedMaxDocs = -1;

        NamespaceString oplogNss("local.oplog.rs");
        ASSERT_OK(engine->createRecordStore(&opCtx, oplogNss.ns(), "ident", options));
        rs = engine->getRecordStore(&opCtx, oplogNss.ns(), "ident", options);
        ASSERT(rs);
    }
    {
        Timestamp t11(1, 1);
        Timestamp t12(1, 2);
        Timestamp t21(2, 1);

        auto t11Doc = BSON("ts" << t11);
        auto t12Doc = BSON("ts" << t12);
        auto t21Doc = BSON("ts" << t21);

        Timestamp allCommitted = engine->getAllCommittedTimestamp();
        MyOperationContext opCtx1(engine);
        WriteUnitOfWork uow1(&opCtx1);
        ASSERT_EQ(invariant(rs->insertRecord(
                      &opCtx1, t11Doc.objdata(), t11Doc.objsize(), Timestamp::min())),
                  RecordId(1, 1));

        Timestamp lastAllCommitted = allCommitted;
        allCommitted = engine->getAllCommittedTimestamp();
        ASSERT_GTE(allCommitted, lastAllCommitted);
        ASSERT_LT(allCommitted, t11);

        MyOperationContext opCtx2(engine);
        WriteUnitOfWork uow2(&opCtx2);
        ASSERT_EQ(invariant(rs->insertRecord(
                      &opCtx2, t21Doc.objdata(), t21Doc.objsize(), Timestamp::min())),
                  RecordId(2, 1));
        uow2.commit();

        lastAllCommitted = allCommitted;
        allCommitted = engine->getAllCommittedTimestamp();
        ASSERT_GTE(allCommitted, lastAllCommitted);
        ASSERT_LT(allCommitted, t11);

        ASSERT_EQ(invariant(rs->insertRecord(
                      &opCtx1, t12Doc.objdata(), t12Doc.objsize(), Timestamp::min())),
                  RecordId(1, 2));

        lastAllCommitted = allCommitted;
        allCommitted = engine->getAllCommittedTimestamp();
        ASSERT_GTE(allCommitted, lastAllCommitted);
        ASSERT_LT(allCommitted, t11);

        uow1.commit();

        lastAllCommitted = allCommitted;
        allCommitted = engine->getAllCommittedTimestamp();
        ASSERT_GTE(allCommitted, lastAllCommitted);
        ASSERT_LTE(allCommitted, t21);
    }
}
Ejemplo n.º 4
0
void
poisson_blend(mve::FloatImage::ConstPtr src, mve::ByteImage::ConstPtr mask,
    mve::FloatImage::Ptr dest, float alpha) {

    assert(src->width() == mask->width() && mask->width() == dest->width());
    assert(src->height() == mask->height() && mask->height() == dest->height());
    assert(src->channels() == 3 && dest->channels() == 3);
    assert(mask->channels() == 1);
    assert(valid_mask(mask));

    const int n = dest->get_pixel_amount();
    const int width = dest->width();
    const int height = dest->height();
    const int channels = dest->channels();

    mve::Image<int>::Ptr indices = mve::Image<int>::create(width, height, 1);
    indices->fill(-1);
    int index = 0;
    for (int i = 0; i < n; ++i) {
        if (mask->at(i) != 0) {
            indices->at(i) = index;
            index++;
        }
    }
    const int nnz = index;

    std::vector<math::Vec3f> coefficients_b;
    coefficients_b.resize(nnz);

    std::vector<Eigen::Triplet<float, int> > coefficients_A;
    coefficients_A.reserve(nnz); //TODO better estimate...

    for (int i = 0; i < n; ++i) {
        const int row = indices->at(i);
        if (mask->at(i) == 126 || mask->at(i) == 128) {
            Eigen::Triplet<float, int> t(row, row, 1.0f);
            coefficients_A.push_back(t);

            coefficients_b[row] = math::Vec3f(&dest->at(i, 0));
        }

        if (mask->at(i) == 255) {
            const int i01 = indices->at(i - width);
            const int i10 = indices->at(i - 1);
            const int i11 = indices->at(i);
            const int i12 = indices->at(i + 1);
            const int i21 = indices->at(i + width);

            /* All neighbours should be eighter border conditions or part of the optimization. */
            assert(i01 != -1 && i10 != -1 && i11 != -1 && i12 != -1 && i21 != -1);

            Eigen::Triplet<float, int> t01(row, i01, 1.0f);

            Eigen::Triplet<float, int> t10(row, i10, 1.0f);
            Eigen::Triplet<float, int> t11(row, i11, -4.0f);
            Eigen::Triplet<float, int> t12(row, i12, 1.0f);

            Eigen::Triplet<float, int> t21(row, i21, 1.0f);

            Eigen::Triplet<float, int> triplets[] = {t01, t10, t11, t12, t21};

            coefficients_A.insert(coefficients_A.end(), triplets, triplets + 5);

            math::Vec3f l_d = simple_laplacian(i, dest);
            math::Vec3f l_s = simple_laplacian(i, src);

            coefficients_b[row] = (alpha * l_s + (1.0f - alpha) * l_d);
        }
    }

    SpMat A(nnz, nnz);
    A.setFromTriplets(coefficients_A.begin(), coefficients_A.end());

    Eigen::SparseLU<SpMat, Eigen::COLAMDOrdering<int> > solver;
    solver.compute(A);

    for (int channel = 0; channel < channels; ++channel) {
        Eigen::VectorXf b(nnz);
        for (std::size_t i = 0; i < coefficients_b.size(); ++i)
            b[i] = coefficients_b[i][channel];

        Eigen::VectorXf x(n);
        x = solver.solve(b);

        for (int i = 0; i < n; ++i) {
            int index = indices->at(i);
            if (index != -1) dest->at(i, channel) = x[index];
        }
    }
}
Ejemplo n.º 5
0
 void f2(LL au_id, LL id, Paper paper, vector<Paper> &paper_au_af, vector<Paper> &paper_ref_ed){
     thread t21(f21, paper, ref(paper_ref_ed));
     thread t22(f22, paper, ref(paper_au_af));
     t21.join();
     t22.join();
 }