bool TestExtOpenssl::test_openssl_csr_sign() {
  Array dn(ArrayInit(7, false).
           set(0, "countryName", "XX").
           set(1, "stateOrProvinceName", "State").
           set(2, "localityName", "SomewhereCity").
           set(3, "organizationName", "MySelf").
           set(4, "organizationalUnitName", "Whatever").
           set(5, "commonName", "mySelf").
           set(6, "emailAddress", "*****@*****.**").
           create());
  String privkeypass = "******";
  int numberofdays = 365;

  Variant privkey = f_openssl_pkey_new();
  VERIFY(!privkey.isNull());
  Variant csr = f_openssl_csr_new(dn, privkey);
  VERIFY(!csr.isNull());
  Variant scert = f_openssl_csr_sign(csr, null, privkey, numberofdays);
  Variant publickey, privatekey, csrStr;
  f_openssl_x509_export(scert, ref(publickey));
  f_openssl_pkey_export(privkey, ref(privatekey), privkeypass);
  f_openssl_csr_export(csr, ref(csrStr));

  //f_var_dump(privatekey); f_var_dump(publickey); f_var_dump(csrStr);
  VERIFY(privatekey.toString().size() > 500);
  VERIFY(publickey.toString().size() > 800);
  VERIFY(csrStr.toString().size() > 500);

  return Count(true);
}
Beispiel #2
0
 dcomplex Exp_DAtR<2>(dcomplex r, dcomplex c, int n, dcomplex z) {
   dcomplex dn(n);
   dcomplex y = c * pow(r, n+1) * exp(-z * r * r) * (-2.0*z);
   if (n != 0) 
     y += c * dn * pow(r, n-1) * exp(-z * r) * (-z);
   return y;
 }
