本文整理汇总了C++中BaseMatrix::CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseMatrix::CopyTo方法的具体用法?C++ BaseMatrix::CopyTo怎么用?C++ BaseMatrix::CopyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseMatrix
的用法示例。
在下文中一共展示了BaseMatrix::CopyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void HostMatrixCOO<ValueType>::CopyFrom(const BaseMatrix<ValueType> &mat) {
// copy only in the same format
assert(this->get_mat_format() == mat.get_mat_format());
if (const HostMatrixCOO<ValueType> *cast_mat = dynamic_cast<const HostMatrixCOO<ValueType>*> (&mat)) {
if (this->get_nnz() == 0)
this->AllocateCOO(mat.get_nnz(), mat.get_nrow(), mat.get_ncol() );
assert((this->get_nnz() == mat.get_nnz()) &&
(this->get_nrow() == mat.get_nrow()) &&
(this->get_ncol() == mat.get_ncol()) );
if (this->get_nnz() > 0) {
omp_set_num_threads(this->local_backend_.OpenMP_threads);
#pragma omp parallel for
for (int j=0; j<this->get_nnz(); ++j)
this->mat_.row[j] = cast_mat->mat_.row[j];
#pragma omp parallel for
for (int j=0; j<this->get_nnz(); ++j)
this->mat_.col[j] = cast_mat->mat_.col[j];
#pragma omp parallel for
for (int j=0; j<this->get_nnz(); ++j)
this->mat_.val[j] = cast_mat->mat_.val[j];
}
} else {
// Host matrix knows only host matrices
// -> dispatching
mat.CopyTo(this);
}
}
示例2: assert
void HostMatrixELL<ValueType>::CopyFrom(const BaseMatrix<ValueType> &mat) {
// copy only in the same format
assert(this->get_mat_format() == mat.get_mat_format());
if (const HostMatrixELL<ValueType> *cast_mat = dynamic_cast<const HostMatrixELL<ValueType>*> (&mat)) {
this->AllocateELL(cast_mat->nnz_, cast_mat->nrow_, cast_mat->ncol_, cast_mat->mat_.max_row);
assert((this->nnz_ == cast_mat->nnz_) &&
(this->nrow_ == cast_mat->nrow_) &&
(this->ncol_ == cast_mat->ncol_));
if (this->nnz_ > 0) {
_set_omp_backend_threads(this->local_backend_, this->nrow_);
int nnz = this->nnz_;
#pragma omp parallel for
for (int i=0; i<nnz; ++i)
this->mat_.val[i] = cast_mat->mat_.val[i];
#pragma omp parallel for
for (int i=0; i<nnz; ++i)
this->mat_.col[i] = cast_mat->mat_.col[i];
}
} else {
// Host matrix knows only host matrices
// -> dispatching
mat.CopyTo(this);
}
}