Ejemplo n.º 1
0
long __Call_cth( CDSR_VMEval& /*vm*/, MMD_Address& addr, UniWord *arg )
{
#if _DEBUG
	if( addr.param2 < 0 )
		throw _T("__Call_(fun) : internal error, out of range");
#endif
	if( addr.param2 == 0 )	// DSRDATA_TYPE_REAL
		*(arg - 1) = CDSRReal( cth( (arg - 1)->getReal() ) );
	else					// DSRDATA_TYPE_COMPLEX
		*(arg - 1) = CDSRComplex( cth( (arg - 1)->getComplex() ) );
	return 1 - addr.param3;
}
bool TrigonometricFunction::unaryCth(ExecutionContext *context, QString *err)
{
    switch (context->obligArg().type()) {
    case PretexVariant::Int:
        context->setReturnValue(cth(context->obligArg().toInt()));
        break;
    case PretexVariant::Real:
        context->setReturnValue(cth(context->obligArg().toReal()));
        break;
    case PretexVariant::String:
    default:
        return bRet(err, tr("Invalid argument type", "error"), false);
    }
    return bRet(err, QString(), true);
}
Ejemplo n.º 3
0
	void testIsEncoded()
	{
		vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));

		VASSERT_TRUE("encoded", cth.isEncoded());
		VASSERT_EQ("encoding", "base64", cth.getEncoding().generate());
	}
Ejemplo n.º 4
0
	void testGetLength()
	{
		vmime::fileContentHandler cth(testFile);

		VASSERT_FALSE("empty", cth.isEmpty());
		VASSERT_EQ("length", testDataEncoded.length(), cth.getLength());
	}
Ejemplo n.º 5
0
	void testGetLength_Encoded()
	{
		vmime::string data("foo=12=34=56bar");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable"));

		// Reported length should be the length of encoded data
		VASSERT_EQ("length", 15, cth.getLength());
	}
Ejemplo n.º 6
0
	void testGetLength()
	{
		vmime::string data("Test Data");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length());

		VASSERT_FALSE("empty", cth.isEmpty());
		VASSERT_EQ("length", 9, cth.getLength());
	}
Ejemplo n.º 7
0
	void testExtract()
	{
		vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.extract(osa);

		// Data should be decoded from B64
		VASSERT_EQ("extract", testDataDecoded, oss.str());
	}
Ejemplo n.º 8
0
	void testGenerate()
	{
		vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.generate(osa, vmime::encoding("quoted-printable"));

		// Data should be reencoded from B64 to QP
		VASSERT_EQ("generate",
			"ABCDEFGHIJKLMNOPQRSTUVWXYZ =124Vx=90 abcdefghijklmnopqrstuvwxyz0123456789", oss.str());
	}
Ejemplo n.º 9
0
	void testExtract()
	{
		vmime::string data("Test Data");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length());

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.extract(osa);

		VASSERT_EQ("extract", "Test Data", oss.str());
	}
Ejemplo n.º 10
0
	void testGenerate_Encoded()
	{
		vmime::string data("foo=12=34=56bar");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable"));

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.generate(osa, vmime::encoding("base64"));

		// Data should be reencoded from QP to B64
		VASSERT_EQ("generate", "Zm9vEjRWYmFy", oss.str());
	}
Ejemplo n.º 11
0
	void testGenerate()
	{
		vmime::string data("foo\x12\x34\x56 bar");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length());

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.generate(osa, vmime::encoding("base64"));

		// Data should be encoded to B64
		VASSERT_EQ("generate", "Zm9vEjRWIGJhcg==", oss.str());
	}
Ejemplo n.º 12
0
	void testExtractRaw_Encoded()
	{
		vmime::string data
			("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("base64"));

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.extractRaw(osa);

		// Data should not be decoded
		VASSERT_EQ("extractRaw",
			"QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=", oss.str());
	}
Ejemplo n.º 13
0
	void testExtract_Encoded()
	{
		vmime::string data
			("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("base64"));

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.extract(osa);

		// Data should be decoded from B64
		VASSERT_EQ("extract",
			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", oss.str());
	}
Ejemplo n.º 14
0
	void testIsEncoded()
	{
		vmime::string data("Test Data");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length());

		VASSERT_FALSE("encoded", cth.isEncoded());
		VASSERT_EQ("encoding", vmime::contentHandler::NO_ENCODING, cth.getEncoding());


		vmime::string data2("Zm9vEjRWYmFy=");
		vmime::shared_ptr <vmime::utility::inputStream> stream2 =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data2);

		vmime::streamContentHandler cth2(stream2, data2.length(), vmime::encoding("base64"));

		VASSERT_TRUE("encoded", cth2.isEncoded());
		VASSERT_EQ("encoding", "base64", cth2.getEncoding().generate());
	}
Ejemplo n.º 15
0
 ///Randomly rotate sgrid_m
 void NonLocalECPComponent::randomize_grid(ParticleSet::ParticlePos_t& sphere, bool randomize)
 {
   if(randomize) {
     //const RealType twopi(6.28318530718);
     //RealType phi(twopi*Random()),psi(twopi*Random()),cth(Random()-0.5),
     RealType phi(TWOPI*((*myRNG)())), psi(TWOPI*((*myRNG)())), cth(((*myRNG)())-0.5);
     RealType sph(std::sin(phi)),cph(std::cos(phi)),
     sth(std::sqrt(1.0-cth*cth)),sps(std::sin(psi)),
     cps(std::cos(psi));
     TensorType rmat( cph*cth*cps-sph*sps, sph*cth*cps+cph*sps,-sth*cps,
         -cph*cth*sps-sph*cps,-sph*cth*sps+cph*cps, sth*sps,
         cph*sth,             sph*sth,             cth     );
     SpherGridType::iterator it(sgridxyz_m.begin());
     SpherGridType::iterator it_end(sgridxyz_m.end());
     SpherGridType::iterator jt(rrotsgrid_m.begin());
     int ic=0;
     while(it != it_end) {*jt = dot(rmat,*it); ++it; ++jt;}
     //copy the radomized grid to sphere
     std::copy(rrotsgrid_m.begin(), rrotsgrid_m.end(), sphere.begin());
   } else {
     //copy sphere to the radomized grid
     std::copy(sphere.begin(), sphere.end(), rrotsgrid_m.begin());
   }
 }