当前位置: 首页>>代码示例>>C++>>正文


C++ BaseMatrix::get_nnz方法代码示例

本文整理汇总了C++中BaseMatrix::get_nnz方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseMatrix::get_nnz方法的具体用法?C++ BaseMatrix::get_nnz怎么用?C++ BaseMatrix::get_nnz使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseMatrix的用法示例。


在下文中一共展示了BaseMatrix::get_nnz方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

void OCLAcceleratorMatrixCOO<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const OCLAcceleratorMatrixCOO<ValueType> *ocl_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // OCL to OCL copy
  if ((ocl_cast_mat = dynamic_cast<const OCLAcceleratorMatrixCOO<ValueType>*> (&src)) != NULL) {
    
    if (this->get_nnz() == 0)
      this->AllocateCOO(src.get_nnz(), src.get_nrow(), src.get_ncol() );

    assert((this->get_nnz()  == src.get_nnz())  &&
	   (this->get_nrow() == src.get_nrow()) &&
	   (this->get_ncol() == src.get_ncol()) );

    if (this->get_nnz() > 0) {

      // Copy object from device to device memory (internal copy)
      ocl_dev2dev<int>(this->get_nnz(), // size
                       ocl_cast_mat->mat_.row, // src
                       this->mat_.row,         // dst
                       OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

      // Copy object from device to device memory (internal copy)
      ocl_dev2dev<int>(this->get_nnz(), // size
                       ocl_cast_mat->mat_.col, // src
                       this->mat_.col,         // dst
                       OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

      // Copy object from device to device memory (internal copy)
      ocl_dev2dev<ValueType>(this->get_nnz(), // size
                             ocl_cast_mat->mat_.val, // src
                             this->mat_.val,         // dst
                             OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

    }

  } else {

    //CPU to OCL
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported OCL matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
开发者ID:LeiDai,项目名称:agros2d,代码行数:59,代码来源:ocl_matrix_coo.cpp

示例2: assert

void MICAcceleratorMatrixCOO<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const MICAcceleratorMatrixCOO<ValueType> *mic_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<const MICAcceleratorMatrixCOO<ValueType>*> (&src)) != NULL) {
    
  if (this->get_nnz() == 0)
    this->AllocateCOO(src.get_nnz(), src.get_nrow(), src.get_ncol() );

    assert((this->get_nnz()  == src.get_nnz())  &&
	   (this->get_nrow() == src.get_nrow()) &&
	   (this->get_ncol() == src.get_ncol()) );

    if (this->get_nnz() > 0) {

      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.row, this->mat_.row, this->get_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.col, this->mat_.col, this->get_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.val, this->mat_.val, this->get_nnz());

    }

  } else {

    //CPU to MIC
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
开发者ID:itabhiyanta,项目名称:paralution_07_rohit,代码行数:48,代码来源:mic_matrix_coo.cpp

示例3:

bool HostMatrixCOO<ValueType>::ConvertFrom(const BaseMatrix<ValueType> &mat) {

  this->Clear();

  // empty matrix is empty matrix
  if (mat.get_nnz() == 0)
    return true;

    if (const HostMatrixCOO<ValueType> *cast_mat = dynamic_cast<const HostMatrixCOO<ValueType>*> (&mat)) {

      this->CopyFrom(*cast_mat);
      return true;

  }


    if (const HostMatrixCSR<ValueType> *cast_mat = dynamic_cast<const HostMatrixCSR<ValueType>*> (&mat)) {

      this->Clear();
      csr_to_coo(this->local_backend_.OpenMP_threads,
                 cast_mat->get_nnz(), cast_mat->get_nrow(), cast_mat->get_ncol(),
		 cast_mat->mat_, &this->mat_);

      this->nrow_ = cast_mat->get_nrow();
      this->ncol_ = cast_mat->get_ncol();
      this->nnz_  = cast_mat->get_nnz();

    return true;

  }
  
  return false;

}
开发者ID:dcm3c,项目名称:agros2d,代码行数:34,代码来源:host_matrix_coo.cpp

示例4: 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);
    
  }
  
}
开发者ID:dcm3c,项目名称:agros2d,代码行数:42,代码来源:host_matrix_coo.cpp

示例5: assert

