<commit_before>//===--- Error.swift ------------------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import ComplexModule

public func relativeError(_ tst: Float, _ ref: Double) -> Double {
  let scale = max(ref.magnitude, Double(Float.leastNormalMagnitude))
  let error = (Double(tst) - ref).magnitude
  return error / scale
}

public func componentwiseError(_ tst: Complex<Float>, _ ref: Complex<Double>) -> Double {
  return max(relativeError(tst.real, ref.real),
             relativeError(tst.imaginary, ref.imaginary))
}

public func relativeError(_ tst: Complex<Float>, _ ref: Complex<Double>) -> Double {
  let scale = max(ref.magnitude, Double(Float.leastNormalMagnitude))
  let dtst = Complex(Double(tst.real), Double(tst.imaginary))
  let error = (dtst - ref).magnitude
  return error / scale
}<commit_msg>Add missing import required to use a conformance<commit_after>//===--- Error.swift ------------------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import ComplexModule
import RealModule

public func relativeError(_ tst: Float, _ ref: Double) -> Double {
  let scale = max(ref.magnitude, Double(Float.leastNormalMagnitude))
  let error = (Double(tst) - ref).magnitude
  return error / scale
}

public func componentwiseError(_ tst: Complex<Float>, _ ref: Complex<Double>) -> Double {
  return max(relativeError(tst.real, ref.real),
             relativeError(tst.imaginary, ref.imaginary))
}

public func relativeError(_ tst: Complex<Float>, _ ref: Complex<Double>) -> Double {
  let scale = max(ref.magnitude, Double(Float.leastNormalMagnitude))
  let dtst = Complex(Double(tst.real), Double(tst.imaginary))
  let error = (dtst - ref).magnitude
  return error / scale
}
{'fraction_non_alphanumeric': 0.2101534828807556, 'fraction_numerical': 0.004722550177095631, 'mean_word_length': 2.6210826210826212, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5302193', 'n_tokens_mistral': 715, 'n_tokens_neox': 675, 'n_words': 217}