NOX::Abstract::Group::ReturnType
LOCA::EigenvalueSort::LargestRealInverseCayley::sort(
                            int n, double* r_evals,
                        double* i_evals,
                        std::vector<int>* perm) const
{
  int i, j, tempord;
  double temp, tempr, tempi;
  Teuchos::LAPACK<int,double> lapack;

  // Reset the index
  if (perm) {
    for (i=0; i < n; i++) {
      (*perm)[i] = i;
    }
  }

  //---------------------------------------------------------------
  // Sort eigenvalues according to the real part of the inverse-Cayley
  // transformation
  //---------------------------------------------------------------
  for (j=1; j < n; ++j) {
    tempr = r_evals[j]; tempi = i_evals[j];
    tempord = (*perm)[j];
    temp=realLambda(r_evals[j],i_evals[j]);
    for (i=j-1; i>=0 && realLambda(r_evals[i],i_evals[i])<temp; --i) {
      r_evals[i+1]=r_evals[i]; i_evals[i+1]=i_evals[i];
      (*perm)[i+1]=(*perm)[i];
    }
    r_evals[i+1] = tempr; i_evals[i+1] = tempi; (*perm)[i+1] = tempord;
  }
  return NOX::Abstract::Group::Ok;
}
NOX::Abstract::Group::ReturnType
LOCA::EigenvalueSort::LargestRealInverseCayley::sort(
                        int n, double* evals,
                        std::vector<int>* perm) const
{
  int i, j;
  int tempord = 0;
  double temp, templambda;
  Teuchos::LAPACK<int,double> lapack;

  TEUCHOS_TEST_FOR_EXCEPT(perm == NULL);

  // Reset the index
  for (i=0; i < n; i++)
    (*perm)[i] = i;

  //---------------------------------------------------------------
  // Sort eigenvalues according to the real part of the inverse-Cayley
  // transformation
  //---------------------------------------------------------------
  for (j=1; j < n; ++j) {
    temp = evals[j];
    tempord = (*perm)[j];
    templambda=realLambda(evals[j],0);
    for (i=j-1; i>=0 && realLambda(evals[i],0)<templambda; --i) {
      evals[i+1]=evals[i];
      (*perm)[i+1]=(*perm)[i];
    }
    evals[i+1] = temp; (*perm)[i+1] = tempord;
  }
  return NOX::Abstract::Group::Ok;
}
示例#3
0
void RealPart
( const BlockMatrix<T>& A, BlockMatrix<Base<T>>& AReal )
{ 
    auto realPart = []( T alpha ) { return RealPart(alpha); };
    function<Base<T>(T)> realLambda( realPart );
    EntrywiseMap( A, AReal, realLambda );
}