Esempio n. 1
0
void NQInt::deleteNullsItems()
{
	//удаление нулевых элементов
	int start = valueLeng -1 ;
	int count = valueLeng + underValueLeng;
	while (start>0 &&!THIS[start]) {
		start--,count--;//сокращение начальных нулей
	}
	if (start == 0)
	{
		if (count == 0) count =1;
		
	}
	if (start != valueLeng - 1)
	{//сокращение конечных нулей
		NQInt Temp(THIS,start,count);
		THIS = Temp;
	}
	int TCount = count;
	while (!THIS[start-count+1] && start-count+1>0) {
		count--;
	}
	if (TCount != count)
	{
		NQInt Temp(THIS,start,count);
		THIS = Temp;
	}
}
void TaskSensores(void *pdata)
{    
#if OS_CRITICAL_METHOD == 3 
    OS_CPU_SR  cpu_sr;
#endif
    struct AdcMsg *m;
    INT16U value = 0;
    INT16U ValorTeclado = 0;
	INT8U err;
	for(;;)
	{
        
        m = (struct AdcMsg *) OSMemGet(dMemory,&err);
        if(err == OS_NO_ERR){
            OSSemPend(STeclado,0,&err);
            ValorTeclado = NumeroSensores;
            OSSemPost(STeclado);       
            m->adc0 = 0;
            m->adc1 = 0;
            m->adc2 = 0;
            switch(ValorTeclado){
                case 3:
                    Delay10TCYx(100);
                    SetChanADC(ADC_CH2);
                    ConvertADC();
                    while( BusyADC() );
                    value = ReadADC();
                    m->adc2 = Temp(value);
                case 2:
                    Delay10TCYx(100);
                    SetChanADC(ADC_CH1);
                    ConvertADC();
                    while( BusyADC() );
                    value = ReadADC();
                    m->adc1 = Temp(value);                    
                case 1:
                    Delay10TCYx(100);
                    SetChanADC(ADC_CH0);
                    ConvertADC();
                    while( BusyADC() );
                    value = ReadADC();
                    m->adc0 = Temp(value);
                default:
                    break;
            }

            err = OSQPost(QueueADC0,m);
            if(err == OS_Q_FULL){
                OSMemPut(dMemory,m);
                OSSemPost(STaskTxSerial);
            }
        }else{
            OSSemPost(STaskTxSerial);
        }
		//OSSemPost(STask2);
		OSTimeDly(1);
	}
}
Esempio n. 3
0
void BaseMesh::CreateBox(float w, float h, float d, int refinement)
{
    Allocate(8, 12);

    MeshVertex Temp(Vec3f::Origin, Vec3f::Origin, RGBColor::White, Vec2f::Origin);

    int i,vc=VertexCount(),ic=IndexCount();
    MeshVertex *V = Vertices();
    DWORD *I = Indices();

    for(i=0;i<8;i++)
    {
        Temp.Pos = Vec3f(CubeVData[i][0],CubeVData[i][1],CubeVData[i][2]);
        V[i] = Temp;        ///load the vertices
    }
    for(i=0;i<12;i++)
    {
        I[i*3+0] = CubeIData[i][0];
        I[i*3+1] = CubeIData[i][1];
        I[i*3+2] = CubeIData[i][2];    //load the triangles
    }

    for(i=0;i<refinement;i++)
    {
        TwoPatch();                //refine the requested number of times
    }

    Stretch(Vec3f(0.5f*w, 0.5f*h, 0.5f*d));    //stretch to the requested dimensions
    GenerateNormals();
}
Esempio n. 4
0
//Степень
NQInt NQInt::pow(NQInt A)
{// возведение в степень
	A.deleteNullsItems();
	if (!THIS.Compare(NQInt(0)) && !A.Compare(NQInt(0))) throw NQIntException(NQIntNullInNull);
	if (!THIS.Compare(NQInt(0))) 
	{
		NQInt Result = 1;
		Result.errSize = errSize;
		return Result;
	}
	if (!A.Compare(NQInt(0)))
	{
		NQInt Result = 1;
		Result.errSize = errSize;
		return Result;
	}
	if (A.underValueLeng) throw NQIntException(NQIntDecimalPow);
	NQInt DSum(1);
	NQInt Result = THIS;
	Result.errSize = errSize;
	for (NQInt Temp(1); (Temp.Compare(A)); Temp = Temp + DSum)
	{//последовательное умножение
		Result = Result * THIS;
	}
	return Result;
}
Esempio n. 5
0
bool CComplexBinary::OnDeserialize (CDatum::ESerializationFormats iFormat, const CString &sTypename, IByteStream &Stream)