Beispiel #3
0
void GagEngine::ExtractCdf(const Common::String &a_fn)
{
	CdfArchive archive(a_fn, true);

	uint pos = a_fn.size();
	for(uint i = 0; i < a_fn.size(); ++i)
	{
		if(a_fn[i] == '.')
			pos = i;
	}

	//TODO: figure out how to create directory
	Common::String dn(ConfMan.get("path") + '/' + Common::String(a_fn.c_str(), pos) + '/');

	Common::ArchiveMemberList member_list;
	archive.listMembers(member_list);
	for(Common::ArchiveMemberList::iterator it = member_list.begin(); it != member_list.end(); ++it)
	{
		Common::ScopedPtr<Common::SeekableReadStream> stream((*it)->createReadStream());

		if(stream)
		{
			uint8 *buffer = new uint8[stream->size()];
			stream->read(buffer, stream->size());

			Common::DumpFile file;
			if(file.open(dn + (*it)->getName()))
				file.write(buffer, stream->size());

			delete [] buffer;
		}
	}
}
Beispiel #4
0
int main()
{
    int i,j;
    doubleMatrix identity(DIM,DIM,0.0);
    doubleMatrix dn(DIM,DIM,0.0);
    doubleMatrix inverse(DIM,DIM,0.0);
    doubleMatrix m1(DIM,DIM,0.0);
    doubleMatrix m2(DIM,DIM,0.0);

    /*
    //  The use of rand(), below, depends on the primary value of 
    //  thread_data->__randnext being initialized to 1. This caused
    //  test failures on Windows NT with OW 1.2 as the thread data
    //  was not being initialized with __InitThreadData()
    */

    for(i=0;i<DIM;++i) {
	for(j=0;j<DIM;++j) {
	    if( i == j ) {
		identity[i][j] = 1;
	    }
	    dn[i][j] = rand()*1.0/RAND_MAX;
	}
    }
    cout << "identity matrix" << endl;
    cout << identity << endl;
    cout << "random matrix" << endl;
    cout << dn << endl;
    cout << "random matrix's inverse" << endl;
    cout << dn.i() << endl;
    cout << "random matrix vertically joined with its inverse" << endl;
    cout << ( dn ^ dn.i() ) << endl;
    cout << "random matrix outer product with its inverse" << endl;
    cout << ( dn & dn.i() ) << endl;
    inverse = dn.i();
    // for some reason this class library has no matrix multiply so we
    // hand code a test of the inverse function
    for(int mrow=0;mrow<DIM;++mrow) {
	for(int mcol=0;mcol<DIM;++mcol) {
	    m1[mrow][mcol] = 0;
	    m2[mrow][mcol] = 0;
	    for(int i=0;i<DIM;++i) {
		m1[mrow][mcol] += inverse[mrow][i] * dn[i][mcol];
		m2[mrow][mcol] += dn[mrow][i] * inverse[i][mcol];
	    }
	    if( fabs(m1[mrow][mcol]) < 1e-14 ) {
		m1[mrow][mcol] = 0;
	    }
	    if( fabs(m2[mrow][mcol]) < 1e-14 ) {
		m2[mrow][mcol] = 0;
	    }
	}
    }
    cout << "random * inverse" << endl;
    cout << m1 << endl;
    cout << "inverse * random" << endl;
    cout << m2 << endl;
    exit( 0 );
}
void
Quad10_2D_SUPG :: computeGradPMatrix(FloatMatrix &answer, GaussPoint *gp)
{
    FloatMatrix dn(1, 2);
    pressureInterpolation.evaldNdx(dn, * gp->giveCoordinates(), FEIElementGeometryWrapper(this));

    answer.beTranspositionOf(dn);
}
Beispiel #6
0
auto fmap_impl(R(&fn)(ARG)) {
	auto lambda_fn =
		[](auto& dn) {
		auto arg_fn = [&dn](auto arg) { return dn(arg); };
		return arg_fn;
	};
	return lambda_fn(fn);
}
Beispiel #7
0
int expand_a_node(int node[N+1][N], int succ_buf[BF][N+1][N])
{
	int i, j, cnt, found, g_val, h_val;
	
	//globals are *start and *goal
	//find the blank
	found = 0;
	for(i = 0; (i < N) && !found; i++){
		for(j = 0; (j < N) && !found; j++){
			if(node[i][j] == 0){
				found = 1;
			}
		}
	}
	//loop runs for extra iteration so values must be decremented
	i--;
	j--;
	//putchar('\n');
	//printf("i:%d j:%d\n", i, j);

	//intializing succ_buff with the board before moves
	int x,y,z;
	for(x = 0; x < BF; x++)
	{
		for(y = 0; y < N+1; y++)
		{
			for(z = 0; z < N; z++)
			{
				succ_buf[x][y][z] = node[y][z];
			}
		}	
	}	

	cnt = 0;
	//check if legal then perform down move
	if(i < (N - 1))
	{
		dn(i, j, 0, succ_buf);
		cnt++;
	}
	//check if legal then perform right move
	if(j < (N - 1))
	{
		rt(i, j, 1, succ_buf);
	}
	//check if legal then perform up move
	if(i > 0)
	{
		up(i, j, 2, succ_buf);
	}
	//check if legal then perform left move
	if(j > 0)
	{
		lt(i, j, 3, succ_buf);
	}

	return cnt;
}
Beispiel #8
0
osg::ref_ptr<osg::Node> Group::exporta(MDagPath &dp)
{
	osg::ref_ptr<osg::Group> osggroup;

	// Get the node of this path
	MObject node = dp.node();

	// 1. Create the adequate type of node
	if( node.hasFn(MFn::kEmitter) ) {
		// Emitters are subclasses of Transform
		// We build the transform and then add the emitter as a child
		osggroup = Transform::exporta(node);
		osggroup->addChild( PointEmitter::exporta(node).get() );
	}
	else if( node.hasFn(MFn::kTransform) ){
		osggroup = Transform::exporta(node);
	}
	else {
		// Generic group (kWorld)
		osggroup = new osg::Group();
	}

	// 2. Process and add children
	for(int i=0; i<dp.childCount(); i++){
		// Add child to the path and recursively call the exportation function
		MDagPath dpc(dp);
		dpc.push(dp.child(i));
		osg::ref_ptr<osg::Node> child = DAGNode::exporta(dpc);
		if(child.valid()){
			// ** Check ** If any children is a LightSource, deactivate culling 
			// for this group in order to apply the light even though it is not
			// directly visible
			if( dynamic_cast<osg::LightSource *>(child.get()) != NULL )
				osggroup->setCullingActive(false);
			osggroup->addChild(child.get());
		}
	}

	// 3. If there are no children, the node is ignored
	if( osggroup->getNumChildren() == 0 ){
		// Buuuuuuut, if there is an animation, it is saved to disk
		// because it can be a useful camera animation
		osg::AnimationPathCallback *cb = dynamic_cast< osg::AnimationPathCallback * >(osggroup->getUpdateCallback());
		if(cb){
			MFnDependencyNode dn(node);
			std::cout << "EXPORTING CAMERA ANIMATION: " << dn.name().asChar() << std::endl;
            CameraAnimation::save(cb->getAnimationPath(), Config::instance()->getSceneFilePath().getDirectory() + "/" + Config::instance()->getSceneFilePath().getFileBaseName() + "_" + std::string(dn.name().asChar()) + ".path" );
		}
		return NULL;
	}

    // Name the node (mesh)
	MFnDependencyNode dnodefn(node);
	osggroup->setName( dnodefn.name().asChar() );

	return (osg::Node *)osggroup.get();
}
void TabListeEleve::addColumn()
{
    Tree<Donnee> tree(bdd()->getArbre<Donnee>(1));
    SelectDonneeDialog dial(tree,this);
    dial.exec();
    Donnee dn(dial.result());
    if(bdd()->get(dn))
        ((ListeEleveModel *) m_model)->insertColumn(dn);
}
Beispiel #10
0
void TheaRenderer::defineLights()
{

	for( size_t objId = 0; objId < this->mtth_scene->lightList.size(); objId++)
	{
		mtth_MayaObject *obj = (mtth_MayaObject *)this->mtth_scene->lightList[objId];
		MMatrix m = obj->transformMatrices[0] * this->mtth_renderGlobals->globalConversionMatrix;

		MFnDependencyNode dn(obj->mobject);
		MColor lightColor;
		getColor("color", dn, lightColor); 
		float intensity = 1.0f;
		getFloat("intensity", dn, intensity);
		lightColor *= intensity;

		TheaSDK::Transform lightPos;
		matrixToTransform(m, lightPos);

		if( this->mtth_renderGlobals->exportSceneFile )
		{
			if( obj->mobject.hasFn(MFn::kPointLight))
			{
				TheaSDK::XML::PointLight light;
				light.name = obj->shortName.asChar();
				light.frame = lightPos;
				light.emitter=TheaSDK::XML::RgbTexture(lightColor.r, lightColor.g, lightColor.b);
				sceneXML.addPointLight(light);
			}
			if( obj->mobject.hasFn(MFn::kSpotLight))
			{
				TheaSDK::XML::PointLight light;
				light.name = obj->shortName.asChar();
				light.frame = lightPos;
				light.type = TheaSDK::XML::PointLight::Spot; 
				light.emitter=TheaSDK::XML::RgbTexture(lightColor.r, lightColor.g, lightColor.b);
				sceneXML.addPointLight(light);
			}

			if( obj->mobject.hasFn(MFn::kDirectionalLight))
			{
				logger.warning(MString("Sorry, directional lights are not supported. Node: ") + obj->shortName);
			}
		}else{
			if( obj->mobject.hasFn(MFn::kPointLight))
			{}
			if( obj->mobject.hasFn(MFn::kDirectionalLight))
			{}
			TheaSDK::Point3D lightPos(0.0f,0.0f,0.5f);
			TheaSDK::AddOmniLight("My Light",lightPos,TheaSDK::Rgb(1,1,1),0,5000);
		}
	}


}
	/**
	 * @return Sorted vector of network tap device names from our virtual networks (not other taps on system)
	 */
	inline std::vector<std::string> networkTapDeviceNames() const
	{
		std::vector<std::string> tapDevs;
		Mutex::Lock _l(_networks_m);
		for(std::map< uint64_t,SharedPtr<Network> >::const_iterator n(_networks.begin());n!=_networks.end();++n) {
			std::string dn(n->second->tapDeviceName());
			if (dn.length())
				tapDevs.push_back(dn);
		}
		return tapDevs;
	}
