Vespucci  1.0.0
dimensionalityestimationdialog.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
21 #include "ui_dimensionalityestimationdialog.h"
23 
24 DimensionalityEstimationDialog::DimensionalityEstimationDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> workspace, const QStringList &matrix_keys) :
25  QDialog(parent),
27 {
28  ui->setupUi(this);
29  matrix_keys_ = matrix_keys;
30  workspace_ = workspace;
31 }
32 
34 {
35  delete ui;
36 }
37 
38 void DimensionalityEstimationDialog::on_buttonBox_accepted()
39 {
40  size_t rank;
41  arma::mat subspace;
42  try{
43  arma::mat matrix = workspace_->GetMatrix(matrix_keys_);
44  QSharedPointer<VespucciDataset> parent_dataset = workspace_->GetDataset(matrix_keys_.first());
45  if (ui->methodComboBox->currentText() == "SVD")
46  rank = arma::rank(matrix);
47  else if (ui->methodComboBox->currentText() == "HySime"){
48  rank = Vespucci::Math::DimensionReduction::HySime(matrix, subspace);
49  parent_dataset->AddAuxiliaryMatrix(matrix_keys_.last() + " HySime subspace", subspace);
50  }
51  else{
52  workspace_->main_window()->DisplayWarning("Error", "Invalid type!");
53  return;
54  }
55  arma::vec rank_mat({double(rank)});
56  parent_dataset->AddAuxiliaryMatrix(matrix_keys_.last() + " Estimated Rank", rank_mat);
57  }catch(std::exception e){
58  workspace_->main_window()->DisplayExceptionWarning(e);
59  }
60  close();
61 }
Definition: ahcadialog.h:26
VESPUCCI_EXPORT size_t HySime(const arma::mat &y, const arma::mat &n, arma::mat &Rn, arma::mat &Ek)
Vespucci::Math::DimensionReduction::HySime.
Definition: VCA.cpp:159
DimensionalityEstimationDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > workspace, const QStringList &matrix_keys)