FRAGMENT(JSString, simple) { AutoSuppressHazardsForTest noanalysis; JS::Rooted<JSString*> empty(cx, JS_NewStringCopyN(cx, nullptr, 0)); JS::Rooted<JSString*> x(cx, JS_NewStringCopyN(cx, "x", 1)); JS::Rooted<JSString*> z(cx, JS_NewStringCopyZ(cx, "z")); // I expect this will be a non-inlined string. JS::Rooted<JSString*> stars(cx, JS_NewStringCopyZ(cx, "*************************" "*************************" "*************************" "*************************")); // This may well be an inlined string. JS::Rooted<JSString*> xz(cx, JS_ConcatStrings(cx, x, z)); // This will probably be a rope. JS::Rooted<JSString*> doubleStars(cx, JS_ConcatStrings(cx, stars, stars)); // Ensure we're not confused by typedefs for pointer types. JSString* xRaw = x; breakpoint(); use(empty); use(x); use(z); use(stars); use(xz); use(doubleStars); use(xRaw); }
FRAGMENT(JSString, simple) { js::Rooted<JSString *> empty(cx, JS_NewStringCopyN(cx, NULL, 0)); js::Rooted<JSString *> x(cx, JS_NewStringCopyN(cx, "x", 1)); js::Rooted<JSString *> z(cx, JS_NewStringCopyZ(cx, "z")); // I expect this will be a non-inlined string. js::Rooted<JSString *> stars(cx, JS_NewStringCopyZ(cx, "*************************" "*************************" "*************************" "*************************")); // This may well be an inlined string. js::Rooted<JSString *> xz(cx, JS_ConcatStrings(cx, x, z)); // This will probably be a rope. js::Rooted<JSString *> doubleStars(cx, JS_ConcatStrings(cx, stars, stars)); breakpoint(); (void) empty; (void) x; (void) z; (void) stars; (void) xz; (void) doubleStars; }
void fun() { int i,f,g; for(i=1;i<=n;i++) { for(f=1;f<=m;f++) { add(i,f); dp[i][f]=xz(i,f); } } }
double Face::getArea() { wcl::Vector p1 = v1->position; wcl::Vector p2 = v2->position; wcl::Vector p3 = v3->position; wcl::Vector xy(p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]); wcl::Vector xz(p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2]); double a = fabs((p1 - p2).normal()); double c = fabs((p1 - p3).normal()); double b = xy.angle(xz); return (a * c * sin(b)) / 2.0; }
void PlayerCameraOgre::onRightButtonPressed() { if (!mRightButtonPressedLastFrame) mMousePosLastFrame = mMouse->getPosition(); mp::Vector2i diff = mMouse->getPosition() - mMousePosLastFrame; const mp::Vector3f &playerPos = mPlayer->model()->getPosition(); Ogre::Vector3 pivotPoint(playerPos.getX(), playerPos.getY() + mPivotHeight, playerPos.getZ()); float yaw = (float)diff.getX() * CAMERA_SPEED; float pitch = (float)-diff.getY() * CAMERA_SPEED; Ogre::Quaternion yawQuat; yawQuat.FromAngleAxis(Ogre::Radian(yaw), Ogre::Vector3::UNIT_Y); Ogre::Matrix3 yawMat; yawQuat.ToRotationMatrix(yawMat); Ogre::Vector3 pivotToPos = Ogre::Vector3(mRealPosition.getX(), mRealPosition.getY(), mRealPosition.getZ()) - pivotPoint; Ogre::Matrix4 pos(1, 0, 0, pivotToPos.x, 0, 1, 0, pivotToPos.y, 0, 0, 1, pivotToPos.z, 0, 0, 0, 1); Ogre::Vector3 xz(pivotToPos.x, 0, pivotToPos.z); Ogre::Vector3 norm(-xz.z, 0, xz.x); Ogre::Quaternion pitchQuat; pitchQuat.FromAngleAxis(Ogre::Radian(pitch), norm); Ogre::Matrix3 pitchMat; pitchQuat.ToRotationMatrix(pitchMat); Ogre::Matrix4 toPivot(1, 0, 0, pivotPoint.x, 0, 1, 0, pivotPoint.y, 0, 0, 1, pivotPoint.z, 0, 0, 0, 1); Ogre::Matrix4 newPosMat = pos * pitchMat * yawMat * toPivot; newPosMat = newPosMat.inverse(); Ogre::Vector3 newPos = newPosMat.getTrans(); mRealPosition.set(-newPos.x, -newPos.y, -newPos.z); setPosition(mRealPosition); lookAt(pivotPoint.x, pivotPoint.y, pivotPoint.z); adjustDistance(); mMousePosLastFrame = mMouse->getPosition(); mRightButtonPressedLastFrame = true; }
void ExtendedKalman::correct(const Matrix& Z) { Matrix K = P; Matrix H(7,7); getH(H, X); { K.dotSelf(H, true); H.transpose(); K.dotSelf(H);// H=H.T } { Matrix R(7,7); getR(R); K += R; } K.inverse(); K.dotSelf(H, true).dotSelf(P, true); // H.T // K = (P * H.T * (H * P * H.T)^-1) { Matrix xz(X); xz.dotSelf(H.transpose(), true);// H = H.T.T (transpose back) xz -= Z; xz *= -1; xz.dotSelf(K, true); X += xz; // X = X + K * (Z - H * X) } K.dotSelf(H); // H K -= Matrix::identity(getN()); K *= -1; P.dotSelf(K, true); // P = (I - K * H) * P }
void MelSpectrogram_drawTriangularFilterFunctions (MelSpectrogram me, Graphics g, bool xIsHertz, int fromFilter, int toFilter, double zmin, double zmax, bool yscale_dB, double ymin, double ymax, int garnish) { double xmin = zmin, xmax = zmax; if (zmin >= zmax) { zmin = my ymin; zmax = my ymax; // mel xmin = xIsHertz ? my v_frequencyToHertz (zmin) : zmin; xmax = xIsHertz ? my v_frequencyToHertz (zmax) : zmax; } if (xIsHertz) { zmin = my v_hertzToFrequency (xmin); zmax = my v_hertzToFrequency (xmax); } if (ymin >= ymax) { ymin = yscale_dB ? -60 : 0; ymax = yscale_dB ? 0 : 1; } fromFilter = fromFilter <= 0 ? 1 : fromFilter; toFilter = toFilter <= 0 || toFilter > my ny ? my ny : toFilter; if (fromFilter > toFilter) { fromFilter = 1; toFilter = my ny; } long n = xIsHertz ? 1000 : 500; autoNUMvector<double> xz (1, n), xhz (1,n), y (1, n); Graphics_setInner (g); Graphics_setWindow (g, xmin, xmax, ymin, ymax); double dz = (zmax - zmin) / (n - 1); for (long iz = 1; iz <= n; iz++) { double f = zmin + (iz - 1) * dz; xz[iz] = f; xhz[iz] = my v_frequencyToHertz (f); // just in case we need the linear scale } for (long ifilter = fromFilter; ifilter <= toFilter; ifilter++) { double zc = Matrix_rowToY (me, ifilter), zl = zc - my dy, zh = zc + my dy; double xo1, yo1, xo2, yo2; if (yscale_dB) { for (long iz = 1; iz <= n; iz++) { double z = xz[iz]; double amp = NUMtriangularfilter_amplitude (zl, zc, zh, z); y[iz] = yscale_dB ? (amp > 0 ? 20 * log10 (amp) : ymin - 10) : amp; } double x1 = xIsHertz ? xhz[1] : xz[1], y1 = y[1]; if (NUMdefined (y1)) { for (long iz = 1; iz <= n; iz++) { double x2 = xIsHertz ? xhz[iz] : xz[iz], y2 = y[iz]; if (NUMdefined (y2)) { if (NUMclipLineWithinRectangle (x1, y1, x2, y2, xmin, ymin, xmax, ymax, &xo1, &yo1, &xo2, &yo2)) { Graphics_line (g, xo1, yo1, xo2, yo2); } } x1 = x2; y1 = y2; } } } else { double x1 = xIsHertz ? my v_frequencyToHertz (zl) : zl; double x2 = xIsHertz ? my v_frequencyToHertz (zc) : zc; if (NUMclipLineWithinRectangle (x1, 0, x2, 1, xmin, ymin, xmax, ymax, &xo1, &yo1, &xo2, &yo2)) { Graphics_line (g, xo1, yo1, xo2, yo2); } double x3 = xIsHertz ? my v_frequencyToHertz (zh) : zh; if (NUMclipLineWithinRectangle (x2, 1, x3, 0, xmin, ymin, xmax, ymax, &xo1, &yo1, &xo2, &yo2)) { Graphics_line (g, xo1, yo1, xo2, yo2); } } } Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_marksBottom (g, 2, 1, 1, 0); Graphics_marksLeftEvery (g, 1, yscale_dB ? 10 : 0.5, 1, 1, 0); Graphics_textLeft (g, 1, yscale_dB ? U"Amplitude (dB)" : U"Amplitude"); Graphics_textBottom (g, 1, Melder_cat (U"Frequency (", ( xIsHertz ? U"Hz" : my v_getFrequencyUnit () ), U")")); } }
void BarkSpectrogram_drawSekeyHansonFilterFunctions (BarkSpectrogram me, Graphics g, bool xIsHertz, int fromFilter, int toFilter, double zmin, double zmax, bool yscale_dB, double ymin, double ymax, int garnish) { double xmin = zmin, xmax = zmax; if (zmin >= zmax) { zmin = my ymin; zmax = my ymax; xmin = xIsHertz ? my v_frequencyToHertz (zmin) : zmin; xmax = xIsHertz ? my v_frequencyToHertz (zmax) : zmax; } if (xIsHertz) { zmin = my v_hertzToFrequency (xmin); zmax = my v_hertzToFrequency (xmax); } if (ymin >= ymax) { ymin = yscale_dB ? -60 : 0; ymax = yscale_dB ? 0 : 1; } fromFilter = fromFilter <= 0 ? 1 : fromFilter; toFilter = toFilter <= 0 || toFilter > my ny ? my ny : toFilter; if (fromFilter > toFilter) { fromFilter = 1; toFilter = my ny; } long n = xIsHertz ? 1000 : 500; autoNUMvector<double> xz (1, n), xhz (1,n), y (1, n); Graphics_setInner (g); Graphics_setWindow (g, xmin, xmax, ymin, ymax); double dz = (zmax - zmin) / (n - 1); for (long iz = 1; iz <= n; iz++) { double f = zmin + (iz - 1) * dz; xz[iz] = f; xhz[iz] = my v_frequencyToHertz (f); // just in case we need the linear scale } for (long ifilter = fromFilter; ifilter <= toFilter; ifilter++) { double zMid = Matrix_rowToY (me, ifilter); for (long iz = 1; iz <= n; iz++) { double z = xz[iz] - (zMid - 0.215); double amp = 7 - 7.5 * z - 17.5 * sqrt (0.196 + z * z); y[iz] = yscale_dB ? amp : pow (10, amp / 10); } // the drawing double x1 = xIsHertz ? xhz[1] : xz[1], y1 = y[1]; for (long iz = 2; iz <= n; iz++) { double x2 = xIsHertz ? xhz[iz] : xz[iz], y2 = y[iz]; if (NUMdefined (x1) && NUMdefined (x2)) { double xo1, yo1, xo2, yo2; if (NUMclipLineWithinRectangle (x1, y1, x2, y2, xmin, ymin, xmax, ymax, &xo1, &yo1, &xo2, &yo2)) { Graphics_line (g, xo1, yo1, xo2, yo2); } } x1 = x2; y1 = y2; } } Graphics_unsetInner (g); if (garnish) { double distance = yscale_dB ? 10 : 0.5; Graphics_drawInnerBox (g); Graphics_marksBottom (g, 2, 1, 1, 0); Graphics_marksLeftEvery (g, 1, distance, 1, 1, 0); Graphics_textLeft (g, 1, yscale_dB ? U"Amplitude (dB)" : U"Amplitude"); Graphics_textBottom (g, 1, Melder_cat (U"Frequency (", xIsHertz ? U"Hz" : my v_getFrequencyUnit (), U")")); } }
Cir Frame::icxz() const { return Ro::round( bound(), xz() ); } ///< xz circle (imaginary, direct)
Cir Frame::cxz() const { return Ro::round( ibound(), xz() ); } ///< xz circle (real, direct)