本文整理汇总了C++中QSharedPointer::GetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer::GetMatrix方法的具体用法?C++ QSharedPointer::GetMatrix怎么用?C++ QSharedPointer::GetMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSharedPointer
的用法示例。
在下文中一共展示了QSharedPointer::GetMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Concatenate
///
/// \brief AnalysisResults::Concatenate
/// \param other
/// Merge the matrices of other into the same-named matrices of this one
/// Will perform a check of mergability for every matrix before performing merge
/// Non mergable matrices are removed from this result.
bool AnalysisResults::Concatenate(QSharedPointer<AnalysisResults> other)
{
QSet<QString> intersection = KeyList().toSet().intersect(other->KeyList().toSet());
//Check mergability (this should not be a problem if both come from same dataset)
//User may be allowed to merge from two different datasets, if for some reason they wanted to do that
QSet<QString> mergeable_matrices = intersection;
for (auto key: intersection)
if (GetMatrix(key).n_rows != other->GetMatrix(key).n_rows) {
mergeable_matrices.remove(key);
RemoveMatrix(key);
}
if (mergeable_matrices.isEmpty()) return false;
for (auto key: mergeable_matrices) {
mat matrix = GetMatrix(key);
mat other_matrix = other->GetMatrix(key);
matrix = join_horiz(matrix, other_matrix);
AddMatrix(key, matrix);
}
return true;
}
示例2: TreeItem
DatasetTreeModel::DatasetTreeModel(QObject *parent, const DataModel *data_model)
: QAbstractItemModel(parent)
{
QStringList root_keys;
QList<QVariant> root_data = {QVariant("Title"), QVariant("Description")};
root_item_ = new TreeItem(TreeItem::ItemType::Base, root_keys, root_data, 0);
QStringList dataset_keys = data_model->DatasetNames();
for (auto dataset_key: dataset_keys){
QStringList dataset_item_keys = {dataset_key};
QList<QVariant> dataset_item_data = {QVariant(dataset_key),
QVariant("Dataset")};
TreeItem *dataset_tree_item = new TreeItem(TreeItem::ItemType::Dataset,
dataset_item_keys, dataset_item_data,
root_item_);
QSharedPointer<VespucciDataset> dataset = data_model->GetDataset(dataset_key);
QList<QStringList> corekeys = {
{dataset_key, "Spectra"},
{dataset_key, "Spectral Abscissa"},
{dataset_key, "x"},
{dataset_key, "y"}
};
QList<QList<QVariant> > coredata = {
{"Spectra", DescribeSpectra(dataset->spectra_ref())},
{"Spectral Abscissa", DescribeAbscissa(dataset->abscissa_ref())},
{"x", DescribeMatrix(dataset->x_ref())},
{"y", DescribeMatrix(dataset->y_ref())}
};
for (int i = 0; i < coredata.size(); ++i){
TreeItem *coreitem = new TreeItem(TreeItem::Matrix,
corekeys[i],
coredata[i],
dataset_tree_item);
dataset_tree_item->appendChild(coreitem);
}
for (auto matrix_key: dataset->AuxiliaryMatrixKeys()){
QStringList item_keys = {dataset_key, matrix_key};
QList<QVariant> item_data =
{QVariant(matrix_key),
QVariant(DescribeMatrix(dataset->GetAuxiliaryMatrix(matrix_key)))
};
TreeItem *matrix_item = new TreeItem(TreeItem::ItemType::Matrix,
item_keys, item_data,
dataset_tree_item);
dataset_tree_item->appendChild(matrix_item);
}
for (auto results_key: dataset->AnalysisResultsKeys()){
QSharedPointer<AnalysisResults> results =
dataset->GetAnalysisResult(results_key);
QStringList results_item_keys = {dataset_key, results_key};
QList<QVariant> results_item_data = {QVariant(results_key),
QVariant(results->type())};
TreeItem *results_tree_item =
new TreeItem(TreeItem::ItemType::AnalysisResult,
results_item_keys,
results_item_data,
dataset_tree_item);
for (auto matrix_key: results->KeyList()){
QStringList matrix_item_keys = {dataset_key, results_key, matrix_key};
QList<QVariant> matrix_item_data = {QVariant(matrix_key),
QVariant(DescribeMatrix(results->GetMatrix(matrix_key)))
};
TreeItem *matrix_tree_item =
new TreeItem(TreeItem::Matrix,
matrix_item_keys,
matrix_item_data,
results_tree_item);
results_tree_item->appendChild(matrix_tree_item);
}
dataset_tree_item->appendChild(results_tree_item);
}
for (auto map_key: dataset->MapKeys()){
QSharedPointer<MapData> mapdata = dataset->GetMapData(map_key);
QStringList map_item_keys = {dataset_key, map_key};
QList<QVariant> map_item_data = {QVariant(map_key),
QVariant(mapdata->type())};
TreeItem *map_tree_item =
new TreeItem(TreeItem::Map,
map_item_keys,
map_item_data,
dataset_tree_item);
dataset_tree_item->appendChild(map_tree_item);
}
root_item_->appendChild(dataset_tree_item);
}
}