int linearComplementarity_newFromFile(LinearComplementarityProblem* problem, FILE* file) { int n = 0; int i; CHECK_IO(fscanf(file, "%d\n", &n)); problem->size = n; problem->M = newNumericsMatrix(); newFromFile(problem->M, file); problem->q = (double *) malloc(problem->M->size1 * sizeof(double)); for (i = 0; i < problem->M->size1; i++) { CHECK_IO(fscanf(file, "%lf ", &(problem->q[i]))); } return 1; }
int secondOrderConeLinearComplementarityProblem_newFromFile(SecondOrderConeLinearComplementarityProblem* problem, FILE* file) { DEBUG_PRINT("Start -- int secondOrderConeLinearComplementarityProblem_newFromFile(SecondOrderConeLinearComplementarityProblem* problem, FILE* file)\n"); int n = 0; int nc = 0; int i; CHECK_IO(fscanf(file, "%d\n", &n)); problem->n = n; CHECK_IO(fscanf(file, "%d\n", &nc)); problem->nc = nc; problem->M = newNumericsMatrix(); /* fix: problem->M->storageType unitialized ! */ newFromFile(problem->M, file); problem->q = (double *) malloc(problem->M->size1 * sizeof(double)); for(i = 0; i < problem->M->size1; i++) { CHECK_IO(fscanf(file, "%lf ", &(problem->q[i]))); } problem->coneIndex = (unsigned int *) malloc((nc+1) * sizeof(unsigned int)); for(i = 0; i < nc+1; i++) { CHECK_IO(fscanf(file, "%d ", &(problem->coneIndex[i]))); } problem->mu = (double *) malloc(nc * sizeof(double)); for(i = 0; i < nc; i++) { CHECK_IO(fscanf(file, "%lf ", &(problem->mu[i]))); } DEBUG_PRINT("End -- int secondOrderConeLinearComplementarityProblem_newFromFile(SecondOrderConeLinearComplementarityProblem* problem, FILE* file)\n"); return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setWindowTitle(QCoreApplication::applicationName()); ui.setupUi(this); // setup preferences dialog connect(&preferences, SIGNAL(accepted()), this, SLOT(getApplicationSettings())); connect(&builder, SIGNAL(highlightLine(const QString &, int, int, const QString &)), this, SLOT(highlightFileLine(const QString &, int, int))); connect(&builder, SIGNAL(finished()), this, SLOT(setBuildAvailable())); connect(&builder, SIGNAL(buildError()), &preferences, SLOT(showPreferences())); parser = language.parser(); connect(&preferences, SIGNAL(updateColors()), this, SLOT(recolorProjectView())); connect(&preferences, SIGNAL(updateFonts(const QFont &)), this, SLOT(recolorProjectView())); connect(&preferences, SIGNAL(updateFonts(const QFont &)), this, SLOT(recolorBuildManager())); connect(&preferences, SIGNAL(accepted()), ui.editorTabs, SIGNAL(accepted())); connect(&preferences, SIGNAL(updateColors()), ui.editorTabs, SIGNAL(updateColors())); connect(&preferences, SIGNAL(updateFonts(const QFont &)), ui.editorTabs, SIGNAL(updateFonts(const QFont &))); recolorProjectView(); recolorBuildManager(); // project editor tabs ui.finder->connectFileManager(ui.editorTabs); QSplitterHandle *hndl = ui.splitter->handle(1); hndl->setEnabled(false); connect(ui.editorTabs, SIGNAL(fileUpdated(int)), this, SLOT(setProject())); // File Menu connect(ui.action_New, SIGNAL(triggered()), ui.editorTabs, SLOT(newFile())); connect(ui.actionNew_From_File, SIGNAL(triggered()), ui.editorTabs, SLOT(newFromFile())); connect(ui.actionNew_From_Template, SIGNAL(triggered()), this, SLOT(newFromTemplate())); connect(ui.action_Open, SIGNAL(triggered()), ui.editorTabs, SLOT(open())); connect(ui.action_Save,SIGNAL(triggered()),ui.editorTabs,SLOT(save())); connect(ui.actionSave_As,SIGNAL(triggered()),ui.editorTabs,SLOT(saveAs())); connect(ui.actionSave_All,SIGNAL(triggered()),ui.editorTabs,SLOT(saveAll())); ui.actionPrint->setEnabled(true); connect(ui.actionPrint,SIGNAL(triggered()),this,SLOT(printFile())); ui.action_Zip->setEnabled(true); connect(ui.action_Zip,SIGNAL(triggered()),this,SLOT(zipFiles())); recentFiles = findChildren<QAction *>(QRegExp("action_[0-9]+_File")); for (int i = 0; i < recentFiles.size(); i++) connect(recentFiles.at(i), SIGNAL(triggered()),this, SLOT(openRecentFile())); connect(ui.action_Close, SIGNAL(triggered()), ui.editorTabs, SLOT(closeFile())); connect(ui.actionClose_All, SIGNAL(triggered()), ui.editorTabs, SLOT(closeAll())); connect(ui.action_Quit, SIGNAL(triggered()), this, SLOT(quitProgram())); connect(ui.editorTabs, SIGNAL(saveAvailable(bool)), this, SLOT(setSaveAvailable(bool))); connect(ui.editorTabs, SIGNAL(saveAvailable(bool)), this, SLOT(setSaveAvailable(bool))); connect(ui.editorTabs, SIGNAL(closeAvailable(bool)), this, SLOT(setCloseAvailable(bool))); connect(ui.editorTabs, SIGNAL(closeAvailable(bool)), this, SLOT(setCloseAvailable(bool))); connect(ui.editorTabs, SIGNAL(closeAvailable(bool)), this, SLOT(setBuildAvailable(bool))); // Edit Menu connect(ui.action_Undo, SIGNAL(triggered()), ui.editorTabs, SLOT(undo())); connect(ui.action_Redo, SIGNAL(triggered()), ui.editorTabs, SLOT(redo())); connect(ui.action_Cut, SIGNAL(triggered()), ui.editorTabs, SLOT(cut())); connect(ui.action_Copy, SIGNAL(triggered()), ui.editorTabs, SLOT(copy())); connect(ui.action_Paste, SIGNAL(triggered()), ui.editorTabs, SLOT(paste())); connect(ui.actionSelect_All, SIGNAL(triggered()), ui.editorTabs, SLOT(selectAll())); connect(ui.action_Find, SIGNAL(triggered()), ui.finder, SLOT(showFinder())); connect(ui.actionFind_Next, SIGNAL(triggered()), ui.finder, SLOT(findNext())); connect(ui.actionFind_Previous,SIGNAL(triggered()), ui.finder, SLOT(findPrevious())); connect(ui.actionPreferences, SIGNAL(triggered()), &preferences, SLOT(showPreferences())); connect(ui.editorTabs, SIGNAL(undoAvailable(bool)), ui.action_Undo,SLOT(setEnabled(bool))); connect(ui.editorTabs, SIGNAL(redoAvailable(bool)), ui.action_Redo,SLOT(setEnabled(bool))); connect(ui.editorTabs, SIGNAL(copyAvailable(bool)), ui.action_Cut,SLOT(setEnabled(bool))); connect(ui.editorTabs, SIGNAL(copyAvailable(bool)), ui.action_Copy,SLOT(setEnabled(bool))); // View Menu connect(ui.actionShow_Browser, SIGNAL(triggered()), this, SLOT(showBrowser())); connect(ui.actionBigger_Font, SIGNAL(triggered()), this, SLOT(fontBigger())); connect(ui.actionSmaller_Font, SIGNAL(triggered()), this, SLOT(fontSmaller())); ui.actionBigger_Font->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomIn << Qt::CTRL+Qt::Key_Equal); // Project Menu connect(ui.actionMemory_Map,SIGNAL(triggered()), this, SLOT(spawnMemoryMap())); connect(ui.actionBuild, SIGNAL(triggered()), this, SLOT(programBuild())); connect(ui.actionRun, SIGNAL(triggered()), this, SLOT(programRun())); connect(ui.actionWrite, SIGNAL(triggered()), this, SLOT(programWrite())); connect(ui.actionTerminal, SIGNAL(triggered()), this, SLOT(spawnTerminal())); // Help Menu connect(ui.actionPropeller_Quick_Reference, SIGNAL(triggered()), this, SLOT(propellerQuickReference())); connect(ui.actionPropeller_Datasheet, SIGNAL(triggered()), this, SLOT(propellerDatasheet())); connect(ui.actionPropeller_Manual, SIGNAL(triggered()), this, SLOT(propellerManual())); connect(ui.actionPropBASIC_Manual, SIGNAL(triggered()), this, SLOT(propBasicManual())); connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about())); // Toolbar Extras cbPort = new QComboBox(this); cbPort->setLayoutDirection(Qt::LeftToRight); cbPort->setToolTip(tr("Select Serial Port")); cbPort->setSizeAdjustPolicy(QComboBox::AdjustToContents); ui.toolBar->addWidget(cbPort); connect(ui.projectview, SIGNAL(showFileLine(QString, int)), this, SLOT(highlightFileLine(QString, int))); updateRecentFileActions(); connect(ui.editorTabs, SIGNAL(sendMessage(const QString &)), this,SLOT(showMessage(const QString &))); connect(ui.finder, SIGNAL(sendMessage(const QString &)), this,SLOT(showMessage(const QString &))); restoreGeometry(QSettings().value("windowSize").toByteArray()); getApplicationSettings(); connect(&manager, SIGNAL(portListChanged()), this, SLOT(updatePorts())); manager.enablePortMonitor(true); updatePorts(); QSettings settings; QString lastport = settings.value("lastPort", QString()).toString(); if (!lastport.isEmpty()) { int index = cbPort->findText(lastport); if (index != -1) cbPort->setCurrentIndex(index); } ui.editorTabs->newFile(); loadSession(); installEventFilter(this); statusBar(); }
int main(void) { printf("========= Starts Numerics tests for NumericsMatrix ========= \n"); int i, nmm = 4 ; NumericsMatrix ** NMM = (NumericsMatrix **)malloc(nmm * sizeof(NumericsMatrix *)) ; NumericsMatrix ** Mread = (NumericsMatrix **)malloc(nmm * sizeof(NumericsMatrix *)) ; for (i = 0 ; i < nmm; i++) { NMM[i] = newNumericsMatrix(); Mread[i] = newNumericsMatrix(); } int info = test_BuildNumericsMatrix(NMM); if (info != 0) { printf("Construction failed ...\n"); return info; } printf("Construction ok ...\n"); /* Test of various I/O functions */ for (i = 0 ; i < nmm; i++) { printf("test on NMM[%i]\n", i); NM_display(NMM[i]); displayRowbyRow(NMM[i]); FILE * foutput = fopen("testprintInfile.dat", "w"); printInFile(NMM[i], foutput); fclose(foutput); FILE * finput = fopen("testprintInfile.dat", "r"); readInFile(NMM[i], finput); fclose(finput); FILE * finput2 = fopen("testprintInfile.dat", "r"); newFromFile(Mread[i], finput2); fclose(finput2); char filename[50] = "testprintInfileName.dat"; printInFileName(NMM[i], filename); readInFileName(NMM[i], filename); printf("end of test on NMM[%i]\n", i); } for (i = 0 ; i < nmm; i++, i++) { FILE * foutput2 = fopen("testprintInfileForScilab.dat", "w"); printInFileForScilab(NMM[i], foutput2); fclose(foutput2); } /* free memory */ for (i = 0 ; i < nmm; i++) { freeNumericsMatrix(NMM[i]); free(NMM[i]); freeNumericsMatrix(Mread[i]); free(Mread[i]); } free(NMM); free(Mread); printf("========= End Numerics tests for NumericsMatrix ========= \n"); return info; }
int mixedLinearComplementarity_newFromFile(MixedLinearComplementarityProblem* problem, FILE* file) { int info = 0; assert(file); if (! problem) { fprintf(stderr, "Numerics, MixedLinearComplementarityProblem printInFile failed, NULL input.\n"); exit(EXIT_FAILURE); } int i, j; int st1, st2; CHECK_IO(fscanf(file, "%d\n", &st1)); problem->isStorageType1 = st1; CHECK_IO(fscanf(file, "%d\n", &st2)); problem->isStorageType2 = st2; int n ; CHECK_IO(fscanf(file, "%d\n", &n)); problem->n = n; int m; CHECK_IO(fscanf(file, "%d\n", &m)); problem->m = m; if (problem->isStorageType1) { int * blocksRows = (int *)malloc((n + m + 1) * sizeof(int)); int nbBlocks = 0; CHECK_IO(fscanf(file, "%d ", &(blocksRows[nbBlocks]))); while (blocksRows[nbBlocks] < (n + m)) { nbBlocks++; CHECK_IO(fscanf(file, "%d ", &(blocksRows[nbBlocks]))); } problem->blocksRows = (int *)malloc((nbBlocks + 1) * sizeof(int)); //CHECK_IO(fscanf(file,"\n")); for (i = 0; i <= nbBlocks; i++) { problem->blocksRows[i] = blocksRows[i]; } free(blocksRows); problem->blocksIsComp = (int *)malloc((nbBlocks) * sizeof(int)); //fprintf(file,"\n"); for (i = 0; i < nbBlocks; i++) { CHECK_IO(fscanf(file, "%d ", &(problem->blocksIsComp[i]))); } //fprintf(file,"\n"); problem->M = newNumericsMatrix(); newFromFile(problem->M, file); problem->q = (double *) malloc(problem->M->size1 * sizeof(double)); for (i = 0; i < problem->M->size1; i++) { CHECK_IO(fscanf(file, "%lf ", &(problem->q[i]))); } //fprintf(file,"\n"); /* return 1; */ /* if (problem->isStorageType2) */ /* { */ /* printf("Numerics, MixedLinearComplementarityProblem printInFile only Storage1 has been printed.\n"); */ /* } */ } if (problem->isStorageType2) { problem->A = (double*)malloc(n * n * sizeof(double)); problem->B = (double*)malloc(m * m * sizeof(double)); problem->C = (double*)malloc(n * m * sizeof(double)); problem->D = (double*)malloc(m * n * sizeof(double)); problem->a = (double*)malloc(n * sizeof(double)); problem->b = (double*)malloc(m * sizeof(double)); for (i = 0; i < problem->n; i++) { for (j = 0; j < problem->n; j++) { CHECK_IO(fscanf(file, "%lf ", &(problem->A[i + j * n]))); } /* CHECK_IO(fscanf(file,"\n")); */ } for (i = 0; i < problem->m; i++) { for (j = 0; j < problem->m; j++) { CHECK_IO(fscanf(file, "%lf ", &(problem->B[i + j * m]))); } /* fprintf(file,"\n"); */ } for (i = 0; i < problem->n; i++) { for (j = 0; j < problem->m; j++) { CHECK_IO(fscanf(file, "%lf ", &(problem->C[i + j * n]))); } /* fprintf(file,"\n"); */ } for (i = 0; i < problem->m; i++) { for (j = 0; j < problem->n; j++) { CHECK_IO(fscanf(file, "%lf ", &(problem->D[i + j * m]))); } /* fprintf(file,"\n"); */ } for (i = 0; i < problem->n; i++) { CHECK_IO(fscanf(file, "%lf ", &(problem->a[i]))); } /* fprintf(file,"\n"); */ for (i = 0; i < problem->m; i++) { CHECK_IO(fscanf(file, "%lf ", &(problem->b[i]))); } } return info; }