Example #1
0
void KNDdeTorusCollocation::PhaseBOTH(KNVector& ph0, KNVector& ph1, KNVector& presol)
{
  ph0.clear();
  ph1.clear();
  for (size_t i2 = 0; i2 < nint2; i2++)
  {
    for (size_t i1 = 0; i1 < nint1; i1++)
    {
      for (size_t j2 = 0; j2 < ndeg2 + 1; j2++)
      {
        for (size_t j1 = 0; j1 < ndeg1 + 1; j1++)
        {
          size_t idx1 = idxmap(j1, j2, i1, i2);
          // matrix multiplication
          for (size_t l2 = 0; l2 < ndeg2 + 1; l2++)
          {
            for (size_t l1 = 0; l1 < ndeg1 + 1; l1++)
            {
              const size_t idx2 = idxmap(l1, l2, i1, i2);
              for (size_t p = 0; p < NDIM; p++)
              {
                ph0(p + NDIM*idx1) += presol(p + NDIM * idx2) * ID1(l1, j1) * I2(l2, j2);
                ph1(p + NDIM*idx1) += presol(p + NDIM * idx2) * I1(l1, j1) * ID2(l2, j2);
              }
            }
          }
        }
      }
    }
  }
}
Example #2
0
void Generator::convert(const SPI & spi,Polynomial & result1) const {
  SPIID ID1(spi.leftID()), ID2(spi.rightID());
  const GroebnerRule & first = retrieve(ID1);
  const GroebnerRule & second = retrieve(ID2);
  Monomial tip1(first.LHS());
  Monomial tip2(second.LHS());
  Monomial right1, left2;
  int len1 = spi.overlapLength();
  MonomialIterator w1 = tip2.begin();
  for(int k=1;k<=len1;++k) { ++w1;};
  int max1 = tip2.numberOfFactors()-1;
  // The following line is for a faster run-time.
  right1.reserve(max1-len1+1);
  for(int i=len1;i<=max1;++i,++w1) {
    right1 *= (*w1);
  }
  MonomialIterator w2 = tip1.begin();
  int max2 = tip1.numberOfFactors() - len1;
  // The following line is for a faster run-time.
  left2.reserve(max2);
  for(i=0;i< max2;++i,++w2) {
    left2 *= (*w2);
  }
  helpConvert(first.RHS(),right1,left2,second.RHS(),result1);
};
  void
  OPCollisionCorrelator::output(magnet::xml::XmlStream &XML)
  {
    for (size_t ID1(0); ID1 < Sim->N; ++ID1)
      for (size_t ID2(ID1+1); ID2 < Sim->N; ++ID2)
	if (lastColl[ID1][ID2] > 100* freetimehist.getBinWidth()) freetimehist.addVal(-1.0);

    XML << magnet::xml::tag("CollisionCorrelator");
  
    freetimehist.outputHistogram(XML, 1.0/Sim->dynamics.units().unitTime());

    XML << magnet::xml::endtag("CollisionCorrelator");
  }