void
Tria1PlateSubSoil :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui)
// Returns the [3x3] strain-displacement matrix {B} of the receiver,
// evaluated at gp.
{
    FloatArray n, ns;
    FloatMatrix dn, dns;

    this->interp_lin.evaldNdx( dn, gp->giveNaturalCoordinates(),  FEIElementGeometryWrapper(this) );
    this->interp_lin.evalN( n, gp->giveNaturalCoordinates(),  FEIElementGeometryWrapper(this) );

    answer.resize(3, 3);
    answer.zero();

    ///@todo Check sign here
    for ( int i = 0; i < 3; ++i ) {
      answer(0, i) = n(i); // eps_z
      answer(1, i) = dn(i, 0); // gamma_xz
      answer(2, i) = dn(i, 1); // gamma_yz
    }
}
Beispiel #13
0
int up(TIFF *T, int i)
{
    if (i < 6)
        return TIFFSetDirectory(T, i);
    else
    {
        if (up(T, face_parent(i)))
            return dn(T, face_index(i));
        else
            return 0;
    }
}
Beispiel #14
0
real ANBSample::Anisotropic_Distance(sample *p1,sample *p2){

	//各向异性距离
	real dp(0.0),dn(0.0);
	dp = p1->distance_sq(p2);
	dp /= sigma_N2;
	for (unsigned di=0; di<p1->_normal.size(); di++)
	{
		dn+=(p1->_normal[di]-p2->_normal[di])*(p1->_normal[di]-p2->_normal[di])/sigma_N2;
	}

	return sqrt(dp+dn)/(0.5f*(p1->r+p2->r));
}
Beispiel #15
0
void
Quad1MindlinShell3D :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui)
{
    FloatArray n, ns;
    FloatMatrix dn, dns;
    const FloatArray &localCoords = * gp->giveNaturalCoordinates();

    this->interp.evaldNdx( dn, localCoords, FEIVertexListGeometryWrapper(lnodes) );
    this->interp.evalN( n, localCoords,  FEIVoidCellGeometry() );

    answer.resize(8, 4 * 5);
    answer.zero();

    // enforce one-point reduced integration if requested
    if ( this->reducedIntegrationFlag ) {
        FloatArray lc(2);
        lc.zero(); // set to element center coordinates

        this->interp.evaldNdx( dns, lc, FEIVertexListGeometryWrapper(lnodes) );
        this->interp.evalN( ns, lc,  FEIVoidCellGeometry() );
    } else {
        dns = dn;
        ns = n;
    }


    // Note: This is just 5 dofs (sixth column is all zero, torsional stiffness handled separately.)
    for ( int i = 0; i < 4; ++i ) {
        ///@todo Check the rows for both parts here, to be consistent with _3dShell material definition
        // Part related to the membrane (columns represent coefficients for D_u, D_v)
        answer(0, 0 + i * 5) = dn(i, 0);//eps_x = du/dx
        answer(1, 1 + i * 5) = dn(i, 1);//eps_y = dv/dy
        answer(2, 0 + i * 5) = dn(i, 1);//gamma_xy = du/dy+dv/dx
        answer(2, 1 + i * 5) = dn(i, 0);

        // Part related to the plate (columns represent the dofs D_w, R_u, R_v)
        ///@todo Check sign here
        answer(3 + 0, 2 + 2 + i * 5) = dn(i, 0);// kappa_x = d(fi_y)/dx
        answer(3 + 1, 2 + 1 + i * 5) =-dn(i, 1);// kappa_y = -d(fi_x)/dy
        answer(3 + 2, 2 + 2 + i * 5) = dn(i, 1);// kappa_xy=d(fi_y)/dy-d(fi_x)/dx
        answer(3 + 2, 2 + 1 + i * 5) =-dn(i, 0);

        // shear strains
        answer(3 + 3, 2 + 0 + i * 5) = dns(i, 0);// gamma_xz = fi_y+dw/dx
        answer(3 + 3, 2 + 2 + i * 5) = ns(i);
        answer(3 + 4, 2 + 0 + i * 5) = dns(i, 1);// gamma_yz = -fi_x+dw/dy
        answer(3 + 4, 2 + 1 + i * 5) = -ns(i);
    }
}
Beispiel #16
0
//---------------------------------------------------------------------------
void CFunction::Format(CExportContext& ctx, const SFString& fmtIn, void *data) const
{
	if (!isShowing())
		return;

	SFString fmt = (fmtIn.IsEmpty() ? defaultFormat() : fmtIn); //.Substitute("\n","\t");
	if (handleCustomFormat(ctx, fmt, data))
		return;

	CFunctionNotify dn(this);
	while (!fmt.IsEmpty())
		ctx << getNextChunk(fmt, nextFunctionChunk, &dn);
}
Beispiel #17
0
void
Quad1Mindlin :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui)
// Returns the [5x9] strain-displacement matrix {B} of the receiver,
// evaluated at gp.
{
    FloatArray n, ns;
    FloatMatrix dn, dns;

    this->interp_lin.evaldNdx( dn, * gp->giveNaturalCoordinates(),  FEIElementGeometryWrapper(this) );
    this->interp_lin.evalN( n, * gp->giveNaturalCoordinates(),  FEIElementGeometryWrapper(this) );

    answer.resize(5, 12);
    answer.zero();

    // enforce one-point reduced integration if requested
    if ( this->reducedIntegrationFlag ) {
        FloatArray lc(2);
        lc.zero(); // set to element center coordinates

        this->interp_lin.evaldNdx( dns, lc, FEIElementGeometryWrapper(this));
        this->interp_lin.evalN( ns, lc,  FEIElementGeometryWrapper(this));
     } else {
        dns = dn;
        ns = n;
    }

    ///@todo Check sign here
    for ( int i = 0; i < 4; ++i ) {
      answer(0, 2 + i * 3) =  dn(i, 0); // kappa_x = d(fi_y)/dx
      answer(1, 1 + i * 3) = -dn(i, 1); // kappa_y = -d(fi_x)/dy
      answer(2, 2 + i * 3) =  dn(i, 1); // kappa_xy=d(fi_y)/dy-d(fi_x)/dx
      answer(2, 1 + i * 3) = -dn(i, 0);

      answer(3, 0 + i * 3) = dns(i, 0); // gamma_xz = fi_y+dw/dx
      answer(3, 2 + i * 3) = ns(i);
      answer(4, 0 + i * 3) = dns(i, 1);// gamma_yz = -fi_x+dw/dy
      answer(4, 1 + i * 3) = -ns(i);
    }
}
Beispiel #18
0
static QString domElementPath(QDomElement e)
      {
      QString s;
      QDomNode dn(e);
      while (!dn.parentNode().isNull()) {
            dn = dn.parentNode();
            const QDomElement e = dn.toElement();
            const QString k(e.tagName());
            if (!s.isEmpty())
                  s += ":";
            s += k;
            }
      return s;
      }
