/*! _dcovector*_drovector operator */
inline _dgematrix operator*(const _dcovector& covec, const _drovector& rovec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _dcovector&, const _drovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(covec.L!=rovec.L){
    std::cerr << "[ERROR] operator*(const dcovector&, const drovector&)"
              << std::endl
              << "These two vectors can not make a product." << std::endl
              << "Your input was (" << covec.L << ") * (" << rovec.L << ")."
              << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(covec.L, covec.L);
  for(long i=0; i<newmat.m; i++){
    for(long j=0; j<newmat.n; j++){
      newmat(i,j) =covec(i)*rovec(j);
    }
  }
  
  covec.destroy();
  rovec.destroy();
  return _(newmat);
}
/*! _drovector*dgbmatrix operator */
inline _drovector operator*(const _drovector& vec, const dgbmatrix& mat)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _drovector&, const dgbmatrix&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vec.L!=mat.M){
    std::cerr << "[ERROR] operator*(const _drovector&, const dgbmatrix&)"
              << 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
  
  drovector newvec(mat.N);
  dgbmv_( 'T', mat.M, mat.N, mat.KL, mat.KU, 1.0,
          mat.Array, mat.KL+mat.KU+1, vec.Array, 1, 0.0, newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
Esempio n. 3
0
/*! return its largest absolute value */
inline double damax(const _drovector& vec)
{
#ifdef  CPPL_VERBOSE
    std::cerr << "# [MARK] damax(const _drovector&)"
              << std::endl;
#endif//CPPL_VERBOSE

    double val( vec.Array[idamax_(vec.L, vec.Array, 1)-1] );
    vec.destroy();
    return val;
}
Esempio n. 4
0
/*! return the index of element having the largest absolute value
  in 0-based numbering system */
inline long idamax(const _drovector& vec)
{
#ifdef  CPPL_VERBOSE
    std::cerr << "# [MARK] idamax(const _drovector&)"
              << std::endl;
#endif//CPPL_VERBOSE

    long i( idamax_(vec.L, vec.Array, 1) -1 );
    vec.destroy();
    return i;
}
Esempio n. 5
0
/*! return its Euclidean norm */
inline double nrm2(const _drovector& vec)
{
#ifdef  CPPL_VERBOSE
    std::cerr << "# [MARK] nrm2(const _drovector&)"
              << std::endl;
#endif//CPPL_VERBOSE

    double val( dnrm2_(vec.L, vec.Array, 1) );
    vec.destroy();
    return val;
}
/*! dcovector*_drovector operator */
inline _dgematrix operator*(const dcovector& covec, const _drovector& rovec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const dcovector&, const _drovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
  dgematrix 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);
}
Esempio n. 7
0
/*! _drovector*dcovector operator */
inline double operator*(const _drovector& rovec, const dcovector& covec)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(rovec.l!=covec.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a product." << std::endl
              << "Your input was (" << rovec.l << ") * (" << covec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  double val( ddot_( rovec.l, rovec.array, 1, covec.array, 1 ) );
  
  rovec.destroy();
  return val;
}
Esempio n. 8
0
/*! _drovector*dgbmatrix operator */
inline _drovector operator*(const _drovector& vec, const dgbmatrix& 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
  
  drovector newvec(mat.n);
  
  dgbmv_( 'T', mat.m, mat.n, mat.kl, mat.ku, 1.0, mat.array, mat.kl+mat.ku+1, vec.array, 1, 0.0, newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}