extern "C" DLL_EXPORT DLL_EXPORT void _cdecl DoCCallBack_LPSTR_OutByRef(CCallBackOutByRef callback) { int len = 10; LPSTR pStr = (LPSTR)CoTaskMemAlloc(len); if(!CheckInput(callback(&pStr))) { ReportFailure("DoCCallBack_LPSTR_OutByRef:NativeSide,the first Check"); } if(!CheckInput(pStr)) { ReportFailure("DoCCallBack_LPSTR_OutByRef:NativeSide,the Second Check"); } CoTaskMemFree(pStr); }
extern "C" DLL_EXPORT void __cdecl DoSCallBack_LPSTR_OutByRef(SCallBackOutByRef callback) { size_t len = 10; LPSTR pStr = (LPSTR)CoreClrAlloc(len); if (!CheckInput(callback(&pStr))) { ReportFailure("DoSCallBack_LPSTR_OutByRef:NativeSide,the first check"); } if (!CheckInput(pStr)) { ReportFailure("DoSCallBack_LPSTR_OutByRef:NativeSide,the second Check"); } CoreClrFree(pStr); }
int main(void) { int h; // initialize a flag bool flag = false; // keep asking for input until it's vaild do { // ask for the height printf("height: "); // record users' input h = GetInt(); // check the input flag = CheckInput(h); } while (flag == false); // draw the chart DrawChart(h); return 0; }
int IdConverter::Convert(std::string & id_in, std::string & id_out) { // sanity check if(int rc = CheckInput(id_in)) { return rc; } // convert id_out = ""; for(size_t ipos = 0; ipos < id_in.size(); ) { if(id_in[ipos + 2] != delimr) { // one-token group if(id_in.compare(ipos, 2, "Z9") == 0) { id_out += "A1-A1"; } else { // increment token char token[8]; IncrementToken(id_in, ipos, token); id_out += token; } ipos += 2; } else { // two-token group if(id_in.compare(ipos, 5, "Z9-Z9") == 0) { // can not be incremented more return 3; } if(id_in.compare(ipos + 3, 2, "Z9") == 0) { // first token should be incremented char token[8]; IncrementToken(id_in, ipos, token); id_out += token; // second token will be "A1" id_out += "-A1"; } else { // increment second token only char token[8]; IncrementToken(id_in, ipos + 3, token); id_out += id_in.substr(ipos, 3); id_out += token; } ipos += 5; } } return 0; }
void CMainMenu::Update(const SUIInput& a_rInput) { if (m_GoingIntoGame) { float half = CPostEffects::GameStartTime / 2.0f; m_CurrentTime += twTime->GetDeltaTime(); float value = m_CurrentTime / half; ((triebWerk::CUIDrawable*)(m_pBackground->GetDrawable()))->m_Material.m_ConstantBuffer.SetValueInBuffer(4, &value); if (m_CurrentTime >= half) { twSceneManager->SetActiveScene("Game"); m_GoingIntoGame = false; m_CurrentTime = 0.0f; } return; } else if (m_LerpToExtras) LerpToExtras(); else if (m_LerpFromExtras) LerpFromExtras(); if (CGameInfo::Instance().m_Menu == EMenus::Main) { ((triebWerk::CFontDrawable*)m_pTextExtras->GetDrawable())->m_pText->SetText("Extras"); CheckInput(a_rInput); } UpdateGraphics(); }
void Example::prepare(float dt) { CheckInput(); DeltaTime = dt; ModelSky->m_RotateY+=(SPEED*DeltaTime); const float ROTSPEED = 50.0f; if(rotate) m_rotationAngle += ROTSPEED * dt; if (m_rotationAngle > 360.0f) m_rotationAngle -= 360.0f; m_angle += 2.0f * dt; if (m_angle > 360.0f) m_angle -= 360.0f; const float LIGHT_SPEED = 0.0005f; m_lightPosZ += LIGHT_SPEED; m_GLSLProgram->sendUniform("time", timer); }
void auto_smzdm::onStart() { if (!CheckInput()) { return; } UpdateData(); control_status = true; ui.lineEdit_msg->setText(QStringLiteral("运行中")); QString msg = QStringLiteral("运行中"); int count = 0; while( control_status ) { QString temp = msg; smzdm_run(); count ++; QString temp2; temp2.setNum(count); ui.lineEdit_msg->setText(temp + temp2); QElapsedTimer t; t.start(); while(t.elapsed()<1000) QCoreApplication::processEvents(); } }
// Open the Shop NamedScript KeyBind void OpenShop(bool OpenLocker) { // If you're dead, return if (GetActorProperty(0, APROP_Health) <= 0) return; // If you're in an Outpost menu, return if (Player.OutpostMenu > 0) return; // If you're in any minigames, return if (Player.InMinigame) return; // If you're looking inside a crate, return if (Player.CrateOpen) return; // Close the main menu if it's open Player.InMenu = false; // Sanity check for pressing use while the shop is open in front of the counter in the Outpost if (Player.InShop && CheckInput(BT_USE, KEY_HELD, false, PlayerNumber())) return; if (Player.InShop) { ActivatorSound("menu/leave", 127); SetPlayerProperty(0, 0, PROP_TOTALLYFROZEN); Player.InShop = false; } else { ActivatorSound("menu/shop", 127); Player.InShop = true; if (OpenLocker) Player.LockerMode = true; } }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) { double tau, rownorm; double *W, *W_thresh, *nz; long p, K, ik, ip, pK; CheckInput(nlhs, plhs, nrhs, prhs); p=mxGetM(prhs[0]); /* # row */ K=mxGetN(prhs[0]); /* # col */ W=mxGetPr(prhs[0]); /* pointer to the input array */ tau=mxGetScalar(prhs[1]); plhs[0]=mxCreateDoubleMatrix(p,K,mxREAL); /* output p x K array */ W_thresh=mxGetPr(plhs[0]); /* pointer to the data W_thresh*/ pK=p*K; for (ip=0; ip<p; ip++) { /* compute the 2-norm of the ip-th row */ for (ik=0, rownorm=0.0; ik<K; ik++) rownorm+=W[ip+p*ik]*W[ip+p*ik]; /* W(ip+1,ik+1)=W[ip + p*ik], ip=0,...,p, ik=0,...,K */ rownorm=sqrt(rownorm); /* perform row-wise group-thresholding */ if (rownorm > tau){ for (ik=0; ik<K; ik++) W_thresh[ip+p*ik]=W[ip+p*ik]*(1-tau/rownorm); /* W(ip+1,ik+1)=W[ip + p*ik], ip=0,...,p, ik=0,...,K */ } else { for (ik=0; ik<K; ik++) W_thresh[ip+p*ik]=0; /* W(ip+1,ik+1)=W[ip + p*ik], ip=0,...,p, ik=0,...,K */ } } }
// This is called every 4096 nodes to check if we have run out of time // or if we have been interrupted by the GUI static void CheckUp(searchinfo_t *sinfo) { if(sinfo->infinite == false && GetTime() >= sinfo->stopTime){ sinfo->stop = true; } CheckInput(sinfo); }
void BiasAdderNet::Execute() { CheckInput(); const Blob* const input = this->input_blobs(0); const Blob* const bias = this->params(0); Blob* const output = this->output_blobs(0); int channels = bias->channels(); CHECK_EQ(channels, input->channels()); int height = input->height(); int width = input->width(); int num = input->num(); LOG(DEBUG) << "input blob: (" << num << "," << input->channels() << "," << height << "," << width << ")"; LOG(DEBUG) << "bias blob: (" << bias->num() << "," << bias->channels() << "," << bias->height() << "," << bias->width() << ")"; float* const dst_head = new float[num*channels*height*width]; int size = height * width; for (int n = 0, offset = 0; n < num; ++n) { for (int ichannel = 0; ichannel < channels; ++ichannel) { for(int i = 0; i < size; ++i, ++offset) { dst_head[offset] = (*input)[offset] + (*bias)[ichannel]; } } } output->CopyData(num, channels, height, width, dst_head); delete []dst_head; CheckOutput(); }
extern "C" DLL_EXPORT void __cdecl DoCCallBack_LPSTR_Out(CCallBackOut callback) { size_t len = 10; LPSTR pStr = (LPSTR)CoreClrAlloc(len); //Check the return value if (!CheckInput(callback(pStr))) { ReportFailure("DoCCallBack_LPSTR_Out:NativeSide,the first check"); } if (!CheckInput(pStr)) { ReportFailure("DoCCallBack_LPSTR_Out:NativeSide,the Second Check"); } CoreClrFree(pStr); }
/** * * Main function of this program. * */ int main() { float input; float input_cents; do { // Get the user input printf("O hai! How much change is owed?\n"); input = GetFloat(); // Validate the user input if(CheckInput(input) == FALSE) { continue; } }while(input < 0.0); // Convert to cents input_cents = (float)round(input * 100); // Lets Start int number_of_coins = 0; while(input_cents > 0.0) { //printf("input_cents=%f\n",input_cents); if(input_cents >= QUATAR) { // This means the input is can be subtracted by a QUATAR input_cents = input_cents - QUATAR; number_of_coins++; } else if(input_cents < QUATAR && input_cents >= DIME) { // This means the input is can be subtracted by a DIME input_cents = input_cents - DIME; number_of_coins++; } else if(input_cents < DIME && input_cents >= NICKEL) { // This means the input is can be subtracted by a NICKEL input_cents = input_cents - NICKEL; number_of_coins++; } else { // This means remaining are PENNIES. So just add as many number of pennies. number_of_coins = number_of_coins + input_cents; input_cents = 0; } } printf("%d\n", number_of_coins); // Good Bye return 0; }
void InputDialog::on_btnOK_clicked() { if(CheckInput()) { strResult = ui->lnInput->text(); done(QDialog::Accepted); } }
extern "C" DLL_EXPORT DLL_EXPORT void _cdecl DoSCallBack_LPSTR_InOut(SCallBackInOut callback) { const char* pTemp = "AAAA"; int len = strlen(pTemp)+1; LPSTR pStr = (LPSTR)CoTaskMemAlloc(len); strncpy(pStr,pTemp,len); if(!CheckInput(callback(pStr))) { ReportFailure("DoSCallBack_LPSTR_InOut:NativeSide,the first check"); } if(!CheckInput(pStr)) { ReportFailure("DoSCallBack_LPSTR_InOut:NativeSide,the second Check"); } CoTaskMemFree(pStr); }
extern "C" DLL_EXPORT void __cdecl DoSCallBack_LPSTR_InOutByRef(SCallBackInOutByRef callback) { const char* pTemp = "AAAA"; size_t len = strlen(pTemp) + 1; LPSTR pStr = (LPSTR)CoreClrAlloc(len); strncpy(pStr, pTemp, len); if (!CheckInput(callback(&pStr))) { ReportFailure("DoSCallBack_LPSTR_InOutByRef:NativeSide,the first check"); } if (!CheckInput(pStr)) { ReportFailure("DoSCallBack_LPSTR_InOutByRef:NativeSide,the second Check"); } CoreClrFree(pStr); }
void MaxPoolingNet::Execute() { // *** Argument *** // const float MIN_THRESHOLD = 0.0f; // *** // CheckInput(); const Blob* const input = this->input_blobs(0); Blob* const output = this->output_blobs(0); int src_h = input->height(); int src_w = input->width(); int num = input->num(); int channels = input->channels(); int dst_h = static_cast<int>(ceil(static_cast<float>( src_h - kernel_h_) / stride_h_)) + 1; int dst_w = static_cast<int>(ceil(static_cast<float>( src_w - kernel_w_) / stride_w_)) + 1; int dst_count = num * channels * dst_h * dst_w; float* const dst_head = new float[dst_count]; const float* src_data = input->data().get(); float* dst_data = dst_head; int src_channel_off = src_h * src_w; int dst_channel_off = dst_h * dst_w; for (int n = 0; n < num; ++n) { for (int c = 0; c < channels; ++c) { for (int dh = 0, hstart = 0; dh < dst_h; ++dh, hstart += stride_h_) { int hend = std::min(hstart + kernel_h_, src_h); for (int dw = 0, wstart = 0; dw < dst_w; ++dw, wstart += stride_w_) { int wend = std::min(wstart + kernel_w_, src_w); int didx = dh * dst_w + dw; float max_val = MIN_THRESHOLD; for (int sh = hstart; sh < hend; ++sh) { for (int sw = wstart; sw < wend; ++sw) { int sidx = sh * src_w + sw; if (src_data[sidx] > max_val) { max_val = src_data[sidx]; } } // for sw } // for sh dst_data[didx] = max_val; } // for dw } // for dh src_data += src_channel_off; dst_data += dst_channel_off; } // for c } // for n output->CopyData(num, channels, dst_h, dst_w, dst_head); delete[] dst_head; CheckOutput(); }
inline void LocalTrrkKernel ( UpperOrLower uplo, Orientation orientationOfA, Orientation orientationOfB, T alpha, const DistMatrix<T,STAR,MC >& A, const DistMatrix<T,MR, STAR>& B, T beta, DistMatrix<T,MC, MR >& C ) { #ifndef RELEASE PushCallStack("LocalTrrkKernel"); CheckInput( orientationOfA, orientationOfB, A, B, C ); #endif const Grid& g = C.Grid(); DistMatrix<T,STAR,MC> AL(g), AR(g); DistMatrix<T,MR,STAR> BT(g), BB(g); DistMatrix<T,MC,MR> CTL(g), CTR(g), CBL(g), CBR(g); DistMatrix<T,MC,MR> DTL(g), DBR(g); const int half = C.Height()/2; ScaleTrapezoid( beta, LEFT, uplo, 0, C ); LockedPartitionRight( A, AL, AR, half ); LockedPartitionDown ( B, BT, BB, half ); PartitionDownDiagonal ( C, CTL, CTR, CBL, CBR, half ); DTL.AlignWith( CTL ); DBR.AlignWith( CBR ); DTL.ResizeTo( CTL.Height(), CTL.Width() ); DBR.ResizeTo( CBR.Height(), CBR.Width() ); //------------------------------------------------------------------------// if( uplo == LOWER ) internal::LocalGemm ( orientationOfA, orientationOfB, alpha, AR, BT, T(1), CBL ); else internal::LocalGemm ( orientationOfA, orientationOfB, alpha, AL, BB, T(1), CTR ); internal::LocalGemm ( orientationOfA, orientationOfB, alpha, AL, BT, T(0), DTL ); AxpyTriangle( uplo, T(1), DTL, CTL ); internal::LocalGemm ( orientationOfA, orientationOfB, alpha, AR, BB, T(0), DBR ); AxpyTriangle( uplo, T(1), DBR, CBR ); //------------------------------------------------------------------------// #ifndef RELEASE PopCallStack(); #endif }
void CHSNumEdit::OnChar (UINT nChar, UINT nRepCnt, UINT nFlags) { if( !isdigit(nChar) && nChar != 8 && nChar != '.' && nChar != '-' && nChar != '+' ) return; CString strWin; GetWindowText(strWin); CEdit::OnChar(nChar,nRepCnt,nFlags); CString strCurText; GetWindowText(strCurText); if( !CheckInput(strCurText) ) { SetWindowText(strWin); } /* if( isdigit(nChar) && CheckInput(nChar) ) CEdit::OnChar(nChar,nRepCnt,nFlags); else { CString txt; GetWindowText(txt); switch (nChar) { case '+' : // set to absolute value { double x = (double) atof(txt); if (x > 0) break; // only break if we already >0, else do "case -" } case '-' : // change sign. { double x = (double) atof(txt); // if(x == 0) // { // ::MessageBeep(MB_ICONQUESTION); // break; // } x = -x; SetValue(x); break; } case '.' : if ( txt.Find('.') == -1 && CheckInput(nChar)) CEdit::OnChar(nChar, nRepCnt, nFlags); break; case VK_BACK: CEdit::OnChar(nChar, nRepCnt, nFlags); break; } } */ }
void DialogInputFileNameForm::ApplyButtonPressed() { //Check the input bool inputOk = CheckInput(); //If the input is ok cloase the dialog with accedpted if(inputOk) { QDialog::accept(); } }
CHARLS_IMEXPORT(JLS_ERROR) JpegLsEncodeStream(ByteStreamInfo compressedStreamInfo, size_t* pcbyteWritten, ByteStreamInfo rawStreamInfo, struct JlsParameters* pparams) { if (pcbyteWritten == NULL) return InvalidJlsParameters; JLS_ERROR parameterError = CheckInput(rawStreamInfo, pparams); if (parameterError != OK) return parameterError; try { JlsParameters info = *pparams; if (info.bytesperline == 0) { info.bytesperline = info.width * ((info.bitspersample + 7)/8); if (info.ilv != ILV_NONE) { info.bytesperline *= info.components; } } Size size = Size(info.width, info.height); JpegMarkerWriter writer(info.jfif, size, info.bitspersample, info.components); if (info.colorTransform != 0) { writer.AddColorTransform(info.colorTransform); } if (info.ilv == ILV_NONE) { LONG cbyteComp = size.cx*size.cy*((info.bitspersample +7)/8); for (LONG component = 0; component < info.components; ++component) { writer.AddScan(rawStreamInfo, &info); SkipBytes(&rawStreamInfo, cbyteComp); } } else { writer.AddScan(rawStreamInfo, &info); } writer.Write(compressedStreamInfo); *pcbyteWritten = writer.GetBytesWritten(); return OK; } catch (const JlsException& e) { return e._error; } }
bool PlayerObject::Update() { if (m_moving) Move(); else CheckInput(); m_animManager->Update(m_position); UpdateViewPosition(); return false; }
extern "C" DLL_EXPORT DLL_EXPORT void _cdecl DoCCallBack_LPSTR_InByRef(CallBackInByRef callback) { const char* pTemp = "AAAA"; int len = strlen(pTemp)+1; LPSTR pStr = (LPSTR)CoTaskMemAlloc(len); strncpy(pStr,pTemp,len); if(!CheckInput(callback(&pStr))) { ReportFailure("DoCCallBack_LPSTR_InByRef:NativeSide"); } CoTaskMemFree(pStr); }
extern "C" DLL_EXPORT void __cdecl DoCCallBack_LPSTR_In(CCallBackIn callback) { const char* pTemp = "AAAA"; size_t len = strlen(pTemp)+1; LPSTR pStr = (LPSTR)CoreClrAlloc(len); strncpy(pStr,pTemp,len); if(!CheckInput(callback(pStr))) { ReportFailure("DoCCallBack_LPSTR_In:NativeSide"); } CoreClrFree(pStr); }
extern "C" DLL_EXPORT LPSTR STDMETHODCALLTYPE SLPStr_InByRef(LPSTR* ppStr) { //Check the Input if (!CheckInput(*ppStr)) { ReportFailure("SLPStr_InByRef:NativeSide"); } //alloc,copy, since we cannot depend the Marshaler's activity. size_t len = strlen(*ppStr) + 1; //+1, Include the NULL Character. LPSTR pBack = (LPSTR)CoreClrAlloc(len); strncpy(pBack, *ppStr, len); return pBack; }
// ---------------------------------------------------------------- int main(int argc, char* argv[]) { Start(); while(CheckInput()) { MoveStuff(); Draw(); } Finish(); return(EXIT_SUCCESS); }
CHARLS_IMEXPORT JLS_ERROR JpegLsEncode(void* pdataCompressed, size_t cbyteBuffer, size_t* pcbyteWritten, const void* pdataUncompressed, size_t cbyteUncompressed, const JlsParamaters* pparams) { JlsParamaters info = *pparams; if(info.bytesperline == 0) { info.bytesperline = info.width * ((info.bitspersample + 7)/8); if (info.ilv != ILV_NONE) { info.bytesperline *= info.components; } } JLS_ERROR parameterError = CheckInput(pdataCompressed, cbyteBuffer, pdataUncompressed, cbyteUncompressed, &info); if (parameterError != OK) return parameterError; if (pcbyteWritten == NULL) return InvalidJlsParameters; Size size = Size(info.width, info.height); LONG cbit = info.bitspersample; JLSOutputStream stream; stream.Init(size, info.bitspersample, info.components); if (info.colorTransform != 0) { stream.AddColorTransform(info.colorTransform); } if (info.ilv == ILV_NONE) { LONG cbyteComp = size.cx*size.cy*((cbit +7)/8); for (LONG icomp = 0; icomp < info.components; ++icomp) { const BYTE* pbyteComp = static_cast<const BYTE*>(pdataUncompressed) + icomp*cbyteComp; stream.AddScan(pbyteComp, &info); } } else { stream.AddScan(pdataUncompressed, &info); } stream.Write((BYTE*)pdataCompressed, cbyteBuffer); *pcbyteWritten = stream.GetBytesWritten(); return OK; }
extern "C" DLL_EXPORT LPSTR __stdcall SLPStr_InOutByRef(LPSTR* ppStr) { //Check the Input if(!CheckInput(*ppStr)) { ReportFailure("SLPStr_InOutByRef:NativeSide"); } //alloc,copy, since we cannot depend the Marshaler's activity. int len = strlen(*ppStr)+ 1 ; //+1, Include the NULL Character. LPSTR pBack = (LPSTR)CoTaskMemAlloc(len); strncpy(pBack,*ppStr,len); return pBack; }
CHARLS_IMEXPORT(JLS_ERROR) JpegLsEncode(void* compressedData, size_t compressedLength, size_t* pcbyteWritten, const void* uncompressedData, size_t uncompressedLength, struct JlsParameters* pparams) { JlsParameters info = *pparams; if(info.bytesperline == 0) { info.bytesperline = info.width * ((info.bitspersample + 7)/8); if (info.ilv != ILV_NONE) { info.bytesperline *= info.components; } } JLS_ERROR parameterError = CheckInput(compressedData, compressedLength, uncompressedData, uncompressedLength, &info); if (parameterError != OK) return parameterError; if (pcbyteWritten == NULL) return InvalidJlsParameters; Size size = Size(info.width, info.height); JLSOutputStream stream; stream.Init(size, info.bitspersample, info.components); if (info.colorTransform != 0) { stream.AddColorTransform(info.colorTransform); } if (info.ilv == ILV_NONE) { LONG cbyteComp = size.cx*size.cy*((info.bitspersample +7)/8); for (LONG component = 0; component < info.components; ++component) { const BYTE* compareData = static_cast<const BYTE*>(uncompressedData) + component*cbyteComp; stream.AddScan(compareData, &info); } } else { stream.AddScan(uncompressedData, &info); } stream.Write((BYTE*)compressedData, compressedLength); *pcbyteWritten = stream.GetBytesWritten(); return OK; }
void QmitkAICPRegistrationView::OnStartRegistration() { d->m_Threshold = m_Controls.m_ThresholdSpinbox->value(); d->m_MaxIterations = m_Controls.m_MaxIterationsSpinbox->value(); d->m_SearchRadius = m_Controls.m_SearchRadius->value(); d->m_TrimmFactor = 0.0; if ( m_Controls.m_EnableTrimming->isChecked() ) { d->m_TrimmFactor = m_Controls.m_TrimmFactorSpinbox->value(); } if (! CheckInput() ) return; d->m_MovingSurface = dynamic_cast<mitk::Surface*>( m_Controls.m_MovingSurfaceComboBox->GetSelectedNode()->GetData() ); d->m_FixedSurface = dynamic_cast<mitk::Surface*>( m_Controls.m_FixedSurfaceComboBox->GetSelectedNode()->GetData() ); // sanity check if ( d->m_FixedSurface.IsNull() || d->m_MovingSurface.IsNull() ) { const char* message = "Input surfaces are NULL."; QMessageBox msg; msg.setIcon(QMessageBox::Critical); msg.setText(message); MITK_ERROR << message; return; } // enable trimming if ( m_Controls.m_EnableTrimming->isChecked() ) { d->m_TrimmFactor = m_Controls.m_TrimmFactorSpinbox->value(); } // set data into the UI thread d->m_Worker->SetRegistrationData(d); // start thread d->m_RegistrationThread->start(); // disable registration button m_Controls.m_RegisterSurfaceButton->setEnabled(false); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }