Esempio n. 1
0
 SepMatrixAccessor( BigMatrix &bm)
 {
   _ppMat = reinterpret_cast<T**>(bm.matrix());
   _rowOffset = bm.row_offset();
   _colOffset = bm.col_offset();
   _totalRows = bm.nrow();
 }
Esempio n. 2
0
/* Pointer utility, returns a double pointer for either a BigMatrix or a
 * standard R matrix.
 */
double *
make_double_ptr (SEXP matrix, SEXP isBigMatrix)
{
  double *matrix_ptr;

  if (LOGICAL_VALUE (isBigMatrix) == (Rboolean) TRUE)   // Big Matrix
    {
      SEXP address = GET_SLOT (matrix, install ("address"));
      BigMatrix *pbm =
        reinterpret_cast < BigMatrix * >(R_ExternalPtrAddr (address));
      if (!pbm)
        return (NULL);

      // Check that have acceptable big.matrix
      if (pbm->row_offset () > 0 && pbm->ncol () > 1)
        {
          std::string errMsg =
            string ("sub.big.matrix objects cannoth have row ") +
            string
            ("offset greater than zero and number of columns greater than 1");
          Rf_error (errMsg.c_str ());
          return (NULL);
        }

      index_type offset = pbm->nrow () * pbm->col_offset ();
      matrix_ptr = reinterpret_cast < double *>(pbm->matrix ()) + offset;
    }
  else                          // Regular R Matrix
    {
      matrix_ptr = NUMERIC_DATA (matrix);
    }

  return (matrix_ptr);
};
Esempio n. 3
0
 MatrixAccessor( BigMatrix &bm )
 {
   _pMat = reinterpret_cast<T*>(bm.matrix());
   _totalRows = bm.total_rows();
   _totalCols = bm.total_columns();
   _rowOffset = bm.row_offset();
   _colOffset = bm.col_offset();
   _nrow = bm.nrow();
   _ncol = bm.ncol();
 }