Ejemplo n.º 1
0
Vector<double> linearSystem::usingLU() const{
	PLU<double> plu(_dim);
	plu = _A.LU();
	
	/* Creo la matriz de permutacion */
	Matrix<double> perm(_dim);
	for(uInt i=1; i<=_dim; i++){
		for(uInt j=1; j<=_dim; j++){
			if(j==plu.P.getValue(i))
				perm.setValue(1,i,j);
			else 
				perm.setValue(0,i,j);
		}
	}
	
	/* Permuto el d */
	Vector<double> d_perm(_dim);
	d_perm = (perm*_d.traspuesta()).traspuesta();
	
	linearSystem ls(plu.LU,d_perm);							//LUx=d
	Vector<double> z(ls.forwardSub());						//Ux=z
	ls._d=z;
	Vector<double> x(ls.backSub());							//Lz=d
	return x;
}
Ejemplo n.º 2
0
Dialog::Dialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Dialog)
{


    ui->setupUi(this);
    ui->groupBox->hide();
    QFile file("Calendar.s3db") ;
    QSqlDatabase db;
    if (file.exists())
    {
        db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("Calendar.s3db");
        db.open();
        QSqlQuery query;
        query.exec("CREATE TABLE Dannie ("
                   "ID INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,"
                   "Data DATE  NULL,"
                   "Vremyanachala TIME  NULL,"
                   "Vremyakonca TIME  NULL,"
                   "Sobitie TEXT  NULL,"
                   "comment TEXT  NULL)");
    }
    else
    {
        db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("Calendar.s3db");
        db.open();
    }


    model = new QSqlTableModel(this);
    model->setTable("Dannie");
   model->select();
    model->setFilter("");
     ui->tableView1->selectRow(0);
    ui->tableView1->setModel(model);
    //     ui->tableView1->hideColumn(0);
    //ui->tableView1->hideColumn(1);

    QDateTime  finishTime = QDateTime::currentDateTime();

    ui->timeEdit->setTime(QTime(finishTime.time().hour(), 0 ));
    ui->timeEdit_2->setTime(QTime(finishTime.time().hour(), 0 ));
    QDateTime dateTime=QDateTime::currentDateTime();
    ui-> dateEdit->setDate(dateTime.date());
    ui->dateEdit->setDate(dateTime.date());
    connect(ui->tableView1,SIGNAL(clicked(QModelIndex)),this,SLOT(on_cliked(QModelIndex)));

   connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(delete1()));
  connect(ui->radioButton,SIGNAL(clicked()),this,SLOT(plu()));

   // connect(ui->pushButton,SIGNAL(clicked()),this, SLOT(on_pushButton_clicked()));

}
Ejemplo n.º 3
0
    void invokeOrphanUpdates(ObjectHost* oh, const QuerierIDType& observer, const SpaceObjectReference& proximateID, ListenerType* listener) {
        ObjectUpdateMap::iterator it = mUpdates.find(proximateID);
        if (it == mUpdates.end()) return;

        const UpdateInfoList& info_list = it->second;
        for(UpdateInfoList::const_iterator info_it = info_list.begin(); info_it != info_list.end(); info_it++) {
            if ((*info_it)->value != NULL) {
                LocProtocolLocUpdate llu( *((*info_it)->value), oh, proximateID.space() );
                listener->onOrphanLocUpdate( observer, llu );
            }
            else if ((*info_it)->opd != NULL) {
                PresencePropertiesLocUpdate plu( (*info_it)->object.object(), *((*info_it)->opd) );
                listener->onOrphanLocUpdate( observer, plu );
            }
        }

        // Once we've notified of these we can get rid of them -- if they
        // need the info again they should re-register it with
        // addUpdateFromExisting before cleaning up the object.
        mUpdates.erase(it);
    }
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
	int nth, nbi, nbj, iter;
	int counter = 0;

	if (3 != argc)
		usage(argv);
	nbi = strtol(argv[1], NULL, 0);
	nbj = strtol(argv[2], NULL, 0);
	if (nbi <= 0 || nbj <= 0)
		usage(argv);
	nth = nbi * nbj;

	int niter = 10;
	for (n = MINDIM; n <= MAXDIM; n *= 2) {

		printf("matrix size: %dx%d = %d (%d bytes) ",
				n, n, n*n, n*n*(int)sizeof(mtype));
		printf("blksize %dx%d thr %4d itr %d:\n",
				n/nbi, n/nbj, nth, niter);
		for (iter = 0; iter < niter; iter++) {
			genmatrix(counter++);
			uint64_t ts = bench_time();
			plu(nbi, nbj);
			ts = bench_time() - ts;
			printf("%lld.%09lld\n",
					(long long)ts / 1000000000,
					(long long)ts % 1000000000);
#if CHECK_CORRECTNESS
			matmult();
			check(Orig, R);
#endif
		}

	}
	return 0;
}
Ejemplo n.º 5
0
int menuDecomposition()
{
	Matrix m,p,l,u;
	int action,i,j;
	int dim=0;
	action=-1;
	while(action!=0)
	{
		for(i=0;i<40;i++)
			printf("-");
		printf("\n\nDECOMPOSITION : \n");
		for(i=0;i<2;i++)
		{
			printf("\t%d./ ",i);
			switch(i)
			{
				case 0:
					printf("Retourner au menu ;\n");
					break;
				case 1:
					printf("Décompostion PLU.\n");
					break;
				default:
					break;
			}
		}
		printf("\n\n");
		for(i=0;i<40;i++)
			printf("-");
		printf("\n\n");

		printf("Que voulez-vous faire?\n");
		scanf("%d",&action);
		printf("\n\n");

		if(action==1)
		{
			printf("Donnez la dimension de la matrice.\n");
			scanf("%d",&dim);
			printf("\n");

			printf("Souhaitez-vous remplir la matrice ou la créer	aléatoirement?\n");
			printf("\t1./ Je remplis la matrice moi-même\n");
			printf("\t2./ Je fais confiance au hasard\n");
			scanf("%d",&action);
			printf("\n\n");

			if((dim>0))
			{
				p=identite(dim,dim);
				l=identite(dim,dim);
				u=newMatrix(dim,dim);
				m=newMatrix(dim,dim);

				if(action==1)
				{
					for(i=0;i<dim;i++)
					{
						for(j=0;j<dim;j++)
						{
							printf("Donnez le %dème coefficient pour l'équation %d:	",j,i);
							scanf("%f",&m->mat[i*dim+j]);
						}
					}
				}
				if(action==2)	
				{
					fillMatrix(m);
				}

				printf("\nVoici les matrices:\n");
				afficheMatrice(m);
				printf("\n");

				plu(m,p,l,u);

				printf("On obtient: \n");
				afficheMatrice(p);
				afficheMatrice(l);
				afficheMatrice(u);
				printf("\n\n\n");

				deleteMatrix(m);
				deleteMatrix(p);
				deleteMatrix(l);
				deleteMatrix(u);
			}
		}
		else
		{
			break;
		}
	}
	return action;
}