/*! _dsymatrix*_dgbmatrix operator */
inline _dgematrix operator*(const _dsymatrix& matA, const _dgbmatrix& matB)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _dsymatrix&, const _dgbmatrix&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(matA.N!=matB.M){
    std::cerr << "[ERROR] operator*(_dsymatrix&, _dgbmatrix&)" << std::endl
              << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.N << "x" << matA.N << ") * ("
              << matB.M << "x" << matB.N << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat( matA.N, matB.N );
  newmat.zero();
  
  long i, j, k;
  for(i=0; i<newmat.m; i++){
    for(j=0; j<newmat.n; j++){
      for(k=max(0,j-matB.KU); k<min(matB.M,j+matB.KL+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  matA.destroy();
  matB.destroy();
  return _(newmat);
}
/*! _dsymatrix*_dcovector operator */
inline _dcovector operator*(const _dsymatrix& mat, const _dcovector& vec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _dsymatrix&, const _dcovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(mat.N!=vec.L){
    std::cerr << "[ERROR] operator*(const _dsymatrix&, const _dcovector&)"
              << std::endl
              << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.N << "x" << mat.N << ") * ("
              << vec.L << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dcovector newvec(mat.N);
  dsymv_( 'L', mat.N, 1.0, mat.Array, mat.N,
          vec.Array, 1, 0.0, newvec.array, 1 );
  
  mat.destroy();
  vec.destroy();
  return _(newvec);
}
/*! _dsymatrix-_dgbmatrix operator */
inline _dgematrix operator-(const _dsymatrix& matA, const _dgbmatrix& matB)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator-(const _dsymatrix&, const _dgbmatrix&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(matA.N!=matB.N || matA.N!=matB.M){
    std::cerr << "[ERROR] operator+(_dsymatrix&, _dgbmatrix&)" << std::endl
              << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.N << "x" << matA.N << ") + ("
              << matB.M << "x" << matB.N << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.N, matA.N);
  for(long i=0; i<matB.M; i++){
    for(long j=i; j<matA.N; j++){
      newmat(i,j) = newmat(j,i) = matA(i,j);
    }
    for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
      newmat(i,j) -= matB(i,j);
    }
  }

  matA.destroy();
  matB.destroy();
  return _(newmat);
}
/*! _dsymatrix*dssmatrix operator */
inline _dgematrix operator*(const _dsymatrix& matA, const dssmatrix& matB)
{
#ifdef  CPPL_VERBOSE
    std::cerr << "# [MARK] operator*(const _dsymatrix&, const dssmatrix&)"
              << std::endl;
#endif//CPPL_VERBOSE

#ifdef  CPPL_DEBUG
    if(matA.N!=matB.M) {
        std::cerr << "[ERROR] operator*(const _dsymatrix&, const dssmatrix&)"
                  << std::endl
                  << "These two matrises can not make a product." << std::endl
                  << "Your input was (" << matA.N << "x" << matA.N << ") * ("
                  << matB.M << "x" << matB.N << ")." << std::endl;
        exit(1);
    }
#endif//CPPL_DEBUG

    dgematrix newmat(matA.N, matB.N);
    newmat.zero();

    for(long c=0; c<matB.VOL; c++) {
        for(long i=0; i<matA.N; i++) {
            newmat(i,matB.Jndx[c]) += matA(i,matB.Indx[c])*matB.Array[c];
        }
    }

    matA.destroy();
    return _(newmat);
}
/*! _dsymatrix-dssmatrix operator */
inline _dgematrix operator-(const _dsymatrix& matA, const dssmatrix& matB)
{
#ifdef  CPPL_VERBOSE
    std::cerr << "# [MARK] operator-(const _dsymatrix&, const dssmatrix&)"
              << std::endl;
#endif//CPPL_VERBOSE

#ifdef  CPPL_DEBUG
    if(matA.N!=matB.M || matA.N!=matB.N) {
        std::cerr << "[ERROR] operator-(const _dsymatrix&, const dssmatrix&)"
                  << std::endl
                  << "These two matrises can not make a subtraction." << std::endl
                  << "Your input was (" << matA.N << "x" << matA.N << ") - ("
                  << matB.M << "x" << matB.N << ")." << std::endl;
        exit(1);
    }
#endif//CPPL_DEBUG

    dgematrix newmat(matA);
    for(long c=0; c<matB.VOL; c++) {
        newmat(matB.Indx[c],matB.Jndx[c]) -= matB.Array[c];
    }

    matA.destroy();
    return _(newmat);
}
Exemplo n.º 6
0
/*! _dgsmatrix+_dsymatrix operator */
inline _dgematrix operator+(const _dgsmatrix& matA, const _dsymatrix& matB)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.m!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat( matB.to_dgematrix() );
  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
    newmat(it->i,it->j) += it->v;
  }
  
  matA.destroy();
  matB.destroy();
  return _(newmat);
}
Exemplo n.º 7
0
/*! dsymatrix*_dsymatrix operator */
inline _dgematrix operator*(const dsymatrix& matA, const _dsymatrix& matB)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  matA.complete();
  matB.complete();  
  dgematrix newmat( matA.n, matA.n );
  
  dgemm_( 'n', 'n', matA.n, matB.n, matA.n, 1.0, matA.array, matA.n,
          matB.array, matB.n, 0.0, newmat.array, matA.n );
  
  matB.destroy();
  return _(newmat);
}
Exemplo n.º 8
0
/*! _dgsmatrix*_dsymatrix operator */
inline _dgematrix operator*(const _dgsmatrix& matA, const _dsymatrix& matB)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.m, matB.n);
  newmat.zero();
  
  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
    for(long i=0; i<matB.n; i++){
      newmat(it->i,i) += it->v*matB(it->j,i);
    }
  }
  
  matA.destroy();
  matB.destroy();
  return _(newmat);
}