//	OnDeserialize
//
//	Deserialize

	{
	if (m_pData)
		{
		delete [] GetBuffer();
		m_pData = NULL;
		}

	DWORD dwLength;
	Stream.Read(&dwLength, sizeof(DWORD));

	if (dwLength > 0)
		{
		CComplexBinary Temp(Stream, dwLength);
		m_pData = Temp.m_pData;
		Temp.m_pData = NULL;
		}

	return true;
	}
Esempio n. 6
0
u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag)
{
	UDSPControl Temp(_uFlag);
	if (!m_InitMixer)
	{
		if (!Temp.DSPHalt)
		{
			InitMixer();
		}
	}
	DSPInterpreter::WriteCR(_uFlag);

	// Check if the CPU has set an external interrupt (CR_EXTERNAL_INT)
	// and immediately process it, if it has.
	if (_uFlag & 2)
	{
		if (!m_bDSPThread)
		{
			DSPCore_CheckExternalInterrupt();
			DSPCore_CheckExceptions();
		}
		else
		{
			DSPCore_SetExternalInterrupt(true);
		}

	}

	return DSPInterpreter::ReadCR();
}
Word BURGER_API Burger::Thread::Start(FunctionPtr pFunction,void *pData)
{
	Word uResult = 10;
	if (!m_pThreadHandle) {
		m_pFunction = pFunction;
		m_pData = pData;
		// Use this temporary semaphore to force synchronization
		Semaphore Temp(0);
		m_pSemaphore = &Temp;
		DWORD uID;
		// Start the thread
		HANDLE hThread = CreateThread(NULL,0,Dispatcher,this,0,&uID);
		if (hThread) {
			// Ensure these are set up
			m_uThreadID = uID;
			m_pThreadHandle = hThread;
			// Wait until the thread has started
			Temp.Acquire();
			// Kill the dangling pointer
			m_pSemaphore = NULL;

			// All good!
			uResult = 0;
		}
	}
	return uResult;
}
Esempio n. 8
0
void CopySpeedLimits(TStrings * Source, TStrings * Dest)
{
  std::unique_ptr<TStringList> Temp(new TStringList());

  bool Unlimited = false;
  for (intptr_t Index = 0; Index < Source->GetCount(); ++Index)
  {
    UnicodeString Text = Source->GetString(Index);
    uintptr_t Speed;
    bool Valid = TryGetSpeedLimit(Text, Speed);
    if ((!Valid || (Speed == 0)) && !Unlimited)
    {
      Temp->Add(LoadStr(SPEED_UNLIMITED));
      Unlimited = true;
    }
    else if (Valid && (Speed > 0))
    {
      Temp->Add(Text);
    }
  }

  if (!Unlimited)
  {
    Temp->Insert(0, LoadStr(SPEED_UNLIMITED));
  }

  Dest->Assign(Temp.get());
}
Esempio n. 9
0
/** Diferentiate data and return the result in a new object.
 *  WARNING: Do not call for recursive functions as it will crash with a stack overflow
 *  \param Var: Variable to differenciate with respect to
 *  \param Trigonometry: Choose to differentiate trigonometric functions as radians or degrees.
 */