Beispiel #19
0
real ANBSample::Mixture_Distance(sample *p1,sample *p2){
	//混合距离
	real dp(0.0f),dn(0.0f);

	dp=p1->distance_sq(p2);
	dp/=sigma_P2;              //标准距离  方程1中
	for (unsigned di=0; di<p1->_normal.size(); di++)
	{
		dn+=(p1->_normal[di]-p2->_normal[di])*(p1->_normal[di]-p2->_normal[di])/sigma_N2;
	}

	return sqrt(dp+dn)/(0.5f*(p1->r+p2->r));

}
void
Quad10_2D_SUPG :: computeDivUMatrix(FloatMatrix &answer, GaussPoint *gp)
{
    FloatMatrix dn(4, 2);
    velocityInterpolation.evaldNdx(dn, * gp->giveCoordinates(), FEIElementGeometryWrapper(this));

    answer.resize(1, 8);
    answer.zero();

    for ( int i = 1; i <= 4; i++ ) {
        answer.at(1, 2 * i - 1) = dn.at(i, 1);
        answer.at(1, 2 * i) = dn.at(i, 2);
    }
}
Beispiel #21
0
static DataNode* buildFromString(const char *data)
{
    DataNode *root(NULL);
    while (*data) {
        DataNode *dn(root->find(*data));
        if (dn) {
            root->lastNode()->next = dn;
            break;
        }
        dn = root->add(*data++);
        if (!root)
            root = dn;
    }
    return root;
}
Beispiel #22
0
int _tmain(int argc, _TCHAR* argv[])
{
    while (1) {
        _tprintf(_T("Enter linklist:"));
        char ll[256] = { 0 };
        scanf_s("%s", ll, (int)_countof(ll));
        DataNode *dn(buildFromString(ll));
        DataNode *ln((DataNode *)unloop(dn));
        _tprintf(_T("loop node: %c\n"), ln ? ln->data : ' ');
        printDataNode(dn);
        dn->remove();
        dn = NULL;
    }
    return 0;
}
Beispiel #23
0
/**
 *  Build a shading node
 */
