| 2932 | |
| 2933 | |
| 2934 | double cTaskLib::Task_Div(cTaskContext& ctx) const |
| 2935 | { |
| 2936 | double quality = 0.0; |
| 2937 | const cArgContainer& args = ctx.GetTaskEntry()->GetArguments(); |
| 2938 | |
| 2939 | const tBuffer<int>& input_buffer = ctx.GetInputBuffer(); |
| 2940 | const long long test_output = ctx.GetOutputBuffer()[0]; |
| 2941 | const int input_size = input_buffer.GetNumStored(); |
| 2942 | |
| 2943 | long long diff = ((long long)INT_MAX + 1) * 2; |
| 2944 | |
| 2945 | for (int i = 0; i < input_size; i ++) { |
| 2946 | for (int j = 0; j < input_size; j ++) { |
| 2947 | if (i == j || input_buffer[j] == 0) continue; |
| 2948 | long long cur_diff = ::llabs((long long)(input_buffer[i] / input_buffer[j]) - test_output); |
| 2949 | if (cur_diff < diff) diff = cur_diff; |
| 2950 | } |
| 2951 | } |
| 2952 | |
| 2953 | int threshold = args.GetInt(0); |
| 2954 | |
| 2955 | if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite |
| 2956 | // If within threshold range, quality decays based on absolute difference |
| 2957 | double halflife = -1.0 * fabs(args.GetDouble(0)); |
| 2958 | quality = pow(2.0, static_cast<double>(diff) / halflife); |
| 2959 | } |
| 2960 | |
| 2961 | return quality; |
| 2962 | } |
| 2963 | |
| 2964 | |
| 2965 | void cTaskLib::Load_Log(const cString& name, const cString& argstr, cEnvReqs&, Feedback& feedback) |
nothing calls this directly
no test coverage detected