Exemple #1
0
  template <typename F> F Cgnr<F>::iteration (csize_t nr, UNUSED std::ostream& log, UNUSED bool profilingRun, Core::ProfilingDataPtr prof) {
    std::vector<ctype>& rvec = this->rvec ();
    std::vector<ctype>& Avecbuffer = this->Avecbuffer ();
    std::vector<ctype>& xvec = this->xvec ();
    std::vector<ctype>& pvec = this->tmpVec1 ();

    if (nr == 0) {
      {
        Core::ProfileHandle _p1 (prof, "matvec1");
        this->matVec ().apply (rvec, pvec, true, prof);
      }
      vars.ro_new = LinAlg::norm (pvec);
    } else {
      {
        Core::ProfileHandle _p1 (prof, "matvec1");
        this->matVec ().apply (rvec, Avecbuffer, true, prof);
      }
      vars.ro_new = LinAlg::norm (Avecbuffer);
      vars.beta = vars.ro_new / vars.ro_old;
      LinAlg::linComb (pvec, vars.beta, Avecbuffer, pvec);
    }
    {
      Core::ProfileHandle _p1 (prof, "matvec2");
      this->matVec ().apply (pvec, Avecbuffer, false, prof);
    }
    ctype alpha = vars.ro_new / LinAlg::norm (Avecbuffer);
    LinAlg::linComb (pvec, alpha, xvec, xvec);
    LinAlg::linComb (Avecbuffer, -alpha, rvec, rvec);
    vars.ro_old = vars.ro_new;
    return LinAlg::norm (rvec);
  }
  template <class F> void IterativeSolverBase<F>::profilingRun (std::ostream& out, std::ostream& log, Core::ProfilingDataPtr prof) {
    this->epsB = 1;
    this->prev_err = 1;
    this->count = 10;
    this->counter = 0;

    {
      Core::ProfileHandle _p1 (prof, "itsolv1");
      iteration (count - 1, log, true, prof);
    }

    const int nr = 5;
    const int mid = nr / 2;
    boost::tuple<uint64_t, int> res[nr];
    {
      Core::ProfileHandle _p1 (prof, "itsolv2");
      Core::TimeSpan now = Core::getCurrentTime ();
      for (int i = 0; i < nr; i++) {
        iteration (count + i, log, true, prof);
        res[i] = boost::make_tuple ((Core::getCurrentTime () - now).getMicroseconds (), i);
        now = Core::getCurrentTime ();
      }
    }

    std::sort (res, res + nr);
    for (int i = 0; i < nr; i++)
      out << "[" << res[i].get<1> () << "]" << Core::TimeSpan (res[i].get<0> ()).toString () << " ";
    uint64_t diff = std::max (res[mid].get<0> () - res[0].get<0> (), res[nr - 1].get<0> () - res[mid].get<0> ());
    out << std::endl;
    out << std::endl;
    out << Core::TimeSpan (res[mid].get<0> ()).toString () << " +- " << Core::TimeSpan (diff).toString () << std::endl;
  }
Exemple #3
0
/*
 * V(1, 0.5, 0.7)
 * Ray P = p + tV
 * Plane  P*N + d = 0
 * t = -(p*N + d)/(V*N);
 * Should T >= 0 ? Ray just in one direction.
 * Return:
 *  0 if ray does not intersect.
 *  1 if ray intersect on the borders.
 *  2 if ray intersect.
 */
