예제 #1
0
Obj_space_virt<SPACE>::v_insert(Phys_addr phys, V_pfn const &virt, Order size,
                                Attr page_attribs)
{
  (void)size;
  assert (size == Order(0));

  Entry *c;

  if (Optimize_local
      && SPACE::mem_space(this) == Mem_space::current_mem_space(current_cpu()))
    {
      c = cap_virt(virt);
      if (!c)
	return Obj::Insert_err_nomem;

      Capability cap;
      if (!Mem_layout::read_special_safe((Capability*)c, cap)
	  && !caps_alloc(virt))
	return Obj::Insert_err_nomem;
    }
  else
    {
      c = get_cap(virt);
      if (!c && !(c = caps_alloc(virt)))
	return Obj::Insert_err_nomem;
      Obj::set_entry(virt, c);
    }

  if (c->valid())
    {
      if (c->obj() == phys)
	{
	  if (EXPECT_FALSE(c->rights() == page_attribs))
	    return Obj::Insert_warn_exists;

	  c->add_rights(page_attribs);
	  return Obj::Insert_warn_attrib_upgrade;
	}
      else
	return Obj::Insert_err_exists;
    }

  c->set(phys, page_attribs);
  return Obj::Insert_ok;
}
예제 #2
0
static ex atan_series(const ex &arg,
                      const relational &rel,
                      int order,
                      unsigned options)
{
	GINAC_ASSERT(is_a<symbol>(rel.lhs()));
	// method:
	// Taylor series where there is no pole or cut falls back to atan_deriv.
	// There are two branch cuts, one runnig from I up the imaginary axis and
	// one running from -I down the imaginary axis.  The points I and -I are
	// poles.
	// On the branch cuts and the poles series expand
	//     (log(1+I*x)-log(1-I*x))/(2*I)
	// instead.
	const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
	if (!(I*arg_pt).info(info_flags::real))
		throw do_taylor();     // Re(x) != 0
	if ((I*arg_pt).info(info_flags::real) && abs(I*arg_pt)<_ex1)
		throw do_taylor();     // Re(x) == 0, but abs(x)<1
	// care for the poles, using the defining formula for atan()...
	if (arg_pt.is_equal(I) || arg_pt.is_equal(-I))
		return ((log(1+I*arg)-log(1-I*arg))/(2*I)).series(rel, order, options);
	if (!(options & series_options::suppress_branchcut)) {
		// method:
		// This is the branch cut: assemble the primitive series manually and
		// then add the corresponding complex step function.
		const symbol &s = ex_to<symbol>(rel.lhs());
		const ex &point = rel.rhs();
		const symbol foo;
		const ex replarg = series(atan(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
		ex Order0correction = replarg.op(0)+csgn(arg)*Pi*_ex_1_2;
		if ((I*arg_pt)<_ex0)
			Order0correction += log((I*arg_pt+_ex_1)/(I*arg_pt+_ex1))*I*_ex_1_2;
		else
			Order0correction += log((I*arg_pt+_ex1)/(I*arg_pt+_ex_1))*I*_ex1_2;
		epvector seq;
		if (order > 0) {
			seq.reserve(2);
			seq.push_back(expair(Order0correction, _ex0));
		}
		seq.push_back(expair(Order(_ex1), order));
		return series(replarg - pseries(rel, std::move(seq)), rel, order);
	}
	throw do_taylor();
}
예제 #3
0
  void Replace(uint64_t seqno, uint64_t ref, uint64_t ref2, int32_t qty,
               int64_t price) {
    auto oit = orders_.find(ref);
    if (oit == orders_.end()) {
      return;
    }

    Order &order = oit->second;
    if (order.bookid != NOBOOK) {
      OrderBook &book = books_[order.bookid];
      bool top = book.Reduce(seqno, order.buy_sell, order.price, order.qty);
      bool top2 = book.Add(seqno, order.buy_sell, price, qty);
      handler_.OnQuote(&book, top || top2);
    }

    orders_.erase(oit);
    orders_.emplace(ref2, Order(price, qty, order.buy_sell, order.bookid));
  }
예제 #4
0
void OrderManager::addOrder(vector<string> fields, int line){
	int count = fields.size();
	string custName = "", prodName = "";
	vector<string> itemList;

	if (count < 3)
		cerr << "Line " << line << ": expected 3 or more fields for an order, found " << count << endl;
	else{
		custName = fields[0];
		prodName = fields[1];

		for (int i = 2; i < count; i++)
			itemList.push_back(fields[i]);
	}

	if (!custName.empty())
		orders.push_back(Order(custName, prodName, itemList));
}
예제 #5
0
void EInventory::getFreeCell(const char *szItemName, int &x, int &y)
{
   int nFreeCellPos;

   // On regarde si on n'a pas déjà cet objet dans l'inventaire
   // et si il n'est pas en plusieurs morceaux
   EInventoryItem *lpItem = NULL;
   lpItem = getItemFromInventory(szItemName);
   
   if (lpItem != NULL)
   {
      // Oui, on a bien cet objet et il est incomplet
      if (lpItem->_nNbPartCurrent < lpItem->_nNbPartNeeded)
      {
         // On le rend visible quitte à scroller l'inventaire
         // et on renvoie ses coordonnées
         setItemVisible(szItemName);
         nFreeCellPos = getItemCell(szItemName);
         x = _InventoryCells[nFreeCellPos]->getPosX() + INVENTORY_CELLWIDTH/2;
         y = _InventoryCells[nFreeCellPos]->getPosY() + INVENTORY_CELLHEIGHT/2;
         return;
      }
   }
   
   // Combien y a t'il d'objets dans l'inventaire
   int nNbInv = getCount(_szUniverseName);

   // Si il y en a moins que de cellule, c'est facile
   if (nNbInv < INVENTORY_CELLMAX) {
      nFreeCellPos = nNbInv-_nFirstCell;
   }
   // Si l'inventaire déborde, il faut décaller les items visibles pour libérer une cellule
   else {
      // On se positionne sur la fin de la liste d'objet, en laissant une case vide
      _nFirstCell = nNbInv - INVENTORY_CELLMAX + 1;
      Order(true);
      nFreeCellPos = INVENTORY_CELLMAX - 1;
   }
   
   x = _InventoryCells[nFreeCellPos]->getPosX() + INVENTORY_CELLWIDTH/2;
   y = _InventoryCells[nFreeCellPos]->getPosY() + INVENTORY_CELLHEIGHT/2;
}
예제 #6
0
void EInventory::setItemVisible(const char *szItemName)
{
   // L'item est déjà visible
   if (getItemCell(szItemName) >= 0)
      return;

   // Compte la position de l'item dans la liste globale
   bool bFind = false;
   int nPosInList = 0;
   EInventoryItem *o = NULL;
   bool bGotNext = EInventoryItem::g_ListInventoryItem.getHead (o);
   if (bGotNext) {
      while (bGotNext) {
         if (strcmp(o->_szItemName, szItemName) == 0) {
            bFind = true;
            break;
         }
         if (strcmp(o->_szUniverseName, _szUniverseName) == 0) {
            nPosInList++;
         }
         bGotNext = EInventoryItem::g_ListInventoryItem.getNext (o);
      }
   }

   // Pas de raison qu'on demande à rendre visible un item qui n'est pas dans l'inventaire
   KAssert(bFind == true);
   if (!bFind) return;

   // On scrolle jusqu'à que cet item soit dans les items visibles
   // Scroll vers les éléments de droite
   if (nPosInList > INVENTORY_CELLMAX)
   {
      _nFirstCell = (nPosInList - INVENTORY_CELLMAX) + 1;
   }
   else
   if (nPosInList < INVENTORY_CELLMAX)
   {
      _nFirstCell = nPosInList;
   }
   Order(true);
}
예제 #7
0
void EInventory::DropItem(const char *szItemName)
{
   bool bFind = false;
   EInventoryItem *o;
   bool bGotNext = EInventoryItem::g_ListInventoryItem.getHead (o);
   if (bGotNext) {
      while (bGotNext) {
         if (strcmp(o->_szItemName, szItemName) == 0 && strcmp(o->_szUniverseName,_szUniverseName) == 0) {
            EInventoryItem::g_ListInventoryItem.remove(o);
            bFind = true;
            delete o;
            break;
         }
         bGotNext = EInventoryItem::g_ListInventoryItem.getNext (o);
      }
   }
   if (!bFind) {
      K_LOG("Not found DropItem(%s) current _szUniverseName=%s",szItemName,_szUniverseName);
   }
   Order();
}
예제 #8
0
파일: kd.c 프로젝트: rokroskar/sph_resample
void kdOutDensity(KD kd,char *pszFile)
{	
	FILE *fp;
	int i;

	if (pszFile) {
		fp = fopen(pszFile,"w");
		assert(fp != NULL);
		}
	else {
		fp = stdout;
		}
	/*
	 ** Make sure the particles are ordered before outputing the densities.
	 */
	Order(kd);
	fprintf(fp,"%d\n",kd->nParticles);
	for (i=0;i<kd->nParticles;++i) {
		fprintf(fp,"%.10g\n",kd->pInit[i].fDensity);
		}
	fclose(fp);
	}
예제 #9
0
파일: Utils.cpp 프로젝트: dlidstrom/ntest
bool CHeightInfo::operator!=(const CHeightInfo& b) const {
   return Order()!=b.Order();
}
예제 #10
0
Order changeTrendAgent::bestRateOrder()
{
    QMap<double, Order> bestOrders;
    for(int i = 2; i <=  STOKS_NUMBER; ++i)
    {
        double diffForSell = m_stocksInfo[i].lowestPrice(m_lowestBuyTime) - m_stocksInfo[i].greatestPrice(m_greatestBuyTime);
        if(m_store.contains(i) && m_stocksInfo[i].lastPrice() && diffForSell > 0.001 &&
                ( (m_stocksInfo[i].getBestSellPrice()*1.005 <=  m_store.getMoney() && m_stocksInfo[i].getBestSellPrice()) ||
                  (m_stocksInfo[i].lastPrice() <= m_store.getMoney()) ) )
        {
            bestOrders.insertMulti(diffForSell, Order(Order::SELL, i, 0, 0));
        }
        double diffForBuy =  m_stocksInfo[i].lowestPrice(m_lowestSellTime) - m_stocksInfo[i].greatestPrice(m_greatestSellTime);
        if(  m_stocksInfo[i].lastPrice() && diffForBuy > 0.001 &&
              ( (m_stocksInfo[i].getBestBuyPrice()*1.025 <=  m_store.getMoney() && m_stocksInfo[i].getBestBuyPrice()) ||
                (m_stocksInfo[i].lastPrice() <= m_store.getMoney()) ))
        {
            bestOrders.insertMulti(diffForBuy, Order(Order::BUY, i, 0, 0));
        }
    }

    if(bestOrders.empty())
        return Order();

    QMutableMapIterator<double, Order> i(bestOrders);
    while (i.hasNext()) {
        i.next();
        if((1.0*qrand())/RAND_MAX < m_bestChooseChance)
        {
            Order order = i.value();
            qint32 price;
            if(m_stocksInfo[order.getStockId()].getBestSellPrice() && m_stocksInfo[order.getStockId()].getBestBuyPrice())
            {
                if(order.getTransactionType() == Order::SELL)
                {
                    price = m_stocksInfo[order.getStockId()].getBestSellPrice()*(1.005 - (0.03*qrand())/RAND_MAX);
                }
                else
                {
                    price = m_stocksInfo[order.getStockId()].getBestBuyPrice()*(0.095 + (0.03*qrand())/RAND_MAX);
                }
            }
            else price = m_stocksInfo[order.getStockId()].lastPrice();

            if(!price)
                continue;
            order.setPrice(price);

            qint32 maxAmount = m_store.getMoney()/price;
            double rand = (1.0*qrand())/RAND_MAX;
            qint32 amount = 3 + qrand()%13;
            if(rand > 0.45 && rand < 0.88)
                amount = 16 + qrand()%35;
            else if(rand >= 0.88)
                amount = 51 + qrand()%75;
            if(maxAmount)
                amount %= maxAmount;
            order.setAmount(amount);
            if(order.getAmount()&& order.getPrice())
                return order;
        }
    }

    Order order = i.value();
    qint32 price;
    if(m_stocksInfo[order.getStockId()].getBestSellPrice() && m_stocksInfo[order.getStockId()].getBestBuyPrice())
    {
        if(order.getTransactionType() == Order::SELL)
        {
            price = m_stocksInfo[order.getStockId()].getBestSellPrice()*(1.005 - (0.03*qrand())/RAND_MAX);
        }
        else
        {
            price = m_stocksInfo[order.getStockId()].getBestBuyPrice()*(0.095 + (0.03*qrand())/RAND_MAX);
        }
    }
    else price = m_stocksInfo[order.getStockId()].lastPrice();
    if(!price)
        return Order();
    order.setPrice(price);

    qint32 maxAmount = m_store.getMoney()/price;
    double rand = (1.0*qrand())/RAND_MAX;
    qint32 amount = 3 + qrand()%13;
    if(rand > 0.45 && rand < 0.88)
        amount = 16 + qrand()%35;
    else if(rand >= 0.88)
        amount = 51 + qrand()%75;
    if(maxAmount)
        amount %= maxAmount;
    order.setAmount(amount);
    if(order.getAmount()&& order.getPrice())
        return order;
    else return Order();
}
예제 #11
0
파일: inifcns.cpp 프로젝트: feelpp/feelpp
static ex Order_imag_part(const ex & x)
{
	if(x.info(info_flags::real))
		return 0;
	return Order(x).hold();
}
예제 #12
0
void EInventory::ScrollLeft()
{
   if (_nFirstCell > 0)
      _nFirstCell--;
   Order();
}
예제 #13
0
void EInventory::ScrollRight()
{
   _nFirstCell++;
   Order();
}
예제 #14
0
파일: inifcns.cpp 프로젝트: feelpp/feelpp
static ex Li2_series(const ex &x, const relational &rel, int order, unsigned options)
{
	const ex x_pt = x.subs(rel, subs_options::no_pattern);
	if (x_pt.info(info_flags::numeric)) {
		// First special case: x==0 (derivatives have poles)
		if (x_pt.is_zero()) {
			// method:
			// The problem is that in d/dx Li2(x==0) == -log(1-x)/x we cannot 
			// simply substitute x==0.  The limit, however, exists: it is 1.
			// We also know all higher derivatives' limits:
			// (d/dx)^n Li2(x) == n!/n^2.
			// So the primitive series expansion is
			// Li2(x==0) == x + x^2/4 + x^3/9 + ...
			// and so on.
			// We first construct such a primitive series expansion manually in
			// a dummy symbol s and then insert the argument's series expansion
			// for s.  Reexpanding the resulting series returns the desired
			// result.
			const symbol s;
			ex ser;
			// manually construct the primitive expansion
			for (int i=1; i<order; ++i)
				ser += pow(s,i) / pow(numeric(i), *_num2_p);
			// substitute the argument's series expansion
			ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
			// maybe that was terminating, so add a proper order term
			epvector nseq { expair(Order(_ex1), order) };
			ser += pseries(rel, std::move(nseq));
			// reexpanding it will collapse the series again
			return ser.series(rel, order);
			// NB: Of course, this still does not allow us to compute anything
			// like sin(Li2(x)).series(x==0,2), since then this code here is
			// not reached and the derivative of sin(Li2(x)) doesn't allow the
			// substitution x==0.  Probably limits *are* needed for the general
			// cases.  In case L'Hospital's rule is implemented for limits and
			// basic::series() takes care of this, this whole block is probably
			// obsolete!
		}
		// second special case: x==1 (branch point)
		if (x_pt.is_equal(_ex1)) {
			// method:
			// construct series manually in a dummy symbol s
			const symbol s;
			ex ser = zeta(_ex2);
			// manually construct the primitive expansion
			for (int i=1; i<order; ++i)
				ser += pow(1-s,i) * (numeric(1,i)*(I*Pi+log(s-1)) - numeric(1,i*i));
			// substitute the argument's series expansion
			ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
			// maybe that was terminating, so add a proper order term
			epvector nseq { expair(Order(_ex1), order) };
			ser += pseries(rel, std::move(nseq));
			// reexpanding it will collapse the series again
			return ser.series(rel, order);
		}
		// third special case: x real, >=1 (branch cut)
		if (!(options & series_options::suppress_branchcut) &&
			ex_to<numeric>(x_pt).is_real() && ex_to<numeric>(x_pt)>1) {
			// method:
			// This is the branch cut: assemble the primitive series manually
			// and then add the corresponding complex step function.
			const symbol &s = ex_to<symbol>(rel.lhs());
			const ex point = rel.rhs();
			const symbol foo;
			epvector seq;
			// zeroth order term:
			seq.push_back(expair(Li2(x_pt), _ex0));
			// compute the intermediate terms:
			ex replarg = series(Li2(x), s==foo, order);
			for (size_t i=1; i<replarg.nops()-1; ++i)
				seq.push_back(expair((replarg.op(i)/power(s-foo,i)).series(foo==point,1,options).op(0).subs(foo==s, subs_options::no_pattern),i));
			// append an order term:
			seq.push_back(expair(Order(_ex1), replarg.nops()-1));
			return pseries(rel, std::move(seq));
		}
	}
	// all other cases should be safe, by now:
	throw do_taylor();  // caught by function::series()
}
예제 #15
0
파일: ORDER.CPP 프로젝트: pyal/eos_cpp
int Order(int fst,int sec) {return Order((void*)&fst,(void*)&sec);};
예제 #16
0
FaceFaceConstraint::FaceFaceConstraint(const InputParameters & parameters) :
    Constraint(parameters),
    CoupleableMooseVariableDependencyIntermediateInterface(this, true),
    _fe_problem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
    _dim(_mesh.dimension()),

    _q_point(_assembly.qPoints()),
    _qrule(_assembly.qRule()),
    _JxW(_assembly.JxW()),
    _coord(_assembly.coordTransformation()),
    _current_elem(_assembly.elem()),

    _master_var(_subproblem.getVariable(_tid, getParam<VariableName>("master_variable"))),
    _slave_var(isParamValid("slave_variable") ? _subproblem.getVariable(_tid, getParam<VariableName>("slave_variable")) : _subproblem.getVariable(_tid, getParam<VariableName>("master_variable"))),
    _lambda(_var.sln()),

    _iface(*_mesh.getMortarInterfaceByName(getParam<std::string>("interface"))),
    _master_penetration_locator(getMortarPenetrationLocator(_iface._master, _iface._slave, Moose::Master, Order(_master_var.order()))),
    _slave_penetration_locator(getMortarPenetrationLocator(_iface._master, _iface._slave, Moose::Slave, Order(_slave_var.order()))),

    _test_master(_master_var.phi()),
    _grad_test_master(_master_var.gradPhi()),
    _phi_master(_master_var.phi()),

    _test_slave(_slave_var.phi()),
    _grad_test_slave(_slave_var.gradPhi()),
    _phi_slave(_slave_var.phi())
{
}
예제 #17
0
void MainWindow::on_listWidget_clicked(QModelIndex index)
{
    Order(index);
}
예제 #18
0
파일: Utils.cpp 프로젝트: dlidstrom/ntest
bool CHeightInfo::operator>(const CHeightInfo& b) const {
   return Order()>b.Order();
}
예제 #19
0
 //--------------------------------------------- GET ORDER --------------------------------------------------
 Order UnitImpl::getOrder() const
 {
   return Order(self->order);
 }
예제 #20
0
 MarketTest() {
     m = new Market();
     Order().resetIdCount();
 }
예제 #21
0
파일: fox.c 프로젝트: BoyzInB/Assignment-1
int main(int argc, char* argv[]) {
    int              p;
    int              my_rank;
    GRID_INFO_T      grid;
    LOCAL_MATRIX_T*  local_A;
    LOCAL_MATRIX_T*  local_B;
    LOCAL_MATRIX_T*  local_C;
    int              n;
    int              n_bar;
    double starttime, endtime;
    
    srand(time(NULL));
    starttime = MPI_Wtime();
    
    void Setup_grid(GRID_INFO_T*  grid);
    void Fox(int n, GRID_INFO_T* grid, LOCAL_MATRIX_T* local_A,
             LOCAL_MATRIX_T* local_B, LOCAL_MATRIX_T* local_C);
    
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
    
    
    /* Need to change the below. Want random matrices.*/
    Setup_grid(&grid);
    if (my_rank == 0) {
        //printf("What's the order of the matrices?\n");
        n = atoi(argv[1]);
    }
    
    MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);
    n_bar = n/grid.q;
    
    local_A = Local_matrix_allocate(n_bar);
    Order(local_A) = n_bar;
    Read_matrix("Generating and distributing A...", local_A, &grid, n);
    Print_matrix("Matrix A:", local_A, &grid, n);
    
    local_B = Local_matrix_allocate(n_bar);
    Order(local_B) = n_bar;
    Read_matrix("Generating and distributing B...", local_B, &grid, n);
    Print_matrix("Matrix B:", local_B, &grid, n);
    
    
    Build_matrix_type(local_A);
    temp_mat = Local_matrix_allocate(n_bar);
    
    local_C = Local_matrix_allocate(n_bar);
    Order(local_C) = n_bar;
    Fox(n, &grid, local_A, local_B, local_C);
    
    endtime   = MPI_Wtime();
    
    Print_matrix("The product is", local_C, &grid, n);
    
    if(my_rank == 0)
        printf("The time it took was %f\n", endtime - starttime);
    
    
    Free_local_matrix(&local_A);
    Free_local_matrix(&local_B);
    Free_local_matrix(&local_C);
    
    MPI_Type_free(&local_matrix_mpi_t);
    
    MPI_Finalize();
    return 0;
}  /* main */
예제 #22
0
파일: inifcns.cpp 프로젝트: feelpp/feelpp
static ex Order_real_part(const ex & x)
{
	return Order(x).hold();
}
예제 #23
0
static ex log_series(const ex &arg,
                     const relational &rel,
                     int order,
                     unsigned options)
{
	GINAC_ASSERT(is_a<symbol>(rel.lhs()));
	ex arg_pt;
	bool must_expand_arg = false;
	// maybe substitution of rel into arg fails because of a pole
	try {
		arg_pt = arg.subs(rel, subs_options::no_pattern);
	} catch (pole_error) {
		must_expand_arg = true;
	}
	// or we are at the branch point anyways
	if (arg_pt.is_zero())
		must_expand_arg = true;
	
	if (arg.diff(ex_to<symbol>(rel.lhs())).is_zero()) {
		throw do_taylor();
	}

	if (must_expand_arg) {
		// method:
		// This is the branch point: Series expand the argument first, then
		// trivially factorize it to isolate that part which has constant
		// leading coefficient in this fashion:
		//   x^n + x^(n+1) +...+ Order(x^(n+m))  ->  x^n * (1 + x +...+ Order(x^m)).
		// Return a plain n*log(x) for the x^n part and series expand the
		// other part.  Add them together and reexpand again in order to have
		// one unnested pseries object.  All this also works for negative n.
		pseries argser;          // series expansion of log's argument
		unsigned extra_ord = 0;  // extra expansion order
		do {
			// oops, the argument expanded to a pure Order(x^something)...
			argser = ex_to<pseries>(arg.series(rel, order+extra_ord, options));
			++extra_ord;
		} while (!argser.is_terminating() && argser.nops()==1);

		const symbol &s = ex_to<symbol>(rel.lhs());
		const ex &point = rel.rhs();
		const int n = argser.ldegree(s);
		epvector seq;
		// construct what we carelessly called the n*log(x) term above
		const ex coeff = argser.coeff(s, n);
		// expand the log, but only if coeff is real and > 0, since otherwise
		// it would make the branch cut run into the wrong direction
		if (coeff.info(info_flags::positive))
			seq.push_back(expair(n*log(s-point)+log(coeff), _ex0));
		else
			seq.push_back(expair(log(coeff*pow(s-point, n)), _ex0));

		if (!argser.is_terminating() || argser.nops()!=1) {
			// in this case n more (or less) terms are needed
			// (sadly, to generate them, we have to start from the beginning)
			if (n == 0 && coeff == 1) {
				ex rest = pseries(rel, epvector{expair(-1, _ex0), expair(Order(_ex1), order)}).add_series(argser);
				ex acc = dynallocate<pseries>(rel, epvector());
				for (int i = order-1; i>0; --i) {
					epvector cterm { expair(i%2 ? _ex1/i : _ex_1/i, _ex0) };
					acc = pseries(rel, std::move(cterm)).add_series(ex_to<pseries>(acc));
					acc = (ex_to<pseries>(rest)).mul_series(ex_to<pseries>(acc));
				}
				return acc;
			}
			const ex newarg = ex_to<pseries>((arg/coeff).series(rel, order+n, options)).shift_exponents(-n).convert_to_poly(true);
			return pseries(rel, std::move(seq)).add_series(ex_to<pseries>(log(newarg).series(rel, order, options)));
		} else  // it was a monomial
			return pseries(rel, std::move(seq));
	}
	if (!(options & series_options::suppress_branchcut) &&
	     arg_pt.info(info_flags::negative)) {
		// method:
		// This is the branch cut: assemble the primitive series manually and
		// then add the corresponding complex step function.
		const symbol &s = ex_to<symbol>(rel.lhs());
		const ex &point = rel.rhs();
		const symbol foo;
		const ex replarg = series(log(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
		epvector seq;
		if (order > 0) {
			seq.reserve(2);
			seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0));
		}
		seq.push_back(expair(Order(_ex1), order));
		return series(replarg - I*Pi + pseries(rel, std::move(seq)), rel, order);
	}
	throw do_taylor();  // caught by function::series()
}
예제 #24
0
 Order operator () (Order s) const
 {
   return s >= Order(Obj::Caps_per_page_ld2)
          ? Order(Obj::Caps_per_page_ld2)
          : Order(0);
 }
예제 #25
0
 //--------------------------------------------- GET SECONDARY ORDER ID -------------------------------------
 Order UnitImpl::getSecondaryOrder() const
 {
   return Order(self->secondaryOrder);
 }
int ON_BezierCage::Degree(int dir) const
{
  int order = Order(dir);
  return (order>=2) ? order-1 : 0;
}
예제 #27
0
bool PhysicalSort::Open(const PartitionOffset &part_off) {
  /**
   * TODO(anyone): multi threads can be used to pipeline!!!
   */
  swap_num_ = 0;
  temp_cur_ = 0;
  /**
   *  first we can store all the data which will be bufferred
   * 1, buffer is the first phase. multi-threads will be applyed to the data
   *    in the buffer.
   * 2, sort the data in the buffer, we choose quicksort to sort the records
   *    by specifying the column to be sorted
   * 3, whether to register the buffer into the blockmanager.
   * */
  BlockStreamBase *block_for_asking;

  state_.partition_offset_ = part_off;

  state_.child_->Open(state_.partition_offset_);

  if (sema_open_.try_wait()) {
    block_buffer_iterator_ = block_buffer_.createIterator();
    open_finished_ = true;
  } else {
    while (!open_finished_) {
      usleep(1);
    }
  }

  if (CreateBlockStream(block_for_asking) == false) {
    LOG(ERROR) << "error in the create block stream!!!" << endl;
    return 0;
  }
  /**
   *  phase 1: store the data in the buffer!
   *          by using multi-threads to speed up
   */
  unsigned block_offset = 0;
  unsigned tuple_count_sum = 0;
  BlockStreamBase::BlockStreamTraverseIterator *iterator_for_scan;
  while (state_.child_->Next(block_for_asking)) {
    tuple_count_sum += block_for_asking->getTuplesInBlock();
    block_buffer_.atomicAppendNewBlock(block_for_asking);
    iterator_for_scan = block_buffer_.getBlock(block_offset)->createIterator();
    void *tuple_ptr = 0;
    while ((tuple_ptr = iterator_for_scan->nextTuple()) != 0) {
      tuple_vector_.push_back(tuple_ptr);
    }
    block_offset++;
    if (CreateBlockStream(block_for_asking) == false) {
      LOG(ERROR) << "error in the create block stream!!!" << endl;
      return 0;
    }
  }

  /**
   *  phase 2: sort the data in the buffer!
   *          by using multi-threads to speed up?
   * TODO(anyone): whether to store the sorted data into the blockmanager.
   */
  //    cout<<"check the memory usage!!!"<<endl;
  unsigned long long int time = curtick();
  //    order(state_.orderbyKey_,tuple_count_sum);
  Order();

  // cout<<"the tuple_count is: "<<tuple_count_sum<<"Total time:
  // "<<getSecond(time)<<" seconds, the swap num is: "<<swap_num<<endl;
  return true;
}
예제 #28
0
int CSuggestor::Suggest(const CFSWString &szWord, bool bStartSentence){
	m_TimeStart=CFSTime::Now();
	m_Items.Cleanup();

	m_Cap.SetCap(szWord);
	if (bStartSentence && m_Cap.GetCapMode()==CFSStrCap<CFSWString>::CAP_LOWER) {
		m_Cap.SetCapMode(CFSStrCap<CFSWString>::CAP_INITIAL);
	}

	CFSWString szWordHigh=szWord.ToUpper();
	INTPTR ipWordLength=szWordHigh.GetLength();
	CFSWString szTemp;
	INTPTR i, j;
	long lLevel=100;
	SetLevel(lLevel);

	// Case problems & change list
	i=SpellWord(szWordHigh, szTemp, &lLevel);
	if ((i==SPL_NOERROR || i==SPL_CHANGEONCE) && !szTemp.IsEmpty()){
		SetLevel(GetLevelGroup(lLevel));
		m_Items.AddItem(CSuggestorItem(szTemp, lLevel));
	}
	else SetLevel(5);
	
	// Abbrevations
	// !!! Unimplemented

	// Quotes
/*	if (ipWordLength>=2 && 
		(szAllQuot.Find(szWordHigh[0])>=0 || szAllQuot.Find(szWordHigh[ipWordLength-1])>=0))
	{
		szTemp=szWordHigh;
		int iPos;
		if (szAllQuot.Find(szTemp[0])>=0){
			if (szQuotLeft.Find(szTemp[0])>=0) { }
			else if ((iPos=szQuotRight.Find(szTemp[0]))>=0) { szTemp[0]=szQuotLeft[iPos]; }
			else if (szDQuotLeft.Find(szTemp[0])>=0) { }
			else if ((iPos=szDQuotRight.Find(szTemp[0]))>=0) { szTemp[0]=szDQuotLeft[iPos]; }

			if (szAllQuot.Find(szTemp[ipWordLength-1])>=0) { szTemp[ipWordLength-1]=(szQuotRight+szDQuotRight)[(szQuotLeft+szDQuotLeft).Find(szTemp[0])];
		}
		else{
			if (szQuotRight.Find(szTemp[ipWordLength-1])>=0) { }
			else if ((iPos=szQuotLeft.Find(szTemp[ipWordLength-1]))>=0) { szTemp[ipWordLength-1]=szQuotRight[iPos]; }
			else if (szDQuotRight.Find(szTemp[ipWordLength-1])>=0) { }
			else if ((iPos=szDQuotLeft.Find(szTemp[ipWordLength-1]))>=0) { szTemp[ipWordLength-1]=szDQuotRight[iPos]; }
		}
		CheckAndAdd(szTemp);
	}*/

	// Add space
	for (i=1; i<ipWordLength-1; i++){
		static CFSWString szPunktuation=FSWSTR(".:,;!?");
		if (szPunktuation.Find(szWord[i])>=0){
			long lLevel1, lLevel2;
			CFSWString szTemp1, szTemp2;
			if (SpellWord(szWord.Left(i+1), szTemp1, &lLevel1)==SPL_NOERROR &&
				SpellWord(szWord.Mid(i+1), szTemp2, &lLevel2)==SPL_NOERROR)
			{
				m_Items.AddItem(CSuggestorItem(szWord.Left(i+1)+L' '+szWord.Mid(i+1), FSMAX(lLevel1, lLevel2)));
			}
		}
	}

	// Delete following blocks: le[nnu][nnu]jaam
	for (i=2; i<=3; i++){
		for (j=0; j<ipWordLength-i-i; j++){
			if (memcmp((const FSWCHAR *)szWordHigh+j, (const FSWCHAR *)szWordHigh+j+i, i*sizeof(FSWCHAR))==0){
				szTemp=szWordHigh.Left(j)+szWordHigh.Mid(j+i);
				CheckAndAdd(szTemp);
			}
		}
	}

	// Change following letters: abb -> aab & aab -> abb
	for (i=1; i<ipWordLength-1; i++){
		if (szWordHigh[i]==szWordHigh[i+1]){
			szTemp=szWordHigh;
			szTemp[i]=szTemp[i-1];
			if (FSIsLetterEst(szTemp[i])) CheckAndAdd(szTemp);
		}
		else if (szWordHigh[i]==szWordHigh[i-1]){
			szTemp=szWordHigh;
			szTemp[i]=szTemp[i+1];
			if (FSIsLetterEst(szTemp[i])) CheckAndAdd(szTemp);
		}
	}

	// Exchange letters: van[na]ema -> van[an]ema
	szTemp=szWordHigh;
	for (i=1; i<ipWordLength; i++){
		if (szTemp[i]!=szTemp[i-1]){
			FSWCHAR ch=szTemp[i];
			szTemp[i]=szTemp[i-1];
			szTemp[i-1]=ch;
			CheckAndAdd(szTemp);
			szTemp[i-1]=szTemp[i];
			szTemp[i]=ch;
		}
	}

	// Change blocks
	for (i=0; i<ipWordLength; i++){
		for (j=0; j<(INTPTR)(sizeof(ChangeStrings)/sizeof(__CChangeStrings)); j++){
			if (szWordHigh.ContainsAt(i, ChangeStrings[j].m_lpszFrom)){
				szTemp=szWordHigh.Left(i)+ChangeStrings[j].m_lpszTo+szWordHigh.Mid(i+FSStrLen(ChangeStrings[j].m_lpszFrom));
				CheckAndAdd(szTemp);
			}
		}
	}

	// Change end blocks
	for (i=0; i<(INTPTR)(sizeof(ChangeStringsEnd)/sizeof(__CChangeStrings)); i++){
		if (szWordHigh.EndsWith(ChangeStringsEnd[i].m_lpszFrom)){
			szTemp=szWordHigh.Left(ipWordLength-FSStrLen(ChangeStringsEnd[i].m_lpszFrom))+ChangeStringsEnd[i].m_lpszTo;
			CheckAndAdd(szTemp);
		}
	}

	// Po~o~sas
	MultiReplace(szWordHigh, 0);

	// gi/ki: Kylli[gi]le -> Kyllile[gi]
	for (i=3; i<=6; i++){
		if (i>ipWordLength) break;
		if (memcmp((const FSWCHAR *)szWordHigh+ipWordLength-i, FSWSTR("GI"), 2*sizeof(FSWCHAR))==0){
			szTemp=szWordHigh.Left(ipWordLength-i)+szWordHigh.Mid(ipWordLength-i+2)+FSWSTR("GI");
			CheckAndAdd(szTemp);
			szTemp=szWordHigh.Left(ipWordLength-i)+szWordHigh.Mid(ipWordLength-i+2)+FSWSTR("KI");
			CheckAndAdd(szTemp);
		}
	}

	// Delete letters: van[n]aema -> vanaema
	szTemp=szWordHigh.Mid(1);
	CheckAndAdd(szTemp);
	for (i=0; i<ipWordLength-1; i++){
		if (szTemp[i]!=szWordHigh[i]){
			szTemp[i]=szWordHigh[i];
			CheckAndAdd(szTemp);
		}
	}

	// Change letters from list
	for (i=0; i<ipWordLength; i++){
		const FSWCHAR *lpszTo=__SuggestChangeLetters(szWordHigh[i]);
		if (!lpszTo) continue;
		szTemp=szWordHigh;
		for (; lpszTo[0]; lpszTo++){
			szTemp[i]=lpszTo[0];
			CheckAndAdd(szTemp);
		}
	}
	
	// Insert letters to word body
	for (i=1; i<ipWordLength; i++){
		szTemp=szWordHigh.Left(i)+FSWSTR(' ')+szWordHigh.Mid(i);
		for (j=0; szInsertLetters[j]; j++){
			szTemp[i]=szInsertLetters[j];
			CheckAndAdd(szTemp);
		}
	}

	// Insert letters to the beginning
	szTemp=CFSWString(FSWSTR(" "))+szWordHigh;
	for (i=0; szInsertLettersBeg[i]; i++){
		if (szTemp[1]==szInsertLettersBeg[i]) continue;
		szTemp[0]=szInsertLettersBeg[i];
		CheckAndAdd(szTemp);
	}

	// Try apostrophe for names
	if (szWord[0]!=szWordHigh[0] && szWordHigh.Find('\'')<0){
		for (i=0; i<5; i++){
			if (i>=ipWordLength) break;
			szTemp=szWordHigh.Left(ipWordLength-i)+L'\''+szWordHigh.Mid(ipWordLength-i);
			CheckAndAdd(szTemp);
		}
	}

	Order();
	RemoveImmoderate();
	RemoveDuplicates();
	return 0;
}
예제 #29
0
/**
 * Unpacks a order from savegames with version 4 and lower
 * @param packed packed order
 * @return unpacked order
 */
static Order UnpackVersion4Order(uint16 packed)
{
	return Order(GB(packed, 8, 8) << 16 | GB(packed, 4, 4) << 8 | GB(packed, 0, 4));
}
예제 #30
0
파일: inifcns.cpp 프로젝트: feelpp/feelpp
static ex Order_expl_derivative(const ex & arg, const symbol & s)
{
	return Order(arg.diff(s));
}