This file is indexed.

/usr/include/trilinos/AnasaziSaddleContainer.hpp is in libtrilinos-anasazi-dev 12.10.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
// @HEADER
// ***********************************************************************
//
//                 Anasazi: Block Eigensolvers Package
//                 Copyright (2004) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
// USA
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
// @HEADER

/*! \file AnasaziSaddleContainer.hpp
 *  \brief Stores a set of vectors of the form [V; L] where V is a distributed multivector
 *  and L is a serialdense matrix.
 *
 *  Used in solving TraceMin's saddle point problem.
*/

#ifndef ANASAZI_SADDLE_CONTAINER_HPP
#define ANASAZI_SADDLE_CONTAINER_HPP

#include "AnasaziConfigDefs.hpp"
#include "Teuchos_VerboseObject.hpp"

#ifdef HAVE_ANASAZI_BELOS
#include "BelosConfigDefs.hpp"
#include "BelosMultiVecTraits.hpp"
#endif

using Teuchos::RCP;
using Teuchos::rcp;

namespace Anasazi {
namespace Experimental {

template <class ScalarType, class MV>
class SaddleContainer //: public Anasazi::SaddleContainer<ScalarType, MV>
{
  template <class Scalar_, class MV_, class OP_> friend class SaddleOperator;

private:
  typedef Anasazi::MultiVecTraits<ScalarType,MV>     MVT;
  typedef Teuchos::SerialDenseMatrix<int,ScalarType> SerialDenseMatrix;
  const ScalarType ONE, ZERO;
  RCP<MV> upper_;
  RCP<SerialDenseMatrix> lowerRaw_;
  std::vector<int> indices_;

  RCP<SerialDenseMatrix> getLower() const;
  void setLower(const RCP<SerialDenseMatrix> lower);

public:
  // Constructors
  SaddleContainer( ) : ONE(Teuchos::ScalarTraits<ScalarType>::one()), ZERO(Teuchos::ScalarTraits<ScalarType>::zero()) { };
  SaddleContainer( const RCP<MV> X, bool eye=false );

  // Things that are necessary for compilation
  // Returns a clone of the current vector
  SaddleContainer<ScalarType, MV> * Clone(const int nvecs) const;
  // Returns a duplicate of the current vector
  SaddleContainer<ScalarType, MV> * CloneCopy() const;
  // Returns a duplicate of the specified vectors
  SaddleContainer<ScalarType, MV> * CloneCopy(const std::vector<int> &index) const;
  SaddleContainer<ScalarType, MV> * CloneViewNonConst(const std::vector<int> &index) const;
  SaddleContainer<ScalarType, MV> * CloneViewNonConst(const Teuchos::Range1D& index) const;
  const SaddleContainer<ScalarType, MV> * CloneView(const std::vector<int> &index) const;
  const SaddleContainer<ScalarType, MV> * CloneView(const Teuchos::Range1D& index) const;
  ptrdiff_t GetGlobalLength() const { return MVT::GetGlobalLength(*upper_) + lowerRaw_->numRows(); };
  int GetNumberVecs() const { return MVT::GetNumberVecs(*upper_); };
  // Update *this with alpha * A * B + beta * (*this)
  void MvTimesMatAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV> &A,
                       const Teuchos::SerialDenseMatrix<int, ScalarType> &B,
                       ScalarType beta);
  // Replace *this with alpha * A + beta * B
  void MvAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV>& A,
               ScalarType beta,  const SaddleContainer<ScalarType,MV>& B);
  // Scale the vectors by alpha
  void MvScale( ScalarType alpha );
  // Scale the i-th vector by alpha[i]
  void MvScale( const std::vector<ScalarType>& alpha );
  // Compute a dense matrix B through the matrix-matrix multiply alpha * A^H * (*this)
  void MvTransMv (ScalarType alpha, const SaddleContainer<ScalarType, MV>& A,
                  Teuchos::SerialDenseMatrix< int, ScalarType >& B) const;
  // Compute a vector b where the components are the individual dot-products, i.e.b[i] = A[i]^H*this[i] where A[i] is the i-th column of A.
  void MvDot (const SaddleContainer<ScalarType, MV>& A, std::vector<ScalarType> &b) const;
  // Compute the 2-norm of each individual vector
  void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec) const;
  // Copy the vectors in A to a set of vectors in *this. The numvecs vectors in
  // A are copied to a subset of vectors in *this indicated by the indices given
  // in index.
  void SetBlock (const SaddleContainer<ScalarType, MV>& A, const std::vector<int> &index);
  // Deep copy.
  void Assign (const SaddleContainer<ScalarType, MV>&A);
  // Fill the vectors in *this with random numbers.
  void  MvRandom ();
  // Replace each element of the vectors in *this with alpha.
  void  MvInit (ScalarType alpha);
  // Prints the multivector to an output stream
  void MvPrint (std::ostream &os) const;
};



