Click here to Skip to main content
15,893,564 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Appropriate algorithm for "bus routing problem" Pin
Gerry Schmitz21-Nov-16 5:34
mveGerry Schmitz21-Nov-16 5:34 
QuestionAlgorithm Help Pin
Member 1282317029-Oct-16 12:20
Member 1282317029-Oct-16 12:20 
AnswerRe: Algorithm Help Pin
Richard MacCutchan29-Oct-16 21:59
mveRichard MacCutchan29-Oct-16 21:59 
AnswerRe: Algorithm Help Pin
Patrice T17-Nov-16 23:39
mvePatrice T17-Nov-16 23:39 
QuestionWhat is the area I would research for schedule prediction? Pin
BurkusCat26-Oct-16 1:25
professionalBurkusCat26-Oct-16 1:25 
AnswerRe: What is the area I would research for schedule prediction? Pin
Bernhard Hiller26-Oct-16 20:49
Bernhard Hiller26-Oct-16 20:49 
AnswerRe: What is the area I would research for schedule prediction? Pin
Gerry Schmitz27-Oct-16 7:19
mveGerry Schmitz27-Oct-16 7:19 
Questionfrequency sweep problem Pin
Cezar Margineanu20-Oct-16 22:40
Cezar Margineanu20-Oct-16 22:40 
Hello,
For my new project, I have to develop an algorithm called frequency sweep.
The function parameters are nFreqStart, nFreqEnd and dSweepTime'.
As an example: for nFreqStart = 800Hz, the period T of this signal is 1.25ms, for nFreqEnd = 1600Hz, T is 0.625ms and the sum of all frequencies from nFreqStart to nFreqEnd must not be higher than dSweepTime.

My first version of this function is:
C++
uint16_t nFrequencies;

void sweep_initialize(const uint16_t nFreqStart, const uint16_t nFreqEnd, const double dSweepTime)
{
	double dTotalTime = 0.0;
	double dIncrement = 0.0;
	uint16_t nStep = 0;
	double dTmpFreq = 0.0;
	bool bSweep = true;

	// we already have 2 frequencies (start + stop)
	double dInitialTime = (1.0 / nFreqStart) + (1.0 / nFreqEnd);
	nFrequencies = 2;
	while (bSweep == true)
	{
		dTotalTime = dInitialTime;

		// get the next frequency
		dIncrement = (double)(nFreqEnd - nFreqStart);
		dIncrement /= (double)(nFrequencies);

		dTmpFreq = (double)nFreqStart;
		nStep = nFrequencies - 1;
		for (uint16_t i = 0; i < nStep; i++)
		{
			dTmpFreq += dIncrement;
			dTotalTime += 1.0 / dTmpFreq;
		}
		nFrequencies += 1;
		if (dTotalTime >= dSweepTime)
		{
			bSweep = false;
			break;
		}
	}
}

The next thing is, I need a counter (cpu clocks) for each frequency:
C++
uint16_t* pSweep_Array;

void sweep_getCounter()
{
	if (pSweep_Array != NULL)
	{
		free(pSweep_Array);
		pSweep_Array = NULL;
	}

	pSweep_Array = (uint16_t*)malloc(sizeof(uint16_t) * nFrequencies);
	if(pSweep_Array != NULL)
		memset(pSweep_Array, 0, sizeof(uint16_t) * nFrequencies);
	
	double dFrequency = (double)nFreqStart;
	double dIncrement = (double)(nFreqEnd - nFreqStart);
	dIncrement /= (double)(nFrequencies - 1);
	
	double dCounter = 0.0;
	for (uint16_t i = 0; i < nFrequencies; i++)
	{		
		dCounter = 65536 - (F_CPU / dFrequency);
		pSweep_Array[i] = (uint16_t)round(dCounter);

		dFrequency += dIncrement;
	}
}


But as a result, the computation complexity is O((n-1)! * n2), where n is the number of frequencies between nFreqStart and nFreqEnd, including nFreqStart & nFreqStop.

I need help for a less complex solution (function).
AnswerRe: frequency sweep problem Pin
BeemerWT21-Nov-16 3:40
professionalBeemerWT21-Nov-16 3:40 
QuestionRoot Sorting Pin
Member 1279635716-Oct-16 6:02
Member 1279635716-Oct-16 6:02 
GeneralRe: Root Sorting Pin
harold aptroot16-Oct-16 10:22
harold aptroot16-Oct-16 10:22 
GeneralRe: Root Sorting Pin
Manfred Rudolf Bihy26-Oct-16 2:45
professionalManfred Rudolf Bihy26-Oct-16 2:45 
GeneralRe: Root Sorting Pin
harold aptroot26-Oct-16 8:43
harold aptroot26-Oct-16 8:43 
AnswerRe: Root Sorting Pin
Manfred Rudolf Bihy26-Oct-16 2:42
professionalManfred Rudolf Bihy26-Oct-16 2:42 
SuggestionRe: Root Sorting Pin
Ashutosh_se9-Nov-16 3:13
Ashutosh_se9-Nov-16 3:13 
GeneralRe: Root Sorting Pin
Manfred Rudolf Bihy9-Nov-16 3:25
professionalManfred Rudolf Bihy9-Nov-16 3:25 
Questionwhich algorithm dominates f(n) or (g(n)) Pin
Member 127799066-Oct-16 7:11
Member 127799066-Oct-16 7:11 
AnswerRe: which algorithm dominates f(n) or (g(n)) Pin
Afzaal Ahmad Zeeshan6-Oct-16 7:32
professionalAfzaal Ahmad Zeeshan6-Oct-16 7:32 
GeneralRe: which algorithm dominates f(n) or (g(n)) Pin
Member 127799066-Oct-16 8:50
Member 127799066-Oct-16 8:50 
Questionquestion about cycle reduction problem Pin
Member 127782295-Oct-16 10:58
Member 127782295-Oct-16 10:58 
AnswerRe: question about cycle reduction problem Pin
Chris Losinger6-Oct-16 3:59
professionalChris Losinger6-Oct-16 3:59 
Questionbooth's algorithm vs russian peasant's algorithm for multiplying two binary numbers Pin
EZCodeProject27-Sep-16 13:45
EZCodeProject27-Sep-16 13:45 
AnswerRe: booth's algorithm vs russian peasant's algorithm for multiplying two binary numbers Pin
harold aptroot28-Sep-16 3:11
harold aptroot28-Sep-16 3:11 
GeneralRe: booth's algorithm vs russian peasant's algorithm for multiplying two binary numbers Pin
EZCodeProject28-Sep-16 7:08
EZCodeProject28-Sep-16 7:08 
QuestionTrying to get additions, deletions and changes between 2 file versions Pin
Christopher Cote26-Sep-16 2:56
Christopher Cote26-Sep-16 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.