int main(int argc, char **argv) { printf("\n"); printf("Welcome to Rasterizer 3000.\n"); printf("===========================\n\n"); Config config; int rows, //9175, cols, //6814, i, j; calcImageSize(&config, &rows, &cols); Index index; index.nodes = malloc(rows*cols*sizeof(PointNode *)); index.config = &config; index.rows = rows; index.cols = cols; Image image; image.pixels = malloc(rows*cols*sizeof(float)); image.rows = rows; image.cols = cols; image.config = &config; // Initialize arrays for (j=0; j<rows; j++) { for (i=0; i<cols; i++) { *(index.nodes+(j*cols)+i) = 0; *(image.pixels+(j*cols)+i) = EMPTY_VAL; } } // data readPointsFromFile("sample.txt", &index); printIndexBins(&index); rasterize(&index, &image); printImage(&image); free(image.pixels); free(index.nodes); return 0; }
int main(int argc, char **argv) { int i; char *pointsFilename = NULL; double* points; hmat_interface_t hmat; hmat_settings_t settings; hmat_value_t type; hmat_info_t mat_info; int n; char arithmetic; hmat_clustering_algorithm_t* clustering; hmat_cluster_tree_t* cluster_tree; hmat_matrix_t * hmatrix; int kLowerSymmetric = 1; /* =0 if not Symmetric */ int rc; problem_data_t problem_data; double l; int nrhs = 1; double *drhs=NULL, *drhsCopy=NULL, derr; float *frhs=NULL, *frhsCopy=NULL, ferr; if (argc != 3) { fprintf(stderr, "Usage: %s pointsfilename (S|D)\n", argv[0]); return 1; } pointsFilename = argv[1]; arithmetic = argv[2][0]; switch (arithmetic) { case 'S': type = HMAT_SIMPLE_PRECISION; break; case 'D': type = HMAT_DOUBLE_PRECISION; break; default: fprintf(stderr, "Unknown arithmetic code %c, exiting...\n", arithmetic); return 1; } hmat_get_parameters(&settings); hmat_init_default_interface(&hmat, type); settings.compressionMethod = hmat_compress_aca_plus; /*settings->recompress = 0;*/ /*settings->admissibilityFactor = 3.;*/ hmat_set_parameters(&settings); if (0 != hmat.init()) { fprintf(stderr, "Unable to initialize HMat library\n"); return 1; } printf("Load points..."); readPointsFromFile(pointsFilename, &points, &n); printf("done\n"); printf("n = %d\n", n); l = correlationLength(points, n); printf("correlationLength = %le\n", l); problem_data.n = n; problem_data.points = points; problem_data.l = l; if(type == HMAT_SIMPLE_PRECISION){ drhs = createRhs(points, n, l); drhsCopy = createRhs(points, n, l); frhs = (float*) calloc(n, sizeof(float)); frhsCopy = (float*) calloc(n, sizeof(float)); for(i=0;i<n;i++) { frhs[i] = drhs[i]; frhsCopy[i] = drhsCopy[i]; } free(drhs); free(drhsCopy); }else{ drhs = createRhs(points, n, l); drhsCopy = createRhs(points, n, l); } clustering = hmat_create_clustering_median(); cluster_tree = hmat_create_cluster_tree(points, 3, n, clustering); hmat_delete_clustering(clustering); printf("ClusterTree node count = %d\n", hmat_tree_nodes_count(cluster_tree)); hmatrix = hmat.create_empty_hmatrix(cluster_tree, cluster_tree, 0); hmat.get_info(hmatrix, &mat_info); printf("HMatrix node count = %d\n", mat_info.nr_block_clusters); fprintf(stdout,"Assembly..."); rc = hmat.assemble_simple_interaction(hmatrix, &problem_data, interaction_real, kLowerSymmetric); if (rc) { fprintf(stderr, "Error in assembly, return code is %d, exiting...\n", rc); hmat.finalize(); return rc; } fprintf(stdout, "done.\n"); hmat.get_info(hmatrix, &mat_info); printf("Rk size = %ld\n", mat_info.compressed_size); hmat_procedure_t* trunc = hmat_create_procedure_epsilon_truncate(type, 1.e-2); fprintf(stdout,"Post-process Rk-matrices..."); hmat.walk(hmatrix, trunc); hmat_delete_procedure(trunc); fprintf(stdout, "done.\n"); hmat.get_info(hmatrix, &mat_info); printf("Rk size = %ld\n", mat_info.compressed_size); fprintf(stdout,"Factorisation..."); rc = hmat.factorize(hmatrix, hmat_factorization_lu); if (rc) { fprintf(stderr, "Error in factorisation, return code is %d, exiting...\n", rc); hmat.finalize(); return rc; } fprintf(stdout, "done.\n"); fprintf(stdout,"Solve..."); if(type == HMAT_SIMPLE_PRECISION){ hmat.solve_systems(hmatrix, frhs, nrhs); }else{ hmat.solve_systems(hmatrix, drhs, nrhs); } fprintf(stdout, "done.\n"); fprintf(stdout, "Accuracy..."); if(type == HMAT_SIMPLE_PRECISION){ simple_precision_error(&problem_data, n, frhs, frhsCopy, &ferr); fprintf(stdout, "||Ax - b|| / ||b|| = %e\n", ferr); free(frhs); free(frhsCopy); }else{ double_precision_error(&problem_data, n, drhs, drhsCopy, &derr); fprintf(stdout, "||Ax - b|| / ||b|| = %le\n", derr); free(drhs); free(drhsCopy); } hmat.destroy(hmatrix); hmat_delete_cluster_tree(cluster_tree); hmat.finalize(); return 0; }
struct3d::struct3d(QWidget *parent) : AbstractStructure(parent), ui(new Ui::struct3d) { ui->setupUi(this); setWindowTitle("Edit 3D structures"); resize(800,600); view = new QGraphicsView; scene = new tethraScene; view->setMouseTracking(true); view->setScene(scene); xSlider = new QSlider(Qt::Horizontal); xSlider->setRange(-90, 90); xSlider->setSingleStep(1); xSlider->setPageStep(10); xSlider->setTickInterval(10); xSlider->setTickPosition(QSlider::TicksBelow); ySlider = new QSlider(Qt::Horizontal); ySlider->setRange(-180, 180); ySlider->setSingleStep(1); ySlider->setPageStep(10); ySlider->setTickInterval(10); ySlider->setTickPosition(QSlider::TicksBelow); ui->comboBox->setCurrentIndex(3); ui->lineEdit->setText("-1"); ui->gridLayout->addWidget(ui->groupBox,0,0,2,1); ui->gridLayout->addWidget(ui->comboBox,2,0,1,1); ui->gridLayout->addWidget(ui->comboBox_2,3,0,1,1); ui->gridLayout->addWidget(ui->comboBox_3,4,0,1,1); ui->gridLayout->addWidget(ui->clearButton,5,0,1,1); ui->gridLayout->addWidget(ui->zoomInButton,6,0,1,1); ui->gridLayout->addWidget(ui->zoomOutButton,7,0,1,1); ui->gridLayout->addWidget(ui->saveButton,8,0,1,1); ui->gridLayout->addWidget(ui->saveButton_2,9,0,1,1); ui->gridLayout->addWidget(ui->okButton,10,0,1,1); ui->gridLayout->addWidget(ui->cancelButton,11,0,1,1); ui->gridLayout->addWidget(ui->label,0,2,1,1); ui->gridLayout->addWidget(ui->lineEdit,0,3,1,1); ui->gridLayout->addWidget(ui->label_2,0,4,1,1); ui->gridLayout->addWidget(ui->lineEdit_2,0,5,1,1); ui->gridLayout->addWidget(view,1,1,10,5); ui->gridLayout->addWidget(xSlider,11,1,1,5); ui->gridLayout->addWidget(ySlider,12,1,1,5); this->setLayout(ui->gridLayout); connect(xSlider, SIGNAL(valueChanged(int)), scene, SLOT(rotateOX(int))); connect(ySlider, SIGNAL(valueChanged(int)), scene, SLOT(rotateOY(int))); QObject::connect(ui->cancelButton,SIGNAL(clicked()),this, SLOT(close())); QObject::connect(ui->zoomInButton,SIGNAL(clicked()),this,SLOT(zoomIn())); QObject::connect(ui->zoomOutButton,SIGNAL(clicked()),this,SLOT(zoomOut())); QObject::connect(ui->colorButton,SIGNAL(clicked()),this,SLOT(color())); QObject::connect(ui->clearButton,SIGNAL(clicked()),scene,SLOT(clear())); QObject::connect(ui->radioButton,SIGNAL(clicked()),scene,SLOT(setStruct1())); QObject::connect(ui->radioButton_2,SIGNAL(clicked()),scene,SLOT(setStruct2())); QObject::connect(ui->okButton,SIGNAL(clicked()),this,SLOT(hide())); // QObject::connect(ui->saveButton,SIGNAL(clicked()),this,SLOT(save())); //QObject::connect(ui->saveButton,SIGNAL(clicked()),scene,SLOT(writePointsToFile())); QObject::connect(ui->saveButton,SIGNAL(clicked()),scene,SLOT(writeCoordinatesToFile())); QObject::connect(ui->saveButton_2,SIGNAL(clicked()),scene,SLOT(readPointsFromFile())); QObject::connect(scene,SIGNAL(checkedPointSelected(int)),this,SLOT(showOrder(int))); }