Beispiel #1
0
/**
 * Description not yet available.
 * \param
 */
double dot(const dmatrix& M,const dmatrix& N)
{
  int mmin=M.indexmin();
  int mmax=M.indexmax();
  if (mmin!=N.indexmin() ||
      mmax!=N.indexmax() )
  {
    cerr << "matrix shapes unequal in"
      " double dot(const dmatrix& M,const dmatrix& N)"
      << endl;
    ad_exit(1);
  }
  if (M(mmin).indexmin()!=N(mmin).indexmin() ||
      M(mmin).indexmax()!=N(mmin).indexmax() )
  {
    cerr << "matrix shapes unequal in"
      " double dot(const dmatrix& M,const dmatrix& N)"
      << endl;
    ad_exit(1);
  }
  double ssum=0;
  for (int i=mmin;i<=mmax;i++)
  {
    int jmin=M(i).indexmin();
    int jmax=M(i).indexmax();
    for (int j=jmin;j<=jmax;j++)
    {
      ssum+=M(i,j)*N(i,j);
    }
  }
  return ssum;
}
Beispiel #2
0
/**
 * Description not yet available.
 * \param
 */
void ghk_test(const dmatrix& eps,int i)
{
  if (i<eps.indexmin())
  {
    cerr << "Index too low in function ghk -- min is "
         << eps.indexmin() << " you have " << i << endl;
    exit(21);
  }
  else  if (i>eps.indexmax())
  {
    cerr << "Index too high in function ghk -- max is "
         << eps.indexmax() << " you have " << i << endl;
    exit(21);
  }
}
Beispiel #3
0
void send_dmatrix_to_slaves(const dmatrix&  x,ivector& jmin,ivector& jmax)
{
  // *********  begin variable send block  *************
  int ii=1;
  for (int i=1; i<=ad_comm::pvm_manager-> nhost; i++)
  {
    for (int j=ad_comm::pvm_manager->slave_assignments(i).indexmin();
             j<=ad_comm::pvm_manager->slave_assignments(i).indexmax();j++)
    {
      int kmin=x.indexmin();
      int kmax=x.indexmax();
      int lmin=jmin(ii);
      int lmax=jmax(ii);
      ii++;
      dmatrix H(kmin,kmax,lmin,lmax);
      for (int k=kmin;k<=kmax;k++)
        for (int l=lmin;l<=lmax;l++)
          H(k,l)=x(k,l);

      int bufid = adpvm_master_cinitsend( PvmDataRaw );
      adpvm_pack(H);
      adpvm_master_csend(ad_comm::pvm_manager->id(i,j));
    }
  }
  // *********  end constant send block  *************
}
Beispiel #4
0
 void initialize(void)
 {
     indx.initialize();
     indx2.fill_seqadd(indexmin(), 1);
     sign = 1;
     L.initialize();
     U.initialize();
     for (int i = L.indexmin(); i <= L.indexmax(); i++)
     {
         L(i, i) = 1.0;
     }
 }
Beispiel #5
0
/**
 * LU Decomposition of a Matrix
 * \param M \f$M\f$ a square matrix to decompose
 * \return a cltudecomp object containg the
 * upper and lower parts of the decomposed matrix
 */
cltudecomp ludecomp(const dmatrix & M)
{
   int mmin = M.indexmin();
   int mmax = M.indexmax();
   cltudecomp clu(mmin, mmax);

   // get upper and lower parts of LU
   dmatrix & alpha = clu.get_L();
   dmatrix & gamma = clu.get_U();	// gamma is the transpose of beta
   // copy M into alpha and gamma
   for (int i = mmin; i <= mmax; i++)
   {
      for (int j = mmin; j <= mmax; j++)
      {
	 clu(i, j) = M(i, j);
      }
   }
   for (int j = mmin; j <= mmax; j++)
   {
      int i = 0;
      for (i = mmin + 1; i < j; i++)
      {
	 // using subvector here
	 clu(i, j) -= alpha(i) (mmin, i - 1) * gamma(j) (mmin, i - 1);
      }
      for (i = j; i <= mmax; i++)
      {
	 // using subvector here
	 if (j > 1)
	 {
	    clu(i, j) -= alpha(i) (mmin, j - 1) * gamma(j) (mmin, j - 1);
	 }
      }
      if (j != mmax)
      {
	 double z = 1.0 / gamma(j, j);
	 for (i = j + 1; i <= mmax; i++)
	 {
	    alpha(i, j) *= z;
	 }
      }
   }
   return clu;
}
Beispiel #6
0
/**
 * Description not yet available.
 * \param
 */
  int sub_unallocated(const dmatrix& m)
  {
    int iflag=0;
    int mmin=m.indexmin();
    int mmax=m.indexmax();
    if (!allocated(m))
    {
      iflag=1;
      return iflag;
    }
    for (int i=mmin;i<=mmax;i++)
    {
      if (!allocated(m(i)))
      {
        iflag=1;
        break;
      }
    }
    return iflag;
  }
Beispiel #7
0
 int indexmin()
 {
     return U.indexmin();
 }
Beispiel #8
0
 int indexmin() const
 {
     return D.indexmin();
 }
Beispiel #9
0
 int indexmin()
 {
     return D.indexmin();
 }