コード例 #1
0
    static
    inline
    int amd_order
    (
     int n, 
     int *col_ptr,
     int *row_idx,
     int *p
     )
    {
      double Info[AMD_INFO];
      
      for(int i = 0; i < AMD_INFO; ++i)
      {Info[i] = 0;}


      //printf("n: %d \n", n);
      int ret = amesos_amd_order(n, col_ptr, row_idx, p, NULL, Info); 

      //if(ret == AMD_OK)
      //printf("OK\n");
      if(ret == AMD_OUT_OF_MEMORY)
        printf("Memory \n");
      if(ret == AMD_INVALID)
        printf("Invalid\n");
      if(ret == AMD_OK_BUT_JUMBLED)
        printf("Jumbled\n");

      return 0;
    }
コード例 #2
0
    static
    inline
    int amd_order
    (
     int n, 
     int *col_ptr,
     int *row_idx,
     int *p, 
     double &l_nnz,
     double &lu_work
     )
    {
      double Info[AMD_INFO];
      
      for(int i = 0; i < AMD_INFO; ++i)
      {Info[i] = 0;}


      //printf("n: %d \n", n);
      int ret = amesos_amd_order(n, col_ptr, row_idx, p, NULL, Info); 

      //if(ret == AMD_OK)
      //printf("OK\n");
      if(ret == AMD_OUT_OF_MEMORY)
        printf("Memory \n");
      if(ret == AMD_INVALID)
        printf("Invalid\n");
      if(ret == AMD_OK_BUT_JUMBLED)
        printf("Jumbled\n");

      //These are round bounds but help in deciding work
      l_nnz   = Info[AMD_LNZ];
      lu_work = Info[AMD_NMULTSUBS_LU];

      return 0;
    }
コード例 #3
0
//==============================================================================
int Ifpack2_AMDReordering::Compute(const Ifpack2_Graph& Graph)
{
  IsComputed_ = false;
  NumMyRows_ = Graph.NumMyRows();
  int NumNz = Graph.NumMyNonzeros();
  
  if (NumMyRows_ == 0)
    IFPACK2_CHK_ERR(-1); // strange graph this one
  
  // Extract CRS format
  vector<int> ia(NumMyRows_+1,0);
  vector<int> ja(NumNz);
  int cnt;
  for( int i = 0; i < NumMyRows_; ++i )
  {
    int * tmpP = &ja[ia[i]];
    Graph.ExtractMyRowCopy( i, NumNz-ia[i], cnt, tmpP );
    ia[i+1] = ia[i] + cnt;
  }

  // Trim down to local only
  vector<int> iat(NumMyRows_+1);
  vector<int> jat(NumNz);
  int loc = 0;
  for( int i = 0; i < NumMyRows_; ++i )
  {
    iat[i] = loc;
    for( int j = ia[i]; j < ia[i+1]; ++j )
    {
      if( ja[j] < NumMyRows_ )
        jat[loc++] = ja[j];
      else
	break;
    }
  }
  iat[NumMyRows_] = loc;

  // Compute AMD permutation
  Reorder_.resize(NumMyRows_);
  vector<double> info(AMD_INFO);

  amesos_amd_order( NumMyRows_, &iat[0], &jat[0], &Reorder_[0], NULL, &info[0] );

  if( info[AMD_STATUS] == AMD_INVALID )
    cout << "AMD ORDERING: Invalid!!!!\n";

  // Build inverse reorder (will be used by ExtractMyRowCopy() 
  InvReorder_.resize(NumMyRows_);

  for (int i = 0 ; i < NumMyRows_ ; ++i)
    InvReorder_[i] = -1;

  for (int i = 0 ; i < NumMyRows_ ; ++i)
    InvReorder_[Reorder_[i]] = i;

  for (int i = 0 ; i < NumMyRows_ ; ++i) {
    if (InvReorder_[i] == -1)
      IFPACK2_CHK_ERR(-1);
  }

  IsComputed_ = true;
  return(0);
}