// THIS IS NEW!
template <class ScalarType, class MV>
RCP< Teuchos::SerialDenseMatrix<int,ScalarType> > SaddleContainer<ScalarType, MV>::getLower() const
{
  if(indices_.empty())
  {
    return lowerRaw_;
  }

  int nrows = lowerRaw_->numRows();
  int ncols = indices_.size();

  RCP<SerialDenseMatrix> lower = rcp(new SerialDenseMatrix(nrows,ncols,false));

  for(int r=0; r<nrows; r++)
  {
    for(int c=0; c<ncols; c++)
    {
      (*lower)(r,c) = (*lowerRaw_)(r,indices_[c]);
    }
  }

  return lower;
}



// THIS IS NEW!
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::setLower(const RCP<SerialDenseMatrix> lower)
{
  // If the indices are empty, lower points to lowerRaw
  if(indices_.empty())
  {
    return;
  }

  int nrows = lowerRaw_->numRows();
  int ncols = indices_.size();

  for(int r=0; r<nrows; r++)
  {
    for(int c=0; c<ncols; c++)
    {
      (*lowerRaw_)(r,indices_[c]) = (*lower)(r,c);
    }
  }
}



// Constructor
template <class ScalarType, class MV>
SaddleContainer<ScalarType, MV>::SaddleContainer( const RCP<MV> X, bool eye )
: ONE(Teuchos::ScalarTraits<ScalarType>::one()), ZERO(Teuchos::ScalarTraits<ScalarType>::zero())
{
  int nvecs = MVT::GetNumberVecs(*X);

  if(eye)
  {
    // Initialize upper_ as all 0s
    upper_ = MVT::Clone(*X, nvecs);
    MVT::MvInit(*upper_);

    // Initialize Y to be I
    lowerRaw_ = rcp(new SerialDenseMatrix(nvecs,nvecs));
    for(int i=0; i < nvecs; i++)
      (*lowerRaw_)(i,i) = ONE;
  }
  else
  {
    // Point upper_ to X
    upper_ = X;

    // Initialize Y to be 0
    lowerRaw_ = rcp(new SerialDenseMatrix(nvecs,nvecs));
  }
}



// Returns a clone of the current vector
template <class ScalarType, class MV>
SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::Clone(const int nvecs) const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::Clone(*upper_,nvecs);
  newSC->lowerRaw_ = rcp(new SerialDenseMatrix(lowerRaw_->numRows(),nvecs));

  return newSC;
}



// Returns a duplicate of the current vector
template <class ScalarType, class MV>
SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneCopy() const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::CloneCopy(*upper_);
  newSC->lowerRaw_ = getLower();

  return newSC;
}



// Returns a duplicate of the specified vectors
template <class ScalarType, class MV>
SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneCopy(const std::vector< int > &index) const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::CloneCopy(*upper_,index);

  int ncols = index.size();
  int nrows = lowerRaw_->numRows();
  RCP<SerialDenseMatrix> lower = getLower();
  newSC->lowerRaw_ = rcp(new SerialDenseMatrix(nrows,ncols));
  for(int c=0; c < ncols; c++)
  {
    for(int r=0; r < nrows; r++)
      (*newSC->lowerRaw_)(r,c) = (*lower)(r,index[c]);
  }

  return newSC;
}



// THIS IS NEW!
template <class ScalarType, class MV>
SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneViewNonConst(const std::vector<int> &index) const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);

  newSC->lowerRaw_ = lowerRaw_;

  if(!indices_.empty())
  {
    newSC->indices_.resize(index.size());
    for(unsigned int i=0; i<index.size(); i++)
    {
      newSC->indices_[i] = indices_[index[i]];
    }
  }
  else
  {
    newSC->indices_ = index;
  }

  return newSC;
}


template <class ScalarType, class MV>
SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneViewNonConst(const Teuchos::Range1D& index) const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);

  newSC->lowerRaw_ = lowerRaw_;

  newSC->indices_.resize(index.size());
  for(unsigned int i=0; i<index.size(); i++)
  {
    newSC->indices_[i] = indices_[index.lbound()+i];
  }

  return newSC;
}



