| 3060 | |
| 3061 | |
| 3062 | double cTaskLib::Task_Log10(cTaskContext& ctx) const |
| 3063 | { |
| 3064 | double quality = 0.0; |
| 3065 | const cArgContainer& args = ctx.GetTaskEntry()->GetArguments(); |
| 3066 | |
| 3067 | const tBuffer<int>& input_buffer = ctx.GetInputBuffer(); |
| 3068 | const long long test_output = ctx.GetOutputBuffer()[0]; |
| 3069 | const int input_size = input_buffer.GetNumStored(); |
| 3070 | |
| 3071 | long long diff = ((long long)INT_MAX + 1) * 2; |
| 3072 | |
| 3073 | for (int i = 0; i < input_size; i ++) { |
| 3074 | long long cur_diff = ::llabs((long long)(log10(fabs(double(input_buffer[i] ? input_buffer[i] : 1)))) - test_output); |
| 3075 | if (cur_diff < diff) diff = cur_diff; |
| 3076 | } |
| 3077 | |
| 3078 | int threshold = args.GetInt(0); |
| 3079 | |
| 3080 | if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite |
| 3081 | // If within threshold range, quality decays based on absolute difference |
| 3082 | double halflife = -1.0 * fabs(args.GetDouble(0)); |
| 3083 | quality = pow(2.0, static_cast<double>(diff) / halflife); |
| 3084 | } |
| 3085 | |
| 3086 | return quality; |
| 3087 | } |
| 3088 | |
| 3089 | |
| 3090 | void cTaskLib::Load_Sqrt(const cString& name, const cString& argstr, cEnvReqs&, Feedback& feedback) |
nothing calls this directly
no test coverage detected