Exemplo n.º 1
0
static int
Qs(q_M_gc)(lua_State *L)
{
    Qs(mLatColMat) *b = Qs(qlua_checkLatColMat)(L, 1, NULL, -1);

    Qx(QDP_D,_destroy_M)(b->ptr);
    b->ptr = 0;

    return 0;
}
Exemplo n.º 2
0
static int
Qs(q_M_fmt)(lua_State *L)
{
    char fmt[72];
    Qs(mLatColMat) *b = Qs(qlua_checkLatColMat)(L, 1, NULL, -1);

    sprintf(fmt, "QDP:ColorMatrix%d(%p)", QC(b), b->ptr);
    lua_pushstring(L, fmt);

    return 1;
}
    vector<vector<int> > levelOrder(TreeNode *root) {
        vector<vector<int> > result;
		if(!root)
			return result;
		vector<queue<TreeNode *> > Qs(2);
		Qs[0].push(root);
		int flag = 0;
		vector<int> item;
		while(!Qs[flag].empty()) {
			TreeNode *node = Qs[flag].front();
			item.push_back(node->val);
			Qs[flag].pop();
			if(node->left)
				Qs[!flag].push(node->left);
			if(node->right)
				Qs[!flag].push(node->right);
			if(Qs[flag].empty()) {
				result.push_back(item);
				item.clear();
				flag = !flag;
			}
		}
		
		return result;
    }
