コード例 #1
0
void CompoundSymMatrix::ComputeRowAMaxImpl(
   Vector& rows_norms,
   bool    init
   ) const
{
   if( !matrices_valid_ )
   {
      matrices_valid_ = MatricesValid();
   } DBG_ASSERT(matrices_valid_);

   // The vector is assumed to be compound Vectors as well except if
   // there is only one component
   CompoundVector* comp_vec = dynamic_cast<CompoundVector*>(&rows_norms);

   //  A few sanity checks
   if( comp_vec )
   {
      DBG_ASSERT(NComps_Dim() == comp_vec->NComps());
   }
   else
   {
      DBG_ASSERT(NComps_Dim() == 1);
   }

   for( Index jcol = 0; jcol < NComps_Dim(); jcol++ )
   {
      for( Index irow = 0; irow < NComps_Dim(); irow++ )
      {
         SmartPtr<Vector> vec_i;
         if( comp_vec )
         {
            vec_i = comp_vec->GetCompNonConst(irow);
         }
         else
         {
            vec_i = &rows_norms;
         } DBG_ASSERT(IsValid(vec_i));
         if( jcol <= irow && ConstComp(irow, jcol) )
         {
            ConstComp(irow, jcol)->ComputeRowAMax(*vec_i, false);
         }
         else if( jcol > irow && ConstComp(jcol, irow) )
         {
            ConstComp(jcol, irow)->ComputeRowAMax(*vec_i, false);
         }
      }
   }
}
コード例 #2
0
  bool CompoundSymMatrix::HasValidNumbersImpl() const
  {
    if (!matrices_valid_) {
      matrices_valid_ = MatricesValid();
    }
    DBG_ASSERT(matrices_valid_);

    for (Index irow=0; irow<NComps_Dim(); irow++) {
      for (Index jcol=0; jcol<=irow; jcol++) {
        if (ConstComp(irow,jcol)) {
          if (!ConstComp(irow,jcol)->HasValidNumbers()) {
            return false;
          }
        }
      }
    }
    return true;
  }
コード例 #3
0
ファイル: IpCompoundMatrix.cpp プロジェクト: MengbinZhu/pfldp
  bool CompoundMatrix::HasValidNumbersImpl() const
  {
    if (!matrices_valid_) {
      matrices_valid_ = MatricesValid();
    }
    DBG_ASSERT(matrices_valid_);

    for ( Index irow = 0; irow < NComps_Rows(); irow++ ) {
      for ( Index jcol = 0; jcol < NComps_Cols(); jcol++ ) {
        if ( (owner_space_->Diagonal() && irow == jcol)
             || (!owner_space_->Diagonal() && ConstComp(irow,jcol)) ) {
          if (!ConstComp(irow, jcol)->HasValidNumbers()) {
            return false;
          }
        }
      }
    }
    return true;
  }
コード例 #4
0
ファイル: IpCompoundMatrix.cpp プロジェクト: MengbinZhu/pfldp
  void CompoundMatrix::ComputeColAMaxImpl(Vector& cols_norms, bool init) const
  {
    if (!matrices_valid_) {
      matrices_valid_ = MatricesValid();
    }
    DBG_ASSERT(matrices_valid_);

    // The vector is assumed to be compound Vectors as well except if
    // there is only one component
    CompoundVector* comp_vec = dynamic_cast<CompoundVector*>(&cols_norms);

#ifndef ALLOW_NESTED
    //  A few sanity checks
    if (comp_vec) {
      DBG_ASSERT(NComps_Cols()==comp_vec->NComps());
    }
    else {
      DBG_ASSERT(NComps_Cols() == 1);
    }
#endif
    if (comp_vec) {
      if (NComps_Cols()!=comp_vec->NComps()) {
        comp_vec = NULL;
      }
    }

    for (Index irow = 0; irow < NComps_Rows(); irow++) {
      for (Index jcol = 0; jcol < NComps_Cols(); jcol++) {
        if (ConstComp(irow, jcol)) {
          SmartPtr<Vector> vec_i;
          if (comp_vec) {
            vec_i = comp_vec->GetCompNonConst(irow);
          }
          else {
            vec_i = &cols_norms;
          }
          DBG_ASSERT(IsValid(vec_i));
          ConstComp(irow, jcol)->ComputeColAMax(*vec_i, false);
        }
      }
    }
  }
