Rectangle::Rectangle(const MyPair & pair_1, const  MyPair & pair_2) ///&&&&&&&&&&& currentAngle(leftDown);
{ ///нет проверки наложения одного прямоугольника на другной
	if ((checkValues(pair_1)) && (checkValues(pair_2)))
	{
		if ((pair_1.first != pair_2.first) && (pair_1.second != pair_2.second))
		{
			coorDiag.push_back(pair_1);
			coorDiag.push_back(pair_2);
			coorDiag.push_back(std::make_pair(pair_1.first, pair_2.second));
			coorDiag.push_back(std::make_pair(pair_2.first, pair_1.second));
			//не нужна первые 2 пары - диагональ , среди всех найти минимум и от него отталкиваться
			mySortClock(coorDiag);
		}
		else
		{
			coorDiag.push_back(std::make_pair(0.0, 0.0));
			coorDiag.push_back(std::make_pair(0.0, 0.0));
			coorDiag.push_back(std::make_pair(0.0, 0.0));
			coorDiag.push_back(std::make_pair(0.0, 0.0));
		}
	}
	else
	{
		coorDiag.push_back(std::make_pair(0.0, 0.0));
		coorDiag.push_back(std::make_pair(0.0, 0.0));
		coorDiag.push_back(std::make_pair(0.0, 0.0));
		coorDiag.push_back(std::make_pair(0.0, 0.0));
	}
	//currentAngle = leftDown;
	count++;

}
Esempio n. 2
0
int runOperatorTests(Epetra_Operator & A, bool verbose) {

  int ierr = 0;


  double residual;
  EPETRA_CHK_ERR(EpetraExt::OperatorToMatrixMarketFile("Test_A1.mm", A, "Official EpetraExt test operator", 
							"This is the official EpetraExt test operator generated by the EpetraExt regression tests"));
  EPETRA_CHK_ERR(EpetraExt::OperatorToMatlabFile("Test_A1.dat", A));

  A.OperatorRangeMap().Comm().Barrier();
  A.OperatorRangeMap().Comm().Barrier();
  Epetra_CrsMatrix * A1; 
  Epetra_CrsMatrix * A2; 
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToCrsMatrix("Test_A1.mm", A.OperatorRangeMap(), A1));
  EPETRA_CHK_ERR(EpetraExt::MatlabFileToCrsMatrix("Test_A1.dat", A.OperatorRangeMap().Comm(), A2));


  residual = A.NormInf(); double rAInf = residual;
  if (verbose) std::cout << "Inf Norm of Operator A                                            = " << residual << std::endl;
  residual = A1->NormInf(); double rA1Inf = residual;
  if (verbose) std::cout << "Inf Norm of Matrix A1                                             = " << residual << std::endl;
  ierr += checkValues(rA1Inf,rAInf,"Inf Norm of A", verbose);


  Epetra_Vector x(A.OperatorDomainMap()); x.Random();
  Epetra_Vector y1(A.OperatorRangeMap());
  Epetra_Vector y2(A.OperatorRangeMap());
  Epetra_Vector y3(A.OperatorRangeMap());
  A.Apply(x,y1);
  A1->Multiply(false, x, y2);
  A2->Multiply(false, x, y3);

  y1.Norm2(&residual); double rAx1 = residual;
  if (verbose) std::cout << "Norm of A*x                                                       = " << residual << std::endl;

  y2.Norm2(&residual); double rAx2 = residual;
  if (verbose) std::cout << "Norm of A1*x                                                      = " << residual << std::endl;
  ierr += checkValues(rAx1,rAx2,"Norm of A1*x", verbose);

  y3.Norm2(&residual); double rAx3 = residual;
  if (verbose) std::cout << "Norm of A2*x                                                      = " << residual << std::endl;
  ierr += checkValues(rAx1,rAx3,"Norm of A2*x", verbose);

  delete A1;
  delete A2;

  return(ierr);
}
// here we start the calc...
void ProjectSquareWell::slotStartCalc() {

	if (!checkValues(true)) return;

	// ok.. now start the game... we create a new temporary system, setting on it
	// all the input parameters. System is a package-class which holds input data
	// and output data. it's passed to the calc factory, the model, when the calc
	// start. However, it's not granted the model is effectively resting.

	System *s = createSystem();
	System *r = NULL;
	
	if (m_dialog->richardsonExtrapolation()) {
		r = createRichardsonSystem();
	}

	//   startCalc return false if the model is working on another system.
	//   in this case, we ask to wait, and discard the system we built.
	//   a smarter code should span another project, but i don't care to be
	//   too much smarter, since i want to preserve that little mental sanity i
	//   currently have. now let's go to see Model::startCalc()

	// new: r is the richardson system. Nothing more than a carbon copy system
	// with half of the points. We pass it to the model

    if (!m_model->startCalc(s,r)) {
		g_error->error("Another calculation in progress","The current project is currently busy. Unable to start new thread.\n Wait for the end or start a new project.");
		delete s;
		if (r) delete r;
		return;
	}

}
Esempio n. 4
0
void QFDlgCSVParameters::reloadCSV()
{
    checkValues(false);
    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    tabmodel->setReadonly(false);
    tabmodel->clear();
    bool ex=false;
    if ((ex=QFile::exists(filename))) {
        tabmodel->readCSV(filename, get_column_separator(), get_decimal_separator(), get_header_start(), get_comment_start());
    }
    ui->tableView->setVisible(ex);
    ui->lstColumns->setModel(NULL);
    QList<int> oldidx;
    for (int i=0; i<colCmb.size(); i++) {
        oldidx<<colCmb[i]->currentIndex();
        colCmb[i]->setModel(NULL);
    }
    colslistCheckable.setEditable(true);
    colslistCheckable.clear();
    colslist.setEditable(true);
    colslist.clear();
    for (int i=0; i<tabmodel->columnCount(); i++) {
        colslistCheckable.addItem(tabmodel->columnTitle(i), true);
        colslist.addItem(tabmodel->columnTitle(i));
    }
    colslist.setEditable(false);
    colslistCheckable.setEditable(false);
    for (int i=0; i<colCmb.size(); i++) {
        colCmb[i]->setModel(&colslist);
        colCmb[i]->setCurrentIndex(oldidx.value(i, i));
    }
    ui->lstColumns->setModel(&colslistCheckable);
    tabmodel->setReadonly(true);
    QApplication::restoreOverrideCursor();
}
Esempio n. 5
0
QFDlgCSVParameters::QFDlgCSVParameters(QWidget* parent, QString columnSeparator, QString decimalSeparator, QString commentStart, QString headerStart):
    QFDialog(parent), ui(new Ui::QFDlgCSVParameters)
{
    colselcombos=0;
    tabmodel=new QFTableModel(this);
    ui->setupUi(this);
    ui->widConfig->registerWidget("column_separator", ui->edtColumn);
    ui->widConfig->registerWidget("comment_start", ui->edtComment);
    ui->widConfig->registerWidget("decimal_separator", ui->edtDecimal);
    ui->widConfig->registerWidget("header_start", ui->edtHeader);
    ui->widConfig->setFilename(QFPluginServices::getInstance()->getConfigFileDirectory()+QString("/csvdlg_csvconfig.ini"));
    ui->edtColumn->setText(QString(columnSeparator));
    //if (QString(columnSeparator).isEmpty()) ui->edtColumn->setEnabled(false);
    ui->edtDecimal->setText(QString(decimalSeparator));
    //if (QString(decimalSeparator).isEmpty()) ui->edtDecimal->setEnabled(false);
    ui->edtComment->setText(QString(commentStart));
    //if (QString(commentStart).isEmpty()) ui->edtComment->setEnabled(false);
    ui->edtHeader->setText(headerStart);
    //if (headerStart.isEmpty()) ui->edtHeader->setEnabled(false);
    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(checkValues()));
    ui->tableView->setModel(tabmodel);

    ProgramOptions::getConfigWindowGeometry(this, "QFDlgCSVParameters/window/");
    ProgramOptions::getConfigQSplitter(ui->splitter, "QFDlgCSVParameters/splitter/");
    ui->widConfig->setCurrentConfig(ProgramOptions::getConfigValue("QFDlgCSVParameters/config/", "").toString());
    setShowColumnsSelection(false);
    ui->lstColumns->setModel(&colslistCheckable);
    guessParameters();
    setWindowFlags(windowFlags()|Qt::WindowMinMaxButtonsHint);
}
MatrixFunctionDialog::MatrixFunctionDialog(Matrix* m, QWidget* parent, Qt::WFlags fl) : KDialog(parent, fl), m_matrix(m) {
	Q_ASSERT(m_matrix);
	setWindowTitle(i18n("Function values"));

	QFrame* mainWidget = new QFrame(this);
	ui.setupUi(mainWidget);
	setMainWidget( mainWidget );

	ui.tbConstants->setIcon( KIcon("labplot-format-text-symbol") );
	ui.tbFunctions->setIcon( KIcon("preferences-desktop-font") );

	QStringList vars;
	vars<<"x"<<"y";
	ui.teEquation->setVariables(vars);
	ui.teEquation->setFocus();

	QString info = "[" + QString::number(m_matrix->xStart()) + ", " + QString::number(m_matrix->xEnd()) + "], " + QString::number(m_matrix->columnCount()) + " " + i18n("values");
	ui.lXInfo->setText(info);
	info = "[" + QString::number(m_matrix->yStart()) + ", " + QString::number(m_matrix->yEnd()) + "], " + QString::number(m_matrix->rowCount()) + " " + i18n("values");
	ui.lYInfo->setText(info);

	ui.teEquation->setPlainText(m_matrix->formula());

	setButtons( KDialog::Ok | KDialog::Cancel );
	setButtonText(KDialog::Ok, i18n("&Generate"));
	setButtonToolTip(KDialog::Ok, i18n("Generate function values"));

	connect( ui.teEquation, SIGNAL(expressionChanged()), this, SLOT(checkValues()) );
	connect( ui.tbConstants, SIGNAL(clicked()), this, SLOT(showConstants()) );
	connect( ui.tbFunctions, SIGNAL(clicked()), this, SLOT(showFunctions()) );
	connect(this, SIGNAL(okClicked()), this, SLOT(generate()));

	resize( QSize(300,0).expandedTo(minimumSize()) );
}
Esempio n. 7
0
void AnagraficaAddDialog::save(void)
{
    //Effettua diversi controlli per verificare che i dati nel dialog
    //siano stati inseriti, se tutti i controlli vengono passati esegue
    //la query.
    qDebug() << "AnagraficaAddDialog::save()";
    prepareMap(m_mapPersona, int(modelCols::id));
    if (!checkValues())
        return;

    QSqlQuery query = prepareQuery();
    if (!query.exec()) {
        if (m_mapPersona.contains(ph::ID))
            showDialogError(this, ERR011, MSG005, query.lastError().text()); //NOTE codice errore 011
        else
            showDialogError(this, ERR025, MSG002, query.lastError().text()); //NOTE codice errore 025

        return;
    }

    while (query.next())
       setId(query.value("id").toString());

    this->accept();
}
Esempio n. 8
0
void main()
{
    DDRA = 0xFF;        // portA -> input
    DDRB = 0x0;         // portB -> output

    sei(); 		// Enable interupts
    setupADC();

    while(1)
    {
		runADC(Achannel);		    // Run ADC on A0, Interupt will then keep manage the
							        // Achannel variable and re-running the ADC

		while(Acomplete);		    // Wait for all ADC operations
	
		if(checkValues())		    // If slider has been moved encode & transmitt
	    {
		    char i=0;
		    for(i=0;i<3;i++)			// If difference copy new values to transmitt / prev out array
				Atrans[i] = Aout[i];

	        encode();
	        transmitt();
		}
		Acomplete = 0;
    }
    return 0;
}
Esempio n. 9
0
void HeaderView::setValues(std::string const name, std::string const preState
	, std::string const playState, std::string const postState, bool pidEnabled)
{
	// TODO refactor this
	this->enableEdit(true);
	
	ui->enablePIDCheckbox->blockSignals(true);
	ui->nameLineEdit->blockSignals(true);
	ui->preStateLineEdit->blockSignals(true);
	ui->playStateLineEdit->blockSignals(true);
	ui->postStateLineEdit->blockSignals(true);
	
	ui->nameLineEdit->setText(QString::fromStdString(name));
	ui->preStateLineEdit->setText(QString::fromStdString(preState));
	ui->playStateLineEdit->setText(QString::fromStdString(playState));
	ui->postStateLineEdit->setText(QString::fromStdString(postState));
	ui->enablePIDCheckbox->setChecked(pidEnabled);
	
	ui->enablePIDCheckbox->blockSignals(false);
	ui->nameLineEdit->blockSignals(false);
	ui->preStateLineEdit->blockSignals(false);
	ui->playStateLineEdit->blockSignals(false);
	ui->postStateLineEdit->blockSignals(false);
	
	pidEnabledChanged(ui->enablePIDCheckbox->isChecked());
	checkValues();
}
Esempio n. 10
0
void NewAnnotationDialog::done(int r) {
  if (QDialog::Accepted == r) {
    if (!checkValues()) {
      return;
    }
    createAnnotation();
  }
  QDialog::done(r);
}
Esempio n. 11
0
    void testValues ()
    {
        testcase ("values");

        checkValues ("0.1.2", 0, 1, 2);
        checkValues ("1.2.3", 1, 2, 3);
        checkValues ("1.2.3-rc1", 1, 2, 3, ids ("rc1"));
        checkValues ("1.2.3-rc1.debug", 1, 2, 3, ids ("rc1", "debug"));
        checkValues ("1.2.3-rc1.debug.asm", 1, 2, 3, ids ("rc1", "debug", "asm"));
        checkValues ("1.2.3+full", 1, 2, 3, ids (), ids ("full"));
        checkValues ("1.2.3+full.prod", 1, 2, 3, ids (), ids ("full", "prod"));
        checkValues ("1.2.3+full.prod.x86", 1, 2, 3, ids (), ids ("full", "prod", "x86"));
        checkValues ("1.2.3-rc1.debug.asm+full.prod.x86", 1, 2, 3,
            ids ("rc1", "debug", "asm"), ids ("full", "prod", "x86"));
    }
