// -*- C++ -*-
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// 
// Copyright Cornell University 1993, 1996, All Rights Reserved.
// 
// This software written by Nobu Katayama and Mike Smyth, Cornell University.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice and author attribution, this list of conditions and the
//    following disclaimer. 
// 2. Redistributions in binary form must reproduce the above copyright
//    notice and author attribution, this list of conditions and the
//    following disclaimer in the documentation and/or other materials
//    provided with the distribution.
// 3. Neither the name of the University nor the names of its contributors
//    may be used to endorse or promote products derived from this software
//    without specific prior written permission.
// 
// Creation of derivative forms of this software for commercial
// utilization may be subject to restriction; written permission may be
// obtained from Cornell University.
// 
// CORNELL MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By way
// of example, but not limitation, CORNELL MAKES NO REPRESENTATIONS OR
// WARRANTIES OF MERCANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
// THE USE OF THIS SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS,
// COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS.  Cornell University shall not be
// held liable for any liability with respect to any claim by the user or any
// other party arising from use of the program.
//

namespace CLHEP {

// swap
//
inline void HepGenMatrix::swap(int &i,int &j) {int t=i;i=j;j=t;}
#ifdef DISABLE_ALLOC
inline void HepGenMatrix::swap(std::vector<double >& i, std::vector<double >& j) {
  std::vector<double > t=i;i=j;j=t;
}
#else
inline void HepGenMatrix::swap(std::vector<double,Alloc<double,25> >& i, std::vector<double,Alloc<double,25> >& j) {
  std::vector<double,Alloc<double,25> > t=i;i=j;j=t;
}
#endif

//
// operator [] (I cannot make it virtual because return types are different.)
// Therefore I will have to use the virtual operator (,).
//
inline double &HepGenMatrix::HepGenMatrix_row::operator[](int c) {
  return _a(_r+1,c+1);
}

inline const double &HepGenMatrix::HepGenMatrix_row_const::
operator[](int c) const {
  return _a(_r+1,c+1);
}

inline HepGenMatrix::HepGenMatrix_row HepGenMatrix::operator[](int r) {
  HepGenMatrix_row b(*this,r); 
  return b;
}

inline const HepGenMatrix::HepGenMatrix_row_const HepGenMatrix::
operator[](int r) const{
  HepGenMatrix_row_const b(*this,r); 
  return b;
}

inline HepGenMatrix::HepGenMatrix_row::HepGenMatrix_row(HepGenMatrix&a,int r) 
: _a(a) {
  _r = r;
}

inline HepGenMatrix::HepGenMatrix_row_const::
HepGenMatrix_row_const (const HepGenMatrix&a, int r) 
   : _a(a) {
  _r = r;
}


}  // namespace CLHEP


// -----------------------------------------------------------------