void OCLAcceleratorMatrixBCSR<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const OCLAcceleratorMatrixBCSR<ValueType> *ocl_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // OCL to OCL copy
  if ((ocl_cast_mat = dynamic_cast<const OCLAcceleratorMatrixBCSR<ValueType>*> (&src)) != NULL) {
    
  if (this->get_nnz() == 0)
    this->AllocateBCSR(src.get_nnz(), src.get_nrow(), src.get_ncol() );  

    assert((this->get_nnz()  == src.get_nnz())  &&
	   (this->get_nrow() == src.get_nrow()) &&
	   (this->get_ncol() == src.get_ncol()) );

    ocl_cast_mat->get_nnz();

    FATAL_ERROR(__FILE__, __LINE__);    

    
  } else {

    //CPU to OCL
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported OCL matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
开发者ID:georgeliao,项目名称:paralution_VBCSR,代码行数:42,代码来源:ocl_matrix_bcsr.cpp

示例6: assert

void MICAcceleratorMatrixDIA<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const MICAcceleratorMatrixDIA<ValueType> *mic_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<const MICAcceleratorMatrixDIA<ValueType>*> (&src)) != NULL) {
    
  if (this->get_nnz() == 0)
    this->AllocateDIA(mic_cast_mat->get_nnz(), mic_cast_mat->get_nrow(), mic_cast_mat->get_ncol(), mic_cast_mat->get_ndiag());

    assert((this->get_nnz()  == src.get_nnz())  &&
	   (this->get_nrow() == src.get_nrow()) &&
	   (this->get_ncol() == src.get_ncol()) );

    if (this->get_nnz() > 0) {

      copy_mic_mic(mic_cast_mat->mat_.val, this->mat_.val, this->get_nnz());
      copy_mic_mic(mic_cast_mat->mat_.offset, this->mat_.offset, this->mat_.num_diag);

      /*
      // TODO
      for (int j=0; j<this->get_nnz(); ++j)
        this->mat_.val[j] = mic_cast_mat->mat_.val[j];
      
      for (int j=0; j<this->mat_.num_diag; ++j)
        this->mat_.offset[j] = mic_cast_mat->mat_.offset[j];
      */

    }

  } else {

    //CPU to MIC
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
开发者ID:dcm3c,项目名称:agros2d,代码行数:53,代码来源:mic_matrix_dia.cpp

示例7:

bool MICAcceleratorMatrixHYB<ValueType>::ConvertFrom(const BaseMatrix<ValueType> &mat) {

  this->Clear();

  // empty matrix is empty matrix
  if (mat.get_nnz() == 0)
    return true;

  const MICAcceleratorMatrixHYB<ValueType>   *cast_mat_hyb;
  
  if ((cast_mat_hyb = dynamic_cast<const MICAcceleratorMatrixHYB<ValueType>*> (&mat)) != NULL) {

    this->CopyFrom(*cast_mat_hyb);
    return true;

  }

  return false;

}
开发者ID:dcm3c,项目名称:agros2d,代码行数:20,代码来源:mic_matrix_hyb.cpp

示例8:

bool OCLAcceleratorMatrixBCSR<ValueType>::ConvertFrom(const BaseMatrix<ValueType> &mat) {

  this->Clear();

  // empty matrix is empty matrix
  if (mat.get_nnz() == 0)
    return true;

  const OCLAcceleratorMatrixBCSR<ValueType> *cast_mat_bcsr;
  
  if ((cast_mat_bcsr = dynamic_cast<const OCLAcceleratorMatrixBCSR<ValueType>*> (&mat)) != NULL) {

      this->CopyFrom(*cast_mat_bcsr);
      return true;

  }

  /*
    const OCLAcceleratorMatrixCSR<ValueType>  *cast_mat_csr;
    if ((cast_mat_csr = dynamic_cast<const OCLAcceleratorMatrixCSR<ValueType>*> (&mat)) != NULL) {

      this->Clear();

      FATAL_ERROR(__FILE__, __LINE__);

      this->nrow_ = cast_mat_csr->get_nrow();
      this->ncol_ = cast_mat_csr->get_ncol();
      this->nnz_  = cast_mat_csr->get_nnz();

    return 0;

  }
  */

  return false;

}
开发者ID:georgeliao,项目名称:paralution_VBCSR,代码行数:37,代码来源:ocl_matrix_bcsr.cpp

示例9: assert

void MICAcceleratorMatrixHYB<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const MICAcceleratorMatrixHYB<ValueType> *mic_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<const MICAcceleratorMatrixHYB<ValueType>*> (&src)) != NULL) {
    
  if (this->get_nnz() == 0)
    this->AllocateHYB(mic_cast_mat->get_ell_nnz(), mic_cast_mat->get_coo_nnz(), mic_cast_mat->get_ell_max_row(),
                      mic_cast_mat->get_nrow(), mic_cast_mat->get_ncol());

    assert((this->get_nnz()  == src.get_nnz())  &&
	   (this->get_nrow() == src.get_nrow()) &&
	   (this->get_ncol() == src.get_ncol()) );

      // TODO
    if (this->get_ell_nnz() > 0) {
      
      copy_mic_mic(mic_cast_mat->mat_.ELL.val, this->mat_.ELL.val, this->get_ell_nnz());
      copy_mic_mic(mic_cast_mat->mat_.ELL.col, this->mat_.ELL.col, this->get_ell_nnz());

      /*
      // ELL

      for (int i=0; i<this->get_ell_nnz(); ++i)
        this->mat_.ELL.col[i] = mic_cast_mat->mat_.ELL.col[i];

      for (int i=0; i<this->get_ell_nnz(); ++i)
        this->mat_.ELL.val[i] = mic_cast_mat->mat_.ELL.val[i];
      */

    }
    
    if (this->get_coo_nnz() > 0) {

      copy_mic_mic(mic_cast_mat->mat_.COO.row, this->mat_.COO.row, this->get_coo_nnz());
      copy_mic_mic(mic_cast_mat->mat_.COO.col, this->mat_.COO.col, this->get_coo_nnz());
      copy_mic_mic(mic_cast_mat->mat_.COO.val, this->mat_.COO.val, this->get_coo_nnz());
      
      /*
      // COO
      for (int i=0; i<this->get_coo_nnz(); ++i)
        this->mat_.COO.row[i] = mic_cast_mat->mat_.COO.row[i];

      for (int i=0; i<this->get_coo_nnz(); ++i)
        this->mat_.COO.col[i] = mic_cast_mat->mat_.COO.col[i];

      for (int i=0; i<this->get_coo_nnz(); ++i)
        this->mat_.COO.val[i] = mic_cast_mat->mat_.COO.val[i];
      */

    }
   
  } else {

    //CPU to MIC
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
开发者ID:dcm3c,项目名称:agros2d,代码行数:76,代码来源:mic_matrix_hyb.cpp

示例10: assert

void OCLAcceleratorMatrixHYB<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const OCLAcceleratorMatrixHYB<ValueType> *ocl_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // OCL to OCL copy
  if ((ocl_cast_mat = dynamic_cast<const OCLAcceleratorMatrixHYB<ValueType>*> (&src)) != NULL) {
    
    if (this->get_nnz() == 0)
      this->AllocateHYB(ocl_cast_mat->get_ell_nnz(), ocl_cast_mat->get_coo_nnz(), ocl_cast_mat->get_ell_max_row(),
                        ocl_cast_mat->get_nrow(), ocl_cast_mat->get_ncol());

    assert((this->get_nnz()  == src.get_nnz())  &&
	   (this->get_nrow() == src.get_nrow()) &&
	   (this->get_ncol() == src.get_ncol()) );


    if (this->get_ell_nnz() > 0) {

      // ELL
      // must be within same opencl context
      ocl_dev2dev<int>(this->get_ell_nnz(), // size
                       ocl_cast_mat->mat_.ELL.col, // src
                       this->mat_.ELL.col,         // dst
                       OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

      ocl_dev2dev<ValueType>(this->get_ell_nnz(), // size
                             ocl_cast_mat->mat_.ELL.val, // src
                             this->mat_.ELL.val,         // dst
                             OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

    }

    if (this->get_coo_nnz() > 0) {

      // COO
      // must be within same opencl context
      ocl_dev2dev<int>(this->get_coo_nnz(), // size
                       ocl_cast_mat->mat_.COO.row, // src
                       this->mat_.COO.row,         // dst
                       OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

      ocl_dev2dev<int>(this->get_coo_nnz(), // size
                       ocl_cast_mat->mat_.COO.col, // src
                       this->mat_.COO.col,         // dst
                       OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

      ocl_dev2dev<ValueType>(this->get_coo_nnz(), // size
                             ocl_cast_mat->mat_.COO.val, // src
                             this->mat_.COO.val,         // dst
                             OCL_HANDLE(this->local_backend_.OCL_handle)->OCL_cmdQueue );

    }

  } else {

    //CPU to OCL
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {

      this->CopyFromHost(*host_cast_mat);

    } else {

      LOG_INFO("Error unsupported OCL matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);

    }

  }

}
开发者ID:LeiDai,项目名称:agros2d,代码行数:76,代码来源:ocl_matrix_hyb.cpp


注:本文中的BaseMatrix::get_nnz方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。