// THIS IS NEW!
template <class ScalarType, class MV>
const SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneView(const std::vector<int> &index) const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);

  newSC->lowerRaw_ = lowerRaw_;

  if(!indices_.empty())
  {
    newSC->indices_.resize(index.size());
    for(unsigned int i=0; i<index.size(); i++)
    {
      newSC->indices_[i] = indices_[index[i]];
    }
  }
  else
  {
    newSC->indices_ = index;
  }

  return newSC;
}


template <class ScalarType, class MV>
const SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneView(const Teuchos::Range1D& index) const
{
  SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();

  newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);

  newSC->lowerRaw_ = lowerRaw_;

  newSC->indices_.resize(index.size());
  for(unsigned int i=0; i<index.size(); i++)
  {
    newSC->indices_[i] = indices_[index.lbound()+i];
  }

  return newSC;
}



// Update *this with alpha * A * B + beta * (*this)
// THIS IS NEW!
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvTimesMatAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV> &A,
                                                      const Teuchos::SerialDenseMatrix<int, ScalarType> &B,
                                                      ScalarType beta)
{
  MVT::MvTimesMatAddMv(alpha,*(A.upper_),B,beta,*upper_);
  RCP<SerialDenseMatrix> lower = getLower();
  RCP<SerialDenseMatrix> Alower = A.getLower();
  lower->multiply(Teuchos::NO_TRANS,Teuchos::NO_TRANS,alpha,*Alower,B,beta);
  setLower(lower);
}



// Replace *this with alpha * A + beta * B
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV>& A,
                                              ScalarType beta,  const SaddleContainer<ScalarType,MV>& B)
{
  MVT::MvAddMv(alpha, *(A.upper_), beta, *(B.upper_), *upper_);

  RCP<SerialDenseMatrix> lower = getLower();
  RCP<SerialDenseMatrix> Alower = A.getLower();
  RCP<SerialDenseMatrix> Blower = B.getLower();

  //int ncolsA = Alower->numCols(); // unused
  //int ncolsThis = lower->numCols(); // unused
  //int nrows = lower->numRows(); // unused

  // Y = alpha A
  lower->assign(*Alower);
  if(alpha != ONE)
    lower->scale(alpha);
  // Y += beta B
  if(beta == ONE)
    *lower += *Blower;
  else if(beta == -ONE)
    *lower -= *Blower;
  else if(beta != ZERO)
  {
    SerialDenseMatrix scaledB(*Blower);
    scaledB.scale(beta);
    *lower += *Blower;
  }

  setLower(lower);
}



// Scale the vectors by alpha
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvScale( ScalarType alpha )
{
  MVT::MvScale(*upper_, alpha);


  RCP<SerialDenseMatrix> lower = getLower();
  lower->scale(alpha);
  setLower(lower);
}



// Scale the i-th vector by alpha[i]
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvScale( const std::vector<ScalarType>& alpha )
{
  MVT::MvScale(*upper_, alpha);

  RCP<SerialDenseMatrix> lower = getLower();

  int nrows = lower->numRows();
  int ncols = lower->numCols();

  for(int c=0; c<ncols; c++)
  {
    for(int r=0; r<nrows; r++)
      (*lower)(r,c) *= alpha[c];
  }

  setLower(lower);
}



// Compute a dense matrix B through the matrix-matrix multiply alpha * A^H * (*this)
// THIS IS NEW!
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvTransMv (ScalarType alpha, const SaddleContainer<ScalarType, MV>& A,
                                                 Teuchos::SerialDenseMatrix< int, ScalarType >& B) const
{
  MVT::MvTransMv(alpha,*(A.upper_),*upper_,B);
  RCP<SerialDenseMatrix> lower = getLower();
  RCP<SerialDenseMatrix> Alower = A.getLower();
  B.multiply(Teuchos::TRANS,Teuchos::NO_TRANS,alpha,*(Alower),*lower,ONE);
}



// Compute a vector b where the components are the individual dot-products, i.e.b[i] = A[i]^H*this[i] where A[i] is the i-th column of A.
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvDot (const SaddleContainer<ScalarType, MV>& A, std::vector<ScalarType> &b) const
{
  MVT::MvDot(*upper_, *(A.upper_), b);

  RCP<SerialDenseMatrix> lower = getLower();
  RCP<SerialDenseMatrix> Alower = A.getLower();

  int nrows = lower->numRows();
  int ncols = lower->numCols();

  for(int c=0; c < ncols; c++)
  {
    for(int r=0; r < nrows; r++)
    {
      b[c] += ((*Alower)(r,c) * (*lower)(r,c));
    }
  }
}



