Пример #1
0
void main(void)
{
   int a[6] = {2, 6, 4, 3, 1, 5};
   int r[6];
   int n = 6;
   Rank(a,n,r);
   Rearrange(a,n,r);
   for (int i = 0; i < n; i++)
      cout << a[i] << ' ';
   cout << endl;
}
Пример #2
0
//   FORWARD FOURIER TRANSFORM, INPLACE VERSION
//     Data - both input data and output
//     N    - length of input data
bool CFFT::Forward(complex * const Data, const unsigned int N) {
    //   Check input parameters
    if (!Data || N < 1 || (N & (N - 1)))
        return false;
    //   Rearrange
    Rearrange(Data, N);
    //   Call FFT implementation
    Perform(Data, N);
    //   Succeeded
    return true;
}
Пример #3
0
//   FORWARD FOURIER TRANSFORM
//     Input  - input data
//     Output - transform result
//     N      - length of both input data and result
bool FFT::Forward(const complex *const Input, complex *const Output, const unsigned int N)
{
    //   Check input parameters
    if (!Input || !Output || N < 1 || N & (N - 1))
        return false;
    //   Initialize data
    Rearrange(Input, Output, N);
    //   Call FFT implementation
    Perform(Output, N);
    //   Succeeded
    return true;
}
Пример #4
0
//   INVERSE FOURIER TRANSFORM, INPLACE VERSION
//     Data  - both input data and output
//     N     - length of both input data and result
//     Scale - if to scale result
bool FFT::Inverse(complex *const Data, const unsigned int N, const bool Scale /* = true */)
{
    //   Check input parameters
    if (!Data || N < 1 || N & (N - 1))
        return false;
    //   Rearrange
    Rearrange(Data, N);
    //   Call FFT implementation
    Perform(Data, N, true);
    //   Scale if necessary
    if (Scale)
        FFT::Scale(Data, N);
    //   Succeeded
    return true;
}
Пример #5
0
//   INVERSE FOURIER TRANSFORM
//     Input  - input data
//     Output - transform result
//     N      - length of both input data and result
//     Scale  - if to scale result
bool FFT::Inverse(const complex *const Input, complex *const Output, const unsigned int N, const bool Scale /* = true */)
{
    //   Check input parameters
    if (!Input || !Output || N < 1 || N & (N - 1))
        return false;
    //   Initialize data
    Rearrange(Input, Output, N);
    //   Call FFT implementation
    Perform(Output, N, true);
    //   Scale if necessary
    if (Scale)
        FFT::Scale(Output, N);
    //   Succeeded
    return true;
}
Пример #6
0
int main()
{
    int num=0;
    NODE *Head = NULL;
     printf("Enter the information in the linked list (Enter -1 to exit):");
     scanf("%d",&num);
  while(num != -1)
  {
             Head = New_Node(Head,num);
             printf("Enter the information in the linked list (Enter -1 to exit):");
             scanf("%d",&num);
  }
  Print_Nodes(Head) ;
  Rearrange(Head);
 getch();
}
Пример #7
0
 void Algo10_11_main()
 {
   RedType d[N]={{278,1},{109,2},{63,3},{930,4},{589,5},{184,6},{505,7},{269,8},{8,9},{83,10}};
   SLList l;
   int *adr;
   InitList(l,d,N);
   printf("排序前(next域还没赋值):\n");
   print(l);
   RadixSort(l);
   printf("排序后(静态链表):\n");
   print(l);
   adr=(int*)malloc((l.recnum)*sizeof(int));
   Sort(l,adr);
   Rearrange(l,adr);
   printf("排序后(重排记录):\n");
   print(l);
 }
Пример #8
0
		void ProcessVector(float *input)
		{
			//Add the FFT to the total
			for (unsigned int i = 0; i < m_vector_length; i++){
				m_buffer[i] += input[i];
			}
			m_count++; //increment the total
			
			if (m_avg_size == m_count){ //we've averaged over the number we intended to
				double freqs[m_vector_length]; //for convenience
				float bands0[m_vector_length]; //bands in order of frequency
				float bands1[m_vector_length]; //fine window bands
				float bands2[m_vector_length]; //coarse window bands
				
				Rearrange(bands0, freqs, m_centre_freq_1, m_bandwidth0); //organise the buffer into a convenient order (saves to bands0)
				GetBands(bands0, bands1, m_bandwidth1); //apply the fine window (saves to bands1)
				GetBands(bands0, bands2, m_bandwidth2); //apply the coarse window (saves to bands2)
				PrintSignals(freqs, bands1, bands2);
				
				m_count = 0; //next time, we're starting from scratch - so note this
				ZeroBuffer(); //get ready to start again
				
				m_wait_count++; //we've just done another listen
				if (m_time/(m_bandwidth0/(double)(m_vector_length * m_avg_size)) <= m_wait_count){ //if we should move to the next frequency
					while (true) { //keep moving to the next frequency until we get to one we can listen on (copes with holes in the tunable range)
						if (m_centre_freq_2 <= m_centre_freq_1){ //we reached the end!
							//do something to end the scan
							fprintf(stderr, "[*] Finished scanning\n"); //say we're exiting
							exit(0); //TODO: This probably isn't the right thing, but it'll do for now
						}
						
						m_centre_freq_1 += m_step; //calculate the frequency we should change to
						double actual = m_source->set_center_freq(m_centre_freq_1); //change frequency
						if ((m_centre_freq_1 - actual < 10.0) && (actual - m_centre_freq_1 < 10.0)){ //success
							break; //so stop changing frequency
						}
					}
					m_wait_count = 0; //new frequency - we've listenned 0 times on it
				}
			}
		}
Пример #9
0
 void main()
 {
   RedType d[N]={{49,1},{38,2},{65,3},{97,4},{76,5},{13,6},{27,7},{49,8}};
   SLinkListType l1,l2;
   int *adr,i;
   TableInsert(&l1,d,N);
   l2=l1; /* 复制静态链表l2与l1相同 */
   printf("排序前:\n");
   print(l1);
   Arrange(&l1);
   printf("l1排序后:\n");
   print(l1);
   adr=(int*)malloc((l2.length+1)*sizeof(int));
   Sort(l2,adr);
   for(i=1;i<=l2.length;i++)
     printf("adr[%d]=%d ",i,adr[i]);
   printf("\n");
   Rearrange(&l2,adr);
   printf("l2排序后:\n");
   print(l2);
 }
void CPDF_VariableText::RearrangePart(const CPVT_WordRange& PlaceRange) {
  Rearrange(PlaceRange);
}
void CPDF_VariableText::RearrangeAll() {
  Rearrange(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
}