コード例 #1
0
/*! _zrovector*zgbmatrix operator */
inline _zrovector operator*(const _zrovector& vec, const zgbmatrix& mat)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _zrovector&, const zgbmatrix&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vec.L!=mat.M){
    std::cerr << "[ERROR] operator*(const _zrovector&, const zgbmatrix&)"
              << std::endl
              << "These vector and matrix can not make a product."
              << std::endl
              << "Your input was (" << vec.L << ") * ("
              << mat.M << "x" << mat.N << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.N);
  zgbmv_( 'T', mat.M, mat.N, mat.KL, mat.KU, std::complex<double>(1.0,0.0),
          mat.Array, mat.KL+mat.KU+1, vec.Array, 1, std::complex<double>(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
コード例 #2
0
ファイル: _zrovector-calc.hpp プロジェクト: phelrine/NBTools
/*! return a conjugate transposed column vector */
inline _zcovector conjt(const _zrovector& rovec)
{VERBOSE_REPORT;
  zcovector covec(rovec.l);
  for(long i=0; i<rovec.l; i++){ covec(i) =std::conj(rovec(i)); }
  
  rovec.destroy();
  return _(covec);
}
コード例 #3
0
/*! _zrovector^T*_zrovector operator (inner product) */
inline std::complex<double> operator%(const _zrovector& vecA, const _zrovector& vecB)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator%(const _zrovector&, const _zrovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vecA.L!=vecB.L){
    std::cerr << "[ERROR] operator%(const _zrovector&, const _zrovector&)"
              << std::endl
              << "These two vectors can not make a dot product." << std::endl
              << "Your input was (" << vecA.L << ") % (" << vecB.L << ")."
              << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  std::complex<double> val( zdotu_( vecA.L, vecA.Array, 1, vecB.Array, 1 ) );
  
  vecA.destroy();
  vecB.destroy();
  return val;
}
コード例 #4
0
/*! zcovector*_zrovector operator */
inline _zgematrix operator*(const zcovector& covec, const _zrovector& rovec)
{
#ifdef  CPPL_VERBOSE
    std::cerr << "# [MARK] operator*(const zcovector&, const _zrovector&)"
              << std::endl;
#endif//CPPL_VERBOSE

    zgematrix newmat(covec.L, rovec.L);
    for(long i=0; i<newmat.m; i++) {
        for(long j=0; j<newmat.n; j++) {
            newmat(i,j) =covec(i)*rovec(j);
        }
    }

    rovec.destroy();
    return _(newmat);
}
コード例 #5
0
/*! _zrovector*_zhematrix operator */
inline _zrovector operator*(const _zrovector& vec, const _zhematrix& mat)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.n){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zhemv_( 'l', mat.n, comple(1.0,0.0), mat.array, mat.n,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  mat.destroy();
  return _(newvec);
}
コード例 #6
0
/*! _zrovector-_zrovector operator */
inline _zrovector operator-(const _zrovector& vecA, const _zrovector& vecB)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator-(const _zrovector&, const _zrovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vecA.L!=vecB.L){
    std::cerr << "[ERROR] operator-(const _zrovector&, const _zrovector&)"
              << std::endl
              << "These two vectors can not make a subtraction." << std::endl
              << "Your input was (" << vecA.L << ") - (" << vecB.L << ")."
              << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<vecA.L; i++){ vecA.Array[i]-=vecB.Array[i]; }
  
  vecB.destroy();
  return vecA;
}
コード例 #7
0
/*! _zrovector*zhsmatrix operator */
inline _zrovector operator*(const _zrovector& vec, const zhsmatrix& mat)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  newvec.zero();
  
  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    newvec(it->j) +=vec(it->i)*it->v;
    if(it->i!=it->j){
      newvec(it->i) +=vec(it->j)*std::conj(it->v);
    }
  }
  
  vec.destroy();
  return _(newvec);
}
コード例 #8
0
ファイル: _zrovector-calc.hpp プロジェクト: phelrine/NBTools
/*! return its largest absolute value */
inline comple damax(const _zrovector& vec)
{VERBOSE_REPORT;
  comple val( vec.array[izamax_(vec.l, vec.array, 1)-1] );
  vec.destroy();
  return val;
}
コード例 #9
0
ファイル: _zrovector-calc.hpp プロジェクト: phelrine/NBTools
/*! return the index of element having the largest absolute value
  in 0-based numbering system */
inline long idamax(const _zrovector& vec)
{VERBOSE_REPORT;
  long i( izamax_(vec.l, vec.array, 1) -1 );
  vec.destroy();
  return i;
}
コード例 #10
0
ファイル: _zrovector-calc.hpp プロジェクト: phelrine/NBTools
/*! return its Euclidean norm */
inline double nrm2(const _zrovector& vec)
{VERBOSE_REPORT;
  double val( dznrm2_(vec.l, vec.array, 1) );
  vec.destroy();
  return val;
}