// Compute the 2-norm of each individual vector
// THIS IS NEW!
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec) const
{
  // TODO: Make this better
  MvDot(*this,normvec);
  for(unsigned int i=0; i<normvec.size(); i++)
    normvec[i] = sqrt(normvec[i]);
}



// Copy the vectors in A to a set of vectors in *this. The numvecs vectors in
// A are copied to a subset of vectors in *this indicated by the indices given
// in index.
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::SetBlock (const SaddleContainer<ScalarType, MV>& A, const std::vector<int> &index)
{
  MVT::SetBlock(*(A.upper_), index, *upper_);

  RCP<SerialDenseMatrix> lower = getLower();
  RCP<SerialDenseMatrix> Alower = A.getLower();

  int nrows = lower->numRows();

  int nvecs = index.size();
  for(int c=0; c<nvecs; c++)
  {
    for(int r=0; r<nrows; r++)
      (*lower)(r,index[c]) = (*Alower)(r,c);
  }

  setLower(lower);
}



// Deep copy.
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::Assign (const SaddleContainer<ScalarType, MV>&A)
{
  MVT::Assign(*(A.upper_),*(upper_));

  RCP<SerialDenseMatrix> lower = getLower();
  RCP<SerialDenseMatrix> Alower = A.getLower();

  *lower = *Alower; // This is a well-defined operator for SerialDenseMatrix

  setLower(lower);
}



// Fill the vectors in *this with random numbers.
// THIS IS NEW!
template <class ScalarType, class MV>
void  SaddleContainer<ScalarType, MV>::MvRandom ()
{
  MVT::MvRandom(*upper_);

  RCP<SerialDenseMatrix> lower = getLower();
  lower->random();
  setLower(lower);
}



// Replace each element of the vectors in *this with alpha.
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvInit (ScalarType alpha)
{
  MVT::MvInit(*upper_,alpha);

  RCP<SerialDenseMatrix> lower = getLower();
  lower->putScalar(alpha);
  setLower(lower);
}



// Prints the multivector to an output stream
template <class ScalarType, class MV>
void SaddleContainer<ScalarType, MV>::MvPrint (std::ostream &os) const
{
  RCP<SerialDenseMatrix> lower = getLower();
  //int nrows = lower->numRows(); // unused
  //int ncols = lower->numCols(); // unused

  os << "Object SaddleContainer" << std::endl;
  os << "X\n";
  upper_->describe(*(Teuchos::VerboseObjectBase::getDefaultOStream()),Teuchos::VERB_EXTREME);
//  os << "X\n" << *upper_ << std::endl;

  os << "Y\n" << *lower << std::endl;
}

} // End namespace Experimental

template<class ScalarType, class MV >
class MultiVecTraits<ScalarType,Experimental::SaddleContainer<ScalarType, MV> >
{
typedef Experimental::SaddleContainer<ScalarType,MV>  SC;

public:
  static RCP<SC > Clone( const SC& mv, const int numvecs )
    { return rcp( const_cast<SC&>(mv).Clone(numvecs) ); }

  static RCP<SC > CloneCopy( const SC& mv )
    { return rcp( const_cast<SC&>(mv).CloneCopy() ); }

  static RCP<SC > CloneCopy( const SC& mv, const std::vector<int>& index )
    { return rcp( const_cast<SC&>(mv).CloneCopy(index) ); }

  static ptrdiff_t GetGlobalLength( const SC& mv )
    { return mv.GetGlobalLength(); }

  static int GetNumberVecs( const SC& mv )
    { return mv.GetNumberVecs(); }

  static void MvTimesMatAddMv( ScalarType alpha, const SC& A,
                               const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
                               ScalarType beta, SC& mv )
    { mv.MvTimesMatAddMv(alpha, A, B, beta); }

  static void MvAddMv( ScalarType alpha, const SC& A, ScalarType beta, const SC& B, SC& mv )
    { mv.MvAddMv(alpha, A, beta, B); }

  static void MvTransMv( ScalarType alpha, const SC& A, const SC& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B)
    { mv.MvTransMv(alpha, A, B); }

  static void MvDot( const SC& mv, const SC& A, std::vector<ScalarType> & b)
    { mv.MvDot( A, b); }

  static void MvScale ( SC& mv, ScalarType alpha )
    { mv.MvScale( alpha ); }

  static void MvScale ( SC& mv, const std::vector<ScalarType>& alpha )
    { mv.MvScale( alpha ); }

  static void MvNorm( const SC& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> & normvec)
    { mv.MvNorm(normvec); }