Example #4
0
KNDdeTorusCollocation::KNDdeTorusCollocation(KNExprSystem& sys_, size_t ndeg1_, size_t ndeg2_, size_t nint1_, size_t nint2_) :
    sys(&sys_),
    ndim(sys_.ndim()), ntau(sys_.ntau()), npar(sys_.npar()),
    ndeg1(ndeg1_), ndeg2(ndeg2_), nint1(nint1_), nint2(nint2_),
    col1(ndeg1_),    col2(ndeg2_),
    mesh1(ndeg1_ + 1), mesh2(ndeg2_ + 1),
    lgr1(ndeg1_ + 1, ndeg1_ + 1), lgr2(ndeg2_ + 1, ndeg2_ + 1),
    dlg1(ndeg1_ + 1, ndeg1_ + 1), dlg2(ndeg2_ + 1, ndeg2_ + 1),
    I1((ndeg1_ + 1), (ndeg1_ + 1)),
    ID1((ndeg1_ + 1), (ndeg1_ + 1)),
    I2((ndeg2_ + 1), (ndeg2_ + 1)),
    ID2((ndeg2_ + 1), (ndeg2_ + 1)),
    mlg1((ndeg1_ + 1)*(ndeg1_ + 1)),
    mlg2((ndeg2_ + 1)*(ndeg2_ + 1)),
    mlgd1((ndeg1_ + 1)*(ndeg1_ + 1)),
    mlgd2((ndeg2_ + 1)*(ndeg2_ + 1)),
    ilg1((ndeg1_ + 1)*(ndeg1_ + 1) + 1),
    ilg2((ndeg2_ + 1)*(ndeg2_ + 1) + 1),
    ilgd1((ndeg1_ + 1)*(ndeg1_ + 1) + 1),
    ilgd2((ndeg2_ + 1)*(ndeg2_ + 1) + 1),
    time1(ndeg1*ndeg2*nint1*nint2), time2(ndeg1*ndeg2*nint1*nint2),
    kk((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    ee((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    rr((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    p_tau(ntau, ndeg1*ndeg2*nint1*nint2), p_dtau(ntau, ndeg1*ndeg2*nint1*nint2),
    p_xx(ndim, ntau+2*(ntau+1), ndeg1*ndeg2*nint1*nint2),
    p_fx(ndim, ndeg1*ndeg2*nint1*nint2),
    p_dfp(ndim, 1, ndeg1*ndeg2*nint1*nint2),
    p_dfx(ndim, ndim, ndeg1*ndeg2*nint1*nint2),
    p_dummy(0, 0, ndeg1*ndeg2*nint1*nint2)
{
  lobatto(mesh1);
  lobatto(mesh2);
  gauss(col1);
  gauss(col2);
  for (size_t i = 0; i < mesh1.size(); i++)
  {
    poly_coeff_lgr(lgr1(i), mesh1, i);
    poly_coeff_diff(dlg1(i), lgr1(i));
  }
  for (size_t i = 0; i < mesh2.size(); i++)
  {
    poly_coeff_lgr(lgr2(i), mesh2, i);
    poly_coeff_diff(dlg2(i), lgr2(i));
  }

  // here comes the phase condition for par(OMEGA0) and par(OMEGA1)
  // the integration in the bottom border
  // construct the diffint matrix
  for (size_t i = 0; i < ndeg1 + 1; i++)
  {
    for (size_t k = 0; k < ndeg1 + 1; k++)
    {
      mlg1.clear();
      mlgd1.clear();
      ilg1.clear();
      ilgd1.clear();
      poly_coeff_mul(mlg1,  lgr1(i), lgr1(k));
      poly_coeff_mul(mlgd1, dlg1(i), lgr1(k));
      poly_coeff_int(ilg1,  mlg1);
      poly_coeff_int(ilgd1,  mlgd1);
      I1(i, k) = (poly_eval(ilg1, 1.0)-poly_eval(ilg1, 0.0)) / nint1;
      ID1(i, k) = poly_eval(ilgd1, 1.0);
    }
  }
  for (size_t j = 0; j < ndeg2 + 1; j++)
  {
    for (size_t l = 0; l < ndeg2 + 1; l++)
    {
      mlg2.clear();
      mlgd2.clear();
      ilg2.clear();
      ilgd2.clear();
      poly_coeff_mul(mlg2,  lgr2(j), lgr2(l));
      poly_coeff_mul(mlgd2, dlg2(j), lgr2(l));
      poly_coeff_int(ilg2,  mlg2);
      poly_coeff_int(ilgd2,  mlgd2);
      I2(j, l) = (poly_eval(ilg2, 1.0) - poly_eval(ilg2, 0.0))/ nint2;
      ID2(j, l) = poly_eval(ilgd2, 1.0);
    }
  }
}
Example #5
0
void CompoundTransliteratorTest::TestGetSetAdoptTransliterator(){
    logln("Testing the getTransliterator() API of CompoundTransliterator");
    UnicodeString ID("Latin-Greek;Greek-Latin;Latin-Devanagari;Devanagari-Latin;Latin-Cyrillic;Cyrillic-Latin;Any-Hex;Hex-Any");
    UErrorCode status = U_ZERO_ERROR;
    UParseError parseError;
    CompoundTransliterator *ct1=new CompoundTransliterator(ID, parseError, status);
    if(U_FAILURE(status)){
        dataerrln("CompoundTransliterator construction failed - %s", u_errorName(status));
        return;
    }
    int32_t count=ct1->getCount();
    UnicodeString *array=split(ID, 0x003b, count);
    int i;
    for(i=0; i < count; i++){
        UnicodeString child= ct1->getTransliterator(i).getID();
        if(child != *(array+i)){
            errln("Error getTransliterator() failed: Expected->" + *(array+i) + " Got->" + child);
        }else {
            logln("OK: getTransliterator() passed: Expected->" + *(array+i) + " Got->" + child);
        }
    }
    delete []array;

    logln("Testing setTransliterator() API of CompoundTransliterator");
    UnicodeString ID2("Hex-Any;Any-Hex;Latin-Cyrillic;Cyrillic-Latin;Halfwidth-Fullwidth;Fullwidth-Halfwidth");
    array=split(ID2, 0x003b, count);
    Transliterator** transarray=new Transliterator*[count];
    for(i=0;i<count;i++){
        transarray[i]=Transliterator::createInstance(*(array+i), UTRANS_FORWARD, parseError, status);
        if(U_FAILURE(status)){
            errln("Error could not create Transliterator with ID :"+*(array+i));
        }else{
            logln("The ID for the transltierator created is " + transarray[i]->getID());
        }
        status = U_ZERO_ERROR;
    }

    /*setTransliterator and adoptTransliterator */

    ct1->setTransliterators(transarray, count);
    if(ct1->getCount() != count || ct1->getID() != ID2){
        errln((UnicodeString)"Error: setTransliterators() failed.\n\t Count:- expected->" + count + (UnicodeString)".  got->" + ct1->getCount() +
                                                   (UnicodeString)"\n\tID   :- expected->" + ID2 + (UnicodeString)".  got->" + ct1->getID());
    }
    else{
        logln("OK: setTransliterators() passed"); 
    }
    /*UnicodeString temp;
    for(i=0;i<count-1;i++){
        temp.append(ct1->getTransliterator(i).getID());
        temp.append(";");
    }
    temp.append(ct1->getTransliterator(i).getID());
    if(temp != ID2){
        errln("Error: setTransliterator() failed.  Expected->" + ID2 + "\nGot->" + temp);
    }
    else{
        logln("OK: setTransliterator() passed");
    }*/
    logln("Testing adoptTransliterator() API of CompoundTransliterator");
    UnicodeString ID3("Latin-Katakana");
    Transliterator **transarray2=(Transliterator **)uprv_malloc(sizeof(Transliterator*)*1);
    transarray2[0] = Transliterator::createInstance(ID3,UTRANS_FORWARD,parseError,status);
    if (transarray2[0] != 0) {
        ct1->adoptTransliterators(transarray2, 1);
    }
    if(ct1->getCount() != 1 || ct1->getID() != ID3){
        errln((UnicodeString)"Error: adoptTransliterators() failed.\n\t Count:- expected->1" + (UnicodeString)".  got->" + ct1->getCount() +
                                                   (UnicodeString)"\n\tID   :- expected->" + ID3 + (UnicodeString)".  got->" + ct1->getID());
    }
    else{
        logln("OK: adoptTranslterator() passed");
    }
    delete ct1;
    for(i=0;i<count;i++){
        delete transarray[i];
    }
    delete []transarray;
    delete []array;
}