MCPcopy Create free account
hub / github.com/FreeFem/FreeFem-sources / cmaes_WriteToFilePtr

Function cmaes_WriteToFilePtr

plugin/seq/cmaes.cpp:1034–1528  ·  view source on GitHub ↗

--------------------------------------------------------- */

Source from the content-addressed store, hash-verified

1032
1033/* --------------------------------------------------------- */
1034void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) {
1035 /* this hack reads key words from input key for data to be written to
1036 * a file, see file signals.par as input file. The length of the keys
1037 * is mostly fixed, see key += number in the code! If the key phrase
1038 * does not match the expectation the output might be strange. for
1039 * cmaes_t *t == 0 it solely prints key as a header line. Input key
1040 * must be zero terminated.
1041 */
1042 int i, k, N = (t ? t->sp.N : 0);
1043 char const *keyend;
1044 const char *s = "few";
1045
1046 if (key == nullptr) {
1047 key = s;
1048 }
1049
1050 keyend = key + strlen(key);
1051
1052 while (key < keyend) {
1053 if (strncmp(key, "axisratio", 9) == 0) {
1054 fprintf(fp, "%.2e", sqrt(t->maxEW / t->minEW));
1055
1056 while (*key != '+' && *key != '\0' && key < keyend) {
1057 ++key;
1058 }
1059
1060 fprintf(fp, "%c", (*key == '+') ? '\t' : '\n');
1061 }
1062
1063 if (strncmp(key, "idxminSD", 8) == 0) {
1064 int mini = 0;
1065
1066 for (i = N - 1; i > 0; --i) {
1067 if (t->mindiagC == t->C[i][i]) {
1068 mini = i;
1069 }
1070 }
1071
1072 fprintf(fp, "%d", mini + 1);
1073
1074 while (*key != '+' && *key != '\0' && key < keyend) {
1075 ++key;
1076 }
1077
1078 fprintf(fp, "%c", (*key == '+') ? '\t' : '\n');
1079 }
1080
1081 if (strncmp(key, "idxmaxSD", 8) == 0) {
1082 int maxi = 0;
1083
1084 for (i = N - 1; i > 0; --i) {
1085 if (t->maxdiagC == t->C[i][i]) {
1086 maxi = i;
1087 }
1088 }
1089
1090 fprintf(fp, "%d", maxi + 1);
1091

Callers 2

cmaes_WriteToFileAWFunction · 0.85
cmaes_ReadFromFilePtrFunction · 0.85

Calls 12

new_voidFunction · 0.85
Sorted_indexFunction · 0.85
timings_updateFunction · 0.85
rgdouMaxFunction · 0.85
rgdouMinFunction · 0.85
MaxIdxFunction · 0.85
MinIdxFunction · 0.85
cmaes_GetFunction · 0.85
ERRORMESSAGEFunction · 0.85
FATALFunction · 0.85
sqrtFunction · 0.50
qsortClass · 0.50

Tested by

no test coverage detected