Esempio n. 12
0
/* all, any */
SEXP attribute_hidden do_logic3(SEXP call, SEXP op, SEXP args, SEXP env)
{
    SEXP ans, s, t, call2;
    int narm, has_na = 0;
    /* initialize for behavior on empty vector
       all(logical(0)) -> TRUE
       any(logical(0)) -> FALSE
     */
    Rboolean val = PRIMVAL(op) == _OP_ALL ? TRUE : FALSE;

    PROTECT(args = fixup_NaRm(args));
    PROTECT(call2 = duplicate(call));
    SETCDR(call2, args);

    if (DispatchGroup("Summary", call2, op, args, env, &ans)) {
	UNPROTECT(2);
	return(ans);
    }

    ans = matchArgExact(R_NaRmSymbol, &args);
    narm = asLogical(ans);

    for (s = args; s != R_NilValue; s = CDR(s)) {
	t = CAR(s);
	/* Avoid memory waste from coercing empty inputs, and also
	   avoid warnings with empty lists coming from sapply */
	if(xlength(t) == 0) continue;
	/* coerceVector protects its argument so this actually works
	   just fine */
	if (TYPEOF(t) != LGLSXP) {
	    /* Coercion of integers seems reasonably safe, but for
	       other types it is more often than not an error.
	       One exception is perhaps the result of lapply, but
	       then sapply was often what was intended. */
	    if(TYPEOF(t) != INTSXP)
		warningcall(call,
			    _("coercing argument of type '%s' to logical"),
			    type2char(TYPEOF(t)));
	    t = coerceVector(t, LGLSXP);
	}
	val = checkValues(PRIMVAL(op), narm, LOGICAL(t), XLENGTH(t));
        if (val != NA_LOGICAL) {
            if ((PRIMVAL(op) == _OP_ANY && val)
                || (PRIMVAL(op) == _OP_ALL && !val)) {
                has_na = 0;
                break;
            }
        } else has_na = 1;
    }
    UNPROTECT(2);
    return has_na ? ScalarLogical(NA_LOGICAL) : ScalarLogical(val);
}
Esempio n. 13
0
void HeaderView::handleFieldChanged()
{
	HeaderData data;
	
	data.motion_name = this->getMotionName();
	data.pre_state   = this->getPreState();
	data.play_state  = this->getPlayState();
	data.post_state  = this->getPostState();
	data.pid_enabled = this->getPIDEnabled();
	
	checkValues();
	dataChanged(data);
	pidEnabledChanged(ui->enablePIDCheckbox->isChecked());
}
Esempio n. 14
0
int checkMultiVectors( Epetra_MultiVector & X, Epetra_MultiVector & Y, string message = "", bool verbose = false) {
  int numVectors = X.NumVectors();
  int length = Y.MyLength();
  int badvalue = 0;
  int globalbadvalue = 0;
  for (int j=0; j<numVectors; j++)
    for (int i=0; i< length; i++)
      if (checkValues(X[j][i], Y[j][i])==1) badvalue = 1;
  X.Map().Comm().MaxAll(&badvalue, &globalbadvalue, 1);

  if (verbose) {
    if (globalbadvalue==0) cout << message << " check OK." << endl;
    else cout << "********* " << message << " check failed.********** " << endl;
  }
  return(globalbadvalue);
}
Esempio n. 15
0
/**
 *
 * @param position start or end position relative or absolute
 * @param posVariant the variant startpos or endpos
 */
