本文整理汇总了C++中BaseVector::get_size方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseVector::get_size方法的具体用法?C++ BaseVector::get_size怎么用?C++ BaseVector::get_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseVector
的用法示例。
在下文中一共展示了BaseVector::get_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool HostMatrixCOO<ValueType>::Permute(const BaseVector<int> &permutation) {
assert(&permutation != NULL);
// symmetric permutation only
assert( (permutation.get_size() == this->get_nrow()) &&
(permutation.get_size() == this->get_ncol()) );
const HostVector<int> *cast_perm = dynamic_cast<const HostVector<int>*> (&permutation) ;
assert(cast_perm != NULL);
HostMatrixCOO<ValueType> src(this->local_backend_);
src.AllocateCOO(this->get_nnz(), this->get_nrow(), this->get_ncol());
src.CopyFrom(*this);
omp_set_num_threads(this->local_backend_.OpenMP_threads);
#pragma omp parallel for
for (int i=0; i<this->get_nnz(); ++i) {
this->mat_.row[i] = cast_perm->vec_[ src.mat_.row[i] ];
this->mat_.col[i] = cast_perm->vec_[ src.mat_.col[i] ];
}
return true;
}
示例2: assert
bool HostMatrixCOO<ValueType>::PermuteBackward(const BaseVector<int> &permutation) {
assert(&permutation != NULL);
// symmetric permutation only
assert( (permutation.get_size() == this->nrow_) &&
(permutation.get_size() == this->ncol_) );
const HostVector<int> *cast_perm = dynamic_cast<const HostVector<int>*> (&permutation);
assert(cast_perm != NULL);
HostMatrixCOO<ValueType> src(this->local_backend_);
src.AllocateCOO(this->nnz_, this->nrow_, this->ncol_);
src.CopyFrom(*this);
_set_omp_backend_threads(this->local_backend_, this->nnz_);
// TODO
// Is there a better way?
int *pb = NULL;
allocate_host(this->nrow_, &pb);
#pragma omp parallel for
for (int i=0; i<this->nrow_; ++i)
pb [ cast_perm->vec_[i] ] = i;
#pragma omp parallel for
for (int i=0; i<this->nnz_; ++i) {
this->mat_.row[i] = pb[src.mat_.row[i]];
this->mat_.col[i] = pb[src.mat_.col[i]];
}
free_host(&pb);
return true;
}