void AssertFloat(const char *title, float x, float y) { float resx = GetFloat(); float resy = GetFloat(); if (!CompareFloat(resx, x) || !CompareFloat(resy, y)) { assertFailed_ = true; printf("%s: Failed %f, %f != expected %f, %f\n", title, resx, resy, x, y); } }
void AssertFloat(const char *title, float x) { float resx = GetFloat(); if (!CompareFloat(resx, x)) { assertFailed_ = true; printf("%s: Failed %f != expected %f\n", title, resx, x); } }
Boolean AEComparisons::TryPrimitiveComparison(DescType comparisonOperator, const AEDesc *desc1, const AEDesc *desc2) { Boolean result = false; // This has to handle all the data types used in the application's // object model implementation. switch (desc1->descriptorType) { case typeChar: result = CompareTexts(comparisonOperator, desc1, desc2); break; case typeShortInteger: // also covers typeSMInt 'shor' case typeLongInteger: // also covers typeInteger 'long' case typeMagnitude: // 'magn' result = CompareInteger(comparisonOperator, desc1, desc2); break; case typeEnumerated: result = CompareEnumeration(comparisonOperator, desc1, desc2); break; case typeFixed: result = CompareFixed(comparisonOperator, desc1, desc2); break; case typeFloat: result = CompareFloat(comparisonOperator, desc1, desc2); break; case typeBoolean: result = CompareBoolean(comparisonOperator, desc1, desc2); break; case typeRGBColor: result = CompareRGBColor(comparisonOperator, desc1, desc2); break; case typeQDRectangle: result = CompareRect(comparisonOperator, desc1, desc2); break; case typeQDPoint: result = ComparePoint(comparisonOperator, desc1, desc2); break; default: ThrowOSErr(errAEWrongDataType); } return result; }
/* Run one inverse FFT test in test mode */ float RunOneInverseTest(int fft_log_size, int signal_type, float signal_value, struct SnrResult* snr) { OMX_F32* x; OMX_FC32* y; OMX_F32* z; struct AlignedPtr* x_aligned; struct AlignedPtr* y_aligned; struct AlignedPtr* z_aligned; OMX_FC32* yTrue; struct AlignedPtr* yTrueAligned; OMX_INT n; OMX_INT fft_spec_buffer_size; OMXResult status; OMXFFTSpec_R_F32 * fft_fwd_spec = NULL; OMXFFTSpec_R_F32 * fft_inv_spec = NULL; int fft_size; fft_size = 1 << fft_log_size; status = omxSP_FFTGetBufSize_R_F32(fft_log_size, &fft_spec_buffer_size); if (verbose > 3) { printf("fft_spec_buffer_size = %d\n", fft_spec_buffer_size); } fft_inv_spec = (OMXFFTSpec_R_F32*)malloc(fft_spec_buffer_size); status = omxSP_FFTInit_R_F32(fft_inv_spec, fft_log_size); if (status) { fprintf(stderr, "Failed to init backward FFT: status = %d\n", status); exit(1); } x_aligned = AllocAlignedPointer(32, sizeof(*x) * fft_size); y_aligned = AllocAlignedPointer(32, sizeof(*y) * (fft_size / 2 + 1)); z_aligned = AllocAlignedPointer(32, sizeof(*z) * fft_size); yTrueAligned = AllocAlignedPointer(32, sizeof(*y) * (fft_size / 2 + 1)); x = x_aligned->aligned_pointer_; y = y_aligned->aligned_pointer_; z = z_aligned->aligned_pointer_; yTrue = yTrueAligned->aligned_pointer_; GenerateSignal(x, yTrue, fft_size, signal_type, signal_value); if (verbose > 255) { printf("input = %p - %p\n", yTrue, yTrue + fft_size / 2 + 1); printf("output = %p - %p\n", z, z + fft_size); DumpFFTSpec(fft_inv_spec); } if (verbose > 63) { printf("Inverse FFT Input Signal\n"); DumpArrayComplexFloat("y", 1 + fft_size / 2, yTrue); printf("Expected Inverse FFT output\n"); DumpArrayFloat("x", fft_size, x); } status = InverseRFFT((OMX_F32 *) yTrue, z, fft_inv_spec); if (status) { fprintf(stderr, "Inverse FFT failed: status = %d\n", status); exit(1); } if (verbose > 63) { printf("Actual Inverse FFT Output\n"); DumpArrayFloat("z", fft_size, z); } CompareFloat(snr, z, x, fft_size); FreeAlignedPointer(x_aligned); FreeAlignedPointer(y_aligned); FreeAlignedPointer(z_aligned); FreeAlignedPointer(yTrueAligned); free(fft_inv_spec); return snr->real_snr_; }
int CQueueListCtrl::SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { const CUpDownClient *item1 = (CUpDownClient *)lParam1; const CUpDownClient *item2 = (CUpDownClient *)lParam2; int iColumn = (lParamSort >= 100) ? lParamSort - 100 : lParamSort; int iResult = 0; switch (iColumn) { case 0: if (item1->GetUserName() && item2->GetUserName()) iResult = CompareLocaleStringNoCase(item1->GetUserName(), item2->GetUserName()); else if (item1->GetUserName() == NULL) iResult = 1; // place clients with no usernames at bottom else if (item2->GetUserName() == NULL) iResult = -1; // place clients with no usernames at bottom break; case 1: { const CKnownFile *file1 = theApp.sharedfiles->GetFileByID(item1->GetUploadFileID()); const CKnownFile *file2 = theApp.sharedfiles->GetFileByID(item2->GetUploadFileID()); if (file1 != NULL && file2 != NULL) iResult = CompareLocaleStringNoCase(file1->GetFileName(), file2->GetFileName()); else if (file1 == NULL) iResult = 1; else iResult = -1; break; } case 2: { const CKnownFile *file1 = theApp.sharedfiles->GetFileByID(item1->GetUploadFileID()); const CKnownFile *file2 = theApp.sharedfiles->GetFileByID(item2->GetUploadFileID()); if (file1 != NULL && file2 != NULL) // ==> PowerShare [ZZ/MorphXT] - Stulle // ==> Fair Play [AndCycle/Stulle] - Stulle { if (!file1->GetPowerShared() && !file1->statistic.GetFairPlay() && (file2->GetPowerShared() || file2->statistic.GetFairPlay())) iResult=-1; else if ((file1->GetPowerShared() || file1->statistic.GetFairPlay()) && !file2->GetPowerShared() && !file2->statistic.GetFairPlay()) iResult=1; else // <== Fair Play [AndCycle/Stulle] - Stulle // <== PowerShare [ZZ/MorphXT] - Stulle iResult = (file1->GetUpPriority() == PR_VERYLOW ? -1 : file1->GetUpPriority()) - (file2->GetUpPriority() == PR_VERYLOW ? -1 : file2->GetUpPriority()); } // PowerShare [ZZ/MorphXT] - Stulle else if (file1 == NULL) iResult = 1; else iResult = -1; break; } case 3: iResult = CompareUnsigned(item1->GetScore(false, false, true), item2->GetScore(false, false, true)); break; case 4: // ==> Superior Client Handling [Stulle] - Stulle if(!item1->IsSuperiorClient() && item2->IsSuperiorClient()) iResult=-1; else if(item1->IsSuperiorClient() && !item2->IsSuperiorClient()) iResult=1; else // <== Superior Client Handling [Stulle] - Stulle iResult = CompareUnsigned(item1->GetScore(false), item2->GetScore(false)); break; case 5: iResult = CompareUnsigned(item1->GetAskedCount(), item2->GetAskedCount()); break; case 6: iResult = CompareUnsigned(item1->GetLastUpRequest(), item2->GetLastUpRequest()); break; case 7: // ==> SUQWT [Moonlight/EastShare/ MorphXT] - Stulle /* iResult = CompareUnsigned(item1->GetWaitStartTime(), item2->GetWaitStartTime()); */ { sint64 time1 = item1->GetWaitStartTime(); sint64 time2 = item2->GetWaitStartTime(); if ( time1 == time2 ) { iResult = 0; } else if ( time1 > time2 ) { iResult = 1; } else { iResult = -1; } break; } // <== SUQWT [Moonlight/EastShare/ MorphXT] - Stulle break; case 8: iResult = item1->IsBanned() - item2->IsBanned(); break; case 9: // ==> Sort progress bars by percentage [Fafner/Xman] - Stulle /* iResult = CompareUnsigned(item1->GetUpPartCount(), item2->GetUpPartCount()); */ if (item1->GetHisCompletedPartsPercent_UP() == item2->GetHisCompletedPartsPercent_UP()) iResult=0; else iResult=item1->GetHisCompletedPartsPercent_UP() > item2->GetHisCompletedPartsPercent_UP()?1:-1; // <== Sort progress bars by percentage [Fafner/Xman] - Stulle break; //Xman version see clientversion in every window case 10: // Maella -Support for tag ET_MOD_VERSION 0x55- if(item1->GetClientSoft() == item2->GetClientSoft()) if(item1->GetVersion() == item2->GetVersion() && (item1->GetClientSoft() == SO_EMULE || item1->GetClientSoft() == SO_AMULE)){ iResult = item2->DbgGetFullClientSoftVer().CompareNoCase( item1->DbgGetFullClientSoftVer()); } else { iResult = item1->GetVersion() - item2->GetVersion(); } else iResult = -(item1->GetClientSoft() - item2->GetClientSoft()); // invert result to place eMule's at top break; //Xman show complete up/down in queuelist case 11: if(item1->Credits() && item2->Credits()) iResult=CompareUnsigned64(item1->credits->GetUploadedTotal(), item2->credits->GetUploadedTotal()); else iResult=0; break; //Xman end // ==> push small files [sivka] - Stulle case 12: iResult=item1->GetSmallFilePush() - item2->GetSmallFilePush(); break; // <== push small files [sivka] - Stulle // ==> push rare file - Stulle case 13: iResult=CompareFloat(item1->GetRareFilePushRatio(),item2->GetRareFilePushRatio()); break; // <== push rare file - Stulle } if (lParamSort >= 100) iResult = -iResult; // SLUGFILLER: multiSort remove - handled in parent class /* //call secondary sortorder, if this one results in equal int dwNextSort; if (iResult == 0 && (dwNextSort = theApp.emuledlg->transferwnd->GetQueueList()->GetNextSortOrder(lParamSort)) != -1) iResult = SortProc(lParam1, lParam2, dwNextSort); */ // SLUGFILLER: multiSort remove - handled in parent class return iResult; }
void TimeOneNE10RFFT(int count, int fft_log_size, float signal_value, int signal_type) { OMX_F32* x; /* Source */ OMX_FC32* y; /* Transform */ OMX_F32* z; /* Inverse transform */ OMX_F32* temp; OMX_F32* y_true; /* True FFT */ struct AlignedPtr* x_aligned; struct AlignedPtr* y_aligned; struct AlignedPtr* z_aligned; int n; ne10_result_t status; ne10_fft_r2c_cfg_float32_t fft_fwd_spec; int fft_size; struct timeval start_time; struct timeval end_time; double elapsed_time; struct SnrResult snr_forward; struct SnrResult snr_inverse; fft_size = 1 << fft_log_size; x_aligned = AllocAlignedPointer(32, sizeof(*x) * 4 * fft_size); /* The transformed value is in CCS format and is has fft_size + 2 values */ y_aligned = AllocAlignedPointer(32, sizeof(*y) * (4 * fft_size + 2)); z_aligned = AllocAlignedPointer(32, sizeof(*z) * 4 * fft_size); x = x_aligned->aligned_pointer_; y = y_aligned->aligned_pointer_; z = z_aligned->aligned_pointer_; y_true = (OMX_F32*) malloc(sizeof(*y_true) * (fft_size + 2)); GenerateRealFloatSignal(x, (struct ComplexFloat*) y_true, fft_size, signal_type, signal_value); fft_fwd_spec = ne10_fft_alloc_r2c_float32(fft_size); if (!fft_fwd_spec) { fprintf(stderr, "NE10 RFFT: Cannot initialize FFT structure for order %d\n", fft_log_size); return; } if (do_forward_test) { GetUserTime(&start_time); for (n = 0; n < count; ++n) { ne10_fft_r2c_1d_float32_neon((ne10_fft_cpx_float32_t *) y, x, fft_fwd_spec); } GetUserTime(&end_time); elapsed_time = TimeDifference(&start_time, &end_time); CompareComplexFloat(&snr_forward, (OMX_FC32*) y, (OMX_FC32*) y_true, fft_size / 2 + 1); PrintResult("Forward NE10 RFFT", fft_log_size, elapsed_time, count, snr_forward.complex_snr_); if (verbose >= 255) { printf("FFT Actual:\n"); DumpArrayComplexFloat("y", fft_size / 2 + 1, y); printf("FFT Expected:\n"); DumpArrayComplexFloat("true", fft_size / 2 + 1, (OMX_FC32*) y_true); } } if (do_inverse_test) { // Ne10 FFTs destroy the input. GetUserTime(&start_time); for (n = 0; n < count; ++n) { //memcpy(y, y_true, (fft_size >> 1) * sizeof(*y)); // The inverse appears not to be working. ne10_fft_c2r_1d_float32_neon(z, (ne10_fft_cpx_float32_t *) y_true, fft_fwd_spec); } GetUserTime(&end_time); elapsed_time = TimeDifference(&start_time, &end_time); CompareFloat(&snr_inverse, (OMX_F32*) z, (OMX_F32*) x, fft_size); PrintResult("Inverse NE10 RFFT", fft_log_size, elapsed_time, count, snr_inverse.complex_snr_); if (verbose >= 255) { printf("IFFT Actual:\n"); DumpArrayFloat("z", fft_size, z); printf("IFFT Expected:\n"); DumpArrayFloat("x", fft_size, x); } } ne10_fft_destroy_r2c_float32(fft_fwd_spec); FreeAlignedPointer(x_aligned); FreeAlignedPointer(y_aligned); FreeAlignedPointer(z_aligned); }
void TimeOneFloatRFFT(int count, int fft_log_size, float signal_value, int signal_type) { OMX_F32* x; /* Source */ OMX_F32* y; /* Transform */ OMX_F32* z; /* Inverse transform */ OMX_F32* y_true; /* True FFT */ struct AlignedPtr* x_aligned; struct AlignedPtr* y_aligned; struct AlignedPtr* z_aligned; struct AlignedPtr* y_true_aligned; OMX_INT n, fft_spec_buffer_size; OMXResult status; OMXFFTSpec_R_F32 * fft_fwd_spec = NULL; OMXFFTSpec_R_F32 * fft_inv_spec = NULL; int fft_size; struct timeval start_time; struct timeval end_time; double elapsed_time; struct SnrResult snr_forward; struct SnrResult snr_inverse; fft_size = 1 << fft_log_size; x_aligned = AllocAlignedPointer(32, sizeof(*x) * fft_size); /* The transformed value is in CCS format and is has fft_size + 2 values */ y_aligned = AllocAlignedPointer(32, sizeof(*y) * (fft_size + 2)); z_aligned = AllocAlignedPointer(32, sizeof(*z) * fft_size); y_true_aligned = AllocAlignedPointer(32, sizeof(*z) * (fft_size + 2)); x = x_aligned->aligned_pointer_; y = y_aligned->aligned_pointer_; z = z_aligned->aligned_pointer_; y_true = y_true_aligned->aligned_pointer_; GenerateRealFloatSignal(x, (OMX_FC32*) y_true, fft_size, signal_type, signal_value); status = omxSP_FFTGetBufSize_R_F32(fft_log_size, &fft_spec_buffer_size); fft_fwd_spec = (OMXFFTSpec_R_F32*) malloc(fft_spec_buffer_size); fft_inv_spec = (OMXFFTSpec_R_F32*) malloc(fft_spec_buffer_size); status = omxSP_FFTInit_R_F32(fft_fwd_spec, fft_log_size); status = omxSP_FFTInit_R_F32(fft_inv_spec, fft_log_size); if (do_forward_test) { GetUserTime(&start_time); for (n = 0; n < count; ++n) { FORWARD_FLOAT_RFFT(x, y, fft_fwd_spec); } GetUserTime(&end_time); elapsed_time = TimeDifference(&start_time, &end_time); CompareComplexFloat(&snr_forward, (OMX_FC32*) y, (OMX_FC32*) y_true, fft_size / 2 + 1); PrintResult("Forward Float RFFT", fft_log_size, elapsed_time, count, snr_forward.complex_snr_); } if (do_inverse_test) { GetUserTime(&start_time); for (n = 0; n < count; ++n) { INVERSE_FLOAT_RFFT(y_true, z, fft_inv_spec); } GetUserTime(&end_time); elapsed_time = TimeDifference(&start_time, &end_time); CompareFloat(&snr_inverse, (OMX_F32*) z, (OMX_F32*) x, fft_size); PrintResult("Inverse Float RFFT", fft_log_size, elapsed_time, count, snr_inverse.complex_snr_); } FreeAlignedPointer(x_aligned); FreeAlignedPointer(y_aligned); FreeAlignedPointer(z_aligned); free(fft_fwd_spec); free(fft_inv_spec); }
void TimeOnePfRFFT(int count, int fft_log_size, float signal_value, int signal_type) { struct AlignedPtr* x_aligned; struct AlignedPtr* y_aligned; struct AlignedPtr* z_aligned; struct AlignedPtr* y_tmp_aligned; float* x; struct ComplexFloat* y; OMX_F32* z; float* y_true; float* y_tmp; int n; int fft_size; struct timeval start_time; struct timeval end_time; double elapsed_time; PFFFT_Setup *s; struct SnrResult snr_forward; struct SnrResult snr_inverse; fft_size = 1 << fft_log_size; x_aligned = AllocAlignedPointer(32, sizeof(*x) * fft_size); y_aligned = AllocAlignedPointer(32, sizeof(*y) * (fft_size + 2)); z_aligned = AllocAlignedPointer(32, sizeof(*z) * fft_size); y_tmp_aligned = AllocAlignedPointer(32, sizeof(*y_tmp) * (fft_size + 2)); y_true = (float*) malloc(sizeof(*y_true) * 2 * fft_size); x = x_aligned->aligned_pointer_; y = y_aligned->aligned_pointer_; z = z_aligned->aligned_pointer_; y_tmp = y_tmp_aligned->aligned_pointer_; s = pffft_new_setup(fft_size, PFFFT_REAL); if (!s) { fprintf(stderr, "TimeOnePfRFFT: Could not initialize structure for order %d\n", fft_log_size); } GenerateRealFloatSignal(x, (struct ComplexFloat*) y_true, fft_size, signal_type, signal_value); if (do_forward_test) { GetUserTime(&start_time); for (n = 0; n < count; ++n) { pffft_transform_ordered(s, (float*)x, (float*)y, NULL, PFFFT_FORWARD); } GetUserTime(&end_time); elapsed_time = TimeDifference(&start_time, &end_time); /* * Arrange the output of the FFT to match the expected output. */ y[fft_size / 2].Re = y[0].Im; y[fft_size / 2].Im = 0; y[0].Im = 0; CompareComplexFloat(&snr_forward, (OMX_FC32*) y, (OMX_FC32*) y_true, fft_size / 2 + 1); PrintResult("Forward PFFFT RFFT", fft_log_size, elapsed_time, count, snr_forward.complex_snr_); if (verbose >= 255) { printf("FFT Actual:\n"); DumpArrayComplexFloat("y", fft_size / 2 + 1, (OMX_FC32*) y); printf("FFT Expected:\n"); DumpArrayComplexFloat("true", fft_size / 2 + 1, (OMX_FC32*) y_true); } } if (do_inverse_test) { float scale = 1.0 / fft_size; /* Copy y_true to true, but arrange the values according to what rdft wants. */ memcpy(y_tmp, y_true, sizeof(y_tmp[0]) * fft_size); y_tmp[1] = y_true[fft_size / 2]; GetUserTime(&start_time); for (n = 0; n < count; ++n) { int m; pffft_transform_ordered(s, (float*)y_tmp, (float*)z, NULL, PFFFT_BACKWARD); /* * Need to include cost of scaling the inverse */ ScaleVector(z, fft_size, fft_size); } GetUserTime(&end_time); elapsed_time = TimeDifference(&start_time, &end_time); CompareFloat(&snr_inverse, (OMX_F32*) z, (OMX_F32*) x, fft_size); PrintResult("Inverse PFFFT RFFT", fft_log_size, elapsed_time, count, snr_inverse.complex_snr_); if (verbose >= 255) { printf("IFFT Actual:\n"); DumpArrayFloat("z", fft_size, z); printf("IFFT Expected:\n"); DumpArrayFloat("x", fft_size, x); } } FreeAlignedPointer(x_aligned); FreeAlignedPointer(y_aligned); FreeAlignedPointer(z_aligned); FreeAlignedPointer(y_tmp_aligned); pffft_destroy_setup(s); free(y_true); }