Ejemplo n.º 1
0
int DichotomySearch::Search(int * array, int element, int size) {
    int **addit_array = Preprocess(array, size);
    int leftborder, rightborder, middle, temp;
    leftborder = 0;
    rightborder = size - 1;
    while (1) {
        middle = (leftborder + rightborder) / 2;
        if (element < addit_array[middle][1]) {
            rightborder = middle - 1;
        } else if (element > addit_array[middle][1]) {
            leftborder = middle + 1;
        } else {
            temp = addit_array[middle][0];
            DeleteMemory(addit_array, size);
            return temp;
        }
        if (leftborder > rightborder) {
            DeleteMemory(addit_array, size);
            return  -1;
        }
    }
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
Epetra_FECrsMatrix& Epetra_FECrsMatrix::operator=(const Epetra_FECrsMatrix& src)
{
  if (this == &src) {
    return( *this );
  }

  DeleteMemory();

  Epetra_CrsMatrix::operator=(src);

  useNonlocalMatrix_ = src.useNonlocalMatrix_;

  myFirstRow_ = src.myFirstRow_;
  myNumRows_ = src.myNumRows_;
  ignoreNonLocalEntries_ = src.ignoreNonLocalEntries_;

#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
  if (src.RowMap().GlobalIndicesInt() && nonlocalRows_int_.size() < 1) {
    return( *this );
  }
#endif

#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
  if (src.RowMap().GlobalIndicesLongLong() && nonlocalRows_LL_.size() < 1) {
    return( *this );
  }
#endif

  if (useNonlocalMatrix_ && src.nonlocalMatrix_ != 0) {
    *nonlocalMatrix_ = *src.nonlocalMatrix_;
    return( *this );
  }

#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
  if (src.RowMap().GlobalIndicesInt()) {
    nonlocalRows_int_ = src.nonlocalRows_int_;
    nonlocalCols_int_ = src.nonlocalCols_int_;
  }
#endif

#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
  if (src.RowMap().GlobalIndicesLongLong()) {
    nonlocalRows_LL_ = src.nonlocalRows_LL_;
    nonlocalCols_LL_ = src.nonlocalCols_LL_;
  }
#endif

  nonlocalCoefs_= src.nonlocalCoefs_;

  return( *this );
}
Ejemplo n.º 3
0
//----------------------------------------------------------------------------
Epetra_FECrsMatrix::~Epetra_FECrsMatrix()
{
  DeleteMemory();
}