  static void SetBlock( const SC& A, const std::vector<int>& index, SC& mv )
    { mv.SetBlock(A, index); }

  static void Assign( const SC& A, SC& mv )
    { mv.Assign(A); }

  static void MvRandom( SC& mv )
    { mv.MvRandom(); }

  static void MvInit( SC& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
    { mv.MvInit(alpha); }

  static void MvPrint( const SC& mv, std::ostream& os )
    { mv.MvPrint(os); }
};

} // end namespace Anasazi

#ifdef HAVE_ANASAZI_BELOS
namespace Belos
{

template<class ScalarType, class MV >
class MultiVecTraits< ScalarType, Anasazi::Experimental::SaddleContainer<ScalarType,MV> >
{
typedef Anasazi::Experimental::SaddleContainer<ScalarType,MV>  SC;
public:
  static RCP<SC > Clone( const SC& mv, const int numvecs )
    { return rcp( const_cast<SC&>(mv).Clone(numvecs) ); }

  static RCP<SC > CloneCopy( const SC& mv )
    { return rcp( const_cast<SC&>(mv).CloneCopy() ); }

  static RCP<SC > CloneCopy( const SC& mv, const std::vector<int>& index )
    { return rcp( const_cast<SC&>(mv).CloneCopy(index) ); }

  static RCP<SC> CloneViewNonConst( SC& mv, const std::vector<int>& index )
    { return rcp( mv.CloneViewNonConst(index) ); }

  static RCP<SC> CloneViewNonConst( SC& mv, const Teuchos::Range1D& index )
    { return rcp( mv.CloneViewNonConst(index) ); }

  static RCP<const SC> CloneView( const SC& mv, const std::vector<int> & index )
    { return rcp( mv.CloneView(index) ); }

  static RCP<const SC> CloneView( const SC& mv, const Teuchos::Range1D& index )
    { return rcp( mv.CloneView(index) ); }

  static ptrdiff_t GetGlobalLength( const SC& mv )
    { return mv.GetGlobalLength(); }

  static int GetNumberVecs( const SC& mv )
    { return mv.GetNumberVecs(); }

  static void MvTimesMatAddMv( ScalarType alpha, const SC& A,
                               const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
                               ScalarType beta, SC& mv )
    { mv.MvTimesMatAddMv(alpha, A, B, beta); }

  static void MvAddMv( ScalarType alpha, const SC& A, ScalarType beta, const SC& B, SC& mv )
    { mv.MvAddMv(alpha, A, beta, B); }

  static void MvTransMv( ScalarType alpha, const SC& A, const SC& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B)
    { mv.MvTransMv(alpha, A, B); }

  static void MvDot( const SC& mv, const SC& A, std::vector<ScalarType> & b)
    { mv.MvDot( A, b); }

  static void MvScale ( SC& mv, ScalarType alpha )
    { mv.MvScale( alpha ); }

  static void MvScale ( SC& mv, const std::vector<ScalarType>& alpha )
    { mv.MvScale( alpha ); }

  // TODO: MAKE SURE TYPE == TWONORM
  static void MvNorm( const SC& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> & normvec, NormType type=TwoNorm)
    { mv.MvNorm(normvec); }

  static void SetBlock( const SC& A, const std::vector<int>& index, SC& mv )
    { mv.SetBlock(A, index); }

  static void Assign( const SC& A, SC& mv )
    { mv.Assign(A); }

  static void MvRandom( SC& mv )
    { mv.MvRandom(); }

  static void MvInit( SC& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
    { mv.MvInit(alpha); }

  static void MvPrint( const SC& mv, std::ostream& os )
    { mv.MvPrint(os); }

#ifdef HAVE_BELOS_TSQR
  /// \typedef tsqr_adaptor_type
  /// \brief TsqrAdaptor specialization for the multivector type MV.
  ///
  /// By default, we provide a "stub" implementation.  It has the
  /// right methods and typedefs, but its constructors and methods
  /// all throw std::logic_error.  If you plan to use TSQR in Belos
  /// (e.g., through TsqrOrthoManager or TsqrMatOrthoManager), and
  /// if your multivector type MV is neither Epetra_MultiVector nor
  /// Tpetra::MultiVector, you must implement a functional TSQR
  /// adapter.  Please refer to Epetra::TsqrAdapter (for
  /// Epetra_MultiVector) or Tpetra::TsqrAdaptor (for
  /// Tpetra::MultiVector) for examples.
  typedef Belos::details::StubTsqrAdapter<SC> tsqr_adaptor_type;
#endif // HAVE_BELOS_TSQR
};

} // end namespace Belos
#endif

#endif