boost::shared_ptr<TFuncData> TFuncData::MakeDif(const TElem &Var, TTrigonometry Trigonometry) const
{
  if(Data.empty())
    throw EFuncError(ecNoFunc);

  if(CheckRecursive())
    throw EFuncError(ecRecursiveDif);

  try
  {
    boost::shared_ptr<TFuncData> Temp(new TFuncData);
		CopyReplaceArgs(Temp->Data, Data.begin(), std::vector<std::vector<TElem> >());
    DEBUG_LOG(std::wclog << L"f(x)=" << MakeText(Temp->Data.begin()) << std::endl);
    boost::shared_ptr<TFuncData> Dest(new TFuncData);
    Dest->AddDif(Temp->Data.begin(), Var, Trigonometry, 0);

    //It is sometimes necesarry to optimize. For example d(x^2) needs an ln(x) optimized away
    DEBUG_LOG(std::wclog << L"Before simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl);
    Dest->Simplify();
    DEBUG_LOG(std::wclog << L"After simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl);
		Dest->Simplify();
    DEBUG_LOG(std::wclog << L"After simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl);
    return Dest;
  }
  catch(boost::bad_any_cast &E)
  {
    throw EFuncError(ecInternalError);
  }
}
Esempio n. 10
0
const aghMatrix<char> aghMatrix<char>::operator*(const aghMatrix<char>& A)
{
   aghMatrix<char> Temp(wier, A.kol);

   for(int i=0; i<wier; i++)
      for(int j=0; j<A.kol; j++)
         Temp.tab[i][j]=0;

   if(kol==A.wier)
   {
      for (int i=0; i<wier; i++)
          for (int j=0; j<A.kol; j++)
         {
            for (int p=0; p<kol; p++)
            {
               Temp.tab[i][j] = Temp.tab[i][j] +  ((tab[i][p]-'a') * (A.tab[p][j]-'a'))  % (( 'z' - 'a') +1 ) ;
            }
            Temp.tab[i][j] = Temp.tab[i][j] % ( ('z' - 'a') +1 ) + 'a';
         }

   Temp.wier=wier;
   Temp.kol=A.kol;


   return Temp;
   }
   else
   throw aghException(0, "Zle rozmiary macierzy", __FILE__, __LINE__);

}
Esempio n. 11
0
void Matrix::add(int row, int col, float number)//Adiciona valores a matriz,
{                                               //se tiver valores maiores que as dimensões da matriz,
    int tempRow, tempCol;                       //coloca o valor na posição indicada completando o resto com 0

    if(this->rows < row)
        tempRow = row;
    else
        tempRow = this->rows;
    if(this->cols < col)
        tempCol = col;
    else
        tempCol = this->cols;

    Matrix Temp(tempRow, tempCol);
    if((this->rows != 0) && (this->cols != 0))
    {
        for(int i = 0; i < this->rows; i++)
            for (int j = 0; j < this->cols; j++)
                Temp.Mat[i][j] = this->Mat[i][j];
    }

    Temp.Mat[row-1][col-1] = number;
    this->init(tempRow, tempCol);

    for(int i = 0; i < Temp.rows; i++)
        for (int j = 0; j < Temp.cols; j++)
            this->Mat[i][j] = Temp.Mat[i][j];

}
Esempio n. 12
0
String String::operator+ (String& Arg)
{
  String Temp( length + Arg.length );
  strcpy(Temp.char_ptr, char_ptr);
  strcat(Temp.char_ptr, Arg.char_ptr);
  return Temp;
}
Esempio n. 13
0
void RoboPult::TempS()
  {
   askStena->setChecked(false);	
   askFree->setChecked(false);
      switchButt();
  emit Temp();
  };
Esempio n. 14
0
EXPORT	void	fprint_raw_gas_data(
	FILE		*file,
	Locstate	state,
	int		dim)
{
	(void) fprintf(file,"state 0x%p\n",(POINTER)state);
	if (state == NULL)
	{
	    (void) printf("NULL state\n");
	    return;
	}
	(void) fprintf(file,"\tState Data ");
	(void) fprintf(file,"\n");
	switch (state_type(state))
	{
	case GAS_STATE:
	    g_fprint_raw_state(file,state,dim);
	    break;

	case EGAS_STATE:
	    g_fprint_raw_Estate(file,state,dim);
	    break;

	case TGAS_STATE:
	    g_fprint_raw_Tstate(file,state,dim);
	    break;

	case FGAS_STATE:
	    g_fprint_raw_Fstate(file,state,dim);
	    break;

	case OBSTACLE_STATE:
	    (void) fprintf(file,"Obstacle state type,  "
				"printing as GAS_STATE\n");
	    g_fprint_raw_state(file,state,dim);
	    break;

	case VGAS_STATE:
	    g_fprint_raw_Tstate(file,state,dim);
	    (void) printf("Specific internal energy = %"FFMT"\n",Int_en(state));
	    (void) printf("Entropy = %"FFMT"\n",Entropy(state));
	    (void) printf("Sound_speed = %"FFMT"\n",sound_speed(state));
#if defined(VERBOSE_GAS_PLUS)
	    (void) printf("Enthalpy = %"FFMT"\n",Enthalpy(state));
	    (void) printf("Temperature = %"FFMT"\n",Temp(state));
#endif /* defined(VERBOSE_GAS_PLUS) */
	    break;

	case UNKNOWN_STATE:
	    (void) fprintf(file,"Unknown state type,  printing as GAS_STATE\n");
	    g_fprint_raw_state(file,state,dim);
	    break;

	default:
	    screen("ERROR in fprint_raw_gas_data(), "
	           "unknown state type %d\n",state_type(state));
	    clean_up(ERROR);
	}
}		/*end fprint_raw_gas_data*/
Esempio n. 15
0
//---------------------------------------------------------------------------
void GUI_Main_HTML::GUI_Refresh()
{
    std::string Temp(wxConvUTF8.cWX2MB(C->Inform_Get().c_str()));
    wxFileSystem::AddHandler(new wxMemoryFSHandler);
    wxMemoryFSHandler::AddFile(__T("index.html"), Temp.c_str(), Temp.size());
    LoadPage(__T("memory:index.html"));
    wxMemoryFSHandler::RemoveFile(__T("index.html"));
}
Esempio n. 16
0
void Elements::recount(int time)
{
	vector<double> Temp(numofnods);
	double kxx=MATERIAL_COND;
	double kyy=MATERIAL_COND;
	double h=MATERIAL_EXCH;
	Matrix<double> K(numofnods);
	for(int i=0;i<numofnods;i++)
		K[i][i]=0;
	Row<double> F(numofnods);
	Row<double> Fi(3);
	Matrix<double> Ki(3);
	for(unsigned int i=0;i<Set.size();i++)
	{
		double A=Set[i].square();
		Ki=kxx/4/A*Set[i].B()+kyy/4/A*Set[i].C();
		Fi=Set[i].Q(time);
		for(int s=0;s<3;s++)
		{
			F[Data[i].index(s)]+=Fi[s];
			for(int p=0;p<3;p++)
				K[Data[i].index(s)][Data[i].index(p)]+=Ki[s][p];
		}
	}
	for(unsigned int i=0;i<Conditions.size();i++)
	{
		Ki=Conditions[i].L()*h;
		Fi=Conditions[i].R();
		if(Conditions[i].type()) Fi*=h;
		for(int s=0;s<2;s++)
		{
			F[Conditions[i].index(s)]+=Fi[s];
			for(int p=0;p<2;p++)
				K[Conditions[i].index(s)][Conditions[i].index(p)]+=Ki[s][p];
		}
	}
	int diag=(min(NUMOFCOLS,NUMOFROWS)+1)*2+1;
	DiagonalSystem<double> Solution(K,F,diag);
	Solution.Gauss();
	Temp=Solution.solutuion().ToVector();
	if(time==0)
	{
		ofstream file;
		file.open("matrixoutput.txt");
		file<<K<<"Free vector:\n"<<F;
		file<<"Solution:\n";
		file<<Solution.solutuion();
		file.close();
		/*DWORD thID;
		DSystem TempSystem(K,F);
		CreateThread(NULL, NULL, FileWriter, &TempSystem, NULL, &thID);*/
	}
	for(unsigned int i=0;i<Set.size();i++)
	{
		Set[i].settemp(Temp[Data[i].i()],Temp[Data[i].k()],Temp[Data[i].j()]);
		Set[i].recounttemp();
	}
}
Esempio n. 17
0
vector < Player > Game_Engine::Player_Generate(const int &n) {
	vector < Player > Temp(n);
	for (int i = 0; i < n; i++) {
		Temp[i] = Player_Generate();
		Temp[i].Player_Number = i;
		Temp[i].Team_Number = i; //TODO: for someone
	}
	return Temp;
}
Esempio n. 18
0
void Path::Decode(std::string &path) {
	if (path[0] != 94) // "^"
		return;
	try {
		if (path.find("^CONFIG") == 0) {
			path.replace(0, 7, Config());
			return;
		}

		if (path.find("^USER") == 0) {
			path.replace(0, 5, User());
			return;
		}

		if (path.find("^DATA") == 0) {
			path.replace(0, 5, Data());
			return;
		}

		if (path.find("^DOC") == 0) {
			path.replace(0, 4, Doc());
			return;
		}

		if (path.find("^TEMP") == 0) {
			path.replace(0, 5, Temp());
			return;
		}

		if (path.find("^AUDIO") == 0) {
			std::string path_str(opt->Get("Last/Audio")->GetString());
			Decode(path_str);
			path.replace(0, 6, path_str);
			return;
		}

		if (path.find("^VIDEO") == 0) {
			std::string path_str(opt->Get("Last/Video")->GetString());
			Decode(path_str);
			path.replace(0, 6, path_str);
			return;
		}

		if (path.find("^SUBTITLE") == 0) {
			std::string path_str(opt->Get("Last/Subtitle")->GetString());
			Decode(path_str);
			path.replace(0, 5, path_str);
			return;
		}

		throw PathErrorInvalid("Invalid cookie used");

	} catch (OptionErrorNotFound&) {
		throw PathErrorInternal("Failed to find key in Decode");
	}
}
Esempio n. 19
0
ModelClass& ModelClass::operator=(const ModelClass& other)
{
	if(this != &other)
	{
		Release();
		ModelClass Temp(other);
		Swap(Temp);
	}
	return *this;
}
Esempio n. 20
0
////////////////////////////////////////////////////////////
/// Assignment operator
////////////////////////////////////////////////////////////
SoundBuffer& SoundBuffer::operator =(const SoundBuffer& Other)
{
    SoundBuffer Temp(Other);

    mySamples.swap(Temp.mySamples);
    std::swap(myBuffer,   Temp.myBuffer);
    std::swap(myDuration, Temp.myDuration);

    return *this;
}
Esempio n. 21
0
Driver& Driver::operator= (const Driver& other)
{
    Driver Temp(other);

    swap(Temp.lexer, this->lexer);
    swap(Temp.parser, this->parser);
    swap(Temp.result, this->result);

    return *this;
}
Esempio n. 22
0
//--------------------------------------------------------------------------//
// Rotate the matrix.														//
//--------------------------------------------------------------------------//
void CAGMatrix::Rotate(double Angle, double x, double y)
{
	double AngleRadian = Angle * PI / 180;	

	Translate(-x, -y);
	double CosAngle = cos(AngleRadian);
	double SinAngle = sin(AngleRadian);
	CAGMatrix Temp(CosAngle, -SinAngle, SinAngle, CosAngle);
	*this *= Temp;
	Translate(x, y);
}
Esempio n. 23
0
////////////////////////////////////////////////////////////
/// Assignment operator
////////////////////////////////////////////////////////////
SoundBuffer& SoundBuffer::operator =(const SoundBuffer& Other)
{
    SoundBuffer Temp(Other);

    std::swap(mySamples,  Temp.mySamples);
    std::swap(myBuffer,   Temp.myBuffer);
    std::swap(myDuration, Temp.myDuration);
    std::swap(mySounds,   Temp.mySounds); // swap sounds too, so that they are detached when Temp is destroyed

    return *this;
}
Esempio n. 24
0
int cInventory::RemoveItem(const cItem & a_ItemStack)
{
	int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack);

	if (RemovedItems < a_ItemStack.m_ItemCount)
	{
		cItem Temp(a_ItemStack);
		Temp.m_ItemCount -= RemovedItems;
		RemovedItems += m_InventorySlots.RemoveItem(Temp);
	}

	return RemovedItems;
}
FUniqueObjectGuid FUniqueObjectGuid::FixupForPIE(int32 PlayInEditorID) const
{
	FUniqueObjectGuid Temp(*this);

	check(PlayInEditorID != -1)
	const FGuid *FoundGuid = PIEGuidMap[PlayInEditorID % MAX_PIE_INSTANCES].Find(Temp.GetGuid());

	if (FoundGuid)
	{
		Temp = *FoundGuid;
	}
	return Temp;
}
Esempio n. 26
0
/******************************************************************************************

>	void PrintPrefsDlg::Do(OpDescriptor*)

	Author:		Neville_Humphrys (Xara Group Ltd) <*****@*****.**>
	Created:	12/4/95
	Inputs:		-
	Outputs:	-
	Returns:	-
	Purpose:	Creates then opens the dialog in response to a request from the user.
	Errors:		-
	SeeAlso:	-

******************************************************************************************/
void PrintPrefsDlg::Do(OpDescriptor*)
{
	BOOL ok;

	if (OptionsTabs::pPrefsDlg != NULL)
	{
		ERROR3("PrintPrefsDlg::Do an options tabbed dialog box is already present");
		return;
	}
	
	// Set up the name that the main dialog page is going to use
	String_256 Temp(_R(IDN_PRINTOPTS)); 
	TitleString = Temp;
	SetName(&TitleString);

	// Make sure that our options tabs have a link to the dialog box class
	OptionsTabs::pPrefsDlg = this;
	OptionsTabs::SetApplyNowState(FALSE);

	// Make sure that we have set up our class variables so that the tabs know what
	// is the current document and spread to work on.
	Document *pDocument = Document::GetSelected();
	OptionsTabs::SetCurrentDocAndSpread(pDocument);
	// Work out the document name so that it is ready for options tabs to display.
	OptionsTabs::SetDocumentName(pDocument);
	
		
	// Force the dialog box to be created, as it is non-modal it must be opened if the create
	// works ok.
	ok = Create();							// create the dialog box

	if ( ok )
	{
//		// Modal at present so remove the Open()
//		Open();								// created ok so open the dialog box up
//		
//		// grey out the apply now button as this should only become enabled when we have 
//		// made a change to the dialog box.
//		OptionsTabs::SetInitMessageState(FALSE);
//		OptionsTabs::SetApplyNowState(FALSE);
//		OptionsTabs::GreyApplyNow();
	}
	else
	{
		// Could not create the dialog box so call inform error 
		InformError();						// Show user the error
  		End(); 		   						// End the operation 
	}				   	
}
Esempio n. 27
0
//---------------------------------------------------------------------------
UnicodeString TFileMasks::ComposeMaskStr(
  TStrings * MasksStr, bool Directory)
{
  UnicodeString Result;
  UnicodeString ResultNoDirMask;
  for (intptr_t I = 0; I < MasksStr->GetCount(); ++I)
  {
    UnicodeString Str = MasksStr->GetString(I).Trim();
    if (!Str.IsEmpty())
    {
      for (intptr_t P = 1; P <= Str.Length(); P++)
      {
        if (Str.IsDelimiter(AllFileMasksDelimiters, P))
        {
          Str.Insert(Str[P], P);
          P++;
        }
      }

      UnicodeString StrNoDirMask;
      if (Directory)
      {
        StrNoDirMask = Str;
        Str = MakeDirectoryMask(Str);
      }
      else
      {
        while (Str.IsDelimiter(DirectoryMaskDelimiters, Str.Length()))
        {
          Str.SetLength(Str.Length() - 1);
        }
        StrNoDirMask = Str;
      }

      AddToList(Result, Str, FileMasksDelimiterStr);
      AddToList(ResultNoDirMask, StrNoDirMask, FileMasksDelimiterStr);
    }
  }

  // For directories, the above will add slash ay the end of masks,
  // breaking size and time masks and thus circumverting their validation.
  // This performes as hoc validation to cover the scenario.
  // For files this makes no difference, but no harm either
  TFileMasks Temp(Directory ? 1 : 0);
  Temp = ResultNoDirMask;

  return Result;
}
Esempio n. 28
0
    /**
     * Applies the inverse transform to the spectrum.
     *
     * @param spectrum input spectrum
     * @param x output signal
     */
    void AquilaFft::ifft(SpectrumType spectrum, double x[])
    {
        SpectrumType spectrumCopy(spectrum);
        unsigned int a = 1, b = 0, c = 0;
        for (b = 1; b < N; ++b)
        {
            if (b < a)
            {
                spectrumCopy[a - 1] = spectrum[b - 1];
                spectrumCopy[b - 1] = spectrum[a - 1];
            }
            c = N / 2;
            while (c < a)
            {
                a -= c;
                c /= 2;
            }
            a += c;
        }

        unsigned int numStages = static_cast<unsigned int>(
            std::log(static_cast<double>(N)) / LN_2);
        unsigned int L = 0, M = 0, p = 0, q = 0, r = 0;
        ComplexType Wi(0, 0), Temp(0, 0);
        ComplexType** Wi_cache = getCachedFftWi(numStages);
        for (unsigned int k = 1; k <= numStages; ++k)
        {
            L = 1 << k;
            M = 1 << (k - 1);
            Wi = -Wi_cache[k][0];
            for (p = 1; p <= M; ++p)
            {
                for (q = p; q <= N; q += L)
                {
                    r = q + M;
                    Temp = spectrumCopy[r - 1] * Wi;
                    spectrumCopy[r - 1] = spectrumCopy[q - 1] - Temp;
                    spectrumCopy[q - 1] = spectrumCopy[q - 1] + Temp;
                }
                Wi = -Wi_cache[k][p];
            }
        }

        for (unsigned int k = 0; k < N; ++k)
        {
            x[k] = std::abs(spectrumCopy[k]) / static_cast<double>(N);
        }
    }
Esempio n. 29
0
NQInt NQInt::sqrt(int Err)
{//Кто будет говорить, что корень не тригонометрия, тот ошибается =DD
	deleteNullsItems();
	
	NQInt Temp(0);
	if (!THIS.Positive) 

	{
		throw NQIntException(NQIntPositive);
	}

	if (!THIS.Compare(Temp))
		return NQInt(0);
	
	NQInt Eps(1);
	Eps.setErrSize(errSize);
	

	int SErr = Err;
	while (SErr > 0)
	{
		Eps = Eps/NQInt(10);
		Eps.setErrSize(errSize);
		SErr--;
	}
	Eps.valueLeng = 1;
	Eps.value = new int[Eps.valueLeng];
	Eps.value[0] = 0;

	NQInt X;
	NQInt NextX = THIS;
	NQInt Compared;
	do 
	{//разложим по формуле итерационной Герона
		X = NextX;
		
		NQInt Times = THIS/X;
		Times.setErrSize(errSize);
		NQInt Summary = (X + Times);
		Summary.setErrSize(errSize);
		NextX = Summary/NQInt(2);
		NextX.setErrSize(errSize);
		NextX.Trancate(Err);
		Compared = NextX - X;
		
	} while (Compared.Compare(Eps) == 1);
	return NextX;
}
Esempio n. 30
0
bool Myazo::Init(void)
{
	Instance=GetModuleHandle(nullptr);
	std::vector<wchar_t> Temp(MAX_PATH,0);
	SHGetSpecialFolderPath(nullptr,Temp.data(),CSIDL_APPDATA,false);
	SettingFileDirectory=Temp.data();
	SettingFileDirectory+=(*--SettingFileDirectory.end()==L'\\'?L"":L"\\")+AppName;
	if(!ImageEncoder.Init()) return false;
	if(!InitWindowClass()) return false;
	InitSetting();
	if(FirstBoot) OpenAuthWindow();
	else if(CheckArgumentOrUpload()||!InitWindow()) return false;
	LayerWindowFont.reset(new Gdiplus::Font(L"Tahoma",8));
	UIFont.reset(new Gdiplus::Font(L"MS UI Gothic",9.75f));
	return true;
}