ShadingNode *ShadingNodeFactory::build( const MObject &node, ShadingNetwork &shading_network )
{
    MFnDependencyNode dn(node);
    std::string node_name = dn.name().asChar();

    osg::ref_ptr<ShadingNode> sn = shading_network.getShadingNode(node_name);

    if ( sn.valid() ) {
        return sn.get();
    }

    if ( node.hasFn( MFn::kPhong ) ) {
        sn = new Phong( node, shading_network );
    }
    else if ( node.hasFn( MFn::kBlinn ) ) {
        sn = new Blinn( node, shading_network );
    }
    else if ( node.hasFn( MFn::kLambert ) ) {
        sn = new Lambert( node, shading_network );
    }
    else if ( node.hasFn( MFn::kSurfaceShader ) ) {
        sn = new FlatShader( node, shading_network );
    }
    else if ( node.hasFn( MFn::kFileTexture ) ) {
        sn = new FileTexture( node, shading_network );
    }
    else if ( node.hasFn( MFn::kBump ) ) {
		if ( Config::instance()->getEnableBumpMapping() ) {
	        sn = new Bump2D( node, shading_network );
		}
		else {
			std::cerr << "Bump mapping disabled in the exporter configuration" << std::endl;
		}
    }
    // *** ... TO-DO: CHECK FOR OTHER SHADING NODES...
    else {
        std::cerr << "ERROR: Unsupported shading node : " << node.apiTypeStr() << std::endl;
    }

    if ( sn.valid() ) {
        shading_network.registerShadingNode( sn.get(), node_name );
    }

    return sn.get();
}
Beispiel #24
0
/**
 *	Check if this node has animations connected (AnimCurves or MotionPaths)
 *	and indicate the type of the animation found (if any)
 */