void evePosCalc::setPos(QString position, eveVariant* posVariant) {

    if ((axisType == eveDateTimeT) && absolute){
        // absolute: we accept only "yyyy-MM-dd HH:mm:ss(.zzz)" or "HH:mm:ss(.zzz)" format
        if (!position.contains(QRegExp("^\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}([.]\\d{1,3})?$")) &&
                !position.contains(QRegExp("^\\d{1,2}:\\d{1,2}:\\d{1,2}([.]\\d{1,3})?$"))){
            sendError(ERROR, QString("invalid absolute datetime format %1, using current time").arg(position));
            posVariant->setValue(QDateTime::currentDateTime());
            return;
        }
    }
    else if ((axisType == eveDateTimeT) && !absolute){
        // relative: we accept an ISO duration format or obsolete HH:mm:ss
        QRegExp duration = QRegExp("^P(\\d+)Y(\\d+)M(\\d+)DT(\\d+)H(\\d+)M([\\d.]+)S$");
        if (position.contains(duration) && (duration.numCaptures() == 6)){
            bool ok;
            QStringList list = duration.capturedTexts();
            if ((list.at(1).toInt(&ok)!= 0) || (list.at(2).toInt(&ok)!= 0) || (list.at(3).toInt(&ok)!= 0))
                sendError(MINOR, QString("ISO Duration not implemented for Y/M/D (%1)").arg(position));
            double seconds = list.at(4).toDouble(&ok)*3600 + list.at(5).toDouble(&ok)*60 + list.at(6).toDouble(&ok);
            posVariant->setValue(seconds);
            return ;
        }
        // obsolete relative format accepts only a number for seconds or HH:mm:ss format
        else if (position.contains(QRegExp("^\\d{1,2}:\\d{1,2}:\\d{1,2}([.]\\d{1,3})?$"))){
            // obsolete relative format accepts only a number for seconds or HH:mm:ss format
            QString format;
            if (position.contains("."))
                format = "h:m:s.z";
            else
                format = "h:m:s";
            posVariant->setValue(QDateTime::fromString(position,format));
            return;
        }
        else {
            sendError(ERROR, QString("invalid relative datetime format %1, using 0").arg(position));
            posVariant->setValue(QDateTime());
            return;
        }
    }
    if (!posVariant->setValue(position))
        sendError(ERROR, QString("unable to set %1 as start/end position").arg(position));
    checkValues();
    return;
}
Esempio n. 16
0
void WinWindow::doSave()
{
    if (const char* error = checkValues())
    {
        MessageBox(NULL, error, "Error!",  MB_ICONERROR | MB_OK);
        return;
    }

    m_config->setValue("REMOTE_ADDRESS", getText(EDIT_ADDRESS));
    m_config->setValue("USER", getText(EDIT_USERNAME));
    if (getText(EDIT_PASSWORD))
        m_config->setValue("PASS", Sha512(getText(EDIT_PASSWORD)).to_string());

    if (m_config->save())
        MessageBox(NULL, "Server connection info successfully saved.", "Success!",  MB_ICONINFORMATION | MB_OK);
    else
        MessageBox(NULL, "Server connection info could not be saved.", "Error!",  MB_ICONERROR | MB_OK);
}
Esempio n. 17
0
//! [0]
ImageDialog::ImageDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);
    okButton->setAutoDefault(false);
    cancelButton->setAutoDefault(false);
//! [0]

    colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
    colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
    colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
    colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
    colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
    colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));

    connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
//! [1]
    connect(okButton, SIGNAL(clicked()), this, SLOT(checkValues()));
}
Esempio n. 18
0
void ProjectBarrier::slotStartCalc() {

	if (!checkValues(true)) return;

	System *s = createSystem();
	System *r = NULL;
	
	if (m_dialog->richardsonExtrapolation()) {
		r = createRichardsonSystem();
	}
		
    if (!m_model->startCalc(s,r)) {
		g_error->error("Another calculation in progress","The current project is currently busy. Unable to start new thread.\n Wait for the end or start a new project.");
		delete s;
		if (r) delete r;
		return;
	}

}
void getDeviceClick_rpsgame(const char *src, unsigned char *button, int dev){
	if(strcmp(src, "mouse_clark")==0)
		dev = 0;
	else
		dev = 1;

	if(!device_click[dev]){
		switch((int)button[0]){
			case ROCK: 
				setValidClick(ROCK, dev);
				break;
			case PAPER:
				setValidClick(PAPER, dev);
				break;
			case SCISSORS:
				setValidClick(SCISSORS, dev);
				break;
		}
		//printf("Mouse %d: %d\n", dev, (int)button[0]);
		checkValues();
	}
}
Esempio n. 20
0
/**
 * \brief stepwidth is always relative (it is a double in case axistype == datetime)
 *
 * @param stepwidth to calculate the next step ( must be convertible to int or double)
 */