int Polygon::ray_intersect(const Point &p, const Point &v)
{
    double pnormal = p.x*normal.a + p.y*normal.b + p.z*normal.c;
    // Right angle
    if (!(normal.a*v.x + normal.b*v.y + normal.c*v.z)) {
        return 0;
    }

    double t = -(pnormal + normal.d) / (normal.a*v.x + normal.b*v.y + normal.c*v.z);

    if (t < 0)
        return 0;

    Point _p1(p.x + t*v.x, p.y + t*v.y, p.z + t*v.z);

    if (is_point_in_polygon(_p1)) {
        if (is_in_border(_p1)) {
            return 1;
        }
        return 2;
    }
    return 0;
}
Exemple #4
0
  template <typename F> F GpuQmrCs<F>::iteration (csize_t nr, UNUSED std::ostream& log, UNUSED bool profilingRun, Core::ProfilingDataPtr prof) {
    const std::vector<cl::CommandQueue>& queues = this->queues ();
    const cl::CommandQueue& queue = queues[0];
    INFO ("");

    DipVector<ftype>& rvec = this->rvec ();
    DipVector<ftype>& Avecbuffer = this->Avecbuffer ();
    DipVector<ftype>& xvec = this->xvec ();

    DipVector<ftype>& v = this->tmpVec1 ();
    DipVector<ftype>& vtilda = this->tmpVec2 ();
    DipVector<ftype>& p_old = this->tmpVec3 ();
    DipVector<ftype>& p_new = this->tmpVec4 ();

    ftype rtmp1 = norm ((vars + &Vars::beta).read (queue)) * this->residScale;
    if (nr == 0)
      ASSERT (!(rtmp1 > 1e+38f) || profilingRun); // Allow very low beta values (seen e.g. when using --load-start-dip-pol)
    else
      ASSERT (!(rtmp1 < 1e-10f || rtmp1 > 1e+38f) || profilingRun);

    INFO (rtmp1);

    {
      Core::ProfileHandle _p1 (prof, "matvec");
      this->matVec ().apply (queues, v, Avecbuffer, false, prof);
    }

    ctype alpha = vecProdConj (queues, v, Avecbuffer);

    (vars + &Vars::mAlpha).write (queue, -alpha);

    INFO (vtilda);

    if (nr == 0)
      this->linComb.linComb (queues, v, vars + &Vars::mAlpha, Avecbuffer, vtilda);
    else {
      this->linComb.linComb (queues, vtilda, vars + &Vars::mBeta, v, vars + &Vars::mAlpha, Avecbuffer, vtilda);
    }

    INFO (vars + &Vars::mAlpha); INFO (vars + &Vars::mBeta); INFO (v); INFO (Avecbuffer); INFO (vtilda);

    ctype ctmp3 = vecProdConj (queues, vtilda, vtilda);
    this->linComb.reduce (queues, vtilda, vars + &Vars::vtildaNorm);

    ctype ctmp1 = (vars + &Vars::omega_old).read (queue) * (vars + &Vars::beta).read (queue);
    ctype ctmp2 = (vars + &Vars::omega_new).read (queue) * alpha;

    ctype theta = conj ((vars + &Vars::s_old).read (queue)) * ctmp1;
    ctype eta = (vars + &Vars::c_old).read (queue) * (vars + &Vars::c_new).read (queue) * ctmp1 + conj ((vars + &Vars::s_new).read (queue)) * ctmp2;
    ctype zetatilda = (vars + &Vars::c_new).read (queue) * ctmp2 - (vars + &Vars::c_old).read (queue) * (vars + &Vars::s_new).read (queue) * ctmp1;
    (vars + &Vars::beta).write (queue, std::sqrt (ctmp3));
    (vars + &Vars::mBeta).write (queue, -(vars + &Vars::beta).read (queue));
    (vars + &Vars::omega_old).write (queue, (vars + &Vars::omega_new).read (queue));
    (vars + &Vars::omega_new).write (queue, std::sqrt ((vars + &Vars::vtildaNorm).read (queue)) / abs ((vars + &Vars::beta).read (queue)));
    ftype zetaabs = std::sqrt (norm (zetatilda) + (vars + &Vars::vtildaNorm).read (queue));

    ftype rtmp3 = std::sqrt (norm (zetatilda));
    ctype zeta;
    if (rtmp3 < 1e-40f)
      zeta = zetaabs;
    else
      zeta = zetaabs / rtmp3 * zetatilda;
    (vars + &Vars::c_old).write (queue, (vars + &Vars::c_new).read (queue));
    (vars + &Vars::c_new).write (queue, rtmp3 / zetaabs);
    (vars + &Vars::s_old).write (queue, (vars + &Vars::s_new).read (queue));
    (vars + &Vars::s_new).write (queue, (vars + &Vars::omega_new).read (queue) * ((vars + &Vars::beta).read (queue) / zeta));

    (vars + &Vars::tau).write (queue, (vars + &Vars::c_new).read (queue) * (vars + &Vars::tautilda).read (queue));
    (vars + &Vars::tautilda).write (queue, -(vars + &Vars::s_new).read (queue) * (vars + &Vars::tautilda).read (queue));

    (vars + &Vars::zetaInv).write (queue, Const::one / zeta);
    (vars + &Vars::mEtaZeta).write (queue, -eta / zeta);
    (vars + &Vars::mThetaZeta).write (queue, -theta / zeta);
    (vars + &Vars::betaInv).write (queue, Const::one / (vars + &Vars::beta).read (queue));
    (vars + &Vars::normSNew).write (queue, norm ((vars + &Vars::s_new).read (queue)));
    (vars + &Vars::cNewOmegaNewTautilda).write (queue, ((vars + &Vars::c_new).read (queue) / (vars + &Vars::omega_new).read (queue)) * (vars + &Vars::tautilda).read (queue));

    INFO (vars + &Vars::zetaInv); INFO (vars + &Vars::mEtaZeta); INFO (vars + &Vars::mThetaZeta); INFO (vars + &Vars::betaInv); INFO (vars + &Vars::normSNew); INFO (vars + &Vars::cNewOmegaNewTautilda);

    if (nr == 0) {
      this->linComb.linComb (queues, v, vars + &Vars::zetaInv, p_new);
    } else {
      if (nr == 1)
        this->linComb.linComb (queues, p_new, vars + &Vars::mEtaZeta, v, vars + &Vars::zetaInv, p_old);
      else
        this->linComb.linComb (queues, p_old, vars + &Vars::mThetaZeta, p_new, vars + &Vars::mEtaZeta, v, vars + &Vars::zetaInv, p_old);
      swap (p_old, p_new);
    }

    this->linComb.linComb (queues, p_new, vars + &Vars::tau, xvec, xvec);
    this->linComb.linComb (queues, vtilda, vars + &Vars::betaInv, vtilda);
    swap (v, vtilda);
    this->linComb.linComb (queues, rvec, vars + &Vars::normSNew, v, vars + &Vars::cNewOmegaNewTautilda, rvec);
    INFO (p_new); INFO (p_old); INFO (xvec); INFO (vtilda); INFO (v); INFO (rvec);
    this->linComb.reduce (queues, rvec, vars + &Vars::rvecNorm);
    return (vars + &Vars::rvecNorm).read (queue);
  }