Exemplo n.º 4
0
static void
Qs(float_DD_put)(char *buf, size_t index, int count, void *v_arg)
{
    Qs(USQCDArgs) *arg = v_arg;
#if QNc == 'N'
    typedef QLA_DN_DiracPropagator(arg->nc, Ptype);
#else
    typedef Qx(QLA_D,_DiracPropagator) Ptype;
#endif
    Ptype *P = arg->P;
    Ptype *dst = &P[index];
    QLA_F_Complex *src = (void *)buf;
    int js = arg->js;
    int jc = arg->jc;
    int is, ic;
    
    if (count != 1)
        luaL_error(arg->L, "qcd.ddpairs.read(): count != 1");
    
    for (is = 0; is < QDP_Ns; is++) {
        for (ic = 0; ic < arg->nc; ic++, src++) {
            QLA_c_eq_r_plus_ir(QLA_elem_P(*dst, ic, is, jc, js),
                               QLA_real(*src), QLA_imag(*src));
        }
    }
}
Exemplo n.º 5
0
//Compute subGLCM features.
std::vector<float> ComputeQFeatures(std::vector<cv::Mat> GLCMs)
{
	std::vector<float> Qs(8, 0);


	for (size_t i = 0; i < GLCMs.size(); i++) {
		cv::Mat GLCM = GLCMs[i];
		size_t width_t = GLCM.cols;
		size_t height_t = GLCM.rows;
		size_t wStep = width_t / 2;
		size_t hStep = height_t / 2;
		int qIndex = 0;
		for (size_t u = 0; u < 2; u++) {
			for (size_t j = 0; j < 2; j++) {
				if (qIndex == 2)
				{
					qIndex++;
					continue;
				}

				size_t startX = wStep*j, endX = wStep + wStep*j, startY = hStep*u, endY = hStep + hStep*u;

				float Q = ComputeQFeature(GLCM, startX, endX, startY, endY);
				Qs[qIndex + 4* i] += Q;
				qIndex++;
			}
		}
	}
	Qs[2] = Qs[3];
	Qs[3] = Qs[4];
	Qs[4] = Qs[5];
	Qs[5] = Qs[7];
	Qs.resize(6);
	return Qs;
}
Exemplo n.º 6
0
static int
Qs(q_g_mul_p_)(lua_State *L)
{
    mClifford *m = qlua_checkClifford(L, 1);
    Qs(mSeqDirProp) *f = Qs(qlua_checkSeqDirProp)(L, 2, -1);
    Qs(mSeqDirProp) *mf = Qs(qlua_newSeqDirProp)(L, QC(f));
    Qs(mSeqDirProp) *r = Qs(qlua_newZeroSeqDirProp)(L, QC(f));
    int i;
    
    for (i = 0; i < 16; i++) {
        switch (m->g[i].t) {
        case qG_z: continue;
        case qG_p:
            Qx(QLA_D,_P_eq_gamma_times_P)(QNC(QC(f)) mf->ptr, f->ptr, i);
            Qx(QLA_D,_P_peq_P)(QNC(QC(f)) r->ptr, mf->ptr);
            break;
        case qG_m:
            Qx(QLA_D,_P_eq_gamma_times_P)(QNC(QC(f)) mf->ptr, f->ptr, i);
            Qx(QLA_D,_P_meq_P)(QNC(QC(f)) r->ptr, mf->ptr);
            break;
        case qG_r:
            Qx(QLA_D,_P_eq_gamma_times_P)(QNC(QC(f)) mf->ptr, f->ptr, i);
            Qx(QLA_D,_P_peq_r_times_P)(QNC(QC(f)) r->ptr, &m->g[i].r, mf->ptr);
            break;
        case qG_c:
            Qx(QLA_D,_P_eq_gamma_times_P)(QNC(QC(f)) mf->ptr, f->ptr, i);
            Qx(QLA_D,_P_peq_c_times_P)(QNC(QC(f)) r->ptr, &m->g[i].c, mf->ptr);
            break;
        }
    }
    return 1;
}
Exemplo n.º 7
0
static int
Qs(q_g_mul_D_)(lua_State *L)
{
    mClifford *m = qlua_checkClifford(L, 1);
    Qs(mLatDirFerm) *f = Qs(qlua_checkLatDirFerm)(L, 2, NULL, -1);
    mLattice *S = qlua_ObjLattice(L, 2);
    int Sidx = lua_gettop(L);
    Qs(mLatDirFerm) *mf = Qs(qlua_newLatDirFerm)(L, Sidx, QC(f));
    Qs(mLatDirFerm) *r = Qs(qlua_newZeroLatDirFerm)(L, Sidx, QC(f));
    int i;

    CALL_QDP(L);
    for (i = 0; i < 16; i++) {
        switch (m->g[i].t) {
        case qG_z: continue;
        case qG_p:
            Qx(QDP_D,_D_eq_gamma_times_D)(mf->ptr, f->ptr, i, *S->qss);
            Qx(QDP_D,_D_peq_D)(r->ptr, mf->ptr, *S->qss);
            break;
        case qG_m:
            Qx(QDP_D,_D_eq_gamma_times_D)(mf->ptr, f->ptr, i, *S->qss);
            Qx(QDP_D,_D_meq_D)(r->ptr, mf->ptr, *S->qss);
            break;
        case qG_r:
            Qx(QDP_D,_D_eq_gamma_times_D)(mf->ptr, f->ptr, i, *S->qss);
            Qx(QDP_D,_D_peq_r_times_D)(r->ptr, &m->g[i].r, mf->ptr, *S->qss);
            break;
        case qG_c:
            Qx(QDP_D,_D_eq_gamma_times_D)(mf->ptr, f->ptr, i, *S->qss);
            Qx(QDP_D,_D_peq_c_times_D)(r->ptr, &m->g[i].c, mf->ptr, *S->qss);
            break;
        }
    }
    return 1;
}
void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
{
    if (updated())
    {
        return;
    }
    // Since we're inside initEvaluate/evaluate there might be processor
    // comms underway. Change the tag we use.
    int oldTag = UPstream::msgType();
    UPstream::msgType() = oldTag+1;


    const mapDistribute& mapDist = this->mappedPatchBase::map();

    const label patchi = patch().index();

    const label nbrPatchi = samplePolyPatch().index();

    if (baffleActivated_)
    {
        const fvPatch& nbrPatch = patch().boundaryMesh()[nbrPatchi];

        const compressible::turbulenceModel& turbModel =
            db().template lookupObject<compressible::turbulenceModel>
            (
                "turbulenceModel"
            );

        // local properties
        const scalarField kappaw(turbModel.kappaEff(patchi));

        const fvPatchScalarField& Tp =
            patch().template lookupPatchField<volScalarField, scalar>(TName_);


        scalarField Qr(Tp.size(), 0.0);

        if (QrName_ != "none")
        {
            Qr = patch().template lookupPatchField<volScalarField, scalar>
                (QrName_);

            Qr = QrRelaxation_*Qr + (1.0 - QrRelaxation_)*QrPrevious_;
            QrPrevious_ = Qr;
        }

        tmp<scalarField> Ti = patchInternalField();

        scalarField myKDelta(patch().deltaCoeffs()*kappaw);

        // nrb properties
        scalarField nbrTp =
            turbModel.thermo().T().boundaryField()[nbrPatchi];
        mapDist.distribute(nbrTp);

        // solid properties
        scalarField kappas(patch().size(), 0.0);
        forAll(kappas, i)
        {
            kappas[i] = solid().kappa(0.0, (Tp[i] + nbrTp[i])/2.0);
        }

        const scalarField KDeltaSolid(kappas/baffleThickness());

        const scalarField alpha(KDeltaSolid - Qr/Tp);

        valueFraction() = alpha/(alpha + myKDelta);

        refValue() = (KDeltaSolid*nbrTp + Qs()/2.0)/alpha;

        if (debug)
        {
            scalar Q = gAverage(kappaw*snGrad());
            Info<< patch().boundaryMesh().mesh().name() << ':'
                << patch().name() << ':'
                << this->dimensionedInternalField().name() << " <- "
                << nbrPatch.name() << ':'
                << this->dimensionedInternalField().name() << " :"
                << " heat[W]:" << Q
                << " walltemperature "
                << " min:" << gMin(*this)
                << " max:" << gMax(*this)
                << " avg:" << gAverage(*this)
                << endl;
        }
    }