| 2977 | |
| 2978 | |
| 2979 | double cTaskLib::Task_Log(cTaskContext& ctx) const |
| 2980 | { |
| 2981 | double quality = 0.0; |
| 2982 | const cArgContainer& args = ctx.GetTaskEntry()->GetArguments(); |
| 2983 | |
| 2984 | const tBuffer<int>& input_buffer = ctx.GetInputBuffer(); |
| 2985 | const long long test_output = ctx.GetOutputBuffer()[0]; |
| 2986 | const int input_size = input_buffer.GetNumStored(); |
| 2987 | |
| 2988 | long long diff = ((long long)INT_MAX + 1) * 2; |
| 2989 | |
| 2990 | for (int i = 0; i < input_size; i ++) { |
| 2991 | long long cur_diff = ::llabs((long long)(log(fabs(double(input_buffer[i] ? input_buffer[i] : 1)))) - test_output); |
| 2992 | if (cur_diff < diff) diff = cur_diff; |
| 2993 | } |
| 2994 | |
| 2995 | int threshold = args.GetInt(0); |
| 2996 | |
| 2997 | if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite |
| 2998 | // If within threshold range, quality decays based on absolute difference |
| 2999 | double halflife = -1.0 * fabs(args.GetDouble(0)); |
| 3000 | quality = pow(2.0, static_cast<double>(diff) / halflife); |
| 3001 | } |
| 3002 | |
| 3003 | return quality; |
| 3004 | } |
| 3005 | |
| 3006 | |
| 3007 | void cTaskLib::Load_Log2(const cString& name, const cString& argstr, cEnvReqs&, Feedback& feedback) |
nothing calls this directly
no test coverage detected