Exemple #5
0
void drive_operation()
{

    // Uint64 tests

    CQLValue a1(Uint64(10));
    CQLValue a2(Uint64(15));
    CQLValue a3(Uint64(25));
    CQLValue a4(Uint64(30));
    CQLValue a5(Uint64(150));

    PEGASUS_TEST_ASSERT(a1 != a2);
    PEGASUS_TEST_ASSERT(a5 == a5);
    PEGASUS_TEST_ASSERT(a1 < a2);
    PEGASUS_TEST_ASSERT(a2 >= a1);
    PEGASUS_TEST_ASSERT(a1 <= a2);
    PEGASUS_TEST_ASSERT(a2 > a1);

    // Sint64 tests

    CQLValue b1(Sint64(10));
    CQLValue b2(Sint64(15));
    CQLValue b3(Sint64(25));
    CQLValue b4(Sint64(30));
    CQLValue b5(Sint64(150));

    PEGASUS_TEST_ASSERT(b1 != b2);
    PEGASUS_TEST_ASSERT(b5 == b5);
    PEGASUS_TEST_ASSERT(b1 < b2);
    PEGASUS_TEST_ASSERT(b2 >= b1);
    PEGASUS_TEST_ASSERT(b1 <= b2);
    PEGASUS_TEST_ASSERT(b2 > b1);

    // Real64 tests

    CQLValue c1(Real64(10.00));
    CQLValue c2(Real64(15.00));
    CQLValue c3(Real64(25.00));
    CQLValue c4(Real64(30.00));
    CQLValue c5(Real64(150.00));

    PEGASUS_TEST_ASSERT(c1 != c2);
    PEGASUS_TEST_ASSERT(c5 == c5);
    PEGASUS_TEST_ASSERT(c1 < c2);
    PEGASUS_TEST_ASSERT(c2 >= c1);
    PEGASUS_TEST_ASSERT(c1 <= c2);
    PEGASUS_TEST_ASSERT(c2 > c1);

    // Misc
    PEGASUS_TEST_ASSERT(a1 == b1);
    PEGASUS_TEST_ASSERT(a1 == c1);
    PEGASUS_TEST_ASSERT(b1 == a1);
    PEGASUS_TEST_ASSERT(b1 == c1);
    PEGASUS_TEST_ASSERT(c1 == a1);
    PEGASUS_TEST_ASSERT(c1 == b1);

    PEGASUS_TEST_ASSERT(a2 != b1);
    PEGASUS_TEST_ASSERT(a2 != c1);
    PEGASUS_TEST_ASSERT(b2 != a1);
    PEGASUS_TEST_ASSERT(b2 != c1);
    PEGASUS_TEST_ASSERT(c2 != a1);
    PEGASUS_TEST_ASSERT(c2 != b1);

    PEGASUS_TEST_ASSERT(a2 >= b1);
    PEGASUS_TEST_ASSERT(a2 >= c1);
    PEGASUS_TEST_ASSERT(b2 >= a1);
    PEGASUS_TEST_ASSERT(b2 >= c1);
    PEGASUS_TEST_ASSERT(c2 >= a1);
    PEGASUS_TEST_ASSERT(c2 >= b1);

    PEGASUS_TEST_ASSERT(a2 <= b3);
    PEGASUS_TEST_ASSERT(a2 <= c3);
    PEGASUS_TEST_ASSERT(b2 <= a3);
    PEGASUS_TEST_ASSERT(b2 <= c3);
    PEGASUS_TEST_ASSERT(c2 <= a3);
    PEGASUS_TEST_ASSERT(c2 <= b3);

    PEGASUS_TEST_ASSERT(a2 > b1);
    PEGASUS_TEST_ASSERT(a2 > c1);
    PEGASUS_TEST_ASSERT(b2 > a1);
    PEGASUS_TEST_ASSERT(b2 > c1);
    PEGASUS_TEST_ASSERT(c2 > a1);
    PEGASUS_TEST_ASSERT(c2 > b1);

    PEGASUS_TEST_ASSERT(a2 < b3);
    PEGASUS_TEST_ASSERT(a2 < c3);
    PEGASUS_TEST_ASSERT(b2 < a3);
    PEGASUS_TEST_ASSERT(b2 < c3);
    PEGASUS_TEST_ASSERT(c2 < a3);
    PEGASUS_TEST_ASSERT(c2 < b3);

    //Overflow testing
    CQLValue real1(Real64(0.00000001));
    CQLValue sint1(Sint64(-1));
    CQLValue uint1(Sint64(1));
    CQLValue uint2(Uint64(0));

    PEGASUS_TEST_ASSERT(uint1 > sint1);
    PEGASUS_TEST_ASSERT(real1 > sint1);
    PEGASUS_TEST_ASSERT(uint2 > sint1);
    PEGASUS_TEST_ASSERT(real1 > uint2);

    CQLValue real2(Real64(25.00000000000001));
    CQLValue real3(Real64(24.99999999999999));
    CQLValue sint2(Sint64(25));
    CQLValue uint3(Uint64(25));

    PEGASUS_TEST_ASSERT(real2 > real3);
    PEGASUS_TEST_ASSERT(real2 > sint2);
    PEGASUS_TEST_ASSERT(real2 > uint3);
    PEGASUS_TEST_ASSERT(real3 < sint2);
    PEGASUS_TEST_ASSERT(real3 < uint3);

    // String tests

    CQLValue d1(String("HELLO"));
    CQLValue d2(String("HEL"));
    CQLValue d3(String("LO"));
    CQLValue d4(String("AHELLO"));
    CQLValue d5(String("ZHELLO"));

    PEGASUS_TEST_ASSERT(d1 == d2 + d3);
    PEGASUS_TEST_ASSERT(d1 != d2 + d4);

    PEGASUS_TEST_ASSERT(d1 <= d5);
    PEGASUS_TEST_ASSERT(d1 <  d5);

    PEGASUS_TEST_ASSERT(d1 >= d4);
    PEGASUS_TEST_ASSERT(d1 >  d4);

    String str1("0x10");
    String str2("10");
    String str3("10B");
    String str4("10.10");


    CQLValue e1( str1, CQLValue::Hex);
    CQLValue e2( str2, CQLValue::Decimal);
    CQLValue e3( str3, CQLValue::Binary);
    CQLValue e4( str4, CQLValue::Real);

    CQLValue e5(Uint64(16));
    CQLValue e6(Uint64(10));
    CQLValue e7(Uint64(2));
    CQLValue e8(Real64(10.10));

    PEGASUS_TEST_ASSERT(e1 == e5);
    PEGASUS_TEST_ASSERT(e2 == e6);
    PEGASUS_TEST_ASSERT(e3 == e7);
    PEGASUS_TEST_ASSERT(e4 == e8);

    Array<Uint64> array1;

    array1.append(1);
    array1.append(2);
    array1.append(3);
    array1.append(4);
    array1.append(5);
    array1.append(6);
    array1.append(7);
    array1.append(8);
    array1.append(9);
    array1.append(10);

    Array<Sint64> array2;

    array2.append(1);
    array2.append(2);
    array2.append(3);
    array2.append(4);
    array2.append(5);
    array2.append(6);
    array2.append(7);
    array2.append(8);
    array2.append(9);
    array2.append(10);
    array2.append(3);

    Array<Real64> array3;

    array3.append(1.00);
    array3.append(2.00);
    array3.append(3.00);
    array3.append(9.00);
    array3.append(10.00);
    array3.append(3.00);
    array3.append(4.00);
    array3.append(5.00);
    array3.append(6.00);
    array3.append(7.00);
    array3.append(8.00);

    Array<Uint64> array4;

    array4.append(1);
    array4.append(23);
    array4.append(3);
    array4.append(4);
    array4.append(5);
    array4.append(6);
    array4.append(7);
    array4.append(88);
    array4.append(9);
    array4.append(10);

    Array<Sint64> array5;

    array5.append(-1);
    array5.append(2);
    array5.append(3);
    array5.append(4);
    array5.append(5);
    array5.append(-6);
    array5.append(7);
    array5.append(8);
    array5.append(9);
    array5.append(10);
    array5.append(-3);

    Array<Real64> array6;

    array6.append(1.23);
    array6.append(2.00);
    array6.append(3.00);
    array6.append(9.00);
    array6.append(10.00);
    array6.append(3.00);
    array6.append(4.14);
    array6.append(5.00);
    array6.append(6.00);
    array6.append(7.00);
    array6.append(8.00);

    CIMValue cv1(array1);
    CIMValue cv2(array2);
    CIMValue cv3(array3);
    CIMValue cv4(array4);
    CIMValue cv5(array5);
    CIMValue cv6(array6);

    CQLValue vr1(cv1);
    CQLValue vr2(cv1);
    CQLValue vr3(cv2);
    CQLValue vr4(cv3);
    CQLValue vr5(cv4);
    CQLValue vr6(cv5);
    CQLValue vr7(cv6);

    PEGASUS_TEST_ASSERT(vr1 == vr2);
    PEGASUS_TEST_ASSERT(vr1 == vr3);
    PEGASUS_TEST_ASSERT(vr1 == vr4);
    PEGASUS_TEST_ASSERT(vr4 == vr3);

    PEGASUS_TEST_ASSERT(vr1 != vr5);
    PEGASUS_TEST_ASSERT(vr3 != vr6);
    PEGASUS_TEST_ASSERT(vr4 != vr7);

    const CIMName _cimName(String("CIM_OperatingSystem"));

    CIMInstance _i1(_cimName);
    CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
    CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
    CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
    CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                    CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

    _i1.addProperty(_p1);
    _i1.addProperty(_p2);
    _i1.addProperty(_p3);
    _i1.addProperty(_p4);

    CIMInstance _i2(_cimName);
    CIMProperty _p5(CIMName("Description"),
                    CIMValue(String("Dave Rules Everything")));
    CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2)));
    CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
    CIMProperty _p8(CIMName("TimeOfLastStateChange"),
                    CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

    _i2.addProperty(_p5);
    _i2.addProperty(_p6);
    _i2.addProperty(_p7);
    _i2.addProperty(_p8);

    CQLValue cql1(_i1);
    CQLValue cql2(_i1);
    CQLValue cql3(_i2);
    CQLValue cql4(_i2);

    //PEGASUS_TEST_ASSERT(cql1 == cql1);

    return;
}
Exemple #6
0
void drive_resolve_specialChars()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11)));
        CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded")));
        Array<Uint16> array16;
        array16.append(Uint16(0));
        array16.append(Uint16(1));
        array16.append(Uint16(2));
        array16.append(Uint16(3));
        CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);

        CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400"));
        CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX"));
        CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded"));

        CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS"));

        CQLChainedIdentifier ci6(
            String("CIM_OperatingSystem.CIM_OperatingSystem::"
                   "OperationalStatus[2]"));
        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);

        CQLValue a5(ci5);
        CQLValue a6(ci6);


        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);

        a6.resolve(_i1, _query);

        try
        {
            a3.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        try
        {
            a5.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11)));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36)));


        PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2)));


    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}
Exemple #7
0
void drive_resolve_primitive()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
        CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
        CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
        CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                        CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);
        _i1.addProperty(_p4);

        CQLChainedIdentifier ci1(
            String("CIM_OperatingSystem.CIM_OperatingSystem::Description"));
        CQLChainedIdentifier
        ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState"));
        CQLChainedIdentifier ci3(
            String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone"));
        CQLChainedIdentifier ci4(
            String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci5(String(
                "CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci7(String("CIM_OperatingSystem"));

        CQLChainedIdentifier
        ci9(String(
                "CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName"));

        CQLChainedIdentifier
        ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba"));

        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);
        CQLValue a4(ci4);
        CQLValue a5(ci5);

        CQLValue a7(ci7);

        CQLValue a9(ci9);
        CQLValue a10(ci10);

        CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem")));

        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);
        a3.resolve(_i1, _query);
        a4.resolve(_i1, _query);
        a5.resolve(_i1, _query);
        a7.resolve(_i1, _query);
        a10.resolve(_i1, _query1);

        a9.resolve(_i1, _query);

        PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules")));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2)));
        PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600)));
        PEGASUS_TEST_ASSERT(a4 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        PEGASUS_TEST_ASSERT(a5 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        //PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1));
        PEGASUS_TEST_ASSERT(a9.isNull());
        PEGASUS_TEST_ASSERT(a10.isNull());

    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}
bool urdf_traverser::helpers::getCommonParentPath(const std::string& p1, const std::string& p2, std::string& result)
{
    if (p1.empty() || p2.empty())
    {
        ROS_ERROR("Both p1 and p2 have to be set in getCommonParentPath()");
        return false;
    }
    boost::filesystem::path __p1(p1);
    boost::filesystem::path __p2(p2);
    bool correctAbsolute = __p1.is_relative() || __p2.is_relative();

    boost::filesystem::path _p1(boost::filesystem::absolute(__p1));
    boost::filesystem::path _p2(boost::filesystem::absolute(__p2));
    boost::filesystem::path buildPath;

    boost::filesystem::path::iterator it1(_p1.begin());
    boost::filesystem::path::iterator it1_end(_p1.end());
    boost::filesystem::path::iterator it2(_p2.begin());
    boost::filesystem::path::iterator it2_end(_p2.end());

    int p1Len = numDirectories(p1);
    int p2Len = numDirectories(p2);
    // ROS_INFO_STREAM("p1: "<<p1<<", p2: "<<p2);
    // ROS_INFO_STREAM("p1: "<<p1Len<<", p2: "<<p2Len);
    if (p2Len > p1Len)
    {
        //swap around paths
        boost::filesystem::path::iterator tmp(it2);
        it2 = it1;
        it1 = tmp;
        tmp = it2_end;
        it2_end = it1_end;
        it1_end = tmp;
    }

    --it1_end;  // make sure the iteration goes only until the previous-last
    // entry, because the last entry is either '.' or a filename
    for (; it1 != it1_end; ++it1, ++it2)
    {
        // ROS_INFO_STREAM("Comp "<<it1->string()<<", 2 "<<it2->string());
        if ((it2 == it2_end)
                || (*it1 != *it2))
        {
            break;
        }

        // append the directory
        buildPath /= *it1;

        // std::cout << buildPath.string() << std::endl;
    }
    if (!buildPath.empty())
    {
        result = buildPath.string();
        // make sure notation ends with separator.
        // Last element *will* be directory as no files
        // have been added in the loop.
        enforceDirectory(result, false);
        // If the current directory was used to build an absolute path, remove it again.
        if (correctAbsolute)
        {
            std::string currDir = boost::filesystem::current_path().string();
            urdf_traverser::helpers::enforceDirectory(currDir, false);
            if (!urdf_traverser::helpers::getSubdirPath(currDir, result, result))
            {
                ROS_ERROR_STREAM("Could not remove temporarily created current directory for absolute path");
                return false;
            }
        }
        return true;
    }
    return false;
}
  template <class F> boost::shared_ptr<std::vector<std::complex<F> > > IterativeSolverBase<F>::getPolVec (const std::vector<ctype>& einc, ftype eps, std::ostream& log, const std::vector<ctype>& start, Core::ProfilingDataPtr prof) {
    this->inprodR_ = initGeneral (einc, log, start, prof);
    log << "inprodR = " << this->inprodR_ << std::endl;

    this->epsB = eps * eps / this->residScale;
    this->prev_err = std::sqrt (this->residScale * this->inprodR_);
    this->count = 0;
    this->counter = 0;

    this->inprodRInit = this->inprodR_;
    this->needNewline = false;
    this->initTime = Core::getCurrentTime ();

    {
      Core::ProfileHandle _p1 (prof, "itsolv");
      init (log, prof);
      while (inprodR_ >= epsB /* && count + 1 <= maxIter && counter <= maxResIncrease */) {
        if (this->count >= maxIter) {
          ABORT_MSG ("Too many iterations");
        } else if (this->counter > this->maxResIncrease) {
          ABORT_MSG ("Too many iterations w/o increase");
        }
        ftype inprodRplus1 = iteration (count, log, false, prof);
        count++;
        { // LoopUpdate
          if (inprodRplus1 <= inprodR_) {
            inprodR_ = inprodRplus1;
            counter = 0;
          } else {
            counter++;
          }
          ftype err = std::sqrt (residScale * inprodRplus1);
          ftype progr = 1 - err / prev_err;
          std::stringstream progStr;
          ftype prog = (std::log (this->inprodR_) - std::log (this->inprodRInit)) / (std::log (epsB) - std::log (this->inprodRInit));
          Core::TimeSpan now = Core::getCurrentTime ();
          Core::TimeSpan remain = (now - this->initTime) * static_cast<double> ((1 - prog) / prog);
          progStr << "RE_" << std::setfill ('0') << std::setw (5) << count << " = " << std::scientific << std::setfill (' ') << std::setw (12) << err << "  ";
          if (counter == 0)
            progStr << "+ ";
          else if (progr > 0)
            progStr << "-+";
          else
            progStr << "- ";
          progStr << "  [" << std::fixed << std::setprecision (2) << std::setw (6) << prog * 100 << "%]  [" << std::setfill (' ') << std::setw (12) << remain.toString () << "]";
          if (this->needNewline)
            Core::OStream::getStderr () << "\n";
          Core::OStream::getStderr () << progStr.str ();
          /*
            this->needNewline = count <= 1
            || (count < 100 && count % 10 == 0)
            || (count <= 1000 && count % 100 == 0);
          */
          this->needNewline = false;
          Core::OStream::getStderr () << "\r" << std::flush;
          log << progStr.str () << std::endl;
          prev_err = err;
        }
      }
      Core::OStream::getStderr () << std::endl;
    }

    return getResult (log, prof);
  }