LRESULT FulAdvancedPage::onClickedShortcuts(WORD /* wNotifyCode */, WORD wID, HWND /* hWndCtl */, BOOL& /* bHandled */) { if (wID == IDC_WEB_SHORTCUTS_ADD) { WebShortcut* ws; ws = new WebShortcut(); WebShortcutsProperties wsp(wsList, ws); if (wsp.DoModal() == IDOK) { wsList.push_back(ws); addListItem(ws); } else { delete ws; } } else if (wID == IDC_WEB_SHORTCUTS_PROPERTIES) { if (ctrlWebShortcuts.GetSelectedCount() == 1) { int sel = ctrlWebShortcuts.GetSelectedIndex(); WebShortcut* ws = wsList[sel]; WebShortcutsProperties wsp(wsList, ws); if (wsp.DoModal() == IDOK) { updateListItem(sel); } } } else if (wID == IDC_WEB_SHORTCUTS_REMOVE) { if (ctrlWebShortcuts.GetSelectedCount() == 1) { int sel = ctrlWebShortcuts.GetSelectedIndex(); dcassert(sel >= 0 && sel < (int)wsList.size()); wsList.erase(find(wsList.begin(), wsList.end(), wsList[sel])); ctrlWebShortcuts.DeleteItem(sel); } } return S_OK; }
static void comma(struct ParseData *d) { wsp(d); if (*d->str == ',') d->str++; else return; wsp(d); }
void TestLevel::init() { IAnimatedMesh* mesh = smgr->getMesh("img/sydney.md2"); IAnimatedMeshSceneNode * tmpnode = smgr->addAnimatedMeshSceneNode(mesh); if (tmpnode) { tmpnode->setMaterialFlag(EMF_LIGHTING, false); tmpnode->setMD2Animation(scene::EMAT_STAND); tmpnode->setMaterialTexture(0, driver->getTexture("img/sydney.bmp")); } tmpnode->setPosition(vector3df(-222,0,0)); vector3df wsp(0,5,-10); ship = new TestPlayerShip(TestPlayerShip::createTestPlayerShipNode(context)); ship->attachNewCamera(new StaticCamera(context,ship)); // ship.attachCamera(cam); this->node = new NonPlayerShip(tmpnode); testPlanet = Planet::createTestPlanet(context); }
static void parse(struct ParseData *d, kvec_uchar_t *commands, kvec_float_t *coords) { for (;;) { wsp(d); if (*d->str == 0) break; switch (*d->str) { case 'M': case 'm': parseHelper(d, commands, coords, 2, 0); break; case 'L': parseHelper(d, commands, coords, 2, 1); break; case 'Q': parseHelper(d, commands, coords, 4, 1); break; case 'C': parseHelper(d, commands, coords, 6, 1); break; case 'Z': case 'z': d->str++; kv_push_back(*commands, 'Z'); break; default: longjmp(d->buf, 1); break; } } }
Vector rmvn_L_mt(RNG &rng, const Vector &mu, const Matrix &L) { // L is the lower cholesky triangle of Sigma. uint n = mu.size(); Vector wsp(n); for (uint i = 0; i < n; ++i) wsp[i] = rnorm_mt(rng, 0, 1); return Lmult(L, wsp) + mu; }
static int hasComma(struct ParseData *d) { const char *save = d->str; wsp(d); int result = (*d->str == ','); d->str = save; return result; }
void WritePolicy::process(OutputContext& output) { idx state_count = policy.getStateCount(); RL::WriteSinglePolicy wsp(policy,0); for(idx i = 0; i < state_count; i++) { wsp.setStateIndex(i); wsp.process(output); } }
//---------------------------- // Differentiation Methods //---------------------------- void StdExpansion2D::PhysTensorDeriv(const Array<OneD, const NekDouble>& inarray, Array<OneD, NekDouble> &outarray_d0, Array<OneD, NekDouble> &outarray_d1) { int nquad0 = m_base[0]->GetNumPoints(); int nquad1 = m_base[1]->GetNumPoints(); if (outarray_d0.num_elements() > 0) // calculate du/dx_0 { DNekMatSharedPtr D0 = m_base[0]->GetD(); if(inarray.data() == outarray_d0.data()) { Array<OneD, NekDouble> wsp(nquad0 * nquad1); Vmath::Vcopy(nquad0 * nquad1,inarray.get(),1,wsp.get(),1); Blas::Dgemm('N', 'N', nquad0, nquad1, nquad0, 1.0, &(D0->GetPtr())[0], nquad0, &wsp[0], nquad0, 0.0, &outarray_d0[0], nquad0); } else { Blas::Dgemm('N', 'N', nquad0, nquad1, nquad0, 1.0, &(D0->GetPtr())[0], nquad0, &inarray[0], nquad0, 0.0, &outarray_d0[0], nquad0); } } if (outarray_d1.num_elements() > 0) // calculate du/dx_1 { DNekMatSharedPtr D1 = m_base[1]->GetD(); if(inarray.data() == outarray_d1.data()) { Array<OneD, NekDouble> wsp(nquad0 * nquad1); Vmath::Vcopy(nquad0 * nquad1,inarray.get(),1,wsp.get(),1); Blas:: Dgemm('N', 'T', nquad0, nquad1, nquad1, 1.0, &wsp[0], nquad0, &(D1->GetPtr())[0], nquad1, 0.0, &outarray_d1[0], nquad0); } else { Blas:: Dgemm('N', 'T', nquad0, nquad1, nquad1, 1.0, &inarray[0], nquad0, &(D1->GetPtr())[0], nquad1, 0.0, &outarray_d1[0], nquad0); } } }
static void numbers(struct ParseData *d, int alignment, int multiple, kvec_float_t *v) { int i; wsp(d); for (;;) { for (i = 0; i < alignment; ++i) { if (i == 0) { kv_push_back(*v, number(d)); } else { comma(d); kv_push_back(*v, number(d)); } } if (!multiple) break; if (hasComma(d)) { comma(d); continue; } wsp(d); if (!hasNumber(d)) break; } }
/** * The operation is evaluated locally (i.e. with respect to all local * expansion modes) by the function ExpList#IProductWRTBase. The inner * product with respect to the global expansion modes is than obtained * by a global assembly operation. * * The values of the function \f$f(x)\f$ evaluated at the quadrature * points \f$x_i\f$ should be contained in the variable #m_phys of the * ExpList object \a in. The result is stored in the array * #m_coeffs. * * @param In An ExpList, containing the discrete evaluation * of \f$f(x)\f$ at the quadrature points in its * array #m_phys. */ void ContField1D::IProductWRTBase( const Array<OneD, const NekDouble> &inarray, Array<OneD, NekDouble> &outarray, CoeffState coeffstate) { if(coeffstate == eGlobal) { Array<OneD, NekDouble> wsp(m_ncoeffs); IProductWRTBase_IterPerExp(inarray,wsp); Assemble(wsp,outarray); } else { IProductWRTBase_IterPerExp(inarray,outarray); } }
/** * Given a function \f$f(x)\f$ defined at the quadrature * points, this function determines the unknown global coefficients * \f$\boldsymbol{\hat{u}}^{\mathcal{H}}\f$ employing a discrete * Galerkin projection from physical space to coefficient * space. The operation is evaluated by the function #GlobalSolve using * the global mass matrix. * * The values of the function \f$f(x)\f$ evaluated at the * quadrature points \f$x_i\f$ should be contained in the * variable #m_phys of the ExpList object \a Sin. The resulting global * coefficients \f$\hat{u}_g\f$ are stored in the array #m_coeffs. * * @param inarray Discrete \f$f(x)\f$. * @param outarray Storage for result. * @param coeffstate */ void ContField1D::FwdTrans(const Array<OneD, const NekDouble> &inarray, Array<OneD, NekDouble> &outarray, CoeffState coeffstate) { // Inner product of forcing Array<OneD,NekDouble> wsp(m_ncoeffs); IProductWRTBase(inarray,wsp,eGlobal); // Solve the system GlobalLinSysKey key(StdRegions::eMass, m_locToGloMap); GlobalSolve(key,wsp,outarray); if(coeffstate == eLocal) { GlobalToLocal(outarray,outarray); } }
/** * Consider the one dimensional Helmholtz equation, * \f[\frac{d^2u}{dx^2}-\lambda u(x) = f(x),\f] * supplemented with appropriate boundary conditions (which are * contained in the data member #m_bndCondExpansions). Applying a * \f$C^0\f$ continuous Galerkin discretisation, this equation leads to * the following linear system: * \f[\left( \boldsymbol{M}+\lambda\boldsymbol{L}\right) * \boldsymbol{\hat{u}}_g=\boldsymbol{\hat{f}}\f] * where \f$\boldsymbol{M}\f$ and \f$\boldsymbol{L}\f$ are the mass and * Laplacian matrix respectively. This function solves the system above * for the global coefficients \f$\boldsymbol{\hat{u}}\f$ by a call to * the function #GlobalSolve. * * The values of the function \f$f(x)\f$ evaluated at the * quadrature points \f$\boldsymbol{x}_i\f$ should be contained in the * variable #m_phys of the ExpList object \a inarray. The resulting * global coefficients \f$\boldsymbol{\hat{u}}_g\f$ are stored in the * array #m_coeffs. * * @param inarray Input containing forcing function * \f$\boldsymbol{f}\f$ at the quadrature points. * @param outarray Output containing the coefficients * \f$\boldsymbol{u}_g\f$ * @param lambda Parameter value. * @param Sigma Coefficients of lambda. * @param varcoeff Variable diffusivity coefficients. * @param coeffstate * @param dirForcing Dirichlet Forcing. */ void ContField1D::v_HelmSolve( const Array<OneD, const NekDouble> &inarray, Array<OneD, NekDouble> &outarray, const FlagList &flags, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const Array<OneD, const NekDouble> &dirForcing) { // Inner product of forcing int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs(); Array<OneD,NekDouble> wsp(contNcoeffs); IProductWRTBase(inarray,wsp,eGlobal); // Note -1.0 term necessary to invert forcing function to // be consistent with matrix definition Vmath::Neg(contNcoeffs, wsp, 1); // Forcing function with weak boundary conditions int i; for(i = 0; i < m_bndCondExpansions.num_elements(); ++i) { if(m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::eDirichlet) { wsp[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(i)] += m_bndCondExpansions[i]->GetCoeff(0); } } // Solve the system GlobalLinSysKey key(StdRegions::eHelmholtz, m_locToGloMap,factors,varcoeff); if(flags.isSet(eUseGlobal)) { GlobalSolve(key,wsp,outarray,dirForcing); } else { Array<OneD,NekDouble> tmp(contNcoeffs,0.0); GlobalSolve(key,wsp,tmp,dirForcing); GlobalToLocal(tmp,outarray); } }
// Computes matrix exponential for dense input H SEXP R_dgpadm(SEXP ideg, SEXP m_, SEXP t, SEXP H, SEXP ldh) { int m = INTEGER(m_)[0]; int ns = 0, iflag = 0; int lwsp = 4*m*m + INTEGER(ideg)[0] + 1; Rcpp::NumericVector wsp(lwsp); Rcpp::IntegerVector ipiv(m); Rcpp::IntegerVector iexph(1); Rcpp::List ret; wrapdgpadm_(INTEGER(ideg), &m, REAL(t), REAL(H), INTEGER(ldh), REAL(wsp), &lwsp, INTEGER(ipiv), INTEGER(iexph), &ns, &iflag); //FIXME you should really be checking the iflag return... ret["wsp"] = wsp; ret["ind"] = iexph; return ret; }
void StdExpansion1D::PhysTensorDeriv(const Array<OneD, const NekDouble>& inarray, Array<OneD, NekDouble>& outarray) { int nquad = GetTotPoints(); DNekMatSharedPtr D = m_base[0]->GetD(); #ifdef NEKTAR_USING_DIRECT_BLAS_CALLS if( inarray.data() == outarray.data()) { Array<OneD, NekDouble> wsp(nquad); CopyArray(inarray, wsp); Blas::Dgemv('N',nquad,nquad,1.0,&(D->GetPtr())[0],nquad, &wsp[0],1,0.0,&outarray[0],1); } else { Blas::Dgemv('N',nquad,nquad,1.0,&(D->GetPtr())[0],nquad, &inarray[0],1,0.0,&outarray[0],1); } #else //NEKTAR_USING_DIRECT_BLAS_CALLS NekVector<NekDouble> out(nquad,outarray,eWrapper); if(inarray.data() == outarray.data()) // copy intput array { NekVector<NekDouble> in(nquad,inarray,eCopy); out = (*D)*in; } else { NekVector<NekDouble> in (nquad,inarray,eWrapper); out = (*D)*in; } #endif //NEKTAR_USING_DIRECT_BLAS_CALLS }