bool Transform::hasAnimation(MObject &obj, MFn::Type &type)
{
	MFnDependencyNode dn(obj);
	MPlugArray conns;
	dn.getConnections(conns);
	for(int i=0; i<conns.length(); i++){
		MPlug conn = conns[i];
		if( conn.name() == dn.name() + ".translateX" ||
			conn.name() == dn.name() + ".translateY" ||
			conn.name() == dn.name() + ".translateZ" ||
			conn.name() == dn.name() + ".rotateX" ||
			conn.name() == dn.name() + ".rotateY" ||
			conn.name() == dn.name() + ".rotateZ" ||
			conn.name() == dn.name() + ".scaleX" ||
			conn.name() == dn.name() + ".scaleY" ||
			conn.name() == dn.name() + ".scaleZ" ){

			MPlugArray connectedTo;
			// Get all connections having this node as destination
			conn.connectedTo(connectedTo, true, false);
#ifdef GENERIC_EXPORTER
			if ( connectedTo.length() > 0 ) {
				return true;
			}
#else
			for(int j=0; j<connectedTo.length(); j++){
				MPlug origin = connectedTo[j];
				MObject origin_node = origin.node();
				if(origin_node.hasFn(MFn::kAnimCurve)){
					type = MFn::kAnimCurve;
					return true;
				}
				else if(origin_node.hasFn(MFn::kMotionPath)){
					type = MFn::kMotionPath;
					return true;
				}
			}
#endif
		}
	}
	type = MFn::kInvalid;
	return false;
}
Beispiel #25
0
void Node::parseAll()
{
    n();
    dn();
    d2n();
    i();
    Omega();
    omega();
    M();
    e();
    bstar();
    satelliteNumber();
    satelliteName();
    designator();
    classification();
    ephemerisType();
    elementNumber();
    revolutionNumber();
    preciseEpoch();
}
Beispiel #26
0
std::string Node::secondString() const
{
    std::string res = "1 ";
    res += string2string(satelliteNumber(), 5);
    const char cl = classification();
    res += (isprint(cl) ? std::string(1, cl) : " ") + " ";
    res += string2string(designator(), 8) + " ";
    res += date2string(preciseEpoch(), 14) + " ";
    res += double2string(dn(), 10, 8, false, false, false) + " ";
    res += double2string(d2n(), 8, 3, true, true, false) + " ";
    res += double2string(bstar(), 8, 3, true, true, false) + " ";
    const char eph = ephemerisType();
    res += (isprint(eph) ? std::string(1, eph) : " ") + " ";
    res += int2string(elementNumber(), 4, false);

    // Checksum
    int sum = checksum(res);
    res += int2string(sum, 1);

    return res;
}
 int maxProduct(vector<int>& arr) 
 {
     int n=arr.size();
     vector<int> dp(n,1), dn(n,1);
     if(n==1) return arr[0];
     //dp[0]=nums[0];
     //dn[0]=nums[0];
     int maxpos=0, minpos=0;
     int ans=0;
     for(int i=0;i<n;i++)
     {
         if(arr[i]<0)
         {
             swap(minpos, maxpos);
         }
         maxpos=max(maxpos*arr[i],arr[i]);
         minpos=min(minpos*arr[i],arr[i]);
         ans=max(ans, maxpos);
     }
     
     return ans;
 }
