void fft(CArray& x) { const size_t N = x.size(); if (N <= 1) return; CArray even = x[std::slice(0, N / 2, 2)]; CArray odd = x[std::slice(1, N / 2, 2)]; fft(even); fft(odd); for (size_t k = 0; k < N / 2; ++k) { Complex t = std::polar(1.0, -2 * PI * k / N) * odd[k]; x[k] = even[k] + t; x[k + N / 2] = even[k] - t; } }
// Search java.exe in the environment int findJavaInEnvPath(CPath *outJavaPath) { SetLastError(0); int currVersion = 0; const char* envPath = getenv("JAVA_HOME"); if (envPath != NULL) { CPath p(envPath); currVersion = checkBinPath(&p); if (currVersion > 0) { if (gIsDebug) { fprintf(stderr, "Java %d found via JAVA_HOME: %s\n", currVersion, p.cstr()); } *outJavaPath = p; } if (currVersion >= MIN_JAVA_VERSION) { // As an optimization for runtime, if we find a suitable java // version in JAVA_HOME we won't waste time looking at the PATH. return currVersion; } } envPath = getenv("PATH"); if (!envPath) return currVersion; // Otherwise look at the entries in the current path. // If we find more than one, keep the one with the highest version. CArray<CString> *paths = CString(envPath).split(';'); for(int i = 0; i < paths->size(); i++) { CPath p((*paths)[i].cstr()); int v = checkPath(&p); if (v > currVersion) { if (gIsDebug) { fprintf(stderr, "Java %d found via env PATH: %s\n", v, p.cstr()); } currVersion = v; *outJavaPath = p; } } delete paths; return currVersion; }
void FftLib::fft(CArray &signal) { const size_t signal_size = signal.size(); if (signal_size <= 1) return; // divide: Splitting in even and odd part of the signal CArray even = signal[std::slice(0, signal_size / 2, 2)]; CArray odd = signal[std::slice(1, signal_size / 2, 2)]; // conquer: Recursive call with the previously splitted signal. fft(even); fft(odd); // combine for (size_t k = 0; k < signal_size / 2; ++k) { ComplexDouble t = std::polar(1.0, -2 * kPI * k / signal_size) * odd[k]; signal[k] = even[k] + t; signal[k + signal_size / 2] = even[k] - t; } }
// Cooley–Tukey FFT (in-place) inline void fft(CArray& x) { const size_t N = x.size(); if (N <= 1) return; // divide CArray even = x[std::slice(0, N/2, 2)]; CArray odd = x[std::slice(1, N/2, 2)]; // conquer fft(even); fft(odd); // combine for (size_t k = 0; k < N/2; ++k) { Complex t = std::polar(1.0f, -2 * float(M_PI) * k / N) * odd[k]; x[k ] = even[k] + t; x[k+N/2] = even[k] - t; } }
int Management_Connection::X_PropertyScan (Array < PropertyInfo > &p) { p.resize (0); PropertyInfo p1; uchar obj, i; obj = 0; do { i = 0; do { p1.obj = obj; p1.property = 0; if (A_Property_Desc (obj, p1.property, i, p1.type, p1.count, p1.access) == -1) return -1; if (p1.property == 1 && p1.type == 4) { CArray a; if (A_Property_Read (obj, 1, 1, 1, a) == -1) return -1; if (a.size() != 2) return -1; p1.count = (a[0] << 8) | (a[1]); } if (p1.property != 0) p.push_back (p1); i++; } while (p1.property != 0); obj++; } while (i != 1); return 0; }
void ifft(CArray& x){ x = x.apply(std::conj); fft(x); x= x.apply(std::conj); x /= x.size(); }
st_bool CCommandLineParser::ParseCommandLineFile(const char* pFilename, const char* pExeName, SUserSettings& sConfig) { st_bool bSuccess = false; FILE* pFile = fopen(pFilename, "r"); if (pFile) { // parse the cmd-line options in the file and store in an array of arguments CArray<CFixedString> aArguments; CFixedString strTemp; st_bool bInQuotes = false; while (!feof(pFile)) { st_char chTemp = (st_char)fgetc(pFile); st_bool bSaveString = false; if (chTemp == '#') { // skip rest of comment line while (!feof(pFile) && (chTemp != '\r' && chTemp != '\n')) chTemp = (st_char)fgetc(pFile); bSaveString = true; } else if (chTemp == '\"') { // quote delimited string if (bInQuotes) bSaveString = true; bInQuotes = !bInQuotes; } else if (!bInQuotes && (chTemp == ' ' || chTemp == '\r' || chTemp == '\n')) { // other whitespace bSaveString = true; } else { strTemp += chTemp; } if (bSaveString && !strTemp.empty( )) { // save this string as an argument aArguments.push_back(strTemp); strTemp.resize(0); } } fclose(pFile); // convert the array to a standard argv-type data structure const st_int32 c_nNumArgs = st_int32(aArguments.size( ) + 1); char** argv = new char*[c_nNumArgs]; for (st_int32 i = 1; i < c_nNumArgs; ++i) argv[i] = (char*) aArguments[i - 1].c_str( ); argv[0] = (char*) pExeName; // normally contains the exe name // feed back into the parse routine bSuccess = Parse(c_nNumArgs, argv, sConfig); delete [] argv; } return bSuccess; }