TVerdict CDataReadyCancelNotificationStep::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { if (TestStepResult()==EPass) { _LIT8(KTestOutBuf,"test message"); HBufC* InBuf = HBufC::NewLC(KTestOutBuf().Length() / 2); TPtr ptr = InBuf->Des(); TPtr8 inBuf(ptr.Collapse()); TBuf<50> msg; _LIT(KOperReading, "Data available request canceled in port <%d>"); _LIT(KOperWriting, "Written port <%d>"); TRequestStatus status; for(TInt i = 0; i < KSupportedPorts; i++) { if(IsEven(i)) { iPortList[i].port.Write(status, KTestOutBuf); msg.Format(KOperWriting, i); User::WaitForRequest(status); TestErrorCodeL(status.Int(), msg); } else { iPortList[i].port.NotifyDataAvailableCancel(); msg.Format(KOperReading, i); } } CleanupStack::PopAndDestroy(); SetTestStepResult(EPass); } return TestStepResult(); }
TBool TInteger::IsPrimeL(void) const { if( NotPositive() ) { return EFalse; } else if( IsEven() ) { return *this == Two(); } else if( *this <= KLastSmallPrime ) { assert(KLastSmallPrime < KMaxTUint); return IsSmallPrime(this->ConvertToUnsignedLong()); } else if( *this <= KLastSmallPrimeSquared ) { return !HasSmallDivisorL(*this); } else { return !HasSmallDivisorL(*this) && IsStrongProbablePrimeL(*this); } }
void NairnFEA::EnergyResults(void) { double temp; int incolm,i,ind; char fline[200]; if(outFlags[ENERGY_OUT]=='N') return; // heading sprintf(fline,"STRAIN ENERGIES IN ELEMENTS (in %s)",UnitsController::Label(FEAWORK_UNITS)); PrintSection(fline); cout << " Elem Strain Energy Elem Strain Energy" << endl; cout << "------------------------------------------------------------------" << endl; temp=0.; if(IsEven(nelems)) incolm=nelems/2; else incolm=(nelems+1)/2; double escale = UnitsController::Scaling(1.e-3); for(i=1;i<=incolm;i++) { ind=i+incolm; if(ind<=nelems) { sprintf(fline,"%5d %15.7e %5d %15.7e", i,escale*theElements[i-1]->strainEnergy,ind,escale*theElements[ind-1]->strainEnergy); temp+=theElements[ind-1]->strainEnergy; } else sprintf(fline,"%5d %15.7e",i,escale*theElements[i-1]->strainEnergy); temp+=theElements[i-1]->strainEnergy; cout << fline << endl; } cout << "------------------------------------------------------------------" << endl; sprintf(fline,"Total %15.7e",escale*temp); cout << fline << endl << endl; }
bool IsOdd(unsigned n) { return (!IsEven(n)); }
/* ** FUNCTION: W6j. ** PURPOSE: calculate the 6j symbol. ** INPUT: {int j1}, ** angular momentum. ** {int j2}, ** angular momentum. ** {int j3}, ** angular momentum. ** {int i1}, ** angular momentum. ** {int i2}, ** angular momentum. ** {int i3}, ** angular momentum. ** RETURN: {double}, ** 6j symbol. ** SIDE EFFECT: ** NOTE: */ double W6j(int j1, int j2, int j3, int i1, int i2, int i3) { int n1, n2, n3, n4, n5, n6, n7, k, kmin, kmax, ic, ki; double r, a; #ifdef PERFORM_STATISTICS clock_t start, stop; start = clock(); #endif if (!(Triangle(j1, j2, j3) && Triangle(j1, i2, i3) && Triangle(i1, j2, i3) && Triangle(i1, i2, j3))) return 0.0; n1 = (j1 + j2 + j3) / 2; n2 = (i2 + i1 + j3) / 2; n3 = (j1 + i2 + i3) / 2; n4 = (j2 + i1 + i3) / 2; n5 = (j1 + j2 + i2 + i1) / 2; n6 = (j1 + i1 + j3 + i3) / 2; n7 = (j2 + i2 + j3 + i3) / 2; kmin = Max(n1, n2); kmin = Max(kmin, n3); kmin = Max(kmin, n4) + 1; kmax = Min(n5, n6); kmax = Min(kmax, n7) + 1; r = 1.0; ic = 0; for (k = kmin + 1; k <= kmax; k++) { ki = kmax -ic; r = 1.0 - (r * ki * (n5-ki+2.0) * (n6-ki+2.0) * (n7-ki+2.0))/ ((ki-1.0-n1) * (ki-1.0-n2) * (ki-1.0-n3) * (ki - 1.0 - n4)); ic++; } a = (LnFactorial(kmin) - LnFactorial(kmin-n1-1) - LnFactorial(kmin-n2-1) - LnFactorial(kmin-n3-1) - LnFactorial(kmin-n4-1) - LnFactorial(n5+1-kmin) - LnFactorial(n6+1-kmin) - LnFactorial(n7+1-kmin)) + ((LnFactorial(n1-j1) + LnFactorial(n1-j2) + LnFactorial(n1-j3) - LnFactorial(n1+1) + LnFactorial(n2-i2) + LnFactorial(n2-i1) + LnFactorial(n2-j3) - LnFactorial(n2+1) + LnFactorial(n3-j1) + LnFactorial(n3-i2) + LnFactorial(n3-i3) - LnFactorial(n3+1) + LnFactorial(n4-j2) + LnFactorial(n4-i1) + LnFactorial(n4-i3) - LnFactorial(n4+1))/2.0); r = r * exp(a); if (IsEven(n5+kmin)) r = -r; if (IsOdd(((j1+j2+i1+i2)/2))) r = -r; #ifdef PERFORM_STATISTICS stop = clock(); timing.w6j += stop - start; #endif return r; }
NTKERNELAPI NTSTATUS NTAPI FsRtlValidateReparsePointBuffer(IN ULONG BufferLength, IN PREPARSE_DATA_BUFFER ReparseBuffer) { USHORT DataLength; ULONG ReparseTag; PREPARSE_GUID_DATA_BUFFER GuidBuffer; /* Validate data size range */ if (BufferLength < REPARSE_DATA_BUFFER_HEADER_SIZE || BufferLength > MAXIMUM_REPARSE_DATA_BUFFER_SIZE) { return STATUS_IO_REPARSE_DATA_INVALID; } GuidBuffer = (PREPARSE_GUID_DATA_BUFFER)ReparseBuffer; DataLength = ReparseBuffer->ReparseDataLength; ReparseTag = ReparseBuffer->ReparseTag; /* Validate size consistency */ if (DataLength + REPARSE_DATA_BUFFER_HEADER_SIZE != BufferLength && DataLength + REPARSE_GUID_DATA_BUFFER_HEADER_SIZE != BufferLength) { return STATUS_IO_REPARSE_DATA_INVALID; } /* REPARSE_DATA_BUFFER is reserved for MS tags */ if (DataLength + REPARSE_DATA_BUFFER_HEADER_SIZE == BufferLength && !IsReparseTagMicrosoft(ReparseTag)) { return STATUS_IO_REPARSE_DATA_INVALID; } /* If that a GUID data buffer, its GUID cannot be null, and it cannot contain a MS tag */ if (DataLength + REPARSE_GUID_DATA_BUFFER_HEADER_SIZE == BufferLength && ((!IsReparseTagMicrosoft(ReparseTag) && IsNullGuid(&GuidBuffer->ReparseGuid)) || (ReparseTag == IO_REPARSE_TAG_MOUNT_POINT || ReparseTag == IO_REPARSE_TAG_SYMLINK))) { return STATUS_IO_REPARSE_DATA_INVALID; } /* Check the data for MS non reserved tags */ if (!(ReparseTag & 0xFFF0000) && ReparseTag != IO_REPARSE_TAG_RESERVED_ZERO && ReparseTag != IO_REPARSE_TAG_RESERVED_ONE) { /* If that's a mount point, validate the MountPointReparseBuffer branch */ if (ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { /* We need information */ if (DataLength >= REPARSE_DATA_BUFFER_HEADER_SIZE) { /* Substitue must be the first in row */ if (!ReparseBuffer->MountPointReparseBuffer.SubstituteNameOffset) { /* Substitude must be null-terminated */ if (ReparseBuffer->MountPointReparseBuffer.PrintNameOffset == ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + sizeof(UNICODE_NULL)) { /* There must just be the Offset/Length fields + buffer + 2 null chars */ if (DataLength == ReparseBuffer->MountPointReparseBuffer.PrintNameLength + ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + (FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) - FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.SubstituteNameOffset)) + 2 * sizeof(UNICODE_NULL)) { return STATUS_SUCCESS; } } } } } else { #define FIELDS_SIZE (FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer) - FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.SubstituteNameOffset)) /* If that's not a symlink, accept the MS tag as it */ if (ReparseTag != IO_REPARSE_TAG_SYMLINK) { return STATUS_SUCCESS; } /* We need information */ if (DataLength >= FIELDS_SIZE) { /* Validate lengths */ if (ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength && ReparseBuffer->SymbolicLinkReparseBuffer.PrintNameLength) { /* Validate unicode strings */ if (IsEven(ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength) && IsEven(ReparseBuffer->SymbolicLinkReparseBuffer.PrintNameLength) && IsEven(ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameOffset) && IsEven(ReparseBuffer->SymbolicLinkReparseBuffer.PrintNameOffset)) { if ((DataLength + REPARSE_DATA_BUFFER_HEADER_SIZE >= ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameOffset + ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength + FIELDS_SIZE + REPARSE_DATA_BUFFER_HEADER_SIZE) && (DataLength + REPARSE_DATA_BUFFER_HEADER_SIZE >= ReparseBuffer->SymbolicLinkReparseBuffer.PrintNameLength + ReparseBuffer->SymbolicLinkReparseBuffer.PrintNameOffset + FIELDS_SIZE + REPARSE_DATA_BUFFER_HEADER_SIZE)) { return STATUS_SUCCESS; } } } } #undef FIELDS_SIZE } return STATUS_IO_REPARSE_DATA_INVALID; } return STATUS_IO_REPARSE_TAG_INVALID; }
// Checks if the number is in the sieve, since we skip even numbers and numbers smaller than 3. constexpr bool HasIndex(size_t n) { return !IsEven(n) && n >= 3; }
static struct FaceCount MaximumStrip(GLUhalfEdge* eOrig) { /* Here we are looking for a maximal strip that contains the vertices * eOrig->Org, eOrig->Dst, eOrig->Lnext->Dst (in that order or the * reverse, such that all triangles are oriented CCW). * * Again we walk forward and backward as far as possible. However for * strips there is a twist: to get CCW orientations, there must be * an *even* number of triangles in the strip on one side of eOrig. * We walk the strip starting on a side with an even number of triangles; * if both side have an odd number, we are forced to shorten one side. */ struct FaceCount newFace={0, NULL, &RenderStrip}; long headSize=0, tailSize=0; GLUface* trail=NULL; GLUhalfEdge* e; GLUhalfEdge* eTail; GLUhalfEdge* eHead; for (e=eOrig; !Marked(e->Lface); ++tailSize, e=e->Onext) { AddToTrail(e->Lface, trail); ++tailSize; e=e->Dprev; if (Marked(e->Lface)) { break; } AddToTrail(e->Lface, trail); } eTail=e; for (e=eOrig; !Marked(e->Rface); ++headSize, e=e->Dnext) { AddToTrail(e->Rface, trail); ++headSize; e=e->Oprev; if (Marked(e->Rface)) { break; } AddToTrail(e->Rface, trail); } eHead=e; newFace.size=tailSize+headSize; if (IsEven(tailSize)) { newFace.eStart=eTail->Sym; } else { if (IsEven(headSize)) { newFace.eStart=eHead; } else { /* Both sides have odd length, we must shorten one of them. In fact, * we must start from eHead to guarantee inclusion of eOrig->Lface. */ --newFace.size; newFace.eStart=eHead->Onext; } } /*LINTED*/ FreeTrail(trail); return newFace; }
int CIRadialQk(cfac_t *cfac, double *qk, double e1, double e2, int kb, int kbp, int k) { double pk[MAXNTE][MAXNKL], pkp[MAXNTE][MAXNKL]; double e0, te; ORBITAL *orb; int kappab, jb, klb, i, j, t, kl, klp; int js[4], ks[4]; int jmin, jmax, ko2; int kf, kappaf, kf0, kappa0, kf1, kappa1; int kl0, kl0p, kl1, kl1p; int j0, j1, j1min, j1max; double z, r, rp, sd, se, s; double jb1; int kl_max0, kl_max1, kl_max2, kl_min2; int type; int one = 1; double logj; ko2 = k/2; for (i = 0; i < n_tegrid; i++) { for (j = 0; j < pw_scratch.nkl0; j++) { pk[i][j] = 0.0; } } for (i = 0; i < n_tegrid; i++) { qk[i] = 0.0; } r = GetRMax(cfac); z = GetResidualZ(cfac); t = r*sqrt(e1+2.0*z/r); kl_max0 = pw_scratch.max_kl; kl_max0 = Min(kl_max0, t); orb = GetOrbital(cfac, kb); kappab = orb->kappa; GetJLFromKappa(kappab, &jb, &klb); klb /= 2; jmin = abs(k - jb); jmax = k + jb; jb1 = jb + 1.0; t = r*sqrt(e2+2.0*z/r); kl_max2 = pw_scratch.max_kl_eject + klb; kl_max2 = Min(kl_max2, t); kl_min2 = klb - pw_scratch.max_kl_eject; if (kl_min2 < 0) kl_min2 = 0; for (j = jmin; j <= jmax; j += 2) { for (klp = j - 1; klp <= j + 1; klp += 2) { kappaf = GetKappaFromJL(j, klp); kl = klp/2; if (kl > kl_max2) break; if (kl < kl_min2) continue; if (IsEven(kl + klb + ko2)) { type = ko2; } else { type = -1; } /* if (kl < pw_scratch.qr) { js[2] = 0; } else { js[2] = j; if (kappaf > 0) kappaf = -kappaf - 1; } */ js[2] = 0; kf = OrbitalIndex(cfac, 0, kappaf, e2); ks[2] = kf; if (xborn) { for (i = 0; i < n_tegrid; i++) { CERadialQkBorn(cfac, kb, kf, kbp, kf, k, tegrid[i]+e2, e1, &r, 0); qk[i] += r; } continue; } if (type >= 0 && type < CBMULT) { kl_max1 = pw_scratch.kl_cb; } else { kl_max1 = kl_max0; } for (i = 0; i < n_tegrid; i++) { for (t = 0; t < pw_scratch.nkl0; t++) { pkp[i][t] = 0.0; } } for (t = 0; ; t++) { kl0 = pw_scratch.kl[t]; if (kl0 > kl_max1) { break; } kl0p = 2*kl0; for (j0 = abs(kl0p - 1); j0 <= kl0p + 1; j0 += 2) { kappa0 = GetKappaFromJL(j0, kl0p); if (kl0 < pw_scratch.qr) { js[1] = 0; } else { js[1] = j0; if (kappa0 > 0) kappa0 = -kappa0 - 1; } j1min = abs(j0 - k); j1max = j0 + k; for (j1 = j1min; j1 <= j1max; j1 += 2) { for (kl1p = j1 - 1; kl1p <= j1 + 1; kl1p += 2) { kappa1 = GetKappaFromJL(j1, kl1p); kl1 = kl1p/2; if (kl1 < pw_scratch.qr) { js[3] = 0; } else { js[3] = j1; if (kappa1 > 0) kappa1 = -kappa1 - 1; } kf1 = OrbitalIndex(cfac, 0, kappa1, e1); ks[3] = kf1; for (i = 0; i < n_tegrid; i++) { te = tegrid[i]; e0 = e1 + e2 + te; kf0 = OrbitalIndex(cfac, 0, kappa0, e0); ks[1] = kf0; js[0] = 0; ks[0] = kb; if (kl1 >= pw_scratch.qr && kl0 >= pw_scratch.qr) { SlaterTotal(cfac, &sd, &se, js, ks, k, -1); } else { SlaterTotal(cfac, &sd, &se, js, ks, k, 1); } r = sd + se; if (!r) break; if (kbp != kb) { js[0] = 0; ks[0] = kbp; if (kl1 >= pw_scratch.qr && kl0 >= pw_scratch.qr) { SlaterTotal(cfac, &sd, &se, js, ks, k, -1); } else { SlaterTotal(cfac, &sd, &se, js, ks, k, 1); } rp = sd + se; if (!rp) break; } else { rp = r; } r = r*rp; pk[i][t] += r; pkp[i][t] += r; } } } } } } } if (xborn == 0) { t = pw_scratch.nkl; for (i = 0; i < n_tegrid; i++) { r = pk[i][0]; for (j = 1; j < t; j++) { r += pk[i][j]; kl0 = pw_scratch.kl[j-1]; kl1 = pw_scratch.kl[j]; for (kl = kl0+1; kl < kl1; kl++) { logj = LnInteger(kl); UVIP3P(t, pw_scratch.log_kl, pk[i], one, &logj, &s); r += s; } } qk[i] += r; qk[i] /= jb1; } } else { for (i = 0; i < n_tegrid; i++) { qk[i] /= jb1; } } return 0; }
/* Calculate Stiffness Matrix */ void CSTriangle::Stiffness(int np) { double detjac,asr,dv; double xiDeriv[MaxElNd],etaDeriv[MaxElNd],asbe[MaxElNd],sfxn[MaxElNd]; double bte[MxFree*MaxElNd][5],temp; double thck=thickness,deltaT; int numnds=NumberNodes(); int ind1,ind2,i,j,irow,jcol,nst=2*numnds; MaterialBase *matl=theMaterials[material-1]; Vector xi; // Load nodal coordinates (ce[]), temperature (te[]), and // material props (pr.C[][] and pr.alpha[]) GetProperties(np); // Zero upper hald element stiffness matrix (se[]) and reaction vector (re[]) for(irow=1;irow<=nst;irow++) { re[irow]=0.; for(jcol=irow;jcol<=nst;jcol++) se[irow][jcol]=0.; } /* Call shape routine to calculate element B (be,asbe) matrix and the determinant of the Jacobian - both at centriod */ xi.x=(ce[1].x+ce[2].x+ce[3].x)/3.; xi.y=(ce[1].y+ce[2].y+ce[3].y)/3.; ShapeFunction(&xi,BMATRIX,&sfxn[1],&xiDeriv[1],&etaDeriv[1],&ce[1], &detjac,&asr,&asbe[1]); /* Form matrix product BT E - exploit known sparcity of B matrix and only include multiplications by nonzero elements */ deltaT=0.; ind1=-1; if(np!=AXI_SYM) { dv=thck*detjac; for(i=1;i<=numnds;i++) { ind1=ind1+2; ind2=ind1+1; for(j=1;j<=3;j++) { bte[ind1][j]=dv*(xiDeriv[i]*matl->pr.C[1][j]+etaDeriv[i]*matl->pr.C[3][j]); bte[ind2][j]=dv*(etaDeriv[i]*matl->pr.C[2][j]+xiDeriv[i]*matl->pr.C[3][j]); } deltaT+=te[i]*sfxn[i]; } } else { dv=asr*detjac; for(i=1;i<=numnds;i++) { ind1=ind1+2; ind2=ind1+1; for(j=1;j<=4;j++) { bte[ind1][j]=dv*(xiDeriv[i]*matl->pr.C[1][j]+etaDeriv[i]*matl->pr.C[3][j] +asbe[i]*matl->pr.C[4][j]); bte[ind2][j]=dv*(etaDeriv[i]*matl->pr.C[2][j]+xiDeriv[i]*matl->pr.C[3][j]); } deltaT+=te[i]*sfxn[i]; } } /* Form stiffness matrix by getting BT E B and add in initial strains into element load vector */ for(irow=1;irow<=nst;irow++) { for(j=1;j<=3;j++) { re[irow]+=bte[irow][j]*matl->pr.alpha[j]*deltaT; } if(np!=AXI_SYM) { for(jcol=irow;jcol<=nst;jcol++) { if(IsEven(jcol)) { ind1=jcol/2; temp=bte[irow][2]*etaDeriv[ind1] +bte[irow][3]*xiDeriv[ind1]; } else { ind1=(jcol+1)/2; temp=bte[irow][1]*xiDeriv[ind1] +bte[irow][3]*etaDeriv[ind1]; } se[irow][jcol]+=temp; } } else { re[irow]+=bte[irow][4]*matl->pr.alpha[j]*deltaT; for(jcol=irow;jcol<=nst;jcol++) { if(IsEven(jcol)) { ind1=jcol/2; temp=bte[irow][2]*etaDeriv[ind1] +bte[irow][3]*xiDeriv[ind1]; } else { ind1=(jcol+1)/2; temp=+bte[irow][1]*xiDeriv[ind1] +bte[irow][3]*etaDeriv[ind1] +bte[irow][4]*asbe[ind1]; } se[irow][jcol]+=temp; } } } /* Fill in lower half of stiffness matrix */ for(irow=1;irow<=nst-1;irow++) { for(jcol=irow+1;jcol<=nst;jcol++) { se[jcol][irow]=se[irow][jcol]; } } }
void CDemoMFCDlg::OnDiffFailPred1() { OnFailingAssert(); MOD_ASSERT(rb1_PRED(3, IsEven())); }