Exemple #1
0
void main(){
	int count = 0;
	double Numbers[30],Answer;
	char symbols[30];
	count = Input(Numbers,symbols);
	Print(Numbers, symbols, count);
	Answer = Calculate(Numbers, symbols, &count);

	printf(" = %.1f\n", Answer);
}
Exemple #2
0
void LinearRegression::addXY(const double& x, const double& y)
{
	n++;
	sumX += x;
	sumY += y;
	sumXsquared += x * x;
	sumYsquared += y * y;
	sumXY += x * y;
	Calculate();
}
Exemple #3
0
//---------------------------------------------------------------------------
bool mmImages::mmCalcMethod::Execute(void)
{
	SendLogMessage(mmLog::debug,mmString(L"Start Execute"));

	bool v_bResult = Calculate();

	SendLogMessage(mmLog::debug,mmString(L"End Execute"));

	return v_bResult;
}
Exemple #4
0
void main(int argc, char **argv)
{
	setlocale(0, "Russian");
	double s1 = Calculate(mt1, len(mt1));
	double s2 = Calculate(mt2, len(mt2));
	double s3 = Calculate(mt3, len(mt3));

	double max_value = max(max(s1, s2), s3);

	printf("Максимальное значение %0.1lf содержится в:\n", s1);
	if (max_value == s1)
		printf(" mt1", s1);
	if (max_value == s2)
		printf(" mt2", s1);
	if (max_value == s3)
		printf(" mt3", s1);

	printf("\n");
}
Exemple #5
0
int FGTurboProp::InitRunning(void)
{
  FDMExec->SuspendIntegration();
  Cutoff=false;
  Running=true;  
  N2=16.0;
  Calculate();
  FDMExec->ResumeIntegration();
  return phase==tpRun;
}
void Decision::run()
{
    while(ros::ok())
    {
        Calculate();
        ros::spinOnce();
        loop_rate.sleep();
    }

}
bool FGAtmosphere::Run(bool Holding)
{
  if (FGModel::Run(Holding)) return true;
  if (Holding) return false;

  Calculate(in.altitudeASL);

  Debug(2);
  return false;
}
Exemple #8
0
// ***************************************************************************
// Function:    CommandWhile
// Description: Our '/while' command
// Usage:       /while (<conditions>)
// ***************************************************************************
VOID CommandWhile(PSPAWNINFO pChar, PCHAR szLine)
{
    CHAR szCond[MAX_STRING] = {0};
    if (!gMacroBlock) {
        MacroError("Can only use /while during a macro.");
        return;
    }
   bRunNextCommand = TRUE;
   if (szLine[0]!='(')
   {
       FatalError("Failed to parse /while command.  Expected () around conditions.");
      SyntaxError("Usage: /while (<conditions>)");
        return;
   }
   PCHAR pEnd=&szLine[1];
   DWORD nParens=1;
   while(1)
   {
      if (*pEnd=='(')
         nParens++;
      else if (*pEnd==')')
      {
         nParens--;
         if (nParens==0)
         {
            pEnd++;
            if (*pEnd!=0)
            {
               FatalError("Failed to parse /while command. Parameters after conditions.");
               SyntaxError("Usage: /while (<conditions>)");
               return;
            }
            break;
         }
      }
      else if (*pEnd==0)
      {
         FatalError("Failed to parse /while command.  Could not find conditions to evaluate.");
         SyntaxError("Usage: /while (<conditions>)");
         return;
      }
      ++pEnd;
   } // while

   strcpy(szCond,szLine);

   DOUBLE Result=0;
   if (!Calculate(szCond,Result))
   {
      FatalError("Failed to parse /while condition '%s', non-numeric encountered",szCond);
      return;
   }
   if (Result==0)
      EndWhile(pChar, gMacroBlock);
}
const TRotation& KVFlowTensor::GetAziReacPlaneRotation()
{
    // Returns the azimuthal rotation around the beam axis required
    // to put the X-axis in the reaction plane defined by the beam axis
    // and the major axis (largest eignevalue) of the ellipsoid.
    // The azimuthal angle of the rotation is that of the major axis
    // in the forward direction.

    if (!fCalculated) Calculate();
    return fAziReacPlane;
}
Exemple #10
0
const TRotation& KVFlowTensor::GetFlowReacPlaneRotation()
{
    // Returns composition of two rotations:
    //   - around Z-axis to put X-axis in reaction plane (see GetAziReacPlaneRotation)
    //   - around Y-axis to align Z-axis with flow (major) axis
    // In this rotated frame, theta is polar angle with respect to flow axis
    // and phi is azimuthal angle around flow axis (phi=0,180 => in-plane)

    if (!fCalculated) Calculate();
    return fFlowReacPlane;
}
Exemple #11
0
void main(int argc, char **argv)
{
    setlocale(0, "");
    int s1 = Calculate(mt1, len(mt1));
    int s2 = Calculate(mt2, len(mt2));
    int s3 = Calculate(mt3, len(mt3));

    int u = max(max(s1,s2),s3);

    printf("Больше сумма элементов, не попадающих в заданный диапазон [%i; %i] содержится в:\n", TrgetNumber1, TrgetNumber2);
    if(u==s1)
        printf(" mt1");
    if(u==s2)
        printf(" mt2");
    if(u==s3)
        printf(" mt3");

    printf("\n");
    system("pause");
}
Exemple #12
0
int main(void)
{
	struct Points *Field; 
	struct Cluster *Clusters;
	int Width, Height;
	int NumOfPoints;
	int NumOfClusters;
	Field = Init(&Height,&Width,&NumOfPoints);
	Clusters = Calculate(Field, Height, Width, &NumOfClusters, NumOfPoints);
	Output_Data(Clusters, Field, NumOfClusters);
	return 0;
}
void BroadCollisionStrategy::Detect(
	int nLayer,
	Player * pPlayer,
	Stack * stack,
	list<Space *> * retVal)
{
	Calculate(
		nLayer,
		pPlayer, 
		stack, 
		retVal);
}
void LinearRegression::addXY(const double& x, const double& y, bool auto_calculate)
{
    n++;
    sumX += x;
    sumY += y;
    sumXsquared += x * x;
    sumYsquared += y * y;
    sumXY += x * y;
    
    if(auto_calculate)
		Calculate();
}
Exemple #15
0
int FGTurbine::InitRunning(void)
{
  FDMExec->SuspendIntegration();
  Cutoff=false;
  Running=true;  
  N1_factor = MaxN1 - IdleN1;
  N2_factor = MaxN2 - IdleN2;      
  N2 = IdleN2 + ThrottlePos * N2_factor;
  N1 = IdleN1 + ThrottlePos * N1_factor;
  Calculate();
  FDMExec->ResumeIntegration();
  return phase==tpRun;
}
ROOT_FEATURE_CALCULATOR_TEMPLATE
vector<typename ROOT_FEATURE_CALCULATOR_TEMPLATE1::StringBatch>
ROOT_FEATURE_CALCULATOR_TEMPLATE1::Calculate(
    const SyntaxTree& tree)
{
    const vector<SyntaxNode>& nodes = tree.GetNodes();
    vector<StringBatch> features;
    for (size_t nodeIndex = 0; nodeIndex < nodes.size(); ++nodeIndex)
    {
        features.emplace_back(Calculate(nodes[nodeIndex], tree));
    }
    return features;
}
Exemple #17
0
void CDrawDoc::NewStructure(int number) {
	StructureNumber = number;
	int i;

	for (i=1;i<=ct.numofbases;i++) {
		if (ct.basepr[number][i]) {
			Calculate();
			nopair = false;
			return;
		}
	}
	nopair = true;
}
Exemple #18
0
// 得到趋势信号
int CTechnique::GetTrendIntensity(int nIndex, CSPDWordArray & adwDays,
								 UINT itsLong, UINT itsShort, UINT * pnCode )
{
	if( pnCode )	*pnCode	=	ITSC_NOTHING;
	if( nIndex <= 0 )
		return ITS_NOTHING;

	int	nRet	=	ITS_NOTHING;
	for( int k=1; k<adwDays.GetSize(); k++ )
	{
		double	dMALast1, dMALast2, dMANow1, dMANow2;
		if( !Calculate( &dMALast1, nIndex-1, min(adwDays[k-1],adwDays[k]), FALSE )
			|| !Calculate( &dMALast2, nIndex-1, max(adwDays[k-1],adwDays[k]), FALSE )
			|| !Calculate( &dMANow1, nIndex, min(adwDays[k-1],adwDays[k]), FALSE )
			|| !Calculate( &dMANow2, nIndex, max(adwDays[k-1],adwDays[k]), FALSE ) )
			return ITS_NOTHING;
		
		if( dMANow1 >= dMALast1 && dMANow2 >= dMALast2
			&& dMANow1 > dMANow2 && (dMANow1-dMANow2)>=(dMALast1-dMALast2)
			&& (ITS_ISBUY(nRet) || 1==k) )
		{
			if( pnCode )	*pnCode	=	ITSC_LONG;
			nRet	=	itsLong;
		}
		else if( dMANow1 <= dMALast1 && dMANow2 <= dMALast2
			&& dMANow1 < dMANow2 && (dMANow1-dMANow2)<=(dMALast1-dMALast2)
			&& (ITS_ISSELL(nRet) || 1==k) )
		{
			if( pnCode )	*pnCode	=	ITSC_SHORT;
			nRet	=	itsShort;
		}
		else
		{
			if( pnCode )	*pnCode	=	ITSC_NOTHING;
			return ITS_NOTHING;
		}
	}
	return nRet;
}
Exemple #19
0
//---------------------------------------------------------
bool CSG_Regression::Calculate(int nValues, double *x, double *y, TSG_Regression_Type Type)
{
	bool	bResult;

	Destroy();

	m_nValues	= nValues;
	m_x			= x;
	m_y			= y;

	bResult		= Calculate(Type);

	return( bResult );
}
void SceneAnimator::Init(const aiScene* pScene){// this will build the skeleton based on the scene passed to it and CLEAR EVERYTHING
	if(!pScene->HasAnimations()) return;
	Release();
	
	Skeleton = CreateBoneTree( pScene->mRootNode, NULL);
	ExtractAnimations(pScene);
	
	for (unsigned int i = 0; i < pScene->mNumMeshes;++i){
		const aiMesh* mesh = pScene->mMeshes[i];
		
		for (unsigned int n = 0; n < mesh->mNumBones;++n){
			const aiBone* bone = mesh->mBones[n];
			std::map<std::string, cBone*>::iterator found = BonesByName.find(bone->mName.data);
			if(found != BonesByName.end()){// FOUND IT!!! woohoo, make sure its not already in the bone list
				bool skip = false;
				for(size_t j(0); j< Bones.size(); j++){
					std::string bname = bone->mName.data;
					if(Bones[j]->Name == bname) {
						skip = true;// already inserted, skip this so as not to insert the same bone multiple times
						break;
					}
				}
				if(!skip){// only insert the bone if it has not already been inserted
					std::string tes = found->second->Name;
					TransformMatrix(found->second->Offset, bone->mOffsetMatrix);
					found->second->Offset.Transpose();// transpoce their matrix to get in the correct format
					Bones.push_back(found->second);
					BonesToIndex[found->first] = (unsigned int)Bones.size()-1;
				}
			} 
		}
	}
	Transforms.resize( Bones.size());
	float timestep = 1.0f/30.0f;// 30 per second
	for(size_t i(0); i< Animations.size(); i++){// pre calculate the animations
		SetAnimIndex((unsigned int)i);
		float dt = 0;
		for(float ticks = 0; ticks < Animations[i].Duration; ticks += Animations[i].TicksPerSecond/30.0f){
			dt +=timestep;
			Calculate(dt);
			Animations[i].Transforms.push_back(std::vector<mat4>());
			std::vector<mat4>& trans = Animations[i].Transforms.back();
			for( size_t a = 0; a < Transforms.size(); ++a){
				mat4 rotationmat =  Bones[a]->Offset * Bones[a]->GlobalTransform;
				trans.push_back(rotationmat);
			}
		}
	}
	OUTPUT_DEBUG_MSG("Finished loading animations with "<<Bones.size()<<" bones");
}
Exemple #21
0
// 得到趋势信号
int CTechnique::GetTrendIntensity1( int nIndex, UINT itsLong, UINT itsShort, UINT *pnCode )
{
	if( pnCode )	*pnCode	=	ITSC_NOTHING;
	if( nIndex <= 0 )
		return ITS_NOTHING;

	double	dLast = 0, dNow = 0;
	if( !Calculate( &dLast, nIndex-1, FALSE )
		|| !Calculate( &dNow, nIndex, FALSE ) )
		return ITS_NOTHING;

	if( dNow > dLast )
	{
		if( pnCode )	*pnCode	=	ITSC_LONG;
		return itsLong;
	}
	if( dNow < dLast )
	{
		if( pnCode )	*pnCode	=	ITSC_SHORT;
		return itsShort;
	}
	return ITS_NOTHING;
}
Exemple #22
0
void CMandelbrotCalculator::Run (unsigned nCore)
{
	while (1)
	{
#ifdef ARM_ALLOW_MULTI_CORE
		unsigned nHalfWidth  = m_pScreen->GetWidth () / 2;
		unsigned nHalfHeight = (m_pScreen->GetHeight ()-LINES_LEFT_FREE) / 2;

		switch (nCore)
		{
		case 0:
			Calculate (-2.0, 1.0, -1.0, 1.0, MAX_ITERATION,
				   0, nHalfWidth, 0, nHalfHeight);
			break;

		case 1:
			Calculate (-1.5, 0.0, -0.75, 0.25, MAX_ITERATION,
				   nHalfWidth, nHalfWidth, 0, nHalfHeight);
			break;

		case 2:
			Calculate (-1.125, -0.375, -0.5, 0.0, MAX_ITERATION,
				   0, nHalfWidth, nHalfHeight, nHalfHeight);
			break;

		case 3:
			Calculate (-0.9375, -0.5625, -0.375, -0.125, MAX_ITERATION,
				   nHalfWidth, nHalfWidth, nHalfHeight, nHalfHeight);
			break;
		}
#else
		Calculate (-2.0, 1.0, -1.0, 1.0, MAX_ITERATION,
			   0, m_pScreen->GetWidth (), 0, m_pScreen->GetHeight ()-LINES_LEFT_FREE);
#endif
	}
}
bool FGAtmosphere::InitModel(void)
{
  Calculate(0.0);
  SLtemperature = Temperature = 518.67;
  SLpressure = Pressure = 2116.22;
  SLdensity = Density = Pressure/(Reng*Temperature);
  SLsoundspeed = Soundspeed = sqrt(SHRatio*Reng*(Temperature));

  rSLtemperature = 1/SLtemperature ;
  rSLpressure    = 1/SLpressure    ;
  rSLdensity     = 1/SLdensity     ;
  rSLsoundspeed  = 1/SLsoundspeed  ;

  return true;
}
Exemple #24
0
// Main Function
int main()
{
	user = InitiatePoint();
	dest = InitiatePoint();
	pass = InitiatePoint();
	MAP[user.x][user.y] = MAZE[user.x][user.y] = 'S';
	MAP[dest.x][dest.y] = MAZE[dest.x][dest.y] = 'P';
	MAP[pass.x][pass.y] = MAZE[pass.x][pass.y] = 'D';

	ShowMap();

	while (1) {
		printf("Count: %d\n", ++count);
		Search();
		if (!Calculate()) {
			dest = pass;
			break;
		}
		Move();
		if (count == 5)
			return 0;
	}
	count = 0;
	while (1) {
		printf("Count %d\n", ++count);
		Search();
		if (!Calculate()) {
			return 0;
		}
		Move();
		if (count == 3) {
			return 0;
		}
	}
	return 0;
}
Exemple #25
0
//_________________________________________________________________
Double_t KVCaloBase::getvalue_int(Int_t i)
{
   // derived method
   // protected method
   // On retourne la ieme valeur du tableau
   // si i est superieur au nbre de variables definies dans ingredient_list
   // retourne la valeur par defaut (ie 0)
   // appel a la methode Calculate pour mettre a jour
   // les variables avant d effectuer le retour

   if (i < nvl_ing->GetNpar()) {
      Calculate();
      return GetIngValue(i);
   } else return 0;
}
Exemple #26
0
int MeanValues::compute(const char *)
{
    calctype = p_calctype->getValue();
    coDistributedObject *p_output = Calculate(p_data->getCurrentObject(), p_mesh->getCurrentObject(), p_solution->getObjName());
    if (p_output)
    {
        p_solution->setCurrentObject(p_output);
    }
    else
    {
        return FAIL;
    }

    // done
    return CONTINUE_PIPELINE;
}
  void FGStandardAtmosphere::PrintStandardAtmosphereTable()
{
  std::cout << "Altitude (ft)   Temp (F)   Pressure (psf)   Density (sl/ft3)" << std::endl;
  std::cout << "-------------   --------   --------------   ----------------" << std::endl;
  for (int i=0; i<280000; i+=1000) {
    Calculate(i);
    std::cout  << std::setw(12) << std::setprecision(2) << i
       << "  " << std::setw(9)  << std::setprecision(2) << Temperature - 459.67
       << "  " << std::setw(13) << std::setprecision(4) << Pressure
       << "  " << std::setw(18) << std::setprecision(8) << Density
       << std::endl;
  }

  // Re-execute the Run() method to reset the calculated values
  Run(false);
}
Exemple #28
0
/*****************************************************************************
* Function: Calculate
*
* Description: Returns the controller output for a given error.  Derivative error is
*              calculated as a simple dx/dt.  If a derivative error is already
*              calculated then use overloaded method.
*****************************************************************************/
float PID::Calculate
    (
        float error,      // Difference between desired and actual measurement.
        float delta_time  // Change in time since last measurement. (seconds)
    )
{
    float derivative_error = 0.f;

    if (delta_time != 0.0f) // Avoid division by zero.
    {
        derivative_error = (error - previous_error) / delta_time;
    }

    return Calculate(error, derivative_error, delta_time);

} // PID::Calculate()
Exemple #29
0
//----------------------------------------------------------//
void 
CCalculator::Calculate(CCalculator::contract_vector& contracts) {
	if (!contracts.empty()) {
		InterlockedExchange(&m_nContractsProcessed, static_cast<long>(contracts.size()));

		CCalculator::contract_vector::iterator it = contracts.begin();
		CCalculator::contract_vector::iterator it_end = contracts.end();
		for (; it != it_end; it++) {
			CAbstractContract* pContract = *it;
			if (pContract != NULL)
				Calculate(pContract);
		};
		//wait to complete
		::WaitForSingleObject(m_hComplete, INFINITE);
	};
};
Exemple #30
0
void Fibonacci::Calculate() {
    m_mutex.lock();
    if (m_count) {
        u_int64_t tempValue;
        tempValue = m_prevValue + m_currentValue;
        m_prevValue = m_currentValue;
        m_currentValue = tempValue;
        m_mutex.unlock();
        PrintValue();
        std::chrono::milliseconds duration(250);
        std::this_thread::sleep_for(duration);
        Calculate();
    } else {
        m_mutex.unlock();
    }
}