Beispiel #28
0
void
Assembly::addJacobianNeighbor(SparseMatrix<Number> & jacobian, unsigned int ivar, unsigned int jvar, const DofMap & dof_map, std::vector<dof_id_type> & dof_indices, std::vector<dof_id_type> & neighbor_dof_indices)
{
  DenseMatrix<Number> & kee = jacobianBlock(ivar, jvar);
  DenseMatrix<Number> & ken = jacobianBlockNeighbor(Moose::ElementNeighbor, ivar, jvar);
  DenseMatrix<Number> & kne = jacobianBlockNeighbor(Moose::NeighborElement, ivar, jvar);
  DenseMatrix<Number> & knn = jacobianBlockNeighbor(Moose::NeighborNeighbor, ivar, jvar);

  std::vector<dof_id_type> di(dof_indices);
  std::vector<dof_id_type> dn(neighbor_dof_indices);
  // stick it into the matrix
  dof_map.constrain_element_matrix(kee, di, false);
  dof_map.constrain_element_matrix(ken, di, dn, false);
  dof_map.constrain_element_matrix(kne, dn, di, false);
  dof_map.constrain_element_matrix(knn, dn, false);

  Real scaling_factor = _sys.getVariable(_tid, ivar).scalingFactor();
  if (scaling_factor != 1.0)
  {
    _tmp_Ke = ken;
    _tmp_Ke *= scaling_factor;
    jacobian.add_matrix(_tmp_Ke, di, dn);

    _tmp_Ke = kne;
    _tmp_Ke *= scaling_factor;
    jacobian.add_matrix(_tmp_Ke, dn, di);

    _tmp_Ke = knn;
    _tmp_Ke *= scaling_factor;
    jacobian.add_matrix(_tmp_Ke, dn);
  }
  else
  {
    jacobian.add_matrix(ken, di, dn);
    jacobian.add_matrix(kne, dn, di);
    jacobian.add_matrix(knn, dn);
  }
}
Beispiel #29
0
void nodeCreatedCB::sCallbackFunc( MObject& node, void* clientData )
//
// The API callback called whenever a node is added. This function handles
// calling all registered MEL callbacks and passing them the appropriate
// node name argument.
//
{
	int numProcs = nodeCreatedCB::sMelProcs.length();
	for ( int i = 0; i < numProcs; i++ ) {
		MString melCmd = nodeCreatedCB::sMelProcs[i];
		MString nodeName;
		if ( nodeCreatedCB::sFullDagPath[i] && 
			 node.hasFn( MFn::kDagNode ) ) {
			MFnDagNode dagObj( node );
			nodeName = dagObj.fullPathName();
		} else {
			MFnDependencyNode dn( node );
			nodeName = dn.name();
		}
		melCmd += " \"" + nodeName + "\"";
		MGlobal::executeCommand( melCmd );
	}
}
    void MagnetGeneratorPlugin::generateMagnet()
    {
        bt::TorrentInterface* tor = getGUI()->getTorrentActivity()->getCurrentTorrent();
        if (!tor)
            return;

        QUrl dn(tor->getStats().torrent_name);
        SHA1Hash ih(tor->getInfoHash());

        QString uri("magnet:?xt=urn:btih:");
        uri.append(ih.toString());

        if (MagnetGeneratorPluginSettings::dn())
        {
            uri.append("&dn=");
            uri.append(QUrl::toPercentEncoding(dn.toString(), "{}", NULL));
        }

        if ((MagnetGeneratorPluginSettings::customtracker() && MagnetGeneratorPluginSettings::tr().length() > 0) && !MagnetGeneratorPluginSettings::torrenttracker())
        {
            uri.append("&tr=");
            QUrl tr(MagnetGeneratorPluginSettings::tr());
            uri.append(QUrl::toPercentEncoding(tr.toString(), "{}", NULL));
        }

        if (MagnetGeneratorPluginSettings::torrenttracker())
        {
            QList<bt::TrackerInterface*> trackers = tor->getTrackersList()->getTrackers();
            if (!trackers.isEmpty())
            {
                Tracker* trk = (Tracker*)trackers.first();
                QUrl tr(trk->trackerURL());

                uri.append("&tr=");
                uri.append(QUrl::toPercentEncoding(tr.toString(), "{}", NULL));
            }

        }

        addToClipboard(uri);

        if (MagnetGeneratorPluginSettings::popup())
            showPopup();

    }