コード例 #5
0
  void CompoundSymMatrix::MultVectorImpl(Number alpha, const Vector &x,
                                         Number beta, Vector &y) const
  {
    if (!matrices_valid_) {
      matrices_valid_ = MatricesValid();
    }
    DBG_ASSERT(matrices_valid_);

    // The vectors are assumed to be compound Vectors as well
    const CompoundVector* comp_x = dynamic_cast<const CompoundVector*>(&x);
    CompoundVector* comp_y = dynamic_cast<CompoundVector*>(&y);

    //  A few sanity checks
    if (comp_x) {
      DBG_ASSERT(NComps_Dim()==comp_x->NComps());
    }
    else {
      DBG_ASSERT(NComps_Dim() == 1);
    }
    if (comp_y) {
      DBG_ASSERT(NComps_Dim()==comp_y->NComps());
    }
    else {
      DBG_ASSERT(NComps_Dim() == 1);
    }

    // Take care of the y part of the addition
    if( beta!=0.0 ) {
      y.Scal(beta);
    }
    else {
      y.Set(0.0);  // In case y hasn't been initialized yet
    }

    for (Index irow=0; irow<NComps_Dim(); irow++) {
      SmartPtr<Vector> y_i;
      if (comp_y) {
        y_i = comp_y->GetCompNonConst(irow);
      }
      else {
        y_i = &y;
      }
      DBG_ASSERT(IsValid(y_i));

      for (Index jcol=0; jcol<=irow; jcol++) {
        SmartPtr<const Vector> x_j;
        if (comp_x) {
          x_j = comp_x->GetComp(irow);
        }
        else {
          x_j = &x;
        }
        DBG_ASSERT(IsValid(x_j));

        if (ConstComp(irow,jcol)) {
          ConstComp(irow,jcol)->MultVector(alpha, *comp_x->GetComp(jcol),
                                           1., *comp_y->GetCompNonConst(irow));
        }
      }

      for (Index jcol = irow+1; jcol < NComps_Dim(); jcol++) {
        if (ConstComp(jcol,irow)) {
          ConstComp(jcol,irow)->TransMultVector(alpha, *comp_x->GetComp(jcol),
                                                1., *comp_y->GetCompNonConst(irow));
        }
      }
    }
  }
コード例 #6
0
ファイル: IpCompoundMatrix.cpp プロジェクト: MengbinZhu/pfldp
  void CompoundMatrix::MultVectorImpl(Number alpha, const Vector &x,
                                      Number beta, Vector &y) const
  {
    if (!matrices_valid_) {
      matrices_valid_ = MatricesValid();
    }
    DBG_ASSERT(matrices_valid_);

    // The vectors are assumed to be compound Vectors as well
    const CompoundVector* comp_x = dynamic_cast<const CompoundVector*>(&x);
    CompoundVector* comp_y = dynamic_cast<CompoundVector*>(&y);

#ifndef ALLOW_NESTED
    //  A few sanity checks
    if (comp_x) {
      DBG_ASSERT(NComps_Cols()==comp_x->NComps());
    }
    else {
      DBG_ASSERT(NComps_Cols() == 1);
    }

    if (comp_y) {
      DBG_ASSERT(NComps_Rows()==comp_y->NComps());
    }
    else {
      DBG_ASSERT(NComps_Rows() == 1);
    }
#endif
    if (comp_x) {
      if (NComps_Cols()!=comp_x->NComps()) {
        comp_x = NULL;
      }
    }
    if (comp_y) {
      if (NComps_Rows()!=comp_y->NComps()) {
        comp_y = NULL;
      }
    }

    // Take care of the y part of the addition
    if ( beta!=0.0 ) {
      y.Scal(beta);
    }
    else {
      y.Set(0.0);  // In case y hasn't been initialized yet
    }

    for ( Index irow = 0; irow < NComps_Rows(); irow++ ) {
      SmartPtr<Vector> y_i;
      if (comp_y) {
        y_i = comp_y->GetCompNonConst(irow);
      }
      else {
        y_i = &y;
      }
      DBG_ASSERT(IsValid(y_i));

      for ( Index jcol = 0; jcol < NComps_Cols(); jcol++ ) {
        if ( (owner_space_->Diagonal() && irow == jcol)
             || (!owner_space_->Diagonal() && ConstComp(irow,jcol)) ) {
          SmartPtr<const Vector> x_j;
          if (comp_x) {
            x_j = comp_x->GetComp(jcol);
          }
          else if (NComps_Cols() == 1) {
            x_j = &x;
          }
          DBG_ASSERT(IsValid(x_j));

          ConstComp(irow, jcol)->MultVector(alpha, *x_j,
                                            1., *y_i);
        }
      }
    }
  }