int main(void) { unsigned char i; double sum_t = 0; double sum_p = 0; printf("%s %5s %5s\n", "T", "E(T)", "T(E(T))"); printf("----------------\n"); for (i = 10; i < 31; i++) { sum_p = reference_function(i); sum_t = inverse_function(sum_p); printf("%2d %2.3lf %2.3lf\n", i, sum_p, sum_t); } printf("\n%s %8s %5s\n", "E", "T(E)", "E(T(E))"); printf("-------------------\n"); for (i = 0; i < 15; i++) { sum_t = inverse_function(test_potentials[i]); sum_p = reference_function(sum_t); printf("%1.3lf %2.3lf %3.3lf\n", test_potentials[i], sum_t, sum_p); } return 0; }
int temperature(float thermocouple_voltage, int thermistor_voltage) { // the thermocouple voltage is amplified // aproximatelly 300 times float v_tc = thermocouple_voltage / 300; float v_ref = reference_function(reference_temperature(thermistor_voltage)); return inverse_function(v_tc + v_ref); }
static void check_functions( parasail_function_group_t f, char **sequences, unsigned long *sizes, unsigned long pair_limit, const parasail_matrix_t *matrix_, gap_score_t gap) { const parasail_function_info_t *functions = f.fs; unsigned long matrix_index = 0; unsigned long gap_index = 0; unsigned long function_index = 0; unsigned long pair_index = 0; parasail_function_t *reference_function = NULL; const parasail_matrix_t ** matrices = parasail_matrices; const parasail_matrix_t * single_matrix[] = { matrix_, NULL }; if (NULL != matrix_) { matrices = single_matrix; } printf("checking %s functions\n", f.name); for (matrix_index=0; NULL!=matrices[matrix_index]; ++matrix_index) { const parasail_matrix_t *matrix = matrices[matrix_index]; const char *matrixname = matrix->name; if (verbose) printf("\t%s\n", matrixname); for (gap_index=0; INT_MIN!=gap_scores[gap_index].open; ++gap_index) { int open = gap_scores[gap_index].open; int extend = gap_scores[gap_index].extend; if (gap.open != INT_MIN && gap.extend != INT_MIN) { open = gap.open; extend = gap.extend; } if (verbose) printf("\t\topen=%d extend=%d\n", open, extend); reference_function = functions[0].pointer; for (function_index=1; NULL!=functions[function_index].pointer; ++function_index) { if (verbose) printf("\t\t\t%s\n", functions[function_index].name); unsigned long saturated = 0; #pragma omp parallel for for (pair_index=0; pair_index<pair_limit; ++pair_index) { parasail_result_t *reference_result = NULL; parasail_result_t *result = NULL; unsigned long a = 0; unsigned long b = 1; k_combination2(pair_index, &a, &b); //printf("\t\t\t\tpair=%lu (%lu,%lu)\n", pair_index, a, b); reference_result = reference_function( sequences[a], sizes[a], sequences[b], sizes[b], open, extend, matrix); result = functions[function_index].pointer( sequences[a], sizes[a], sequences[b], sizes[b], open, extend, matrix); if (result->saturated) { /* no point in comparing a result that saturated */ parasail_result_free(reference_result); parasail_result_free(result); #pragma omp atomic saturated += 1; continue; } if (reference_result->score != result->score) { #pragma omp critical(printer) { printf("%s(%lu,%lu,%d,%d,%s) wrong score (%d!=%d)\n", functions[function_index].name, a, b, open, extend, matrixname, reference_result->score, result->score); } } if (reference_result->end_query != result->end_query) { #pragma omp critical(printer) { printf("%s(%lu,%lu,%d,%d,%s) wrong end_query (%d!=%d)\n", functions[function_index].name, a, b, open, extend, matrixname, reference_result->end_query, result->end_query); } } if (reference_result->end_ref != result->end_ref) { #pragma omp critical(printer) { printf("%s(%lu,%lu,%d,%d,%s) wrong end_ref (%d!=%d)\n", functions[function_index].name, a, b, open, extend, matrixname, reference_result->end_ref, result->end_ref); } } if (reference_result->matches != result->matches) { #pragma omp critical(printer) { printf("%s(%lu,%lu,%d,%d,%s) wrong matches (%d!=%d)\n", functions[function_index].name, a, b, open, extend, matrixname, reference_result->matches, result->matches); } } if (reference_result->similar != result->similar) { #pragma omp critical(printer) { printf("%s(%lu,%lu,%d,%d,%s) wrong similar (%d!=%d)\n", functions[function_index].name, a, b, open, extend, matrixname, reference_result->similar, result->similar); } } if (reference_result->length != result->length) { #pragma omp critical(printer) { printf("%s(%lu,%lu,%d,%d,%s) wrong length (%d!=%d)\n", functions[function_index].name, a, b, open, extend, matrixname, reference_result->length, result->length); } } parasail_result_free(reference_result); parasail_result_free(result); } if (verbose && saturated) { printf("%s %d %d %s saturated %lu times\n", functions[function_index].name, open, extend, matrixname, saturated); } } if (gap.open != INT_MIN && gap.extend != INT_MIN) { /* user-specified gap, don't loop */ break; } } } }