BOOL CSetKDataDlg::StoreKData( CString strStockCode ) { if( strStockCode.GetLength() <= 0 ) return FALSE; UpdateData( ); if( m_tmDate.GetTime() == -1 ) return FALSE; if( !IsNumber(m_strOpen,FALSE) || !IsNumber(m_strHigh,FALSE) || !IsNumber(m_strLow,FALSE) || !IsNumber(m_strClose,FALSE) ) { AfxMessageBox( IDS_SETKDATA_NOTNUMBER ); return FALSE; } DWORD dwMarket = CStock::marketUnknown; CStockInfo info; if( info.SetStockCode(dwMarket, strStockCode) ) dwMarket = info.GetMarket(); int nKType = m_comboKType.GetSelect(); CSPTime sptime = m_tmDate.GetTime(); KDATA kd; memset( &kd, 0, sizeof(kd) ); kd.m_dwMarket = dwMarket; strncpy( kd.m_szCode, strStockCode, min(sizeof(kd.m_szCode)-1,strStockCode.GetLength()) ); kd.m_time = m_tmDate.GetTime(); kd.m_date = sptime.ToStockTime(CKData::IsDayOrMin(nKType)); kd.m_fOpen = (float)atof(m_strOpen); kd.m_fHigh = (float)atof(m_strHigh); kd.m_fLow = (float)atof(m_strLow); kd.m_fClose = (float)atof(m_strClose); kd.m_fVolume = (float)m_dwVolume*100; kd.m_fAmount = (float)m_dwAmount*1000; CKData kdata(nKType); kdata.Add( kd ); AfxGetDB().InstallKData( kdata ); return TRUE; }
void read_options_freefem (string string_option, superlu_options_t *options) { static const yes_no_t enumyes_no_t[2] = {NO, YES}; static const fact_t enumfact_t[4] = {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED}; static const colperm_t enumcolperm_t[5] = {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}; static const trans_t enumtrans_t[3] = {NOTRANS, TRANS, CONJ}; static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA}; static const char *compyes_no_t [] = {"NO", "YES", 0}; static const char *compfact_t [] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED", 0}; static const char *compcolperm_t [] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0}; static const char *comptrans_t [] = {"NOTRANS", "TRANS", "CONJ", 0}; static const char *compIterRefine_t [] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0}; static const char *comp [] = {"Fact", "Equil", "ColPerm", "DiagPivotThresh", "Trans", "IterRefine", "SymmetricMode", "PivotGrowth", "ConditionNumber", "PrintStat", 0}; /* Set the default values for options argument: * options.Fact = DOFACT; * options.Equil = YES; * options.ColPerm = COLAMD; * options.DiagPivotThresh = 1.0; * options.Trans = NOTRANS; * options.IterRefine = NOREFINE; * options.SymmetricMode = NO; * options.PivotGrowth = NO; * options.ConditionNumber = NO; * options.PrintStat = YES; */ // cout << "string_option" << *string_option << endl; KN<char> kdata(string_option.size() + 1); char *data = kdata; strcpy(data, string_option.c_str()); cout << "data=" << data << endl; char *tictac; tictac = strtok(data, " =,\t\n"); cout << "tictac=" << data << endl; // #ifdef __cplusplus // while(tictac != NULL){ // int id_option = s_(tictac, "Fact", "Equil","ColPerm", // "DiagPivotThresh","Trans","IterRefine", // "SymmetricMode","PivotGrowth","ConditionNumber", // "PrintStat",0); // tictac = strtok(NULL," ,\t\n"); // int val_options; // switch (id_option) // { // case 1 : // Fact // val_options= s_(tictac, "DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","Fact"); // exit(1); // } // options->Fact= enumfact_t[val_options-1]; // break; // case 2: // Equil // val_options= s_(tictac, "NO", "YES", 0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","Equil"); // exit(1); // } // options->Equil= enumyes_no_t[val_options-1]; // break; // case 3: // ColPerm // val_options= s_(tictac,"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","ColPerm"); // exit(1); // } // options->ColPerm= enumcolperm_t[val_options-1]; // case 4: // DiagPivotThresh // options->DiagPivotThresh= strtod(tictac,&tictac); // break; // case 5: // Trans // val_options= s_(tictac, "NOTRANS", "TRANS", "CONJ",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","Trans"); // exit(1); // } // options->Trans= enumtrans_t[val_options-1]; // break; // case 6: // IterRefine // val_options= s_(tictac, "NOREFINE", "SINGLE", "DOUBLE", "EXTRA",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","IterRefine"); // exit(1); // } // options->IterRefine= enumIterRefine_t[val_options-1]; // break; // case 7: // SymmetricMode // val_options= s_(tictac, "NO","YES",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","SymmetricMode"); // exit(1); // } // options->SymmetricMode= enumyes_no_t[val_options-1]; // break; // case 8: // PivotGrowth // val_options= s_(tictac, "NO","YES",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","PivotGrowth"); // exit(1); // } // options->PivotGrowth= enumyes_no_t[val_options-1]; // break; // case 9: // ConditionNumber // val_options= s_(tictac, "NO","YES",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","ConditionNumber"); // exit(1); // } // options->ConditionNumber = enumyes_no_t[val_options-1]; // break; // case 10: // PrintStat // val_options= s_(tictac, "NO","YES",0); // if( val_options == 0){ // printf("value given for SuperLU for options %s is not correct\n","PrintStat"); // exit(1); // } // options->PrintStat = enumyes_no_t[val_options-1]; // break; // case 0: // Equivalent of case default // printf("A false parameter for SuperLU is given %s \n",tictac); // exit(1); // } // tictac = strtok(NULL," ,\t\n"); // } // #else while (tictac != NULL) { // char* comp[] = {"Fact", "Equil","ColPerm", // "DiagPivotThresh","Trans","IterRefine", // "SymmetricMode","PivotGrowth","ConditionNumber", // "PrintStat",0 }; int id_option = s_(tictac, comp); tictac = strtok(NULL, " =,\t\n"); int val_options; switch (id_option) { case 1: // Fact // char* comp1[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0}; val_options = s_(tictac, compfact_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "Fact"); exit(1); } options->Fact = enumfact_t[val_options - 1]; break; case 2: // Equil // char* comp2[] = {"NO", "YES", 0}; val_options = s_(tictac, compyes_no_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "Equil"); exit(1); } options->Equil = enumyes_no_t[val_options - 1]; break; case 3: // ColPerm // char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0}; val_options = s_(tictac, compcolperm_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "ColPerm"); exit(1); } options->ColPerm = enumcolperm_t[val_options - 1]; break; case 4: // DiagPivotThresh options->DiagPivotThresh = strtod(tictac, &tictac); break; case 5: // Trans // char* comp5[] = {"NOTRANS", "TRANS", "CONJ", 0}; val_options = s_(tictac, comptrans_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "Trans"); exit(1); } options->Trans = enumtrans_t[val_options - 1]; break; case 6: // IterRefine // char* comp6[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0}; val_options = s_(tictac, compIterRefine_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "IterRefine"); exit(1); } options->IterRefine = enumIterRefine_t[val_options - 1]; break; case 7: // SymmetricMode // char* comp7[] = {"NO","YES", 0}; val_options = s_(tictac, compyes_no_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "SymmetricMode"); exit(1); } options->SymmetricMode = enumyes_no_t[val_options - 1]; break; case 8: // PivotGrowth // char* comp8[] = {"NO","YES", 0}; val_options = s_(tictac, compyes_no_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "PivotGrowth"); exit(1); } options->PivotGrowth = enumyes_no_t[val_options - 1]; break; case 9: // ConditionNumber // char* comp9[] = {"NO","YES", 0}; val_options = s_(tictac, compyes_no_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "ConditionNumber"); exit(1); } options->ConditionNumber = enumyes_no_t[val_options - 1]; break; case 10:// PrintStat val_options = s_(tictac, compyes_no_t); if (val_options == 0) { printf("value given for SuperLU for options %s is not correct\n", "PrintStat"); exit(1); } options->PrintStat = enumyes_no_t[val_options - 1]; break; case 0: // Equivalent of case default break; } tictac = strtok(NULL, " =,\t\n"); } // #endif }