Anasazi  Version of the Day
AnasaziSolverUtils.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Anasazi: Block Eigensolvers Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 
29 #ifndef ANASAZI_SOLVER_UTILS_HPP
30 #define ANASAZI_SOLVER_UTILS_HPP
31 
48 #include "AnasaziConfigDefs.hpp"
51 #include "Teuchos_ScalarTraits.hpp"
52 
53 #include "AnasaziOutputManager.hpp"
54 #include "Teuchos_BLAS.hpp"
55 #include "Teuchos_LAPACK.hpp"
57 
58 namespace Anasazi {
59 
60  template<class ScalarType, class MV, class OP>
61  class SolverUtils
62  {
63  public:
64  typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
65  typedef typename Teuchos::ScalarTraits<ScalarType> SCT;
66 
68 
69 
71  SolverUtils();
72 
74  virtual ~SolverUtils() {};
75 
77 
79 
80 
82  static void permuteVectors(const int n, const std::vector<int> &perm, MV &Q, std::vector< typename Teuchos::ScalarTraits<ScalarType>::magnitudeType >* resids = 0);
83 
85  static void permuteVectors(const std::vector<int> &perm, Teuchos::SerialDenseMatrix<int,ScalarType> &Q);
86 
88 
90 
91 
93 
114  static void applyHouse(int k, MV &V, const Teuchos::SerialDenseMatrix<int,ScalarType> &H, const std::vector<ScalarType> &tau, Teuchos::RCP<MV> workMV = Teuchos::null);
115 
117 
119 
120 
122 
148  static int directSolver(int size, const Teuchos::SerialDenseMatrix<int,ScalarType> &KK,
151  std::vector< typename Teuchos::ScalarTraits<ScalarType>::magnitudeType > &theta,
152  int &nev, int esType = 0);
154 
156 
157 
159 
161  static typename Teuchos::ScalarTraits<ScalarType>::magnitudeType errorEquality(const MV &X, const MV &MX, Teuchos::RCP<const OP> M = Teuchos::null);
162 
164 
165  private:
166 
168 
169 
173 
175  };
176 
177  //-----------------------------------------------------------------------------
178  //
179  // CONSTRUCTOR
180  //
181  //-----------------------------------------------------------------------------
182 
183  template<class ScalarType, class MV, class OP>
185 
186 
187  //-----------------------------------------------------------------------------
188  //
189  // SORTING METHODS
190  //
191  //-----------------------------------------------------------------------------
192 
194  // permuteVectors for MV
195  template<class ScalarType, class MV, class OP>
197  const int n,
198  const std::vector<int> &perm,
199  MV &Q,
200  std::vector< typename Teuchos::ScalarTraits<ScalarType>::magnitudeType >* resids)
201  {
202  // Permute the vectors according to the permutation vector \c perm, and
203  // optionally the residual vector \c resids
204 
205  int i, j;
206  std::vector<int> permcopy(perm), swapvec(n-1);
207  std::vector<int> index(1);
208  ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
209  ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
210 
211  TEUCHOS_TEST_FOR_EXCEPTION(n > MVT::GetNumberVecs(Q), std::invalid_argument, "Anasazi::SolverUtils::permuteVectors(): argument n larger than width of input multivector.");
212 
213  // We want to recover the elementary permutations (individual swaps)
214  // from the permutation vector. Do this by constructing the inverse
215  // of the permutation, by sorting them to {1,2,...,n}, and recording
216  // the elementary permutations of the inverse.
217  for (i=0; i<n-1; i++) {
218  //
219  // find i in the permcopy vector
220  for (j=i; j<n; j++) {
221  if (permcopy[j] == i) {
222  // found it at index j
223  break;
224  }
225  TEUCHOS_TEST_FOR_EXCEPTION(j == n-1, std::invalid_argument, "Anasazi::SolverUtils::permuteVectors(): permutation index invalid.");
226  }
227  //
228  // Swap two scalars
229  std::swap( permcopy[j], permcopy[i] );
230 
231  swapvec[i] = j;
232  }
233 
234  // now apply the elementary permutations of the inverse in reverse order
235  for (i=n-2; i>=0; i--) {
236  j = swapvec[i];
237  //
238  // Swap (i,j)
239  //
240  // Swap residuals (if they exist)
241  if (resids) {
242  std::swap( (*resids)[i], (*resids)[j] );
243  }
244  //
245  // Swap corresponding vectors
246  index[0] = j;
247  Teuchos::RCP<MV> tmpQ = MVT::CloneCopy( Q, index );
248  Teuchos::RCP<MV> tmpQj = MVT::CloneViewNonConst( Q, index );
249  index[0] = i;
250  Teuchos::RCP<MV> tmpQi = MVT::CloneViewNonConst( Q, index );
251  MVT::MvAddMv( one, *tmpQi, zero, *tmpQi, *tmpQj );
252  MVT::MvAddMv( one, *tmpQ, zero, *tmpQ, *tmpQi );
253  }
254  }
255 
256 
258  // permuteVectors for MV
259  template<class ScalarType, class MV, class OP>
261  const std::vector<int> &perm,
263  {
264  // Permute the vectors in Q according to the permutation vector \c perm, and
265  // optionally the residual vector \c resids
267  const int n = perm.size();
268  const int m = Q.numRows();
269 
270  TEUCHOS_TEST_FOR_EXCEPTION(n != Q.numCols(), std::invalid_argument, "Anasazi::SolverUtils::permuteVectors(): size of permutation vector not equal to number of columns.");
271 
272  // Sort the primitive ritz vectors
274  for (int i=0; i<n; i++) {
275  blas.COPY(m, copyQ[perm[i]], 1, Q[i], 1);
276  }
277  }
278 
279 
280  //-----------------------------------------------------------------------------
281  //
282  // BASIS UPDATE METHODS
283  //
284  //-----------------------------------------------------------------------------
285 
286  // apply householder reflectors to multivector
287  template<class ScalarType, class MV, class OP>
288  void SolverUtils<ScalarType, MV, OP>::applyHouse(int k, MV &V, const Teuchos::SerialDenseMatrix<int,ScalarType> &H, const std::vector<ScalarType> &tau, Teuchos::RCP<MV> workMV) {
289 
290  const int n = MVT::GetNumberVecs(V);
291  const ScalarType ONE = SCT::one();
292  const ScalarType ZERO = SCT::zero();
293 
294  // early exit if V has zero-size or if k==0
295  if (MVT::GetNumberVecs(V) == 0 || MVText::GetGlobalLength(V) == 0 || k == 0) {
296  return;
297  }
298 
299  if (workMV == Teuchos::null) {
300  // user did not give us any workspace; allocate some
301  workMV = MVT::Clone(V,1);
302  }
303  else if (MVT::GetNumberVecs(*workMV) > 1) {
304  std::vector<int> first(1);
305  first[0] = 0;
306  workMV = MVT::CloneViewNonConst(*workMV,first);
307  }
308  else {
309  TEUCHOS_TEST_FOR_EXCEPTION(MVT::GetNumberVecs(*workMV) < 1,std::invalid_argument,"Anasazi::SolverUtils::applyHouse(): work multivector was empty.");
310  }
311  // Q = H_1 ... H_k is square, with as many rows as V has vectors
312  // however, H need only have k columns, one each for the k reflectors.
313  TEUCHOS_TEST_FOR_EXCEPTION( H.numCols() != k, std::invalid_argument,"Anasazi::SolverUtils::applyHouse(): H must have at least k columns.");
314  TEUCHOS_TEST_FOR_EXCEPTION( (int)tau.size() != k, std::invalid_argument,"Anasazi::SolverUtils::applyHouse(): tau must have at least k entries.");
315  TEUCHOS_TEST_FOR_EXCEPTION( H.numRows() != MVT::GetNumberVecs(V), std::invalid_argument,"Anasazi::SolverUtils::applyHouse(): Size of H,V are inconsistent.");
316 
317  // perform the loop
318  // flops: Sum_{i=0:k-1} 4 m (n-i) == 4mnk - 2m(k^2- k)
319  for (int i=0; i<k; i++) {
320  // apply V H_i+1 = V - tau_i+1 (V v_i+1) v_i+1^T
321  // because of the structure of v_i+1, this transform does not affect the first i columns of V
322  std::vector<int> activeind(n-i);
323  for (int j=0; j<n-i; j++) activeind[j] = j+i;
324  Teuchos::RCP<MV> actV = MVT::CloneViewNonConst(V,activeind);
325 
326  // note, below H_i, v_i and tau_i are mathematical objects which use 1-based indexing
327  // while H, v and tau are data structures using 0-based indexing
328 
329  // get v_i+1: i-th column of H
331  // v_i+1(1:i) = 0: this isn't part of v
332  // e_i+1^T v_i+1 = 1 = v(0)
333  v(0,0) = ONE;
334 
335  // compute -tau_i V v_i
336  // tau_i+1 is tau[i]
337  // flops: 2 m n-i
338  MVT::MvTimesMatAddMv(-tau[i],*actV,v,ZERO,*workMV);
339 
340  // perform V = V + workMV v_i^T
341  // flops: 2 m n-i
343  MVT::MvTimesMatAddMv(ONE,*workMV,vT,ONE,*actV);
344 
345  actV = Teuchos::null;
346  }
347  }
348 
349 
350  //-----------------------------------------------------------------------------
351  //
352  // EIGENSOLVER PROJECTION METHODS
353  //
354  //-----------------------------------------------------------------------------
355 
356  template<class ScalarType, class MV, class OP>
358  int size,
362  std::vector< typename Teuchos::ScalarTraits<ScalarType>::magnitudeType > &theta,
363  int &nev, int esType)
364  {
365  // Routine for computing the first NEV generalized eigenpairs of the symmetric pencil (KK, MM)
366  //
367  // Parameter variables:
368  //
369  // size : Dimension of the eigenproblem (KK, MM)
370  //
371  // KK : Hermitian "stiffness" matrix
372  //
373  // MM : Hermitian positive-definite "mass" matrix
374  //
375  // EV : Matrix to store the nev eigenvectors
376  //
377  // theta : Array to store the eigenvalues (Size = nev )
378  //
379  // nev : Number of the smallest eigenvalues requested (input)
380  // Number of the smallest computed eigenvalues (output)
381  // Routine may compute and return more or less eigenvalues than requested.
382  //
383  // esType : Flag to select the algorithm
384  //
385  // esType = 0 (default) Uses LAPACK routine (Cholesky factorization of MM)
386  // with deflation of MM to get orthonormality of
387  // eigenvectors (S^T MM S = I)
388  //
389  // esType = 1 Uses LAPACK routine (Cholesky factorization of MM)
390  // (no check of orthonormality)
391  //
392  // esType = 10 Uses LAPACK routine for simple eigenproblem on KK
393  // (MM is not referenced in this case)
394  //
395  // Note: The code accesses only the upper triangular part of KK and MM.
396  //
397  // Return the integer info on the status of the computation
398  //
399  // info = 0 >> Success
400  //
401  // info < 0 >> error in the info-th argument
402  // info = - 20 >> Failure in LAPACK routine
403 
404  // Define local arrays
405 
406  // Create blas/lapack objects.
409 
410  int rank = 0;
411  int info = 0;
412 
413  if (size < nev || size < 0) {
414  return -1;
415  }
416  if (KK.numCols() < size || KK.numRows() < size) {
417  return -2;
418  }
419  if ((esType == 0 || esType == 1)) {
420  if (MM == Teuchos::null) {
421  return -3;
422  }
423  else if (MM->numCols() < size || MM->numRows() < size) {
424  return -3;
425  }
426  }
427  if (EV.numCols() < size || EV.numRows() < size) {
428  return -4;
429  }
430  if (theta.size() < (unsigned int) size) {
431  return -5;
432  }
433  if (nev <= 0) {
434  return -6;
435  }
436 
437  // Query LAPACK for the "optimal" block size for HEGV
438  std::string lapack_name = "hetrd";
439  std::string lapack_opts = "u";
440  int NB = lapack.ILAENV(1, lapack_name, lapack_opts, size, -1, -1, -1);
441  int lwork = size*(NB+2); // For HEEV, lwork should be NB+2, instead of NB+1
442  std::vector<ScalarType> work(lwork);
443  std::vector<MagnitudeType> rwork(3*size-2);
444  // tt contains the eigenvalues from HEGV, which are necessarily real, and
445  // HEGV expects this vector to be real as well
446  std::vector<MagnitudeType> tt( size );
447  typedef typename std::vector<MagnitudeType>::iterator MTIter;
448 
449  MagnitudeType tol = SCT::magnitude(SCT::squareroot(SCT::eps()));
450  // MagnitudeType tol = 1e-12;
451  ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
452  ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
453 
456 
457  switch (esType) {
458  default:
459  case 0:
460  //
461  // Use LAPACK to compute the generalized eigenvectors
462  //
463  for (rank = size; rank > 0; --rank) {
464 
466  //
467  // Copy KK & MM
468  //
469  KKcopy = Teuchos::rcp( new Teuchos::SerialDenseMatrix<int,ScalarType>( Teuchos::Copy, KK, rank, rank ) );
470  MMcopy = Teuchos::rcp( new Teuchos::SerialDenseMatrix<int,ScalarType>( Teuchos::Copy, *MM, rank, rank ) );
471  //
472  // Solve the generalized eigenproblem with LAPACK
473  //
474  info = 0;
475  lapack.HEGV(1, 'V', 'U', rank, KKcopy->values(), KKcopy->stride(),
476  MMcopy->values(), MMcopy->stride(), &tt[0], &work[0], lwork,
477  &rwork[0], &info);
478  //
479  // Treat error messages
480  //
481  if (info < 0) {
482  std::cerr << std::endl;
483  std::cerr << "Anasazi::SolverUtils::directSolver(): In HEGV, argument " << -info << "has an illegal value.\n";
484  std::cerr << std::endl;
485  return -20;
486  }
487  if (info > 0) {
488  if (info > rank)
489  rank = info - rank;
490  continue;
491  }
492  //
493  // Check the quality of eigenvectors ( using mass-orthonormality )
494  //
495  MMcopy = Teuchos::rcp( new Teuchos::SerialDenseMatrix<int,ScalarType>( Teuchos::Copy, *MM, rank, rank ) );
496  for (int i = 0; i < rank; ++i) {
497  for (int j = 0; j < i; ++j) {
498  (*MMcopy)(i,j) = SCT::conjugate((*MM)(j,i));
499  }
500  }
501  // U = 0*U + 1*MMcopy*KKcopy = MMcopy * KKcopy
503  U->multiply(Teuchos::NO_TRANS,Teuchos::NO_TRANS,one,*MMcopy,*KKcopy,zero) != 0,
504  std::logic_error, "Anasazi::SolverUtils::directSolver() call to Teuchos::SerialDenseMatrix::multiply() returned an error.");
505  // MMcopy = 0*MMcopy + 1*KKcopy^H*U = KKcopy^H * MMcopy * KKcopy
507  MMcopy->multiply(Teuchos::CONJ_TRANS,Teuchos::NO_TRANS,one,*KKcopy,*U,zero) != 0,
508  std::logic_error, "Anasazi::SolverUtils::directSolver() call to Teuchos::SerialDenseMatrix::multiply() returned an error.");
509  MagnitudeType maxNorm = SCT::magnitude(zero);
510  MagnitudeType maxOrth = SCT::magnitude(zero);
511  for (int i = 0; i < rank; ++i) {
512  for (int j = i; j < rank; ++j) {
513  if (j == i)
514  maxNorm = SCT::magnitude((*MMcopy)(i,j) - one) > maxNorm
515  ? SCT::magnitude((*MMcopy)(i,j) - one) : maxNorm;
516  else
517  maxOrth = SCT::magnitude((*MMcopy)(i,j)) > maxOrth
518  ? SCT::magnitude((*MMcopy)(i,j)) : maxOrth;
519  }
520  }
521  /* if (verbose > 4) {
522  std::cout << " >> Local eigensolve >> Size: " << rank;
523  std::cout.precision(2);
524  std::cout.setf(std::ios::scientific, std::ios::floatfield);
525  std::cout << " Normalization error: " << maxNorm;
526  std::cout << " Orthogonality error: " << maxOrth;
527  std::cout << endl;
528  }*/
529  if ((maxNorm <= tol) && (maxOrth <= tol)) {
530  break;
531  }
532  } // for (rank = size; rank > 0; --rank)
533  //
534  // Copy the computed eigenvectors and eigenvalues
535  // ( they may be less than the number requested because of deflation )
536  //
537  // std::cout << "directSolve rank: " << rank << "\tsize: " << size << endl;
538  nev = (rank < nev) ? rank : nev;
539  EV.putScalar( zero );
540  std::copy(tt.begin(),tt.begin()+nev,theta.begin());
541  for (int i = 0; i < nev; ++i) {
542  blas.COPY( rank, (*KKcopy)[i], 1, EV[i], 1 );
543  }
544  break;
545 
546  case 1:
547  //
548  // Use the Cholesky factorization of MM to compute the generalized eigenvectors
549  //
550  // Copy KK & MM
551  //
552  KKcopy = Teuchos::rcp( new Teuchos::SerialDenseMatrix<int,ScalarType>( Teuchos::Copy, KK, size, size ) );
553  MMcopy = Teuchos::rcp( new Teuchos::SerialDenseMatrix<int,ScalarType>( Teuchos::Copy, *MM, size, size ) );
554  //
555  // Solve the generalized eigenproblem with LAPACK
556  //
557  info = 0;
558  lapack.HEGV(1, 'V', 'U', size, KKcopy->values(), KKcopy->stride(),
559  MMcopy->values(), MMcopy->stride(), &tt[0], &work[0], lwork,
560  &rwork[0], &info);
561  //
562  // Treat error messages
563  //
564  if (info < 0) {
565  std::cerr << std::endl;
566  std::cerr << "Anasazi::SolverUtils::directSolver(): In HEGV, argument " << -info << "has an illegal value.\n";
567  std::cerr << std::endl;
568  return -20;
569  }
570  if (info > 0) {
571  if (info > size)
572  nev = 0;
573  else {
574  std::cerr << std::endl;
575  std::cerr << "Anasazi::SolverUtils::directSolver(): In HEGV, DPOTRF or DHEEV returned an error code (" << info << ").\n";
576  std::cerr << std::endl;
577  return -20;
578  }
579  }
580  //
581  // Copy the eigenvectors and eigenvalues
582  //
583  std::copy(tt.begin(),tt.begin()+nev,theta.begin());
584  for (int i = 0; i < nev; ++i) {
585  blas.COPY( size, (*KKcopy)[i], 1, EV[i], 1 );
586  }
587  break;
588 
589  case 10:
590  //
591  // Simple eigenproblem
592  //
593  // Copy KK
594  //
595  KKcopy = Teuchos::rcp( new Teuchos::SerialDenseMatrix<int,ScalarType>( Teuchos::Copy, KK, size, size ) );
596  //
597  // Solve the generalized eigenproblem with LAPACK
598  //
599  lapack.HEEV('V', 'U', size, KKcopy->values(), KKcopy->stride(), &tt[0], &work[0], lwork, &rwork[0], &info);
600  //
601  // Treat error messages
602  if (info != 0) {
603  std::cerr << std::endl;
604  if (info < 0) {
605  std::cerr << "Anasazi::SolverUtils::directSolver(): In DHEEV, argument " << -info << " has an illegal value\n";
606  }
607  else {
608  std::cerr << "Anasazi::SolverUtils::directSolver(): In DHEEV, the algorithm failed to converge (" << info << ").\n";
609  }
610  std::cerr << std::endl;
611  info = -20;
612  break;
613  }
614  //
615  // Copy the eigenvectors
616  //
617  std::copy(tt.begin(),tt.begin()+nev,theta.begin());
618  for (int i = 0; i < nev; ++i) {
619  blas.COPY( size, (*KKcopy)[i], 1, EV[i], 1 );
620  }
621  break;
622  }
623 
624  return info;
625  }
626 
627 
628  //-----------------------------------------------------------------------------
629  //
630  // SANITY CHECKING METHODS
631  //
632  //-----------------------------------------------------------------------------
633 
634  template<class ScalarType, class MV, class OP>
637  {
638  // Return the maximum coefficient of the matrix M * X - MX
639  // scaled by the maximum coefficient of MX.
640  // When M is not specified, the identity is used.
641 
642  MagnitudeType maxDiff = SCT::magnitude(SCT::zero());
643 
644  int xc = MVT::GetNumberVecs(X);
645  int mxc = MVT::GetNumberVecs(MX);
646 
647  TEUCHOS_TEST_FOR_EXCEPTION(xc != mxc,std::invalid_argument,"Anasazi::SolverUtils::errorEquality(): input multivecs have different number of columns.");
648  if (xc == 0) {
649  return maxDiff;
650  }
651 
652  MagnitudeType maxCoeffX = SCT::magnitude(SCT::zero());
653  std::vector<MagnitudeType> tmp( xc );
654  MVT::MvNorm(MX, tmp);
655 
656  for (int i = 0; i < xc; ++i) {
657  maxCoeffX = (tmp[i] > maxCoeffX) ? tmp[i] : maxCoeffX;
658  }
659 
660  std::vector<int> index( 1 );
661  Teuchos::RCP<MV> MtimesX;
662  if (M != Teuchos::null) {
663  MtimesX = MVT::Clone( X, xc );
664  OPT::Apply( *M, X, *MtimesX );
665  }
666  else {
667  MtimesX = MVT::CloneCopy(X);
668  }
669  MVT::MvAddMv( -1.0, MX, 1.0, *MtimesX, *MtimesX );
670  MVT::MvNorm( *MtimesX, tmp );
671 
672  for (int i = 0; i < xc; ++i) {
673  maxDiff = (tmp[i] > maxDiff) ? tmp[i] : maxDiff;
674  }
675 
676  return (maxCoeffX == 0.0) ? maxDiff : maxDiff/maxCoeffX;
677 
678  }
679 
680 } // end namespace Anasazi
681 
682 #endif // ANASAZI_SOLVER_UTILS_HPP
683 
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
An extension of the MultiVecTraits class that adds a new vector length method.This traits class provi...
static ptrdiff_t GetGlobalLength(const MV &mv)
Declaration of basic traits for the multivector type.
virtual ~SolverUtils()
Destructor.
static ScalarType squareroot(ScalarType x)
OrdinalType ILAENV(const OrdinalType ispec, const std::string &NAME, const std::string &OPTS, const OrdinalType N1=-1, const OrdinalType N2=-1, const OrdinalType N3=-1, const OrdinalType N4=-1) const
void COPY(const OrdinalType n, const ScalarType *x, const OrdinalType incx, ScalarType *y, const OrdinalType incy) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Virtual base class which defines basic traits for the operator type.
static Teuchos::ScalarTraits< ScalarType >::magnitudeType errorEquality(const MV &X, const MV &MX, Teuchos::RCP< const OP > M=Teuchos::null)
Return the maximum coefficient of the matrix scaled by the maximum coefficient of MX...
static void Apply(const OP &Op, const MV &x, MV &y)
Application method which performs operation y = Op*x. An OperatorError exception is thrown if there i...
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
Anasazi&#39;s templated, static class providing utilities for the solvers.
static ScalarType conjugate(ScalarType a)
Abstract class definition for Anasazi Output Managers.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static void applyHouse(int k, MV &V, const Teuchos::SerialDenseMatrix< int, ScalarType > &H, const std::vector< ScalarType > &tau, Teuchos::RCP< MV > workMV=Teuchos::null)
Apply a sequence of Householder reflectors (from GEQRF) to a multivector, using minimal workspace...
static int directSolver(int size, const Teuchos::SerialDenseMatrix< int, ScalarType > &KK, Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > MM, Teuchos::SerialDenseMatrix< int, ScalarType > &EV, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &theta, int &nev, int esType=0)
Routine for computing the first NEV generalized eigenpairs of the Hermitian pencil (KK...
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
Traits class which defines basic operations on multivectors.
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
Virtual base class which defines basic traits for the operator type.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow copy).
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec)
Compute the 2-norm of each individual vector of mv. Upon return, normvec[i] holds the value of ...
void HEGV(const OrdinalType itype, const char JOBZ, const char UPLO, const OrdinalType n, ScalarType *A, const OrdinalType lda, ScalarType *B, const OrdinalType ldb, MagnitudeType *W, ScalarType *WORK, const OrdinalType lwork, MagnitudeType *RWORK, OrdinalType *info) const
static magnitudeType magnitude(ScalarType a)
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
OrdinalType numCols() const
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Replace mv with .
void HEEV(const char JOBZ, const char UPLO, const OrdinalType n, ScalarType *A, const OrdinalType lda, MagnitudeType *W, ScalarType *WORK, const OrdinalType lwork, MagnitudeType *RWORK, OrdinalType *info) const
static void permuteVectors(const int n, const std::vector< int > &perm, MV &Q, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > *resids=0)
Permute the vectors in a multivector according to the permutation vector perm, and optionally the res...
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.
OrdinalType numRows() const