void evePosCalc::setStepWidth(QString stepwidth) {

    bool ok=false;
    if (axisType == eveDateTimeT){
        // stepwidth is a double, we accept a number or HH:mm:ss.mmm format
        QRegExp regex = QRegExp("^(\\d+):(\\d+):([\\d.]+)$");
        QRegExp duration = QRegExp("^P(\\d+)Y(\\d+)M(\\d+)DT(\\d+)H(\\d+)M([\\d.]+)S$");
        if (stepwidth.contains(regex) && (regex.numCaptures() == 3)){
            QStringList list = regex.capturedTexts();
            int hours = list.at(1).toInt(&ok);
            int minutes = list.at(2).toInt(&ok);
            double seconds = list.at(3).toDouble(&ok) + (double)(60*minutes + 3600*hours);
            stepWidth.setValue(seconds);
        }
        else if (stepwidth.contains(duration) && (duration.numCaptures() == 6)){
            QStringList list = duration.capturedTexts();
            if ((list.at(1).toInt(&ok)!= 0) || (list.at(2).toInt(&ok)!= 0) || (list.at(3).toInt(&ok)!= 0))
                sendError(MINOR, QString("ISO Duration not implemented for Y/M/D (%1)").arg(stepwidth));
            double seconds = list.at(4).toDouble(&ok)*3600 + list.at(5).toDouble(&ok)*60 + list.at(6).toDouble(&ok);
            stepWidth.setValue(seconds);
        }
        else {
            stepWidth.setValue(stepwidth.toDouble(&ok));
        }
        sendError(DEBUG, QString("set stepwidth to %1 (%2)").arg(stepWidth.toDouble(&ok)).arg(stepwidth));
    }
    else if ((stepmode == MULTIPLY) || (axisType == eveDOUBLE)){
        stepWidth.setValue(stepwidth.toDouble(&ok));
    }
    else if (axisType == eveINT){
        stepWidth.setValue(stepwidth.toInt(&ok));
    }
    else if (axisType == eveStringT){
        stepWidth.setValue(stepwidth.toInt(&ok));
    }

    if (!ok) sendError(ERROR, QString("unable to set %1 as stepwidth").arg(stepwidth));
    checkValues();
}
Esempio n. 21
0
bool HeaderView::requestSave()
{
	checkValues();
	
	if(!warningString.isEmpty()) // if there are warnings - show warning massage
	{
		warningString.prepend("Errors were found:\n\n");
		warningString.append("\nSave it anyway?");
		
		QMessageBox messageBox;
		messageBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
		messageBox.setDefaultButton(QMessageBox::Discard);
		messageBox.setWindowTitle("Warning!");
		messageBox.setText(warningString);
		
		int buttonPressed = messageBox.exec();
		if(buttonPressed == QMessageBox::Discard) // "Dont save" pressed
			return false;
	}
	
	return true;
}
Esempio n. 22
0
void ParameterServer::getValues() {
  std::map<std::string, boost::any>::const_iterator itr;
  for (itr = config.begin(); itr != config.end(); ++itr) {
    std::string name = itr->first;
    if (itr->second.type() == typeid(std::string)) {
      config[name] = getFromParameterServer<std::string> (pre + name,
          boost::any_cast<std::string>(itr->second));
      ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<std::string>(itr->second));
    } else if (itr->second.type() == typeid(int)) {
      config[name] = getFromParameterServer<int> (pre + name,
          boost::any_cast<int>(itr->second));
      ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<int>(itr->second));
    } else if (itr->second.type() == typeid(double)) {
      config[name] = getFromParameterServer<double> (pre + name,
          boost::any_cast<double>(itr->second));
      ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<double>(itr->second));
    } else if (itr->second.type() == typeid(bool)) {
      config[name] = getFromParameterServer<bool> (pre + name,
          boost::any_cast<bool>(itr->second));
      ROS_DEBUG_STREAM("Value for " << name << ":             " << boost::any_cast<bool>(itr->second));
    }
  }
  checkValues();
}
int checkMultiVectors( CT_Epetra_MultiVector_ID_t & X, CT_Epetra_MultiVector_ID_t & Y, string message = "", bool verbose = false) {
  int numVectors = Epetra_MultiVector_NumVectors(X);
  int length = Epetra_MultiVector_MyLength(Y);
  int badvalue = 0;
  int globalbadvalue = 0;
  for (int j=0; j<numVectors; j++) {
    CT_Epetra_Vector_ID_t vecx = Epetra_MultiVector_getVector(X, j);
    CT_Epetra_Vector_ID_t vecy = Epetra_MultiVector_getVector(Y, j);
    for (int i=0; i< length; i++)
      if (checkValues(Epetra_Vector_getElement(vecx, i), Epetra_Vector_getElement(vecy, i))==1) badvalue = 1;
    Epetra_Vector_Destroy(&vecy);
    Epetra_Vector_Destroy(&vecx);
  }
  CT_Epetra_Comm_ID_t Comm = Epetra_DistObject_Comm(Epetra_DistObject_Degeneralize(
      Epetra_MultiVector_Generalize(X)));
  Epetra_Comm_MaxAll_Int(Comm, &badvalue, &globalbadvalue, 1);
  Epetra_Comm_Destroy(&Comm);

  if (verbose) {
    if (globalbadvalue==0) cout << message << " check OK." << endl;
    else cout << "********* " << message << " check failed.********** " << endl;
  }
  return(globalbadvalue);
}
Esempio n. 24
0
int main(int argc, char *argv[]) {

#ifdef HAVE_MPI
  MPI_Init(&argc,&argv);
  Epetra_MpiComm comm (MPI_COMM_WORLD);
#else
  Epetra_SerialComm comm;
#endif

  int MyPID = comm.MyPID();

  bool verbose = false;
  bool verbose1 = false; 
  // Check if we should print results to standard out
  if (argc > 1) {
    if ((argv[1][0] == '-') && (argv[1][1] == 'v')) {
      verbose1 = true;
      if (MyPID==0) verbose = true;
    }
  }

  if (verbose1) cout << comm << endl;


  // Uncomment the next three lines to debug in mpi mode
  //int tmp;
  //if (MyPID==0) cin >> tmp;
  //comm.Barrier();

  Epetra_CrsMatrix * A; 
  EPETRA_CHK_ERR(EpetraExt::MatlabFileToCrsMatrix("A.dat", comm, A));

  Epetra_Vector  x(A->OperatorDomainMap()); 
  Epetra_Vector  b(A->OperatorRangeMap());
  x.Random();
  A->Apply(x,b); // Generate RHS from x
  Epetra_Vector xx(x); // Copy x to xx for later use

  Epetra_LinearProblem problem(A, &x, &b);
  // Construct a solver object for this problem

  AztecOO solver(problem);
  solver.SetAztecOption(AZ_precond, AZ_none);
  if (!verbose1) solver.SetAztecOption(AZ_output, AZ_none);
  solver.SetAztecOption(AZ_kspace, A->NumGlobalRows());
  AztecOO_Operator AOpInv(&solver, A->NumGlobalRows());
  Epetra_InvOperator AInvOp(&AOpInv);

  EPETRA_CHK_ERR(EpetraExt::OperatorToMatlabFile("Ainv.dat", AInvOp));

  comm.Barrier();

  Epetra_CrsMatrix * AInv; 
  EPETRA_CHK_ERR(EpetraExt::MatlabFileToCrsMatrix("Ainv.dat", comm, AInv));

  EPETRA_CHK_ERR(AInv->Apply(b,x));

  EPETRA_CHK_ERR(x.Update(1.0, xx, -1.0));
  double residual = 0.0;
  EPETRA_CHK_ERR(x.Norm2(&residual));
  if (verbose) cout << "Norm of difference between computed x and exact x = " << residual << endl;
  int ierr = checkValues(residual,0.0,"Norm of difference between computed A1x1 and A1x1 from file", verbose);

  
  delete A;
  delete AInv;


  #ifdef HAVE_MPI
  MPI_Finalize() ;
#endif

  return(ierr);
}
Esempio n. 25
0
int runTests(Epetra_Map & map, Epetra_CrsMatrix & A, Epetra_Vector & x, Epetra_Vector & b, Epetra_Vector & xexact, bool verbose) {

  int ierr = 0;

  // Create MultiVectors and put x, b, xexact in both columns of X, B, and Xexact, respectively.
  Epetra_MultiVector X( map, 2, false );
  Epetra_MultiVector B( map, 2, false );
  Epetra_MultiVector Xexact( map, 2, false );

  for (int i=0; i<X.NumVectors(); ++i) {
    *X(i) = x;
    *B(i) = b;
    *Xexact(i) = xexact;
  }
  double residual;
  std::vector<double> residualmv(2);
  residual = A.NormInf(); double rAInf = residual;
  if (verbose) std::cout << "Inf Norm of A                                                     = " << residual << std::endl;
  residual = A.NormOne(); double rAOne = residual;
  if (verbose) std::cout << "One Norm of A                                                     = " << residual << std::endl;
  xexact.Norm2(&residual); double rxx = residual;	
  Xexact.Norm2(&residualmv[0]); std::vector<double> rXX( residualmv );	
  if (verbose) std::cout << "Norm of xexact                                                    = " << residual << std::endl;
  if (verbose) std::cout << "Norm of Xexact                                                    = (" << residualmv[0] << ", " <<residualmv[1] <<")"<< std::endl;
  Epetra_Vector tmp1(map);
  Epetra_MultiVector tmp1mv(map,2,false);
  A.Multiply(false, xexact, tmp1);
  A.Multiply(false, Xexact, tmp1mv);
  tmp1.Norm2(&residual); double rAx = residual;
  tmp1mv.Norm2(&residualmv[0]); std::vector<double> rAX( residualmv );
  if (verbose) std::cout << "Norm of Ax                                                        = " << residual << std::endl;
  if (verbose) std::cout << "Norm of AX                                                        = (" << residualmv[0] << ", " << residualmv[1] <<")"<< std::endl;
  b.Norm2(&residual); double rb = residual;
  B.Norm2(&residualmv[0]); std::vector<double> rB( residualmv );
  if (verbose) std::cout << "Norm of b (should equal norm of Ax)                               = " << residual << std::endl;
  if (verbose) std::cout << "Norm of B (should equal norm of AX)                               = (" << residualmv[0] << ", " << residualmv[1] <<")"<< std::endl;
  tmp1.Update(1.0, b, -1.0);
  tmp1mv.Update(1.0, B, -1.0);
  tmp1.Norm2(&residual);
  tmp1mv.Norm2(&residualmv[0]);
  if (verbose) std::cout << "Norm of difference between compute Ax and Ax from file            = " << residual << std::endl;
  if (verbose) std::cout << "Norm of difference between compute AX and AX from file            = (" << residualmv[0] << ", " << residualmv[1] <<")"<< std::endl;
  map.Comm().Barrier();

  EPETRA_CHK_ERR(EpetraExt::BlockMapToMatrixMarketFile("Test_map.mm", map, "Official EpetraExt test map", 
						       "This is the official EpetraExt test map generated by the EpetraExt regression tests"));

  EPETRA_CHK_ERR(EpetraExt::RowMatrixToMatrixMarketFile("Test_A.mm", A, "Official EpetraExt test matrix", 
							"This is the official EpetraExt test matrix generated by the EpetraExt regression tests"));

  EPETRA_CHK_ERR(EpetraExt::VectorToMatrixMarketFile("Test_x.mm", x, "Official EpetraExt test initial guess", 
						     "This is the official EpetraExt test initial guess generated by the EpetraExt regression tests"));

  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatrixMarketFile("Test_mvX.mm", X, "Official EpetraExt test initial guess", 
					      	          "This is the official EpetraExt test initial guess generated by the EpetraExt regression tests"));
				       
  EPETRA_CHK_ERR(EpetraExt::VectorToMatrixMarketFile("Test_xexact.mm", xexact, "Official EpetraExt test exact solution", 
						     "This is the official EpetraExt test exact solution generated by the EpetraExt regression tests"));

  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatrixMarketFile("Test_mvXexact.mm", Xexact, "Official EpetraExt test exact solution", 
						          "This is the official EpetraExt test exact solution generated by the EpetraExt regression tests"));
				       
  EPETRA_CHK_ERR(EpetraExt::VectorToMatrixMarketFile("Test_b.mm", b, "Official EpetraExt test right hand side", 
						     "This is the official EpetraExt test right hand side generated by the EpetraExt regression tests"));

  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatrixMarketFile("Test_mvB.mm", B, "Official EpetraExt test right hand side", 
						          "This is the official EpetraExt test right hand side generated by the EpetraExt regression tests"));
				       
  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatlabFile("Test_mvB.mat", B));
 
  EPETRA_CHK_ERR(EpetraExt::RowMatrixToMatlabFile("Test_A.dat", A));

  Epetra_Map * map1;
  Epetra_CrsMatrix * A1; 
  Epetra_CrsMatrix * A2; 
  Epetra_CrsMatrix * A3; 
  Epetra_Vector * x1; 
  Epetra_Vector * b1;
  Epetra_Vector * xexact1;
  Epetra_MultiVector * X1; 
  Epetra_MultiVector * B1;
  Epetra_MultiVector * Xexact1;

  EpetraExt::MatrixMarketFileToMap("Test_map.mm", map.Comm(), map1);

  if (map.SameAs(*map1)) {
    if (verbose) std::cout << "Maps are equal.  In/Out works." << std::endl;
  }
  else {
    if (verbose) std::cout << "Maps are not equal.  In/Out fails." << std::endl;
    ierr += 1;
  }
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToCrsMatrix("Test_A.mm", *map1, A1));
  // If map is zero-based, then we can compare to the convenient reading versions
  if (map1->IndexBase()==0) EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToCrsMatrix("Test_A.mm", map1->Comm(), A2));
  if (map1->IndexBase()==0) EPETRA_CHK_ERR(EpetraExt::MatlabFileToCrsMatrix("Test_A.dat", map1->Comm(), A3));
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToVector("Test_x.mm", *map1, x1));
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToVector("Test_xexact.mm", *map1, xexact1));
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToVector("Test_b.mm", *map1, b1));
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToMultiVector("Test_mvX.mm", *map1, X1));
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToMultiVector("Test_mvXexact.mm", *map1, Xexact1));
  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToMultiVector("Test_mvB.mm", *map1, B1));

  residual = A1->NormInf(); double rA1Inf = residual;
  if (verbose) std::cout << "Inf Norm of A1                                                    = " << residual << std::endl;
  ierr += checkValues(rA1Inf,rAInf,"Inf Norm of A", verbose);

  residual = A1->NormOne(); double rA1One = residual;
  if (verbose) std::cout << "One Norm of A1                                                    = " << residual << std::endl;
  ierr += checkValues(rA1One,rAOne,"One Norm of A", verbose);

  xexact1->Norm2(&residual); double rxx1 = residual;
  if (verbose) std::cout << "Norm of xexact1                                                   = " << residual << std::endl;
  ierr += checkValues(rxx1,rxx,"Norm of xexact", verbose);

  Xexact1->Norm2(&residualmv[0]); std::vector<double> rXX1(residualmv);
  if (verbose) std::cout << "Norm of Xexact1                                                   = (" << residualmv[0] <<", " <<residualmv[1]<<")"<< std::endl;
  ierr += checkValues(rXX1[0],rXX[0],"Norm of Xexact", verbose);
  ierr += checkValues(rXX1[1],rXX[1],"Norm of Xexact", verbose);

  Epetra_Vector tmp11(*map1);
  A1->Multiply(false, *xexact1, tmp11);

  Epetra_MultiVector tmp11mv(*map1,2,false);
  A1->Multiply(false, *Xexact1, tmp11mv);

  tmp11.Norm2(&residual); double rAx1 = residual;
  if (verbose) std::cout << "Norm of A1*x1                                                     = " << residual << std::endl;
  ierr += checkValues(rAx1,rAx,"Norm of A1*x", verbose);

  tmp11mv.Norm2(&residualmv[0]); std::vector<double> rAX1(residualmv);
  if (verbose) std::cout << "Norm of A1*X1                                                     = (" << residualmv[0] <<", "<<residualmv[1]<<")"<< std::endl;
  ierr += checkValues(rAX1[0],rAX[0],"Norm of A1*X", verbose);
  ierr += checkValues(rAX1[1],rAX[1],"Norm of A1*X", verbose);

  if (map1->IndexBase()==0) {
    Epetra_Vector tmp12(*map1);
    A2->Multiply(false, *xexact1, tmp12);
    
    tmp12.Norm2(&residual); double rAx2 = residual;
    if (verbose) std::cout << "Norm of A2*x1                                                     = " << residual << std::endl;
    ierr += checkValues(rAx2,rAx,"Norm of A2*x", verbose);

    Epetra_Vector tmp13(*map1);
    A3->Multiply(false, *xexact1, tmp13);
    
    tmp13.Norm2(&residual); double rAx3 = residual;
    if (verbose) std::cout << "Norm of A3*x1                                                     = " << residual << std::endl;
    ierr += checkValues(rAx3,rAx,"Norm of A3*x", verbose);
  }
  b1->Norm2(&residual); double rb1 = residual;
  if (verbose) std::cout << "Norm of b1 (should equal norm of Ax)                              = " << residual << std::endl;
  ierr += checkValues(rb1,rb,"Norm of b", verbose);

  B1->Norm2(&residualmv[0]); std::vector<double> rB1(residualmv);
  if (verbose) std::cout << "Norm of B1 (should equal norm of AX)                              = (" << residualmv[0] <<", "<<residualmv[1]<<")"<< std::endl;
  ierr += checkValues(rB1[0],rB[0],"Norm of B", verbose);
  ierr += checkValues(rB1[1],rB[1],"Norm of B", verbose);

  tmp11.Update(1.0, *b1, -1.0);
  tmp11.Norm2(&residual);
  if (verbose) std::cout << "Norm of difference between computed A1x1 and A1x1 from file        = " << residual << std::endl;
  ierr += checkValues(residual,0.0,"Norm of difference between computed A1x1 and A1x1 from file", verbose);

  tmp11mv.Update(1.0, *B1, -1.0);
  tmp11mv.Norm2(&residualmv[0]);
  if (verbose) std::cout << "Norm of difference between computed A1X1 and A1X1 from file        = (" << residualmv[0] << ", "<<residualmv[1]<<")"<< std::endl;
  ierr += checkValues(residualmv[0],0.0,"Norm of difference between computed A1X1 and A1X1 from file", verbose);
  ierr += checkValues(residualmv[1],0.0,"Norm of difference between computed A1X1 and A1X1 from file", verbose);

  if (map1->IndexBase()==0) {delete A2; delete A3;}
  delete A1;
  delete x1;
  delete b1;
  delete xexact1;
  delete X1;
  delete B1;
  delete Xexact1;
  delete map1;

  return(ierr);
}
Esempio n. 26
0
void HeaderView::setFileName(QString name)
{
	fileName = name;
	checkValues();
}
int powerMethodTests(CT_Epetra_RowMatrix_ID_t & A, CT_Epetra_RowMatrix_ID_t & JadA,
                     CT_Epetra_Map_ID_Flex_t & Map, CT_Epetra_Vector_ID_Flex_t & q,
                     CT_Epetra_Vector_ID_Flex_t & z, CT_Epetra_Vector_ID_Flex_t & resid, bool verbose) {

  // variable needed for iteration
  double lambda = 0.0;
  // int niters = 10000;
  int niters = 300;
  double tolerance = 1.0e-2;
  int ierr = 0;

  /////////////////////////////////////////////////////////////////////////////////////////////////
	
  // Iterate

  CT_Epetra_Comm_ID_t Comm = Epetra_BlockMap_Comm(Map.Epetra_BlockMap);
  CT_Epetra_Time_ID_t timer = Epetra_Time_Create(Comm);
  Epetra_Comm_Destroy(&Comm);
	
  double startTime = Epetra_Time_ElapsedTime(timer);
  EPETRA_TEST_ERR(power_method(FALSE, A, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  double elapsed_time = Epetra_Time_ElapsedTime(timer) - startTime;
  double total_flops = Epetra_CompObject_Flops(q.Epetra_CompObject);
  double MFLOPs = total_flops/elapsed_time/1000000.0;
  double lambdaref = lambda;
  double flopsref = total_flops;

  if (verbose) 
	  cout << "\n\nTotal MFLOPs for reference first solve = " << MFLOPs << endl
		  <<     "Total FLOPS                            = " <<total_flops <<endl<<endl;

  lambda = 0.0;
  startTime = Epetra_Time_ElapsedTime(timer);
  EPETRA_TEST_ERR(power_method(FALSE, JadA, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  elapsed_time = Epetra_Time_ElapsedTime(timer) - startTime;
  total_flops = Epetra_CompObject_Flops(q.Epetra_CompObject);
  MFLOPs = total_flops/elapsed_time/1000000.0;

  if (verbose) 
	  cout << "\n\nTotal MFLOPs for candidate first solve = " << MFLOPs << endl
		  <<     "Total FLOPS                            = " <<total_flops <<endl<<endl;

  EPETRA_TEST_ERR(checkValues(lambda,lambdaref," No-transpose Power Method result", verbose),ierr);
  EPETRA_TEST_ERR(checkValues(total_flops,flopsref," No-transpose Power Method flop count", verbose),ierr);

  /////////////////////////////////////////////////////////////////////////////////////////////////
	
  // Solve transpose problem

  if (verbose) cout << "\n\nUsing transpose of matrix and solving again (should give same result).\n\n"
		    << endl;
  // Iterate
  lambda = 0.0;
  startTime = Epetra_Time_ElapsedTime(timer);
  EPETRA_TEST_ERR(power_method(TRUE, A, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  elapsed_time = Epetra_Time_ElapsedTime(timer) - startTime;
  total_flops = Epetra_CompObject_Flops(q.Epetra_CompObject);
  MFLOPs = total_flops/elapsed_time/1000000.0;
  lambdaref = lambda;
  flopsref = total_flops;

  if (verbose) 
	 cout << "\n\nTotal MFLOPs for reference transpose solve = " << MFLOPs << endl
		 <<     "Total FLOPS                                = " <<total_flops <<endl<<endl;

  lambda = 0.0;
  startTime = Epetra_Time_ElapsedTime(timer);
  EPETRA_TEST_ERR(power_method(TRUE, JadA, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  elapsed_time = Epetra_Time_ElapsedTime(timer) - startTime;
  total_flops = Epetra_CompObject_Flops(q.Epetra_CompObject);
  MFLOPs = total_flops/elapsed_time/1000000.0;

  if (verbose) 
	  cout << "\n\nTotal MFLOPs for candidate transpose solve = " << MFLOPs << endl
		  <<     "Total FLOPS                                = " <<total_flops <<endl<<endl;

  EPETRA_TEST_ERR(checkValues(lambda,lambdaref,"Transpose Power Method result", verbose),ierr);
  EPETRA_TEST_ERR(checkValues(total_flops,flopsref,"Transpose Power Method flop count", verbose),ierr);

  EPETRA_TEST_ERR(check(A, JadA, verbose),ierr);

  return(0);
}
Esempio n. 28
0
int check(Epetra_RowMatrix& A, Epetra_RowMatrix & B, bool verbose)  {

  int ierr = 0;
  EPETRA_TEST_ERR(!A.Comm().NumProc()==B.Comm().NumProc(),ierr);
  EPETRA_TEST_ERR(!A.Comm().MyPID()==B.Comm().MyPID(),ierr);
  EPETRA_TEST_ERR(!A.Filled()==B.Filled(),ierr);
  EPETRA_TEST_ERR(!A.HasNormInf()==B.HasNormInf(),ierr);
  EPETRA_TEST_ERR(!A.LowerTriangular()==B.LowerTriangular(),ierr);
  EPETRA_TEST_ERR(!A.Map().SameAs(B.Map()),ierr);
  EPETRA_TEST_ERR(!A.MaxNumEntries()==B.MaxNumEntries(),ierr);
  EPETRA_TEST_ERR(!A.NumGlobalCols64()==B.NumGlobalCols64(),ierr);
  EPETRA_TEST_ERR(!A.NumGlobalDiagonals64()==B.NumGlobalDiagonals64(),ierr);
  EPETRA_TEST_ERR(!A.NumGlobalNonzeros64()==B.NumGlobalNonzeros64(),ierr);
  EPETRA_TEST_ERR(!A.NumGlobalRows64()==B.NumGlobalRows64(),ierr);
  EPETRA_TEST_ERR(!A.NumMyCols()==B.NumMyCols(),ierr);
  EPETRA_TEST_ERR(!A.NumMyDiagonals()==B.NumMyDiagonals(),ierr);
  EPETRA_TEST_ERR(!A.NumMyNonzeros()==B.NumMyNonzeros(),ierr);
  for (int i=0; i<A.NumMyRows(); i++) {
    int nA, nB;
    A.NumMyRowEntries(i,nA); B.NumMyRowEntries(i,nB);
    EPETRA_TEST_ERR(!nA==nB,ierr);
  }
  EPETRA_TEST_ERR(!A.NumMyRows()==B.NumMyRows(),ierr);
  EPETRA_TEST_ERR(!A.OperatorDomainMap().SameAs(B.OperatorDomainMap()),ierr);
  EPETRA_TEST_ERR(!A.OperatorRangeMap().SameAs(B.OperatorRangeMap()),ierr);
  EPETRA_TEST_ERR(!A.RowMatrixColMap().SameAs(B.RowMatrixColMap()),ierr);
  EPETRA_TEST_ERR(!A.RowMatrixRowMap().SameAs(B.RowMatrixRowMap()),ierr);
  EPETRA_TEST_ERR(!A.UpperTriangular()==B.UpperTriangular(),ierr);
  EPETRA_TEST_ERR(!A.UseTranspose()==B.UseTranspose(),ierr);

  int NumVectors = 5;
  { // No transpose case
    Epetra_MultiVector X(A.OperatorDomainMap(), NumVectors);
    Epetra_MultiVector YA1(A.OperatorRangeMap(), NumVectors);
    Epetra_MultiVector YA2(YA1);
    Epetra_MultiVector YB1(YA1);
    Epetra_MultiVector YB2(YA1);
    X.Random();

    bool transA = false;
    A.SetUseTranspose(transA);
    B.SetUseTranspose(transA);
    A.Apply(X,YA1);
    A.Multiply(transA, X, YA2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YA2,"A Multiply and A Apply", verbose),ierr);
    B.Apply(X,YB1);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB1,"A Multiply and B Multiply", verbose),ierr);
    B.Multiply(transA, X, YB2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB2,"A Multiply and B Apply", verbose), ierr);

  }
  {// transpose case
    Epetra_MultiVector X(A.OperatorRangeMap(), NumVectors);
    Epetra_MultiVector YA1(A.OperatorDomainMap(), NumVectors);
    Epetra_MultiVector YA2(YA1);
    Epetra_MultiVector YB1(YA1);
    Epetra_MultiVector YB2(YA1);
    X.Random();

    bool transA = true;
    A.SetUseTranspose(transA);
    B.SetUseTranspose(transA);
    A.Apply(X,YA1);
    A.Multiply(transA, X, YA2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YA2, "A Multiply and A Apply (transpose)", verbose),ierr);
    B.Apply(X,YB1);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB1, "A Multiply and B Multiply (transpose)", verbose),ierr);
    B.Multiply(transA, X,YB2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB2, "A Multiply and B Apply (transpose)", verbose),ierr);

  }

  Epetra_Vector diagA(A.RowMatrixRowMap());
  EPETRA_TEST_ERR(A.ExtractDiagonalCopy(diagA),ierr);
  Epetra_Vector diagB(B.RowMatrixRowMap());
  EPETRA_TEST_ERR(B.ExtractDiagonalCopy(diagB),ierr);
  EPETRA_TEST_ERR(checkMultiVectors(diagA,diagB, "ExtractDiagonalCopy", verbose),ierr);

  Epetra_Vector rowA(A.RowMatrixRowMap());
  EPETRA_TEST_ERR(A.InvRowSums(rowA),ierr);
  Epetra_Vector rowB(B.RowMatrixRowMap());
  EPETRA_TEST_ERR(B.InvRowSums(rowB),ierr)
  EPETRA_TEST_ERR(checkMultiVectors(rowA,rowB, "InvRowSums", verbose),ierr);

  Epetra_Vector colA(A.RowMatrixColMap());
  EPETRA_TEST_ERR(A.InvColSums(colA),ierr);
  Epetra_Vector colB(B.RowMatrixColMap());
  EPETRA_TEST_ERR(B.InvColSums(colB),ierr);
  EPETRA_TEST_ERR(checkMultiVectors(colA,colB, "InvColSums", verbose),ierr);

  EPETRA_TEST_ERR(checkValues(A.NormInf(), B.NormInf(), "NormInf before scaling", verbose), ierr);
  EPETRA_TEST_ERR(checkValues(A.NormOne(), B.NormOne(), "NormOne before scaling", verbose),ierr);

  EPETRA_TEST_ERR(A.RightScale(colA),ierr);
  EPETRA_TEST_ERR(B.RightScale(colB),ierr);


  EPETRA_TEST_ERR(A.LeftScale(rowA),ierr);
  EPETRA_TEST_ERR(B.LeftScale(rowB),ierr);


  EPETRA_TEST_ERR(checkValues(A.NormInf(), B.NormInf(), "NormInf after scaling", verbose), ierr);
  EPETRA_TEST_ERR(checkValues(A.NormOne(), B.NormOne(), "NormOne after scaling", verbose),ierr);

  vector<double> valuesA(A.MaxNumEntries());
  vector<int> indicesA(A.MaxNumEntries());
  vector<double> valuesB(B.MaxNumEntries());
  vector<int> indicesB(B.MaxNumEntries());
  return(0);
  for (int i=0; i<A.NumMyRows(); i++) {
    int nA, nB;
    EPETRA_TEST_ERR(A.ExtractMyRowCopy(i, A.MaxNumEntries(), nA, &valuesA[0], &indicesA[0]),ierr);
    EPETRA_TEST_ERR(B.ExtractMyRowCopy(i, B.MaxNumEntries(), nB, &valuesB[0], &indicesB[0]),ierr);
    EPETRA_TEST_ERR(!nA==nB,ierr);
    for (int j=0; j<nA; j++) {
      double curVal = valuesA[j];
      int curIndex = indicesA[j];
      bool notfound = true;
      int jj = 0;
      while (notfound && jj< nB) {
	if (!checkValues(curVal, valuesB[jj])) notfound = false;
	jj++;
      }
      EPETRA_TEST_ERR(notfound, ierr);
      vector<int>::iterator p = find(indicesB.begin(),indicesB.end(),curIndex);  // find curIndex in indicesB
      EPETRA_TEST_ERR(p==indicesB.end(), ierr);
    }

  }
  if (verbose) cout << "RowMatrix Methods check OK" << endl;

  return (ierr);
}
Esempio n. 29
0
int powerMethodTests(Epetra_RowMatrix & A, Epetra_RowMatrix & JadA, Epetra_Map & Map,
		     Epetra_Vector & q, Epetra_Vector & z, Epetra_Vector & resid, bool verbose) {

  // variable needed for iteration
  double lambda = 0.0;
  // int niters = 10000;
  int niters = 300;
  double tolerance = 1.0e-2;
  int ierr = 0;

  /////////////////////////////////////////////////////////////////////////////////////////////////
	
  // Iterate

  Epetra_Time timer(Map.Comm());
	
  double startTime = timer.ElapsedTime();
  EPETRA_TEST_ERR(power_method(false, A, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  double elapsed_time = timer.ElapsedTime() - startTime;
  double total_flops = q.Flops();
  double MFLOPs = total_flops/elapsed_time/1000000.0;
  double lambdaref = lambda;
  double flopsref = total_flops;

  if (verbose)
	  cout << "\n\nTotal MFLOPs for reference first solve = " << MFLOPs << endl
		  <<     "Total FLOPS                            = " <<total_flops <<endl<<endl;

  lambda = 0.0;
  startTime = timer.ElapsedTime();
  EPETRA_TEST_ERR(power_method(false, JadA, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  elapsed_time = timer.ElapsedTime() - startTime;
  total_flops = q.Flops();
  MFLOPs = total_flops/elapsed_time/1000000.0;

  if (verbose)
	  cout << "\n\nTotal MFLOPs for candidate first solve = " << MFLOPs << endl
		  <<     "Total FLOPS                            = " <<total_flops <<endl<<endl;

  EPETRA_TEST_ERR(checkValues(lambda,lambdaref," No-transpose Power Method result", verbose),ierr);
  EPETRA_TEST_ERR(checkValues(total_flops,flopsref," No-transpose Power Method flop count", verbose),ierr);

  /////////////////////////////////////////////////////////////////////////////////////////////////
	
  // Solve transpose problem

  if (verbose) cout << "\n\nUsing transpose of matrix and solving again (should give same result).\n\n"
		    << endl;
  // Iterate
  lambda = 0.0;
  startTime = timer.ElapsedTime();
  EPETRA_TEST_ERR(power_method(true, A, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  elapsed_time = timer.ElapsedTime() - startTime;
  total_flops = q.Flops();
  MFLOPs = total_flops/elapsed_time/1000000.0;
  lambdaref = lambda;
  flopsref = total_flops;

  if (verbose)
	 cout << "\n\nTotal MFLOPs for reference transpose solve = " << MFLOPs << endl
		 <<     "Total FLOPS                                = " <<total_flops <<endl<<endl;

  lambda = 0.0;
  startTime = timer.ElapsedTime();
  EPETRA_TEST_ERR(power_method(true, JadA, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
  elapsed_time = timer.ElapsedTime() - startTime;
  total_flops = q.Flops();
  MFLOPs = total_flops/elapsed_time/1000000.0;

  if (verbose)
	  cout << "\n\nTotal MFLOPs for candidate transpose solve = " << MFLOPs << endl
		  <<     "Total FLOPS                                = " <<total_flops <<endl<<endl;

  EPETRA_TEST_ERR(checkValues(lambda,lambdaref,"Transpose Power Method result", verbose),ierr);
  EPETRA_TEST_ERR(checkValues(total_flops,flopsref,"Transpose Power Method flop count", verbose),ierr);

  EPETRA_TEST_ERR(check(A, JadA, verbose),ierr);

  return(0);
}
int check(CT_Epetra_RowMatrix_ID_t& A, CT_Epetra_RowMatrix_ID_t & B, bool verbose)  {  

  int ierr = 0;

  CT_Epetra_Operator_ID_t tmp_oA = Epetra_Operator_Degeneralize(Epetra_RowMatrix_Generalize(A));
  CT_Epetra_Operator_ID_t tmp_oB = Epetra_Operator_Degeneralize(Epetra_RowMatrix_Generalize(B));

  CT_Epetra_Comm_ID_t CommA = Epetra_Operator_Comm(tmp_oA);
  CT_Epetra_Comm_ID_t CommB = Epetra_Operator_Comm(tmp_oB);
  EPETRA_TEST_ERR(!Epetra_Comm_NumProc(CommA)==Epetra_Comm_NumProc(CommB),ierr);
  EPETRA_TEST_ERR(!Epetra_Comm_MyPID(CommA)==Epetra_Comm_MyPID(CommB),ierr);
  Epetra_Comm_Destroy(&CommB);
  Epetra_Comm_Destroy(&CommA);

  EPETRA_TEST_ERR(!Epetra_RowMatrix_Filled(A)==Epetra_RowMatrix_Filled(B),ierr);
  EPETRA_TEST_ERR(!Epetra_Operator_HasNormInf(tmp_oA)==Epetra_Operator_HasNormInf(tmp_oB),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_LowerTriangular(A)==Epetra_RowMatrix_LowerTriangular(B),ierr);

  CT_Epetra_BlockMap_ID_t mapA = Epetra_SrcDistObject_Map(Epetra_SrcDistObject_Degeneralize(
      Epetra_RowMatrix_Generalize(A)));
  CT_Epetra_BlockMap_ID_t mapB = Epetra_SrcDistObject_Map(Epetra_SrcDistObject_Degeneralize(
      Epetra_RowMatrix_Generalize(B)));
  EPETRA_TEST_ERR(!Epetra_BlockMap_SameAs(mapA, mapB),ierr);
  Epetra_BlockMap_Destroy(&mapB);
  Epetra_BlockMap_Destroy(&mapA);

  EPETRA_TEST_ERR(!Epetra_RowMatrix_MaxNumEntries(A)==Epetra_RowMatrix_MaxNumEntries(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumGlobalCols(A)==Epetra_RowMatrix_NumGlobalCols(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumGlobalDiagonals(A)==Epetra_RowMatrix_NumGlobalDiagonals(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumGlobalNonzeros(A)==Epetra_RowMatrix_NumGlobalNonzeros(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumGlobalRows(A)==Epetra_RowMatrix_NumGlobalRows(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumMyCols(A)==Epetra_RowMatrix_NumMyCols(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumMyDiagonals(A)==Epetra_RowMatrix_NumMyDiagonals(B),ierr);
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumMyNonzeros(A)==Epetra_RowMatrix_NumMyNonzeros(B),ierr);
  for (int i=0; i<Epetra_RowMatrix_NumMyRows(A); i++) {
    int nA, nB;
    Epetra_RowMatrix_NumMyRowEntries(A,i,&nA);
    Epetra_RowMatrix_NumMyRowEntries(B,i,&nB);
    EPETRA_TEST_ERR(!nA==nB,ierr);
  }
  EPETRA_TEST_ERR(!Epetra_RowMatrix_NumMyRows(A)==Epetra_RowMatrix_NumMyRows(B),ierr);

  CT_Epetra_BlockMap_ID_t bodmA = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_Operator_OperatorDomainMap(tmp_oA)));
  CT_Epetra_BlockMap_ID_t bodmB = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_Operator_OperatorDomainMap(tmp_oB)));
  EPETRA_TEST_ERR(!Epetra_BlockMap_SameAs(bodmA, bodmB),ierr);

  CT_Epetra_BlockMap_ID_t bormA = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_Operator_OperatorRangeMap(tmp_oA)));
  CT_Epetra_BlockMap_ID_t bormB = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_Operator_OperatorRangeMap(tmp_oB)));
  EPETRA_TEST_ERR(!Epetra_BlockMap_SameAs(bormA, bormB),ierr);

  CT_Epetra_BlockMap_ID_t brcmA = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_RowMatrix_RowMatrixColMap(A)));
  CT_Epetra_BlockMap_ID_t brcmB = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_RowMatrix_RowMatrixColMap(B)));
  EPETRA_TEST_ERR(!Epetra_BlockMap_SameAs(brcmA, brcmB),ierr);

  CT_Epetra_BlockMap_ID_t brrmA = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_RowMatrix_RowMatrixRowMap(A)));
  CT_Epetra_BlockMap_ID_t brrmB = Epetra_BlockMap_Degeneralize(Epetra_Map_Generalize(
      Epetra_RowMatrix_RowMatrixRowMap(B)));
  EPETRA_TEST_ERR(!Epetra_BlockMap_SameAs(brrmA, brrmB),ierr);

  EPETRA_TEST_ERR(!Epetra_RowMatrix_UpperTriangular(A)==Epetra_RowMatrix_UpperTriangular(B),ierr);
  EPETRA_TEST_ERR(!Epetra_Operator_UseTranspose(tmp_oA)==Epetra_Operator_UseTranspose(tmp_oB),ierr);

  int NumVectors = 5;
  { // No transpose case
    CT_Epetra_MultiVector_ID_t X = Epetra_MultiVector_Create(bodmA, NumVectors, TRUE);
    CT_Epetra_MultiVector_ID_t YA1 = Epetra_MultiVector_Create(bormA, NumVectors, TRUE);
    CT_Epetra_MultiVector_ID_t YA2 = Epetra_MultiVector_Duplicate(YA1);
    CT_Epetra_MultiVector_ID_t YB1 = Epetra_MultiVector_Duplicate(YA1);
    CT_Epetra_MultiVector_ID_t YB2 = Epetra_MultiVector_Duplicate(YA1);
    Epetra_MultiVector_Random(X);
    
    boolean transA = FALSE;
    Epetra_Operator_SetUseTranspose(tmp_oA, transA);
    Epetra_Operator_SetUseTranspose(tmp_oB, transA);
    Epetra_Operator_Apply(tmp_oA,X,YA1);
    Epetra_RowMatrix_Multiply(A, transA, X, YA2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YA2,"A Multiply and A Apply", verbose),ierr);
    Epetra_Operator_Apply(tmp_oB,X,YB1);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB1,"A Multiply and B Multiply", verbose),ierr);
    Epetra_RowMatrix_Multiply(B, transA, X, YB2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB2,"A Multiply and B Apply", verbose), ierr);

    Epetra_MultiVector_Destroy(&X);
    Epetra_MultiVector_Destroy(&YB2);
    Epetra_MultiVector_Destroy(&YB1);
    Epetra_MultiVector_Destroy(&YA2);
    Epetra_MultiVector_Destroy(&YA1);
    
  }
  {// transpose case
    CT_Epetra_MultiVector_ID_t X = Epetra_MultiVector_Create(bormA, NumVectors, TRUE);
    CT_Epetra_MultiVector_ID_t YA1 = Epetra_MultiVector_Create(bodmA, NumVectors, TRUE);
    CT_Epetra_MultiVector_ID_t YA2 = Epetra_MultiVector_Duplicate(YA1);
    CT_Epetra_MultiVector_ID_t YB1 = Epetra_MultiVector_Duplicate(YA1);
    CT_Epetra_MultiVector_ID_t YB2 = Epetra_MultiVector_Duplicate(YA1);
    Epetra_MultiVector_Random(X);
    
    boolean transA = TRUE;
    Epetra_Operator_SetUseTranspose(tmp_oA, transA);
    Epetra_Operator_SetUseTranspose(tmp_oB, transA);
    Epetra_Operator_Apply(tmp_oA,X,YA1);
    Epetra_RowMatrix_Multiply(A, transA, X, YA2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YA2, "A Multiply and A Apply (transpose)", verbose),ierr);
    Epetra_Operator_Apply(tmp_oB,X,YB1);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB1, "A Multiply and B Multiply (transpose)", verbose),ierr);
    Epetra_RowMatrix_Multiply(B, transA, X, YB2);
    EPETRA_TEST_ERR(checkMultiVectors(YA1,YB2, "A Multiply and B Apply (transpose)", verbose),ierr);
    
    Epetra_MultiVector_Destroy(&X);
    Epetra_MultiVector_Destroy(&YB2);
    Epetra_MultiVector_Destroy(&YB1);
    Epetra_MultiVector_Destroy(&YA2);
    Epetra_MultiVector_Destroy(&YA1);
    
  }

  CT_Epetra_Vector_ID_Flex_t diagA;
  diagA.Epetra_Vector = Epetra_Vector_Create(brrmA, TRUE);
  EPETRA_TEST_ERR(Epetra_RowMatrix_ExtractDiagonalCopy(A, diagA.Epetra_Vector),ierr);
  CT_Epetra_Vector_ID_Flex_t diagB;
  diagB.Epetra_Vector = Epetra_Vector_Create(brrmB, TRUE);
  EPETRA_TEST_ERR(Epetra_RowMatrix_ExtractDiagonalCopy(B, diagB.Epetra_Vector),ierr);
  EPETRA_TEST_ERR(checkMultiVectors(diagA.Epetra_MultiVector,diagB.Epetra_MultiVector,
      "ExtractDiagonalCopy", verbose),ierr);

  CT_Epetra_Vector_ID_Flex_t rowA;
  rowA.Epetra_Vector = Epetra_Vector_Create(brrmA, TRUE);
  EPETRA_TEST_ERR(Epetra_RowMatrix_InvRowSums(A, rowA.Epetra_Vector),ierr);
  CT_Epetra_Vector_ID_Flex_t rowB;
  rowB.Epetra_Vector = Epetra_Vector_Create(brrmB, TRUE);
  EPETRA_TEST_ERR(Epetra_RowMatrix_InvRowSums(B, rowB.Epetra_Vector),ierr)
  EPETRA_TEST_ERR(checkMultiVectors(rowA.Epetra_MultiVector,rowB.Epetra_MultiVector,
      "InvRowSums", verbose),ierr);

  CT_Epetra_Vector_ID_Flex_t colA;
  colA.Epetra_Vector = Epetra_Vector_Create(brcmA, TRUE);
  EPETRA_TEST_ERR(Epetra_RowMatrix_InvColSums(A, colA.Epetra_Vector),ierr);
  CT_Epetra_Vector_ID_Flex_t colB;
  colB.Epetra_Vector = Epetra_Vector_Create(brcmB, TRUE);
  EPETRA_TEST_ERR(Epetra_RowMatrix_InvColSums(B, colB.Epetra_Vector),ierr);
  EPETRA_TEST_ERR(checkMultiVectors(colA.Epetra_MultiVector,colB.Epetra_MultiVector,
      "InvColSums", verbose),ierr);

  EPETRA_TEST_ERR(checkValues(Epetra_RowMatrix_NormInf(A), Epetra_RowMatrix_NormInf(B), "NormInf before scaling", verbose), ierr);
  EPETRA_TEST_ERR(checkValues(Epetra_RowMatrix_NormOne(A), Epetra_RowMatrix_NormOne(B), "NormOne before scaling", verbose),ierr);

  EPETRA_TEST_ERR(Epetra_RowMatrix_RightScale(A, colA.Epetra_Vector),ierr);  
  EPETRA_TEST_ERR(Epetra_RowMatrix_RightScale(B, colB.Epetra_Vector),ierr);


  EPETRA_TEST_ERR(Epetra_RowMatrix_LeftScale(A, rowA.Epetra_Vector),ierr);
  EPETRA_TEST_ERR(Epetra_RowMatrix_LeftScale(B, rowB.Epetra_Vector),ierr);

  Epetra_Vector_Destroy(&colB.Epetra_Vector);
  Epetra_Vector_Destroy(&colA.Epetra_Vector);
  Epetra_Vector_Destroy(&rowB.Epetra_Vector);
  Epetra_Vector_Destroy(&rowA.Epetra_Vector);
  Epetra_Vector_Destroy(&diagB.Epetra_Vector);
  Epetra_Vector_Destroy(&diagA.Epetra_Vector);

  Epetra_BlockMap_Destroy(&brrmA);
  Epetra_BlockMap_Destroy(&brrmB);
  Epetra_BlockMap_Destroy(&brcmA);
  Epetra_BlockMap_Destroy(&brcmB);
  Epetra_BlockMap_Destroy(&bormA);
  Epetra_BlockMap_Destroy(&bormB);
  Epetra_BlockMap_Destroy(&bodmA);
  Epetra_BlockMap_Destroy(&bodmB);

  EPETRA_TEST_ERR(checkValues(Epetra_RowMatrix_NormInf(A), Epetra_RowMatrix_NormInf(B), "NormInf after scaling", verbose), ierr);
  EPETRA_TEST_ERR(checkValues(Epetra_RowMatrix_NormOne(A), Epetra_RowMatrix_NormOne(B), "NormOne after scaling", verbose),ierr);

  vector<double> valuesA(Epetra_RowMatrix_MaxNumEntries(A));
  vector<int> indicesA(Epetra_RowMatrix_MaxNumEntries(A));  
  vector<double> valuesB(Epetra_RowMatrix_MaxNumEntries(B));
  vector<int> indicesB(Epetra_RowMatrix_MaxNumEntries(B));
  return(0);
  for (int i=0; i<Epetra_RowMatrix_NumMyRows(A); i++) {
    int nA, nB;
    EPETRA_TEST_ERR(Epetra_RowMatrix_ExtractMyRowCopy(A, i, Epetra_RowMatrix_MaxNumEntries(A), &nA, &valuesA[0], &indicesA[0]),ierr); 
    EPETRA_TEST_ERR(Epetra_RowMatrix_ExtractMyRowCopy(B, i, Epetra_RowMatrix_MaxNumEntries(B), &nB, &valuesB[0], &indicesB[0]),ierr);
    EPETRA_TEST_ERR(!nA==nB,ierr);
    for (int j=0; j<nA; j++) {
      double curVal = valuesA[j];
      int curIndex = indicesA[j];
      bool notfound = true;
      int jj = 0;
      while (notfound && jj< nB) {
	if (!checkValues(curVal, valuesB[jj])) notfound = false;
	jj++;
      }
      EPETRA_TEST_ERR(notfound, ierr);
      vector<int>::iterator p = find(indicesB.begin(),indicesB.end(),curIndex);  // find curIndex in indicesB
      EPETRA_TEST_ERR(p==indicesB.end(), ierr);
    }

  }
  if (verbose) cout << "RowMatrix Methods check OK" << endl;

  return (ierr);
}