[
  {
    "path": ".gitignore",
    "content": "*.so\n*.dylib\nDarwin/\nDarwin.tgz\nLinux/\nLinux.tgz\n*.swp\nintel64/\n__pycache__\n.DS_Store\n/.build\n/Packages\n/*.xcodeproj\n"
  },
  {
    "path": "Makefile",
    "content": "ifeq ($(mode),)\nmode := debug\nendif\n\nlink_args := -Xswiftc -Ounchecked $(addprefix -Xcc ,-O2 -ffast-math -ffp-contract=fast -march=native)\n\ngybs := $(shell find Sources Tests -type f -name '*.gyb')\nconv_gybs := $(patsubst %.gyb,%,$(gybs))\nsources := $(conv_gybs) $(shell find Sources Tests -type f -name '*.swift')\nsources := $(sources) $(shell find Sources Tests -type f -name '*.cpp')\nheaders := $(sources) $(shell find Sources Tests -type f -name '*.hpp')\nsources := $(sources) $(shell find Sources Tests -type f -name '*.c')\nheaders := $(sources) $(shell find Sources Tests -type f -name '*.h')\nsources := $(sources) $(headers)\n\nyaml := ./.build/${mode}.yaml\nrun_args := -c $(mode) $(link_args)\n\nall: $(yaml)\n\nrun: $(yaml)\n\t$(prefix) swift run $(run_args)\n\ntest: $(yaml)\n\t$(prefix) swift test $(run_args)\n\n$(yaml): gyb\n\tswift build -v $(run_args)\n\nTests/LinuxMain.swift: Tests/BaseMathTests/BaseMathTests.swift\n\ngyb: $(sources)\n\n%.swift: %.swift.gyb\n\tgyb --line-directive '' -o $@ $<\n\n%.c: %.c.gyb\n\tgyb --line-directive '' -o $@ $<\n\n%.h: %.h.gyb\n\tgyb --line-directive '' -o $@ $<\n\n%.cpp: %.cpp.gyb\n\tgyb --line-directive '' -o $@ $<\n\n%.hpp: %.hpp.gyb\n\tgyb --line-directive '' -o $@ $<\n\nSources/BaseMath/BaseRandom.swift Sources/BaseMath/CBaseRandom.swift Sources/BaseMath/BaseMath.swift Sources/BaseMath/BaseVector.swift Sources/CBaseMath/CBaseMath.cpp: mathfuncs.py cpp_template.py cpp_types.py c2swift.py\nSources/CBaseMath/include/CBaseMath.h: Sources/CBaseMath/CBaseMath.cpp\nSources/CBaseMath/include/CBaseRandom.h: Sources/CBaseMath/CBaseRandom.cpp\n\n.PHONY: clean   \nclean:\n\trm -rf .build $(conv_gybs)\n\n"
  },
  {
    "path": "Package.swift",
    "content": "// swift-tools-version:4.2\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"BaseMath\",\n    products: [\n      .library( name: \"BaseMath\", targets: [\"BaseMath\"]),\n    ],\n    targets: [\n        .target( name: \"CBaseMath\"),\n        .target( name: \"BaseMath\", dependencies: [\"CBaseMath\"]),\n        .testTarget( name: \"BaseMathTests\", dependencies: [\"BaseMath\"]),\n        .target( name: \"bench\", dependencies: [\"BaseMath\"]),\n    ]\n)\n\n"
  },
  {
    "path": "README.md",
    "content": "# BaseMath\n\nBasic math functions for float and double arrays in Swift for Mac or Linux, with no dependencies, via the `BaseVector` protocol. They are generally around 3-5x faster than standard swift loops or maps, since they use pointers, which avoids the overhead of Swift's copy-on-write checking. The following functions are provided (all also have a version suffixed with `_` and a version prefixed with `sum` - see below of details):\n\n- Binary functions,: `sqr`, `abs`, `min`, `max`, `pow`, `atan2`, `copysign`, `fdim`, `fmax`, `fmin`, `hypot`, `nextafter`, `add`, `sub`, `mul`, `div`, `subRev`, `divRev`\n- Unary functions,: `acos`, `acosh`, `asin`, `asinh`, `atan`, `atanh`, `cbrt`, `cos`, `cosh`, `erf`, `erfc`, `exp`, `exp2`, `expm1`, `log`, `log10`, `log1p`, `log2`, `logb`, `nearbyint`, `rint`, `sin`, `sinh`, `tan`, `tanh`, `tgamma`\n\nUse it with Swift Package Manager by adding to your `Package.swift`:\n\n    dependencies: [\n        .package(url:\"https://github.com/jph00/BaseMath.git\", from: \"1.0.0\"),\n    ]\n\nFor reasonable performance, compile with `make` (which is also required if you make changes to the `gyb` templates) or use:\n\n    swift build -Xswiftc -Ounchecked -Xcc -ffast-math -Xcc -O2 -Xcc -march=native\n\nThis library is used by [SwiftyMKL](https://github.com/jph00/SwiftyMKL), which adds more optimized versions of the functions from Intel's Performance Libraries, along with various linear algebra and statistical functions.\n\nMath functions from `Foundation` (which in turn provides the functions available in `math.h`) are used, except for `sum()` (and `sum${f}()`, where `${f}` is a function name from `math.h`), which are written in C, since reductions in Swift are currently not vectorized. The standard math operators are also provided, including optimized assignment versions. Functions with `_` suffix are in-place. In addition the `sqr` function is provided. Note that `abs` is called `fabs` in C versions since that's what it's called in `math.h`.\n\nBecause the library uses pointers, Swift's copy-on-write and `let` immutability are bypassed. Use the provided `copy()` method to get a real copy of an `Array`.\n\nTo avoid surprises, you might prefer to use the provided `AlignedStorage` struct, which supports much of the same functionality as `Array`, but doesn't use copy-on-write, and aligns memory for (sometimes) better performance. In addition, `UnsafeMutableBufferPointer` is extended to conform to `BaseVector` so it also gets the same functionality.\n\nAfter `import BaseVector` you'll find that all the standard unary and binary math functions have been added to `Array` for floats and doubles, along with reduction versions of each which start with `sum` (e.g `sumabs`, `sumcos`, etc).\n\nSee the test suite for examples of use (note that tests won't run on Mac due to objective-c xctest issues). For more information on background and implementation details, see [this article] \\(TBA).\n\n"
  },
  {
    "path": "Sources/BaseMath/BaseMath.swift",
    "content": "import Foundation\nimport CBaseMath\n\n\nextension BinaryFloatingPoint where Self: CVarArg {\n  public func string(_ digits:Int) -> String { return String(format: \"%.\\(digits)f\", self) }\n}\n\nprecedencegroup ExponentiationPrecedence { associativity: right higherThan: MultiplicationPrecedence }\ninfix operator ^^: ExponentiationPrecedence\n\npublic extension Numeric {\n  typealias Element=Self\n  typealias PtrT = UnsafePointer<Element> \n  typealias MutPtrT = UnsafeMutablePointer<Element>\n}\n\npublic protocol SupportsBasicMath:BinaryFloatingPoint {\n  init(_ value: Self)\n  init()\n\n  var nsNumber:NSNumber {get}\n\n  func add(_ b: Self) -> Self\n  func sub(_ b: Self) -> Self\n  func mul(_ b: Self) -> Self\n  func div(_ b: Self) -> Self\n  func subRev(_ b: Self) -> Self\n  func divRev(_ b: Self) -> Self\n  func min(_ b: Self) -> Self\n  func max(_ b: Self) -> Self\n  func pow(_ b: Self) -> Self\n  func atan2(_ b: Self) -> Self\n  func copysign(_ b: Self) -> Self\n  func fdim(_ b: Self) -> Self\n  func fmax(_ b: Self) -> Self\n  func fmin(_ b: Self) -> Self\n  func hypot(_ b: Self) -> Self\n  func nextafter(_ b: Self) -> Self\n  func sqrt() -> Self\n  func acos() -> Self\n  func acosh() -> Self\n  func asin() -> Self\n  func asinh() -> Self\n  func atan() -> Self\n  func atanh() -> Self\n  func cbrt() -> Self\n  func cos() -> Self\n  func cosh() -> Self\n  func erf() -> Self\n  func erfc() -> Self\n  func exp() -> Self\n  func exp2() -> Self\n  func expm1() -> Self\n  func log() -> Self\n  func log10() -> Self\n  func log1p() -> Self\n  func log2() -> Self\n  func logb() -> Self\n  func nearbyint() -> Self\n  func rint() -> Self\n  func sin() -> Self\n  func sinh() -> Self\n  func tan() -> Self\n  func tanh() -> Self\n  func tgamma() -> Self\n\n  static func sqr(_ a:Self) -> Self\n  func sqr() -> Self\n  func abs() -> Self\n  static func sum(_ a:PtrT, _ n:Int32) -> Element\n  static func sumabs(_ a:PtrT, _ n:Int32)->Element\n  static func sumsqrt(_ a:PtrT, _ n:Int32)->Element\n  static func sumacos(_ a:PtrT, _ n:Int32)->Element\n  static func sumacosh(_ a:PtrT, _ n:Int32)->Element\n  static func sumasin(_ a:PtrT, _ n:Int32)->Element\n  static func sumasinh(_ a:PtrT, _ n:Int32)->Element\n  static func sumatan(_ a:PtrT, _ n:Int32)->Element\n  static func sumatanh(_ a:PtrT, _ n:Int32)->Element\n  static func sumcbrt(_ a:PtrT, _ n:Int32)->Element\n  static func sumcos(_ a:PtrT, _ n:Int32)->Element\n  static func sumcosh(_ a:PtrT, _ n:Int32)->Element\n  static func sumerf(_ a:PtrT, _ n:Int32)->Element\n  static func sumerfc(_ a:PtrT, _ n:Int32)->Element\n  static func sumexp(_ a:PtrT, _ n:Int32)->Element\n  static func sumexp2(_ a:PtrT, _ n:Int32)->Element\n  static func sumexpm1(_ a:PtrT, _ n:Int32)->Element\n  static func sumlog(_ a:PtrT, _ n:Int32)->Element\n  static func sumlog10(_ a:PtrT, _ n:Int32)->Element\n  static func sumlog1p(_ a:PtrT, _ n:Int32)->Element\n  static func sumlog2(_ a:PtrT, _ n:Int32)->Element\n  static func sumlogb(_ a:PtrT, _ n:Int32)->Element\n  static func sumnearbyint(_ a:PtrT, _ n:Int32)->Element\n  static func sumrint(_ a:PtrT, _ n:Int32)->Element\n  static func sumsin(_ a:PtrT, _ n:Int32)->Element\n  static func sumsinh(_ a:PtrT, _ n:Int32)->Element\n  static func sumtan(_ a:PtrT, _ n:Int32)->Element\n  static func sumtanh(_ a:PtrT, _ n:Int32)->Element\n  static func sumtgamma(_ a:PtrT, _ n:Int32)->Element\n  static func sumsqr(_ a:PtrT, _ n:Int32)->Element\n\n  static func ^^(x:Self, a:Self) -> Self\n}\n\nextension Float : SupportsBasicMath {\n  public var nsNumber:NSNumber { return NSNumber(value: self) }\n\n  @inlinable public func add(_ b: Float) -> Float {return self + b}\n  @inlinable public func sub(_ b: Float) -> Float {return self - b}\n  @inlinable public func mul(_ b: Float) -> Float {return self * b}\n  @inlinable public func div(_ b: Float) -> Float {return self / b}\n\n  @inlinable public static func sqr(_ a:Float) -> Float {return  a  * a  }\n  @inlinable public        func sqr(        ) -> Float {return self*self}\n\n  @inlinable public func subRev(_ b: Float) -> Float {return b - self}\n  @inlinable public func divRev(_ b: Float) -> Float {return b / self}\n\n  @inlinable public func sqrt() -> Float {return Foundation.sqrt(self)}\n  @inlinable public func acos() -> Float {return Foundation.acos(self)}\n  @inlinable public func acosh() -> Float {return Foundation.acosh(self)}\n  @inlinable public func asin() -> Float {return Foundation.asin(self)}\n  @inlinable public func asinh() -> Float {return Foundation.asinh(self)}\n  @inlinable public func atan() -> Float {return Foundation.atan(self)}\n  @inlinable public func atanh() -> Float {return Foundation.atanh(self)}\n  @inlinable public func cbrt() -> Float {return Foundation.cbrt(self)}\n  @inlinable public func cos() -> Float {return Foundation.cos(self)}\n  @inlinable public func cosh() -> Float {return Foundation.cosh(self)}\n  @inlinable public func erf() -> Float {return Foundation.erf(self)}\n  @inlinable public func erfc() -> Float {return Foundation.erfc(self)}\n  @inlinable public func exp() -> Float {return Foundation.exp(self)}\n  @inlinable public func exp2() -> Float {return Foundation.exp2(self)}\n  @inlinable public func expm1() -> Float {return Foundation.expm1(self)}\n  @inlinable public func log() -> Float {return Foundation.log(self)}\n  @inlinable public func log10() -> Float {return Foundation.log10(self)}\n  @inlinable public func log1p() -> Float {return Foundation.log1p(self)}\n  @inlinable public func log2() -> Float {return Foundation.log2(self)}\n  @inlinable public func logb() -> Float {return Foundation.logb(self)}\n  @inlinable public func nearbyint() -> Float {return Foundation.nearbyint(self)}\n  @inlinable public func rint() -> Float {return Foundation.rint(self)}\n  @inlinable public func sin() -> Float {return Foundation.sin(self)}\n  @inlinable public func sinh() -> Float {return Foundation.sinh(self)}\n  @inlinable public func tan() -> Float {return Foundation.tan(self)}\n  @inlinable public func tanh() -> Float {return Foundation.tanh(self)}\n  @inlinable public func tgamma() -> Float {return Foundation.tgamma(self)}\n\n  @inlinable public func min(_ b: Float) -> Float {return Swift.min(self, b)}\n  @inlinable public func max(_ b: Float) -> Float {return Swift.max(self, b)}\n\n  @inlinable public func abs() -> Float {return Swift.abs(self)}\n\n  @inlinable public func pow(_ b: Float) -> Float {return Foundation.pow(self, b)}\n  @inlinable public func atan2(_ b: Float) -> Float {return Foundation.atan2(self, b)}\n  @inlinable public func copysign(_ b: Float) -> Float {return Foundation.copysign(self, b)}\n  @inlinable public func fdim(_ b: Float) -> Float {return Foundation.fdim(self, b)}\n  @inlinable public func fmax(_ b: Float) -> Float {return Foundation.fmax(self, b)}\n  @inlinable public func fmin(_ b: Float) -> Float {return Foundation.fmin(self, b)}\n  @inlinable public func hypot(_ b: Float) -> Float {return Foundation.hypot(self, b)}\n  @inlinable public func nextafter(_ b: Float) -> Float {return Foundation.nextafter(self, b)}\n\n  @inlinable public static func sum(_ a:PtrT, _ n:Int32) -> Element { return smSum(a, n) }\n  @inlinable public static func sumabs(_ a:PtrT, _ n:Int32)->Element { return smSum_abs(a, n) }\n  @inlinable public static func sumsqrt(_ a:PtrT, _ n:Int32)->Element { return smSum_sqrt(a, n) }\n  @inlinable public static func sumacos(_ a:PtrT, _ n:Int32)->Element { return smSum_acos(a, n) }\n  @inlinable public static func sumacosh(_ a:PtrT, _ n:Int32)->Element { return smSum_acosh(a, n) }\n  @inlinable public static func sumasin(_ a:PtrT, _ n:Int32)->Element { return smSum_asin(a, n) }\n  @inlinable public static func sumasinh(_ a:PtrT, _ n:Int32)->Element { return smSum_asinh(a, n) }\n  @inlinable public static func sumatan(_ a:PtrT, _ n:Int32)->Element { return smSum_atan(a, n) }\n  @inlinable public static func sumatanh(_ a:PtrT, _ n:Int32)->Element { return smSum_atanh(a, n) }\n  @inlinable public static func sumcbrt(_ a:PtrT, _ n:Int32)->Element { return smSum_cbrt(a, n) }\n  @inlinable public static func sumcos(_ a:PtrT, _ n:Int32)->Element { return smSum_cos(a, n) }\n  @inlinable public static func sumcosh(_ a:PtrT, _ n:Int32)->Element { return smSum_cosh(a, n) }\n  @inlinable public static func sumerf(_ a:PtrT, _ n:Int32)->Element { return smSum_erf(a, n) }\n  @inlinable public static func sumerfc(_ a:PtrT, _ n:Int32)->Element { return smSum_erfc(a, n) }\n  @inlinable public static func sumexp(_ a:PtrT, _ n:Int32)->Element { return smSum_exp(a, n) }\n  @inlinable public static func sumexp2(_ a:PtrT, _ n:Int32)->Element { return smSum_exp2(a, n) }\n  @inlinable public static func sumexpm1(_ a:PtrT, _ n:Int32)->Element { return smSum_expm1(a, n) }\n  @inlinable public static func sumlog(_ a:PtrT, _ n:Int32)->Element { return smSum_log(a, n) }\n  @inlinable public static func sumlog10(_ a:PtrT, _ n:Int32)->Element { return smSum_log10(a, n) }\n  @inlinable public static func sumlog1p(_ a:PtrT, _ n:Int32)->Element { return smSum_log1p(a, n) }\n  @inlinable public static func sumlog2(_ a:PtrT, _ n:Int32)->Element { return smSum_log2(a, n) }\n  @inlinable public static func sumlogb(_ a:PtrT, _ n:Int32)->Element { return smSum_logb(a, n) }\n  @inlinable public static func sumnearbyint(_ a:PtrT, _ n:Int32)->Element { return smSum_nearbyint(a, n) }\n  @inlinable public static func sumrint(_ a:PtrT, _ n:Int32)->Element { return smSum_rint(a, n) }\n  @inlinable public static func sumsin(_ a:PtrT, _ n:Int32)->Element { return smSum_sin(a, n) }\n  @inlinable public static func sumsinh(_ a:PtrT, _ n:Int32)->Element { return smSum_sinh(a, n) }\n  @inlinable public static func sumtan(_ a:PtrT, _ n:Int32)->Element { return smSum_tan(a, n) }\n  @inlinable public static func sumtanh(_ a:PtrT, _ n:Int32)->Element { return smSum_tanh(a, n) }\n  @inlinable public static func sumtgamma(_ a:PtrT, _ n:Int32)->Element { return smSum_tgamma(a, n) }\n  @inlinable public static func sumsqr(_ a:PtrT, _ n:Int32)->Element { return smSum_sqr(a, n) }\n\n  public static func ^^(x:Float, a:Float) -> Float { return x.pow(a) }\n}\nextension Double : SupportsBasicMath {\n  public var nsNumber:NSNumber { return NSNumber(value: self) }\n\n  @inlinable public func add(_ b: Double) -> Double {return self + b}\n  @inlinable public func sub(_ b: Double) -> Double {return self - b}\n  @inlinable public func mul(_ b: Double) -> Double {return self * b}\n  @inlinable public func div(_ b: Double) -> Double {return self / b}\n\n  @inlinable public static func sqr(_ a:Double) -> Double {return  a  * a  }\n  @inlinable public        func sqr(        ) -> Double {return self*self}\n\n  @inlinable public func subRev(_ b: Double) -> Double {return b - self}\n  @inlinable public func divRev(_ b: Double) -> Double {return b / self}\n\n  @inlinable public func sqrt() -> Double {return Foundation.sqrt(self)}\n  @inlinable public func acos() -> Double {return Foundation.acos(self)}\n  @inlinable public func acosh() -> Double {return Foundation.acosh(self)}\n  @inlinable public func asin() -> Double {return Foundation.asin(self)}\n  @inlinable public func asinh() -> Double {return Foundation.asinh(self)}\n  @inlinable public func atan() -> Double {return Foundation.atan(self)}\n  @inlinable public func atanh() -> Double {return Foundation.atanh(self)}\n  @inlinable public func cbrt() -> Double {return Foundation.cbrt(self)}\n  @inlinable public func cos() -> Double {return Foundation.cos(self)}\n  @inlinable public func cosh() -> Double {return Foundation.cosh(self)}\n  @inlinable public func erf() -> Double {return Foundation.erf(self)}\n  @inlinable public func erfc() -> Double {return Foundation.erfc(self)}\n  @inlinable public func exp() -> Double {return Foundation.exp(self)}\n  @inlinable public func exp2() -> Double {return Foundation.exp2(self)}\n  @inlinable public func expm1() -> Double {return Foundation.expm1(self)}\n  @inlinable public func log() -> Double {return Foundation.log(self)}\n  @inlinable public func log10() -> Double {return Foundation.log10(self)}\n  @inlinable public func log1p() -> Double {return Foundation.log1p(self)}\n  @inlinable public func log2() -> Double {return Foundation.log2(self)}\n  @inlinable public func logb() -> Double {return Foundation.logb(self)}\n  @inlinable public func nearbyint() -> Double {return Foundation.nearbyint(self)}\n  @inlinable public func rint() -> Double {return Foundation.rint(self)}\n  @inlinable public func sin() -> Double {return Foundation.sin(self)}\n  @inlinable public func sinh() -> Double {return Foundation.sinh(self)}\n  @inlinable public func tan() -> Double {return Foundation.tan(self)}\n  @inlinable public func tanh() -> Double {return Foundation.tanh(self)}\n  @inlinable public func tgamma() -> Double {return Foundation.tgamma(self)}\n\n  @inlinable public func min(_ b: Double) -> Double {return Swift.min(self, b)}\n  @inlinable public func max(_ b: Double) -> Double {return Swift.max(self, b)}\n\n  @inlinable public func abs() -> Double {return Swift.abs(self)}\n\n  @inlinable public func pow(_ b: Double) -> Double {return Foundation.pow(self, b)}\n  @inlinable public func atan2(_ b: Double) -> Double {return Foundation.atan2(self, b)}\n  @inlinable public func copysign(_ b: Double) -> Double {return Foundation.copysign(self, b)}\n  @inlinable public func fdim(_ b: Double) -> Double {return Foundation.fdim(self, b)}\n  @inlinable public func fmax(_ b: Double) -> Double {return Foundation.fmax(self, b)}\n  @inlinable public func fmin(_ b: Double) -> Double {return Foundation.fmin(self, b)}\n  @inlinable public func hypot(_ b: Double) -> Double {return Foundation.hypot(self, b)}\n  @inlinable public func nextafter(_ b: Double) -> Double {return Foundation.nextafter(self, b)}\n\n  @inlinable public static func sum(_ a:PtrT, _ n:Int32) -> Element { return smSum(a, n) }\n  @inlinable public static func sumabs(_ a:PtrT, _ n:Int32)->Element { return smSum_abs(a, n) }\n  @inlinable public static func sumsqrt(_ a:PtrT, _ n:Int32)->Element { return smSum_sqrt(a, n) }\n  @inlinable public static func sumacos(_ a:PtrT, _ n:Int32)->Element { return smSum_acos(a, n) }\n  @inlinable public static func sumacosh(_ a:PtrT, _ n:Int32)->Element { return smSum_acosh(a, n) }\n  @inlinable public static func sumasin(_ a:PtrT, _ n:Int32)->Element { return smSum_asin(a, n) }\n  @inlinable public static func sumasinh(_ a:PtrT, _ n:Int32)->Element { return smSum_asinh(a, n) }\n  @inlinable public static func sumatan(_ a:PtrT, _ n:Int32)->Element { return smSum_atan(a, n) }\n  @inlinable public static func sumatanh(_ a:PtrT, _ n:Int32)->Element { return smSum_atanh(a, n) }\n  @inlinable public static func sumcbrt(_ a:PtrT, _ n:Int32)->Element { return smSum_cbrt(a, n) }\n  @inlinable public static func sumcos(_ a:PtrT, _ n:Int32)->Element { return smSum_cos(a, n) }\n  @inlinable public static func sumcosh(_ a:PtrT, _ n:Int32)->Element { return smSum_cosh(a, n) }\n  @inlinable public static func sumerf(_ a:PtrT, _ n:Int32)->Element { return smSum_erf(a, n) }\n  @inlinable public static func sumerfc(_ a:PtrT, _ n:Int32)->Element { return smSum_erfc(a, n) }\n  @inlinable public static func sumexp(_ a:PtrT, _ n:Int32)->Element { return smSum_exp(a, n) }\n  @inlinable public static func sumexp2(_ a:PtrT, _ n:Int32)->Element { return smSum_exp2(a, n) }\n  @inlinable public static func sumexpm1(_ a:PtrT, _ n:Int32)->Element { return smSum_expm1(a, n) }\n  @inlinable public static func sumlog(_ a:PtrT, _ n:Int32)->Element { return smSum_log(a, n) }\n  @inlinable public static func sumlog10(_ a:PtrT, _ n:Int32)->Element { return smSum_log10(a, n) }\n  @inlinable public static func sumlog1p(_ a:PtrT, _ n:Int32)->Element { return smSum_log1p(a, n) }\n  @inlinable public static func sumlog2(_ a:PtrT, _ n:Int32)->Element { return smSum_log2(a, n) }\n  @inlinable public static func sumlogb(_ a:PtrT, _ n:Int32)->Element { return smSum_logb(a, n) }\n  @inlinable public static func sumnearbyint(_ a:PtrT, _ n:Int32)->Element { return smSum_nearbyint(a, n) }\n  @inlinable public static func sumrint(_ a:PtrT, _ n:Int32)->Element { return smSum_rint(a, n) }\n  @inlinable public static func sumsin(_ a:PtrT, _ n:Int32)->Element { return smSum_sin(a, n) }\n  @inlinable public static func sumsinh(_ a:PtrT, _ n:Int32)->Element { return smSum_sinh(a, n) }\n  @inlinable public static func sumtan(_ a:PtrT, _ n:Int32)->Element { return smSum_tan(a, n) }\n  @inlinable public static func sumtanh(_ a:PtrT, _ n:Int32)->Element { return smSum_tanh(a, n) }\n  @inlinable public static func sumtgamma(_ a:PtrT, _ n:Int32)->Element { return smSum_tgamma(a, n) }\n  @inlinable public static func sumsqr(_ a:PtrT, _ n:Int32)->Element { return smSum_sqr(a, n) }\n\n  public static func ^^(x:Double, a:Double) -> Double { return x.pow(a) }\n}\n\n"
  },
  {
    "path": "Sources/BaseMath/BaseMath.swift.gyb",
    "content": "import Foundation\nimport CBaseMath\n\n%{ import sys; sys.path.append('../..'); from mathfuncs import * }%\n\nextension BinaryFloatingPoint where Self: CVarArg {\n  public func string(_ digits:Int) -> String { return String(format: \"%.\\(digits)f\", self) }\n}\n\nprecedencegroup ExponentiationPrecedence { associativity: right higherThan: MultiplicationPrecedence }\ninfix operator ^^: ExponentiationPrecedence\n\npublic extension Numeric {\n  typealias Element=Self\n  typealias PtrT = UnsafePointer<Element> \n  typealias MutPtrT = UnsafeMutablePointer<Element>\n}\n\npublic protocol SupportsBasicMath:BinaryFloatingPoint {\n  init(_ value: Self)\n  init()\n\n  var nsNumber:NSNumber {get}\n\n% for f in binfs:\n  func ${f}(_ b: Self) -> Self\n% end # f\n% for f in funcs2:\n  func ${f}() -> Self\n% end # f\n\n  static func sqr(_ a:Self) -> Self\n  func sqr() -> Self\n  func abs() -> Self\n  static func sum(_ a:PtrT, _ n:Int32) -> Element\n  % for f in unaryfs:\n  static func sum${f}(_ a:PtrT, _ n:Int32)->Element\n  % end\n  static func sumsqr(_ a:PtrT, _ n:Int32)->Element\n\n  static func ^^(x:Self, a:Self) -> Self\n}\n\n% for t in types:\nextension ${t} : SupportsBasicMath {\n  public var nsNumber:NSNumber { return NSNumber(value: self) }\n\n  % for f,op in zip(op_fs,ops):\n  @inlinable public func ${f}(_ b: ${t}) -> ${t} {return self ${op} b}\n  % end # f,op\n\n  @inlinable public static func sqr(_ a:${t}) -> ${t} {return  a  * a  }\n  @inlinable public        func sqr(        ) -> ${t} {return self*self}\n\n  @inlinable public func subRev(_ b: ${t}) -> ${t} {return b - self}\n  @inlinable public func divRev(_ b: ${t}) -> ${t} {return b / self}\n\n  % for f in funcs2:\n  @inlinable public func ${f}() -> ${t} {return Foundation.${f}(self)}\n  % end # f\n\n  @inlinable public func min(_ b: ${t}) -> ${t} {return Swift.min(self, b)}\n  @inlinable public func max(_ b: ${t}) -> ${t} {return Swift.max(self, b)}\n\n  @inlinable public func abs() -> ${t} {return Swift.abs(self)}\n\n  % for f in funcs3:\n  @inlinable public func ${f}(_ b: ${t}) -> ${t} {return Foundation.${f}(self, b)}\n  % end # f\n\n  @inlinable public static func sum(_ a:PtrT, _ n:Int32) -> Element { return smSum(a, n) }\n  % for f in unaryfs:\n  @inlinable public static func sum${f}(_ a:PtrT, _ n:Int32)->Element { return smSum_${f}(a, n) }\n  % end\n  @inlinable public static func sumsqr(_ a:PtrT, _ n:Int32)->Element { return smSum_sqr(a, n) }\n\n  public static func ^^(x:${t}, a:${t}) -> ${t} { return x.pow(a) }\n}\n% end # t\n\n"
  },
  {
    "path": "Sources/BaseMath/BaseRand.swift",
    "content": "import Foundation\nimport CBaseMath\n\n\npublic protocol Initable { init() }\nextension Float:Initable {}\nextension Double:Initable {}\nextension Int:Initable {}\nextension Int32:Initable {}\nextension Bool:Initable {}\n\npublic protocol CppTypePtr {\n  func delete()\n}\n\npublic class CppType<T:CppTypePtr> {\n  public let p:T\n  init(_ p:T) {self.p=p}\n  deinit {p.delete()}\n}\n\npublic class mt19937:CppType<mt19937C> {\n  public convenience init() { self.init(CBaseMath.mt19937_create()) }\n\n  @usableFromInline static var storeKey:String { get { return \"mt19937\" } }\n  public static var stored:mt19937 { get {\n    if let r = Thread.current.threadDictionary[storeKey] as? mt19937 { return r }\n    return Thread.setToTLS(mt19937(), storeKey)\n  }}\n}\n\npublic protocol DistributionC:CppTypePtr {\n  associatedtype Element:SignedNumeric\n  func call(_ g:mt19937C)->Element\n}\n\npublic class Distribution<T:DistributionC>:CppType<T>,Nullary {\n  public typealias Element=T.Element\n  public var g:mt19937\n\n  public init(_ p:T, _ g:mt19937) {self.g=g; super.init(p) }\n  @inlinable public subscript()->Element { return p.call(g.p) }\n  public subscript(n:Int)->[Element] { return gen_array(n) }\n  public func gen_array(_ n:Int)->[Element] {\n    return [Element].fill(self, n)\n  }\n  public func gen_aligned(_ n:Int)->AlignedStorage<Element> {\n    return AlignedStorage<Element>.fill(self, n)\n  }\n  public func gen_pointer(_ n:Int)->UnsafeMutableBufferPointer<Element> {\n    return UnsafeMutableBufferPointer<Element>.fill(self, n)\n  }\n}\n\n\npublic final class uniform_int_distribution_Int:Distribution<uniform_int_distributionlongC> {\n  public init(_ g_:mt19937 , _ a:Int,_ b:Int) { super.init(uniform_int_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Int,_ b:Int) { self.init(mt19937.stored, a,b) }\n}\nextension Int {\n  public static func uniform_int_distribution(_ g_:mt19937 , _ a:Int,_ b:Int)->uniform_int_distribution_Int {return uniform_int_distribution_Int(g_, a,b)}\n  public static func uniform_int_distribution(_ a:Int,_ b:Int)->uniform_int_distribution_Int {return uniform_int_distribution_Int(a,b)}\n}\n\npublic final class uniform_int_distribution_Int32:Distribution<uniform_int_distributionintC> {\n  public init(_ g_:mt19937 , _ a:Int32,_ b:Int32) { super.init(uniform_int_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Int32,_ b:Int32) { self.init(mt19937.stored, a,b) }\n}\nextension Int32 {\n  public static func uniform_int_distribution(_ g_:mt19937 , _ a:Int32,_ b:Int32)->uniform_int_distribution_Int32 {return uniform_int_distribution_Int32(g_, a,b)}\n  public static func uniform_int_distribution(_ a:Int32,_ b:Int32)->uniform_int_distribution_Int32 {return uniform_int_distribution_Int32(a,b)}\n}\n\npublic final class binomial_distribution_Int:Distribution<binomial_distributionlongC> {\n  public init(_ g_:mt19937 , _ t:Int,_ p:Double) { super.init(binomial_distribution_create(t,p, Element.init()), g_) }\n  public convenience init(_ t:Int,_ p:Double) { self.init(mt19937.stored, t,p) }\n}\nextension Int {\n  public static func binomial_distribution(_ g_:mt19937 , _ t:Int,_ p:Double)->binomial_distribution_Int {return binomial_distribution_Int(g_, t,p)}\n  public static func binomial_distribution(_ t:Int,_ p:Double)->binomial_distribution_Int {return binomial_distribution_Int(t,p)}\n}\n\npublic final class binomial_distribution_Int32:Distribution<binomial_distributionintC> {\n  public init(_ g_:mt19937 , _ t:Int32,_ p:Double) { super.init(binomial_distribution_create(t,p, Element.init()), g_) }\n  public convenience init(_ t:Int32,_ p:Double) { self.init(mt19937.stored, t,p) }\n}\nextension Int32 {\n  public static func binomial_distribution(_ g_:mt19937 , _ t:Int32,_ p:Double)->binomial_distribution_Int32 {return binomial_distribution_Int32(g_, t,p)}\n  public static func binomial_distribution(_ t:Int32,_ p:Double)->binomial_distribution_Int32 {return binomial_distribution_Int32(t,p)}\n}\n\npublic final class negative_binomial_distribution_Int:Distribution<negative_binomial_distributionlongC> {\n  public init(_ g_:mt19937 , _ k:Int,_ p:Double) { super.init(negative_binomial_distribution_create(k,p, Element.init()), g_) }\n  public convenience init(_ k:Int,_ p:Double) { self.init(mt19937.stored, k,p) }\n}\nextension Int {\n  public static func negative_binomial_distribution(_ g_:mt19937 , _ k:Int,_ p:Double)->negative_binomial_distribution_Int {return negative_binomial_distribution_Int(g_, k,p)}\n  public static func negative_binomial_distribution(_ k:Int,_ p:Double)->negative_binomial_distribution_Int {return negative_binomial_distribution_Int(k,p)}\n}\n\npublic final class negative_binomial_distribution_Int32:Distribution<negative_binomial_distributionintC> {\n  public init(_ g_:mt19937 , _ k:Int32,_ p:Double) { super.init(negative_binomial_distribution_create(k,p, Element.init()), g_) }\n  public convenience init(_ k:Int32,_ p:Double) { self.init(mt19937.stored, k,p) }\n}\nextension Int32 {\n  public static func negative_binomial_distribution(_ g_:mt19937 , _ k:Int32,_ p:Double)->negative_binomial_distribution_Int32 {return negative_binomial_distribution_Int32(g_, k,p)}\n  public static func negative_binomial_distribution(_ k:Int32,_ p:Double)->negative_binomial_distribution_Int32 {return negative_binomial_distribution_Int32(k,p)}\n}\n\npublic final class geometric_distribution_Int:Distribution<geometric_distributionlongC> {\n  public init(_ g_:mt19937 , _ p:Double) { super.init(geometric_distribution_create(p, Element.init()), g_) }\n  public convenience init(_ p:Double) { self.init(mt19937.stored, p) }\n}\nextension Int {\n  public static func geometric_distribution(_ g_:mt19937 , _ p:Double)->geometric_distribution_Int {return geometric_distribution_Int(g_, p)}\n  public static func geometric_distribution(_ p:Double)->geometric_distribution_Int {return geometric_distribution_Int(p)}\n}\n\npublic final class geometric_distribution_Int32:Distribution<geometric_distributionintC> {\n  public init(_ g_:mt19937 , _ p:Double) { super.init(geometric_distribution_create(p, Element.init()), g_) }\n  public convenience init(_ p:Double) { self.init(mt19937.stored, p) }\n}\nextension Int32 {\n  public static func geometric_distribution(_ g_:mt19937 , _ p:Double)->geometric_distribution_Int32 {return geometric_distribution_Int32(g_, p)}\n  public static func geometric_distribution(_ p:Double)->geometric_distribution_Int32 {return geometric_distribution_Int32(p)}\n}\n\npublic final class poisson_distribution_Int:Distribution<poisson_distributionlongC> {\n  public init(_ g_:mt19937 , _ mean:Double) { super.init(poisson_distribution_create(mean, Element.init()), g_) }\n  public convenience init(_ mean:Double) { self.init(mt19937.stored, mean) }\n}\nextension Int {\n  public static func poisson_distribution(_ g_:mt19937 , _ mean:Double)->poisson_distribution_Int {return poisson_distribution_Int(g_, mean)}\n  public static func poisson_distribution(_ mean:Double)->poisson_distribution_Int {return poisson_distribution_Int(mean)}\n}\n\npublic final class poisson_distribution_Int32:Distribution<poisson_distributionintC> {\n  public init(_ g_:mt19937 , _ mean:Double) { super.init(poisson_distribution_create(mean, Element.init()), g_) }\n  public convenience init(_ mean:Double) { self.init(mt19937.stored, mean) }\n}\nextension Int32 {\n  public static func poisson_distribution(_ g_:mt19937 , _ mean:Double)->poisson_distribution_Int32 {return poisson_distribution_Int32(g_, mean)}\n  public static func poisson_distribution(_ mean:Double)->poisson_distribution_Int32 {return poisson_distribution_Int32(mean)}\n}\n\npublic final class discrete_distribution_Int:Distribution<discrete_distributionlongC> {\n  public init(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { super.init(discrete_distribution_create(start,end, Element.init()), g_) }\n  public convenience init(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start,end) }\n}\nextension Int {\n  public static func discrete_distribution(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int {return discrete_distribution_Int(g_, start,end)}\n  public static func discrete_distribution(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int {return discrete_distribution_Int(start,end)}\n}\n\npublic final class discrete_distribution_Int32:Distribution<discrete_distributionintC> {\n  public init(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { super.init(discrete_distribution_create(start,end, Element.init()), g_) }\n  public convenience init(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start,end) }\n}\nextension Int32 {\n  public static func discrete_distribution(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int32 {return discrete_distribution_Int32(g_, start,end)}\n  public static func discrete_distribution(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int32 {return discrete_distribution_Int32(start,end)}\n}\n\npublic final class uniform_real_distribution_Float:Distribution<uniform_real_distributionfloatC> {\n  public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(uniform_real_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }\n}\nextension Float {\n  public static func uniform_real_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->uniform_real_distribution_Float {return uniform_real_distribution_Float(g_, a,b)}\n  public static func uniform_real_distribution(_ a:Float,_ b:Float)->uniform_real_distribution_Float {return uniform_real_distribution_Float(a,b)}\n}\n\npublic final class uniform_real_distribution_Double:Distribution<uniform_real_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(uniform_real_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }\n}\nextension Double {\n  public static func uniform_real_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->uniform_real_distribution_Double {return uniform_real_distribution_Double(g_, a,b)}\n  public static func uniform_real_distribution(_ a:Double,_ b:Double)->uniform_real_distribution_Double {return uniform_real_distribution_Double(a,b)}\n}\n\npublic final class exponential_distribution_Float:Distribution<exponential_distributionfloatC> {\n  public init(_ g_:mt19937 , _ l:Float) { super.init(exponential_distribution_create(l, Element.init()), g_) }\n  public convenience init(_ l:Float) { self.init(mt19937.stored, l) }\n}\nextension Float {\n  public static func exponential_distribution(_ g_:mt19937 , _ l:Float)->exponential_distribution_Float {return exponential_distribution_Float(g_, l)}\n  public static func exponential_distribution(_ l:Float)->exponential_distribution_Float {return exponential_distribution_Float(l)}\n}\n\npublic final class exponential_distribution_Double:Distribution<exponential_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ l:Double) { super.init(exponential_distribution_create(l, Element.init()), g_) }\n  public convenience init(_ l:Double) { self.init(mt19937.stored, l) }\n}\nextension Double {\n  public static func exponential_distribution(_ g_:mt19937 , _ l:Double)->exponential_distribution_Double {return exponential_distribution_Double(g_, l)}\n  public static func exponential_distribution(_ l:Double)->exponential_distribution_Double {return exponential_distribution_Double(l)}\n}\n\npublic final class gamma_distribution_Float:Distribution<gamma_distributionfloatC> {\n  public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(gamma_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }\n}\nextension Float {\n  public static func gamma_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->gamma_distribution_Float {return gamma_distribution_Float(g_, a,b)}\n  public static func gamma_distribution(_ a:Float,_ b:Float)->gamma_distribution_Float {return gamma_distribution_Float(a,b)}\n}\n\npublic final class gamma_distribution_Double:Distribution<gamma_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(gamma_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }\n}\nextension Double {\n  public static func gamma_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->gamma_distribution_Double {return gamma_distribution_Double(g_, a,b)}\n  public static func gamma_distribution(_ a:Double,_ b:Double)->gamma_distribution_Double {return gamma_distribution_Double(a,b)}\n}\n\npublic final class weibull_distribution_Float:Distribution<weibull_distributionfloatC> {\n  public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(weibull_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }\n}\nextension Float {\n  public static func weibull_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->weibull_distribution_Float {return weibull_distribution_Float(g_, a,b)}\n  public static func weibull_distribution(_ a:Float,_ b:Float)->weibull_distribution_Float {return weibull_distribution_Float(a,b)}\n}\n\npublic final class weibull_distribution_Double:Distribution<weibull_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(weibull_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }\n}\nextension Double {\n  public static func weibull_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->weibull_distribution_Double {return weibull_distribution_Double(g_, a,b)}\n  public static func weibull_distribution(_ a:Double,_ b:Double)->weibull_distribution_Double {return weibull_distribution_Double(a,b)}\n}\n\npublic final class normal_distribution_Float:Distribution<normal_distributionfloatC> {\n  public init(_ g_:mt19937 , _ mean:Float,_ stddev:Float) { super.init(normal_distribution_create(mean,stddev, Element.init()), g_) }\n  public convenience init(_ mean:Float,_ stddev:Float) { self.init(mt19937.stored, mean,stddev) }\n}\nextension Float {\n  public static func normal_distribution(_ g_:mt19937 , _ mean:Float,_ stddev:Float)->normal_distribution_Float {return normal_distribution_Float(g_, mean,stddev)}\n  public static func normal_distribution(_ mean:Float,_ stddev:Float)->normal_distribution_Float {return normal_distribution_Float(mean,stddev)}\n}\n\npublic final class normal_distribution_Double:Distribution<normal_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ mean:Double,_ stddev:Double) { super.init(normal_distribution_create(mean,stddev, Element.init()), g_) }\n  public convenience init(_ mean:Double,_ stddev:Double) { self.init(mt19937.stored, mean,stddev) }\n}\nextension Double {\n  public static func normal_distribution(_ g_:mt19937 , _ mean:Double,_ stddev:Double)->normal_distribution_Double {return normal_distribution_Double(g_, mean,stddev)}\n  public static func normal_distribution(_ mean:Double,_ stddev:Double)->normal_distribution_Double {return normal_distribution_Double(mean,stddev)}\n}\n\npublic final class lognormal_distribution_Float:Distribution<lognormal_distributionfloatC> {\n  public init(_ g_:mt19937 , _ m:Float,_ s:Float) { super.init(lognormal_distribution_create(m,s, Element.init()), g_) }\n  public convenience init(_ m:Float,_ s:Float) { self.init(mt19937.stored, m,s) }\n}\nextension Float {\n  public static func lognormal_distribution(_ g_:mt19937 , _ m:Float,_ s:Float)->lognormal_distribution_Float {return lognormal_distribution_Float(g_, m,s)}\n  public static func lognormal_distribution(_ m:Float,_ s:Float)->lognormal_distribution_Float {return lognormal_distribution_Float(m,s)}\n}\n\npublic final class lognormal_distribution_Double:Distribution<lognormal_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ m:Double,_ s:Double) { super.init(lognormal_distribution_create(m,s, Element.init()), g_) }\n  public convenience init(_ m:Double,_ s:Double) { self.init(mt19937.stored, m,s) }\n}\nextension Double {\n  public static func lognormal_distribution(_ g_:mt19937 , _ m:Double,_ s:Double)->lognormal_distribution_Double {return lognormal_distribution_Double(g_, m,s)}\n  public static func lognormal_distribution(_ m:Double,_ s:Double)->lognormal_distribution_Double {return lognormal_distribution_Double(m,s)}\n}\n\npublic final class chi_squared_distribution_Float:Distribution<chi_squared_distributionfloatC> {\n  public init(_ g_:mt19937 , _ n:Float) { super.init(chi_squared_distribution_create(n, Element.init()), g_) }\n  public convenience init(_ n:Float) { self.init(mt19937.stored, n) }\n}\nextension Float {\n  public static func chi_squared_distribution(_ g_:mt19937 , _ n:Float)->chi_squared_distribution_Float {return chi_squared_distribution_Float(g_, n)}\n  public static func chi_squared_distribution(_ n:Float)->chi_squared_distribution_Float {return chi_squared_distribution_Float(n)}\n}\n\npublic final class chi_squared_distribution_Double:Distribution<chi_squared_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ n:Double) { super.init(chi_squared_distribution_create(n, Element.init()), g_) }\n  public convenience init(_ n:Double) { self.init(mt19937.stored, n) }\n}\nextension Double {\n  public static func chi_squared_distribution(_ g_:mt19937 , _ n:Double)->chi_squared_distribution_Double {return chi_squared_distribution_Double(g_, n)}\n  public static func chi_squared_distribution(_ n:Double)->chi_squared_distribution_Double {return chi_squared_distribution_Double(n)}\n}\n\npublic final class cauchy_distribution_Float:Distribution<cauchy_distributionfloatC> {\n  public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(cauchy_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }\n}\nextension Float {\n  public static func cauchy_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->cauchy_distribution_Float {return cauchy_distribution_Float(g_, a,b)}\n  public static func cauchy_distribution(_ a:Float,_ b:Float)->cauchy_distribution_Float {return cauchy_distribution_Float(a,b)}\n}\n\npublic final class cauchy_distribution_Double:Distribution<cauchy_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(cauchy_distribution_create(a,b, Element.init()), g_) }\n  public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }\n}\nextension Double {\n  public static func cauchy_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->cauchy_distribution_Double {return cauchy_distribution_Double(g_, a,b)}\n  public static func cauchy_distribution(_ a:Double,_ b:Double)->cauchy_distribution_Double {return cauchy_distribution_Double(a,b)}\n}\n\npublic final class fisher_f_distribution_Float:Distribution<fisher_f_distributionfloatC> {\n  public init(_ g_:mt19937 , _ m:Float,_ n:Float) { super.init(fisher_f_distribution_create(m,n, Element.init()), g_) }\n  public convenience init(_ m:Float,_ n:Float) { self.init(mt19937.stored, m,n) }\n}\nextension Float {\n  public static func fisher_f_distribution(_ g_:mt19937 , _ m:Float,_ n:Float)->fisher_f_distribution_Float {return fisher_f_distribution_Float(g_, m,n)}\n  public static func fisher_f_distribution(_ m:Float,_ n:Float)->fisher_f_distribution_Float {return fisher_f_distribution_Float(m,n)}\n}\n\npublic final class fisher_f_distribution_Double:Distribution<fisher_f_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ m:Double,_ n:Double) { super.init(fisher_f_distribution_create(m,n, Element.init()), g_) }\n  public convenience init(_ m:Double,_ n:Double) { self.init(mt19937.stored, m,n) }\n}\nextension Double {\n  public static func fisher_f_distribution(_ g_:mt19937 , _ m:Double,_ n:Double)->fisher_f_distribution_Double {return fisher_f_distribution_Double(g_, m,n)}\n  public static func fisher_f_distribution(_ m:Double,_ n:Double)->fisher_f_distribution_Double {return fisher_f_distribution_Double(m,n)}\n}\n\npublic final class student_t_distribution_Float:Distribution<student_t_distributionfloatC> {\n  public init(_ g_:mt19937 , _ n:Float) { super.init(student_t_distribution_create(n, Element.init()), g_) }\n  public convenience init(_ n:Float) { self.init(mt19937.stored, n) }\n}\nextension Float {\n  public static func student_t_distribution(_ g_:mt19937 , _ n:Float)->student_t_distribution_Float {return student_t_distribution_Float(g_, n)}\n  public static func student_t_distribution(_ n:Float)->student_t_distribution_Float {return student_t_distribution_Float(n)}\n}\n\npublic final class student_t_distribution_Double:Distribution<student_t_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ n:Double) { super.init(student_t_distribution_create(n, Element.init()), g_) }\n  public convenience init(_ n:Double) { self.init(mt19937.stored, n) }\n}\nextension Double {\n  public static func student_t_distribution(_ g_:mt19937 , _ n:Double)->student_t_distribution_Double {return student_t_distribution_Double(g_, n)}\n  public static func student_t_distribution(_ n:Double)->student_t_distribution_Double {return student_t_distribution_Double(n)}\n}\n\npublic final class piecewise_constant_distribution_Float:Distribution<piecewise_constant_distributionfloatC> {\n  public init(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { super.init(piecewise_constant_distribution_create(start_i,end_i,start_w, Element.init()), g_) }\n  public convenience init(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start_i,end_i,start_w) }\n}\nextension Float {\n  public static func piecewise_constant_distribution(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_constant_distribution_Float {return piecewise_constant_distribution_Float(g_, start_i,end_i,start_w)}\n  public static func piecewise_constant_distribution(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_constant_distribution_Float {return piecewise_constant_distribution_Float(start_i,end_i,start_w)}\n}\n\npublic final class piecewise_constant_distribution_Double:Distribution<piecewise_constant_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { super.init(piecewise_constant_distribution_create(start_i,end_i,start_w, Element.init()), g_) }\n  public convenience init(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start_i,end_i,start_w) }\n}\nextension Double {\n  public static func piecewise_constant_distribution(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_constant_distribution_Double {return piecewise_constant_distribution_Double(g_, start_i,end_i,start_w)}\n  public static func piecewise_constant_distribution(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_constant_distribution_Double {return piecewise_constant_distribution_Double(start_i,end_i,start_w)}\n}\n\npublic final class piecewise_linear_distribution_Float:Distribution<piecewise_linear_distributionfloatC> {\n  public init(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { super.init(piecewise_linear_distribution_create(start_i,end_i,start_w, Element.init()), g_) }\n  public convenience init(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start_i,end_i,start_w) }\n}\nextension Float {\n  public static func piecewise_linear_distribution(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_linear_distribution_Float {return piecewise_linear_distribution_Float(g_, start_i,end_i,start_w)}\n  public static func piecewise_linear_distribution(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_linear_distribution_Float {return piecewise_linear_distribution_Float(start_i,end_i,start_w)}\n}\n\npublic final class piecewise_linear_distribution_Double:Distribution<piecewise_linear_distributiondoubleC> {\n  public init(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { super.init(piecewise_linear_distribution_create(start_i,end_i,start_w, Element.init()), g_) }\n  public convenience init(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start_i,end_i,start_w) }\n}\nextension Double {\n  public static func piecewise_linear_distribution(_ g_:mt19937 , _ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_linear_distribution_Double {return piecewise_linear_distribution_Double(g_, start_i,end_i,start_w)}\n  public static func piecewise_linear_distribution(_ start_i:UnsafeMutablePointer<Double>,_ end_i:UnsafeMutablePointer<Double>,_ start_w:UnsafeMutablePointer<Double>)->piecewise_linear_distribution_Double {return piecewise_linear_distribution_Double(start_i,end_i,start_w)}\n}\n\nextension Int {\n  public static func discrete_distribution(_ d_s:[Double])->discrete_distribution_Int {\n    return discrete_distribution(d_s.p, d_s.p+d_s.count)\n  }\n}\nextension Int32 {\n  public static func discrete_distribution(_ d_s:[Double])->discrete_distribution_Int32 {\n    return discrete_distribution(d_s.p, d_s.p+d_s.count)\n  }\n}\n\n\nextension Float {\n  public static func piecewise_constant_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_constant_distribution_Float {\n    return piecewise_constant_distribution(i_s.p, i_s.p+i_s.count, w_s.p)\n  }\n  public static func piecewise_linear_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_linear_distribution_Float {\n    return piecewise_linear_distribution(i_s.p, i_s.p+i_s.count, w_s.p)\n  }\n}\nextension Double {\n  public static func piecewise_constant_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_constant_distribution_Double {\n    return piecewise_constant_distribution(i_s.p, i_s.p+i_s.count, w_s.p)\n  }\n  public static func piecewise_linear_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_linear_distribution_Double {\n    return piecewise_linear_distribution(i_s.p, i_s.p+i_s.count, w_s.p)\n  }\n}\n\n"
  },
  {
    "path": "Sources/BaseMath/BaseRand.swift.gyb",
    "content": "import Foundation\nimport CBaseMath\n\n%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%\n\npublic protocol Initable { init() }\n% for t in float_swift+int_swift+['Bool']:\nextension ${t}:Initable {}\n% end\n\npublic protocol CppTypePtr {\n  func delete()\n}\n\npublic class CppType<T:CppTypePtr> {\n  public let p:T\n  init(_ p:T) {self.p=p}\n  deinit {p.delete()}\n}\n\npublic class mt19937:CppType<mt19937C> {\n  public convenience init() { self.init(CBaseMath.mt19937_create()) }\n\n  @usableFromInline static var storeKey:String { get { return \"mt19937\" } }\n  public static var stored:mt19937 { get {\n    if let r = Thread.current.threadDictionary[storeKey] as? mt19937 { return r }\n    return Thread.setToTLS(mt19937(), storeKey)\n  }}\n}\n\npublic protocol DistributionC:CppTypePtr {\n  associatedtype Element:SignedNumeric\n  func call(_ g:mt19937C)->Element\n}\n\npublic class Distribution<T:DistributionC>:CppType<T>,Nullary {\n  public typealias Element=T.Element\n  public var g:mt19937\n\n  public init(_ p:T, _ g:mt19937) {self.g=g; super.init(p) }\n  @inlinable public subscript()->Element { return p.call(g.p) }\n  public subscript(n:Int)->[Element] { return gen_array(n) }\n  public func gen_array(_ n:Int)->[Element] {\n    return [Element].fill(self, n)\n  }\n  public func gen_aligned(_ n:Int)->AlignedStorage<Element> {\n    return AlignedStorage<Element>.fill(self, n)\n  }\n  public func gen_pointer(_ n:Int)->UnsafeMutableBufferPointer<Element> {\n    return UnsafeMutableBufferPointer<Element>.fill(self, n)\n  }\n}\n\n% for o,gs,gc in [(o,*gen) for o in dist_types for gen in o.generics]:\n%{\nn = o.typ\np1 = o.pswift.replace('#',gs)\np2 = o.p2\nsep = \",\" if p1 else \"\"\n}%\n\npublic final class ${n}_${gs}:Distribution<${n}${gc}C> {\n  public init(_ g_:mt19937 ${sep} ${p1}) { super.init(${n}_create(${p2}, Element.init()), g_) }\n  public convenience init(${p1}) { self.init(mt19937.stored, ${p2}) }\n}\n% if not gs:\n/*\n% end # gs\nextension ${gs} {\n  public static func ${n}(_ g_:mt19937 ${sep} ${p1})->${n}_${gs} {return ${n}_${gs}(g_, ${p2})}\n  public static func ${n}(${p1})->${n}_${gs} {return ${n}_${gs}(${p2})}\n}\n% if not gs:\n*/\n% end # gs\n% end # o\n\n% for t in int_swift:\nextension ${t} {\n  public static func discrete_distribution(_ d_s:[Double])->discrete_distribution_${t} {\n    return discrete_distribution(d_s.p, d_s.p+d_s.count)\n  }\n}\n% end\n\n\n% for t in float_swift:\nextension ${t} {\n  public static func piecewise_constant_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_constant_distribution_${t} {\n    return piecewise_constant_distribution(i_s.p, i_s.p+i_s.count, w_s.p)\n  }\n  public static func piecewise_linear_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_linear_distribution_${t} {\n    return piecewise_linear_distribution(i_s.p, i_s.p+i_s.count, w_s.p)\n  }\n}\n% end\n\n"
  },
  {
    "path": "Sources/BaseMath/BaseVector.swift",
    "content": "import Foundation\n\npublic protocol Nullary {\n  associatedtype Element:SignedNumeric\n  subscript()->Element {get}\n}\n\npublic protocol BaseVector:\n    RandomAccessCollection, MutableCollection, ExpressibleByArrayLiteral, Equatable, CustomStringConvertible\n  where Index==Int, Element:SignedNumeric {\n  typealias PtrT = UnsafePointer<Element>\n  typealias MutPtrT = UnsafeMutablePointer<Element>\n  typealias NullaryF = ()->(Element)\n  typealias UnaryF = (Element)->(Element)\n  typealias BinaryF = (Element,Element)->(Element)\n  typealias TernaryF = (Element,Element,Element)->(Element)\n\n  init(_ data:[Element])\n  init(_ count:Int)\n\n  func new(_ size:Int)->Self\n  func copy()->Self\n  var p:MutPtrT {get}\n\n  static func fill<T:Nullary>(_ f:T, _ n:Int)->Self where T.Element==Self.Element\n  static func fill(_ f:NullaryF, _ n:Int)->Self\n  func fill<T:Nullary>(_ f:T) where T.Element==Self.Element\n  func fill(_ f:NullaryF)\n  func map(_ f:UnaryF, _ dest: Self)\n  func map(_ f:BinaryF, _ b:Self, _ dest: Self)\n  func map(_ f:TernaryF, _ b:Self, _ c:Self, _ dest: Self)\n}\n\nextension BaseVector {\n  public init(arrayLiteral data: Element...) { self.init(data) }\n  public var indices: Range<Int> { return 0..<endIndex }\n  public var startIndex: Int { return 0 }\n\n  @inlinable public func new(_ size:Int)->Self { return .init(size) }\n  @inlinable public func new()  -> Self { return new(count) }\n  @inlinable public var c:Int32 {get {return numericCast(count)}}\n\n  @inlinable public static func ==(lhs:Self, rhs:Self) -> Bool { return lhs.elementsEqual(rhs) }\n  @inlinable public static func ==(lhs:[Element], rhs:Self) -> Bool { return self.init(lhs) == rhs }\n  @inlinable public static func ==(lhs:Self, rhs:[Element]) -> Bool { return lhs == self.init(rhs) }\n\n  public var description: String { return \"\\(Array(self))\" }\n\n  @inlinable public static func fill<T:Nullary>(_ f:T, _ n:Int)->Self where T.Element==Self.Element {\n    let res = Self(n); res.fill(f); return res\n  }\n  @inlinable public static func fill(_ f:NullaryF, _ n:Int)->Self {\n    let res = Self(n); res.fill(f); return res\n  }\n  @inlinable public func fill<T:Nullary>(_ f:T) where T.Element==Self.Element {\n    let pDest = p; let n = count\n    for i in 0..<n {pDest[i] = f[]}\n  }\n  @inlinable public func fill(_ f:NullaryF) {\n    let pDest = p; let n = count\n    for i in 0..<n {pDest[i] = f()}\n  }\n  @inlinable public func map(_ f:UnaryF, _ dest:Self) {\n    let pSrc = p; let pDest = dest.p; let n = count\n    for i in 0..<n {pDest[i] = f(pSrc[i])}\n  }\n  @inlinable public func map(_ f:BinaryF, _ b:Self, _ dest: Self) {\n    let pSrc = p; let pB = b.p; let pDest = dest.p; let n = count\n    for i in 0..<n {pDest[i] = f(pSrc[i], pB[i])}\n  }\n  @inlinable public func map(_ f:TernaryF, _ b:Self, _ c:Self, _ dest: Self) {\n    let pSrc = p; let pB = b.p; let pC = c.p; let pDest = dest.p; let n = count\n    for i in 0..<n {pDest[i] = f(pSrc[i], pB[i], pC[i])}\n  }\n}\n\n"
  },
  {
    "path": "Sources/BaseMath/CBaseRand.swift",
    "content": "\nimport Foundation\nimport CBaseMath\n\n\nextension uniform_int_distributionlongC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }\n}\n\n\nextension uniform_int_distributionintC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }\n}\n\n\nextension binomial_distributionlongC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }\n}\n\n\nextension binomial_distributionintC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }\n}\n\n\nextension negative_binomial_distributionlongC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }\n}\n\n\nextension negative_binomial_distributionintC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }\n}\n\n\nextension geometric_distributionlongC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }\n}\n\n\nextension geometric_distributionintC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }\n}\n\n\nextension poisson_distributionlongC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }\n}\n\n\nextension poisson_distributionintC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }\n}\n\n\nextension discrete_distributionlongC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }\n}\n\n\nextension discrete_distributionintC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }\n}\n\n\nextension uniform_real_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension uniform_real_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension exponential_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension exponential_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension gamma_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension gamma_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension weibull_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension weibull_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension normal_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension normal_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension lognormal_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension lognormal_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension chi_squared_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension chi_squared_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension cauchy_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension cauchy_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension fisher_f_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension fisher_f_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension student_t_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension student_t_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension piecewise_constant_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension piecewise_constant_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension piecewise_linear_distributionfloatC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }\n}\n\n\nextension piecewise_linear_distributiondoubleC:DistributionC {\n  public func delete() {destroy(self)}\n  public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }\n}\n\n\nextension mt19937C:CppTypePtr {\n  public func delete() {destroy(self)}\n  \n}\n\n\nextension knuth_bC:CppTypePtr {\n  public func delete() {destroy(self)}\n  \n}\n\n\nextension bernoulli_distributionC:CppTypePtr {\n  public func delete() {destroy(self)}\n  \n}\n\n\n"
  },
  {
    "path": "Sources/BaseMath/CBaseRand.swift.gyb",
    "content": "%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%\n\nimport Foundation\nimport CBaseMath\n\n% for o in all_types:\n${o.swift()}\n% end\n\n"
  },
  {
    "path": "Sources/BaseMath/FloatVector.swift",
    "content": "import Foundation\n\n\nextension SupportsBasicMath {\n  @inlinable public static func add(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].add(pSrc2[i]) } }\n  @inlinable public static func add(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].add(val     ) } }\n  @inlinable public static func sub(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sub(pSrc2[i]) } }\n  @inlinable public static func sub(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sub(val     ) } }\n  @inlinable public static func mul(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].mul(pSrc2[i]) } }\n  @inlinable public static func mul(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].mul(val     ) } }\n  @inlinable public static func div(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].div(pSrc2[i]) } }\n  @inlinable public static func div(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].div(val     ) } }\n  @inlinable public static func subRev(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].subRev(pSrc2[i]) } }\n  @inlinable public static func subRev(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].subRev(val     ) } }\n  @inlinable public static func divRev(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].divRev(pSrc2[i]) } }\n  @inlinable public static func divRev(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].divRev(val     ) } }\n  @inlinable public static func min(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].min(pSrc2[i]) } }\n  @inlinable public static func min(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].min(val     ) } }\n  @inlinable public static func max(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].max(pSrc2[i]) } }\n  @inlinable public static func max(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].max(val     ) } }\n  @inlinable public static func pow(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].pow(pSrc2[i]) } }\n  @inlinable public static func pow(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].pow(val     ) } }\n  @inlinable public static func atan2(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atan2(pSrc2[i]) } }\n  @inlinable public static func atan2(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atan2(val     ) } }\n  @inlinable public static func copysign(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].copysign(pSrc2[i]) } }\n  @inlinable public static func copysign(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].copysign(val     ) } }\n  @inlinable public static func fdim(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fdim(pSrc2[i]) } }\n  @inlinable public static func fdim(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fdim(val     ) } }\n  @inlinable public static func fmax(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fmax(pSrc2[i]) } }\n  @inlinable public static func fmax(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fmax(val     ) } }\n  @inlinable public static func fmin(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fmin(pSrc2[i]) } }\n  @inlinable public static func fmin(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fmin(val     ) } }\n  @inlinable public static func hypot(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].hypot(pSrc2[i]) } }\n  @inlinable public static func hypot(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].hypot(val     ) } }\n  @inlinable public static func nextafter(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].nextafter(pSrc2[i]) } }\n  @inlinable public static func nextafter(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].nextafter(val     ) } }\n  @inlinable public static func abs(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].abs() } }\n  @inlinable public static func sqrt(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sqrt() } }\n  @inlinable public static func acos(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].acos() } }\n  @inlinable public static func acosh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].acosh() } }\n  @inlinable public static func asin(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].asin() } }\n  @inlinable public static func asinh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].asinh() } }\n  @inlinable public static func atan(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atan() } }\n  @inlinable public static func atanh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atanh() } }\n  @inlinable public static func cbrt(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].cbrt() } }\n  @inlinable public static func cos(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].cos() } }\n  @inlinable public static func cosh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].cosh() } }\n  @inlinable public static func erf(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].erf() } }\n  @inlinable public static func erfc(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].erfc() } }\n  @inlinable public static func exp(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].exp() } }\n  @inlinable public static func exp2(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].exp2() } }\n  @inlinable public static func expm1(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].expm1() } }\n  @inlinable public static func log(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log() } }\n  @inlinable public static func log10(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log10() } }\n  @inlinable public static func log1p(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log1p() } }\n  @inlinable public static func log2(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log2() } }\n  @inlinable public static func logb(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].logb() } }\n  @inlinable public static func nearbyint(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].nearbyint() } }\n  @inlinable public static func rint(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].rint() } }\n  @inlinable public static func sin(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sin() } }\n  @inlinable public static func sinh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sinh() } }\n  @inlinable public static func tan(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].tan() } }\n  @inlinable public static func tanh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].tanh() } }\n  @inlinable public static func tgamma(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].tgamma() } }\n}\n\npublic protocol FloatVector: BaseVector where Element:SupportsBasicMath {\n  func sum(_ f:UnaryF)->Element\n  func sum(_ f:BinaryF, _ b:Self)->Element\n  func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element\n\n  func add(_ b: Self, _ dest:Self)\n  func add_(_ b:Self)\n  func sub(_ b: Self, _ dest:Self)\n  func sub_(_ b:Self)\n  func mul(_ b: Self, _ dest:Self)\n  func mul_(_ b:Self)\n  func div(_ b: Self, _ dest:Self)\n  func div_(_ b:Self)\n  func subRev(_ b: Self, _ dest:Self)\n  func subRev_(_ b:Self)\n  func divRev(_ b: Self, _ dest:Self)\n  func divRev_(_ b:Self)\n  func min(_ b: Self, _ dest:Self)\n  func min_(_ b:Self)\n  func max(_ b: Self, _ dest:Self)\n  func max_(_ b:Self)\n  func pow(_ b: Self, _ dest:Self)\n  func pow_(_ b:Self)\n  func atan2(_ b: Self, _ dest:Self)\n  func atan2_(_ b:Self)\n  func copysign(_ b: Self, _ dest:Self)\n  func copysign_(_ b:Self)\n  func fdim(_ b: Self, _ dest:Self)\n  func fdim_(_ b:Self)\n  func fmax(_ b: Self, _ dest:Self)\n  func fmax_(_ b:Self)\n  func fmin(_ b: Self, _ dest:Self)\n  func fmin_(_ b:Self)\n  func hypot(_ b: Self, _ dest:Self)\n  func hypot_(_ b:Self)\n  func nextafter(_ b: Self, _ dest:Self)\n  func nextafter_(_ b:Self)\n\n  func abs(_ dest:Self)\n  func abs_()\n  func sqrt(_ dest:Self)\n  func sqrt_()\n  func acos(_ dest:Self)\n  func acos_()\n  func acosh(_ dest:Self)\n  func acosh_()\n  func asin(_ dest:Self)\n  func asin_()\n  func asinh(_ dest:Self)\n  func asinh_()\n  func atan(_ dest:Self)\n  func atan_()\n  func atanh(_ dest:Self)\n  func atanh_()\n  func cbrt(_ dest:Self)\n  func cbrt_()\n  func cos(_ dest:Self)\n  func cos_()\n  func cosh(_ dest:Self)\n  func cosh_()\n  func erf(_ dest:Self)\n  func erf_()\n  func erfc(_ dest:Self)\n  func erfc_()\n  func exp(_ dest:Self)\n  func exp_()\n  func exp2(_ dest:Self)\n  func exp2_()\n  func expm1(_ dest:Self)\n  func expm1_()\n  func log(_ dest:Self)\n  func log_()\n  func log10(_ dest:Self)\n  func log10_()\n  func log1p(_ dest:Self)\n  func log1p_()\n  func log2(_ dest:Self)\n  func log2_()\n  func logb(_ dest:Self)\n  func logb_()\n  func nearbyint(_ dest:Self)\n  func nearbyint_()\n  func rint(_ dest:Self)\n  func rint_()\n  func sin(_ dest:Self)\n  func sin_()\n  func sinh(_ dest:Self)\n  func sinh_()\n  func tan(_ dest:Self)\n  func tan_()\n  func tanh(_ dest:Self)\n  func tanh_()\n  func tgamma(_ dest:Self)\n  func tgamma_()\n\n  func sumabs()->Element\n  func sumsqrt()->Element\n  func sumacos()->Element\n  func sumacosh()->Element\n  func sumasin()->Element\n  func sumasinh()->Element\n  func sumatan()->Element\n  func sumatanh()->Element\n  func sumcbrt()->Element\n  func sumcos()->Element\n  func sumcosh()->Element\n  func sumerf()->Element\n  func sumerfc()->Element\n  func sumexp()->Element\n  func sumexp2()->Element\n  func sumexpm1()->Element\n  func sumlog()->Element\n  func sumlog10()->Element\n  func sumlog1p()->Element\n  func sumlog2()->Element\n  func sumlogb()->Element\n  func sumnearbyint()->Element\n  func sumrint()->Element\n  func sumsin()->Element\n  func sumsinh()->Element\n  func sumtan()->Element\n  func sumtanh()->Element\n  func sumtgamma()->Element\n\n  func sum() -> Element\n}\n\nextension FloatVector {\n  @usableFromInline var storeKey:String { get { return \"FloatVector\\(Element.self)\" } }\n  @usableFromInline var tempStore:Self { get {\n    if let r = Thread.current.threadDictionary[storeKey] as? Self {\n      if (r.count == count) { return r }\n    }\n    return Thread.setToTLS(Self(count), storeKey)\n  }}\n\n  @inlinable public func sum(_ f:UnaryF)->Element {\n    self.map(f, tempStore)\n    return tempStore.sum()\n  }\n  @inlinable public func sum(_ f:BinaryF, _ b:Self)->Element {\n    self.map(f, b, tempStore)\n    return tempStore.sum()\n  }\n  @inlinable public func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element {\n    self.map(f, b, c, tempStore)\n    return tempStore.sum()\n  }\n\n  @inlinable public func new_call(_ f:(Self)         ->()              )->Self { let res = new(); f(      res); return res }\n  @inlinable public func new_call(_ f:(Self, Self)   ->(), _ b:Self    )->Self { let res = new(); f(b,    res); return res }\n  @inlinable public func new_call<T>(_ f:(T, Self)   ->(), _ b:T       )->Self { let res = new(); f(b,    res); return res }\n  @inlinable public func new_call<T>(_ f:(T, T, Self)->(), _ b:T, _ c:T)->Self { let res = new(); f(b, c, res); return res }\n  @inlinable public func new_call<T>(_ f:(T, Self)->(), _ b:T, n:Int   )->Self { let res = new(n); f(b, res);   return res }\n  @inlinable public func new_call<T>(_ f:(T, T, Self)->(), _ b:T, _ c:T, n:Int)->Self { let res = new(n); f(b, c, res); return res }\n\n  @inlinable public func sum() -> Element { return Element.sum(p, numericCast(c)) }\n\n  @inlinable public func sumabs()->Element { return Element.sumabs(p, numericCast(c)) }\n  @inlinable public func sumsqrt()->Element { return Element.sumsqrt(p, numericCast(c)) }\n  @inlinable public func sumacos()->Element { return Element.sumacos(p, numericCast(c)) }\n  @inlinable public func sumacosh()->Element { return Element.sumacosh(p, numericCast(c)) }\n  @inlinable public func sumasin()->Element { return Element.sumasin(p, numericCast(c)) }\n  @inlinable public func sumasinh()->Element { return Element.sumasinh(p, numericCast(c)) }\n  @inlinable public func sumatan()->Element { return Element.sumatan(p, numericCast(c)) }\n  @inlinable public func sumatanh()->Element { return Element.sumatanh(p, numericCast(c)) }\n  @inlinable public func sumcbrt()->Element { return Element.sumcbrt(p, numericCast(c)) }\n  @inlinable public func sumcos()->Element { return Element.sumcos(p, numericCast(c)) }\n  @inlinable public func sumcosh()->Element { return Element.sumcosh(p, numericCast(c)) }\n  @inlinable public func sumerf()->Element { return Element.sumerf(p, numericCast(c)) }\n  @inlinable public func sumerfc()->Element { return Element.sumerfc(p, numericCast(c)) }\n  @inlinable public func sumexp()->Element { return Element.sumexp(p, numericCast(c)) }\n  @inlinable public func sumexp2()->Element { return Element.sumexp2(p, numericCast(c)) }\n  @inlinable public func sumexpm1()->Element { return Element.sumexpm1(p, numericCast(c)) }\n  @inlinable public func sumlog()->Element { return Element.sumlog(p, numericCast(c)) }\n  @inlinable public func sumlog10()->Element { return Element.sumlog10(p, numericCast(c)) }\n  @inlinable public func sumlog1p()->Element { return Element.sumlog1p(p, numericCast(c)) }\n  @inlinable public func sumlog2()->Element { return Element.sumlog2(p, numericCast(c)) }\n  @inlinable public func sumlogb()->Element { return Element.sumlogb(p, numericCast(c)) }\n  @inlinable public func sumnearbyint()->Element { return Element.sumnearbyint(p, numericCast(c)) }\n  @inlinable public func sumrint()->Element { return Element.sumrint(p, numericCast(c)) }\n  @inlinable public func sumsin()->Element { return Element.sumsin(p, numericCast(c)) }\n  @inlinable public func sumsinh()->Element { return Element.sumsinh(p, numericCast(c)) }\n  @inlinable public func sumtan()->Element { return Element.sumtan(p, numericCast(c)) }\n  @inlinable public func sumtanh()->Element { return Element.sumtanh(p, numericCast(c)) }\n  @inlinable public func sumtgamma()->Element { return Element.sumtgamma(p, numericCast(c)) }\n  @inlinable public func sumsqr()->Element { return Element.sumsqr(p, numericCast(c)) }\n\n  @inlinable public func add (_ b:Self)->Self { return new_call(add, b) }\n  @inlinable public func add (_ b:Self, _ dest:Self) { Element.add(count, self.p, b.p, dest.p) }\n  @inlinable public func add_(_ b:Self) { add(b, self) }\n  @inlinable public func add (_ b:Element)->Self { return new_call(add, b) }\n  @inlinable public func add (_ b:Element, _ dest:Self) { Element.add(count, self.p, b, dest.p) }\n  @inlinable public func add_(_ b:Element) { add(b, self) }\n  @inlinable public func sub (_ b:Self)->Self { return new_call(sub, b) }\n  @inlinable public func sub (_ b:Self, _ dest:Self) { Element.sub(count, self.p, b.p, dest.p) }\n  @inlinable public func sub_(_ b:Self) { sub(b, self) }\n  @inlinable public func sub (_ b:Element)->Self { return new_call(sub, b) }\n  @inlinable public func sub (_ b:Element, _ dest:Self) { Element.sub(count, self.p, b, dest.p) }\n  @inlinable public func sub_(_ b:Element) { sub(b, self) }\n  @inlinable public func mul (_ b:Self)->Self { return new_call(mul, b) }\n  @inlinable public func mul (_ b:Self, _ dest:Self) { Element.mul(count, self.p, b.p, dest.p) }\n  @inlinable public func mul_(_ b:Self) { mul(b, self) }\n  @inlinable public func mul (_ b:Element)->Self { return new_call(mul, b) }\n  @inlinable public func mul (_ b:Element, _ dest:Self) { Element.mul(count, self.p, b, dest.p) }\n  @inlinable public func mul_(_ b:Element) { mul(b, self) }\n  @inlinable public func div (_ b:Self)->Self { return new_call(div, b) }\n  @inlinable public func div (_ b:Self, _ dest:Self) { Element.div(count, self.p, b.p, dest.p) }\n  @inlinable public func div_(_ b:Self) { div(b, self) }\n  @inlinable public func div (_ b:Element)->Self { return new_call(div, b) }\n  @inlinable public func div (_ b:Element, _ dest:Self) { Element.div(count, self.p, b, dest.p) }\n  @inlinable public func div_(_ b:Element) { div(b, self) }\n  @inlinable public func subRev (_ b:Self)->Self { return new_call(subRev, b) }\n  @inlinable public func subRev (_ b:Self, _ dest:Self) { Element.subRev(count, self.p, b.p, dest.p) }\n  @inlinable public func subRev_(_ b:Self) { subRev(b, self) }\n  @inlinable public func subRev (_ b:Element)->Self { return new_call(subRev, b) }\n  @inlinable public func subRev (_ b:Element, _ dest:Self) { Element.subRev(count, self.p, b, dest.p) }\n  @inlinable public func subRev_(_ b:Element) { subRev(b, self) }\n  @inlinable public func divRev (_ b:Self)->Self { return new_call(divRev, b) }\n  @inlinable public func divRev (_ b:Self, _ dest:Self) { Element.divRev(count, self.p, b.p, dest.p) }\n  @inlinable public func divRev_(_ b:Self) { divRev(b, self) }\n  @inlinable public func divRev (_ b:Element)->Self { return new_call(divRev, b) }\n  @inlinable public func divRev (_ b:Element, _ dest:Self) { Element.divRev(count, self.p, b, dest.p) }\n  @inlinable public func divRev_(_ b:Element) { divRev(b, self) }\n  @inlinable public func min (_ b:Self)->Self { return new_call(min, b) }\n  @inlinable public func min (_ b:Self, _ dest:Self) { Element.min(count, self.p, b.p, dest.p) }\n  @inlinable public func min_(_ b:Self) { min(b, self) }\n  @inlinable public func min (_ b:Element)->Self { return new_call(min, b) }\n  @inlinable public func min (_ b:Element, _ dest:Self) { Element.min(count, self.p, b, dest.p) }\n  @inlinable public func min_(_ b:Element) { min(b, self) }\n  @inlinable public func max (_ b:Self)->Self { return new_call(max, b) }\n  @inlinable public func max (_ b:Self, _ dest:Self) { Element.max(count, self.p, b.p, dest.p) }\n  @inlinable public func max_(_ b:Self) { max(b, self) }\n  @inlinable public func max (_ b:Element)->Self { return new_call(max, b) }\n  @inlinable public func max (_ b:Element, _ dest:Self) { Element.max(count, self.p, b, dest.p) }\n  @inlinable public func max_(_ b:Element) { max(b, self) }\n  @inlinable public func pow (_ b:Self)->Self { return new_call(pow, b) }\n  @inlinable public func pow (_ b:Self, _ dest:Self) { Element.pow(count, self.p, b.p, dest.p) }\n  @inlinable public func pow_(_ b:Self) { pow(b, self) }\n  @inlinable public func pow (_ b:Element)->Self { return new_call(pow, b) }\n  @inlinable public func pow (_ b:Element, _ dest:Self) { Element.pow(count, self.p, b, dest.p) }\n  @inlinable public func pow_(_ b:Element) { pow(b, self) }\n  @inlinable public func atan2 (_ b:Self)->Self { return new_call(atan2, b) }\n  @inlinable public func atan2 (_ b:Self, _ dest:Self) { Element.atan2(count, self.p, b.p, dest.p) }\n  @inlinable public func atan2_(_ b:Self) { atan2(b, self) }\n  @inlinable public func atan2 (_ b:Element)->Self { return new_call(atan2, b) }\n  @inlinable public func atan2 (_ b:Element, _ dest:Self) { Element.atan2(count, self.p, b, dest.p) }\n  @inlinable public func atan2_(_ b:Element) { atan2(b, self) }\n  @inlinable public func copysign (_ b:Self)->Self { return new_call(copysign, b) }\n  @inlinable public func copysign (_ b:Self, _ dest:Self) { Element.copysign(count, self.p, b.p, dest.p) }\n  @inlinable public func copysign_(_ b:Self) { copysign(b, self) }\n  @inlinable public func copysign (_ b:Element)->Self { return new_call(copysign, b) }\n  @inlinable public func copysign (_ b:Element, _ dest:Self) { Element.copysign(count, self.p, b, dest.p) }\n  @inlinable public func copysign_(_ b:Element) { copysign(b, self) }\n  @inlinable public func fdim (_ b:Self)->Self { return new_call(fdim, b) }\n  @inlinable public func fdim (_ b:Self, _ dest:Self) { Element.fdim(count, self.p, b.p, dest.p) }\n  @inlinable public func fdim_(_ b:Self) { fdim(b, self) }\n  @inlinable public func fdim (_ b:Element)->Self { return new_call(fdim, b) }\n  @inlinable public func fdim (_ b:Element, _ dest:Self) { Element.fdim(count, self.p, b, dest.p) }\n  @inlinable public func fdim_(_ b:Element) { fdim(b, self) }\n  @inlinable public func fmax (_ b:Self)->Self { return new_call(fmax, b) }\n  @inlinable public func fmax (_ b:Self, _ dest:Self) { Element.fmax(count, self.p, b.p, dest.p) }\n  @inlinable public func fmax_(_ b:Self) { fmax(b, self) }\n  @inlinable public func fmax (_ b:Element)->Self { return new_call(fmax, b) }\n  @inlinable public func fmax (_ b:Element, _ dest:Self) { Element.fmax(count, self.p, b, dest.p) }\n  @inlinable public func fmax_(_ b:Element) { fmax(b, self) }\n  @inlinable public func fmin (_ b:Self)->Self { return new_call(fmin, b) }\n  @inlinable public func fmin (_ b:Self, _ dest:Self) { Element.fmin(count, self.p, b.p, dest.p) }\n  @inlinable public func fmin_(_ b:Self) { fmin(b, self) }\n  @inlinable public func fmin (_ b:Element)->Self { return new_call(fmin, b) }\n  @inlinable public func fmin (_ b:Element, _ dest:Self) { Element.fmin(count, self.p, b, dest.p) }\n  @inlinable public func fmin_(_ b:Element) { fmin(b, self) }\n  @inlinable public func hypot (_ b:Self)->Self { return new_call(hypot, b) }\n  @inlinable public func hypot (_ b:Self, _ dest:Self) { Element.hypot(count, self.p, b.p, dest.p) }\n  @inlinable public func hypot_(_ b:Self) { hypot(b, self) }\n  @inlinable public func hypot (_ b:Element)->Self { return new_call(hypot, b) }\n  @inlinable public func hypot (_ b:Element, _ dest:Self) { Element.hypot(count, self.p, b, dest.p) }\n  @inlinable public func hypot_(_ b:Element) { hypot(b, self) }\n  @inlinable public func nextafter (_ b:Self)->Self { return new_call(nextafter, b) }\n  @inlinable public func nextafter (_ b:Self, _ dest:Self) { Element.nextafter(count, self.p, b.p, dest.p) }\n  @inlinable public func nextafter_(_ b:Self) { nextafter(b, self) }\n  @inlinable public func nextafter (_ b:Element)->Self { return new_call(nextafter, b) }\n  @inlinable public func nextafter (_ b:Element, _ dest:Self) { Element.nextafter(count, self.p, b, dest.p) }\n  @inlinable public func nextafter_(_ b:Element) { nextafter(b, self) }\n\n  @inlinable public func abs ()->Self { return new_call(abs) }\n  @inlinable public func abs(_ dest:Self) { Element.abs(count, self.p, dest.p) }\n  @inlinable public func abs_() { abs(self) }\n  @inlinable public func sqrt ()->Self { return new_call(sqrt) }\n  @inlinable public func sqrt(_ dest:Self) { Element.sqrt(count, self.p, dest.p) }\n  @inlinable public func sqrt_() { sqrt(self) }\n  @inlinable public func acos ()->Self { return new_call(acos) }\n  @inlinable public func acos(_ dest:Self) { Element.acos(count, self.p, dest.p) }\n  @inlinable public func acos_() { acos(self) }\n  @inlinable public func acosh ()->Self { return new_call(acosh) }\n  @inlinable public func acosh(_ dest:Self) { Element.acosh(count, self.p, dest.p) }\n  @inlinable public func acosh_() { acosh(self) }\n  @inlinable public func asin ()->Self { return new_call(asin) }\n  @inlinable public func asin(_ dest:Self) { Element.asin(count, self.p, dest.p) }\n  @inlinable public func asin_() { asin(self) }\n  @inlinable public func asinh ()->Self { return new_call(asinh) }\n  @inlinable public func asinh(_ dest:Self) { Element.asinh(count, self.p, dest.p) }\n  @inlinable public func asinh_() { asinh(self) }\n  @inlinable public func atan ()->Self { return new_call(atan) }\n  @inlinable public func atan(_ dest:Self) { Element.atan(count, self.p, dest.p) }\n  @inlinable public func atan_() { atan(self) }\n  @inlinable public func atanh ()->Self { return new_call(atanh) }\n  @inlinable public func atanh(_ dest:Self) { Element.atanh(count, self.p, dest.p) }\n  @inlinable public func atanh_() { atanh(self) }\n  @inlinable public func cbrt ()->Self { return new_call(cbrt) }\n  @inlinable public func cbrt(_ dest:Self) { Element.cbrt(count, self.p, dest.p) }\n  @inlinable public func cbrt_() { cbrt(self) }\n  @inlinable public func cos ()->Self { return new_call(cos) }\n  @inlinable public func cos(_ dest:Self) { Element.cos(count, self.p, dest.p) }\n  @inlinable public func cos_() { cos(self) }\n  @inlinable public func cosh ()->Self { return new_call(cosh) }\n  @inlinable public func cosh(_ dest:Self) { Element.cosh(count, self.p, dest.p) }\n  @inlinable public func cosh_() { cosh(self) }\n  @inlinable public func erf ()->Self { return new_call(erf) }\n  @inlinable public func erf(_ dest:Self) { Element.erf(count, self.p, dest.p) }\n  @inlinable public func erf_() { erf(self) }\n  @inlinable public func erfc ()->Self { return new_call(erfc) }\n  @inlinable public func erfc(_ dest:Self) { Element.erfc(count, self.p, dest.p) }\n  @inlinable public func erfc_() { erfc(self) }\n  @inlinable public func exp ()->Self { return new_call(exp) }\n  @inlinable public func exp(_ dest:Self) { Element.exp(count, self.p, dest.p) }\n  @inlinable public func exp_() { exp(self) }\n  @inlinable public func exp2 ()->Self { return new_call(exp2) }\n  @inlinable public func exp2(_ dest:Self) { Element.exp2(count, self.p, dest.p) }\n  @inlinable public func exp2_() { exp2(self) }\n  @inlinable public func expm1 ()->Self { return new_call(expm1) }\n  @inlinable public func expm1(_ dest:Self) { Element.expm1(count, self.p, dest.p) }\n  @inlinable public func expm1_() { expm1(self) }\n  @inlinable public func log ()->Self { return new_call(log) }\n  @inlinable public func log(_ dest:Self) { Element.log(count, self.p, dest.p) }\n  @inlinable public func log_() { log(self) }\n  @inlinable public func log10 ()->Self { return new_call(log10) }\n  @inlinable public func log10(_ dest:Self) { Element.log10(count, self.p, dest.p) }\n  @inlinable public func log10_() { log10(self) }\n  @inlinable public func log1p ()->Self { return new_call(log1p) }\n  @inlinable public func log1p(_ dest:Self) { Element.log1p(count, self.p, dest.p) }\n  @inlinable public func log1p_() { log1p(self) }\n  @inlinable public func log2 ()->Self { return new_call(log2) }\n  @inlinable public func log2(_ dest:Self) { Element.log2(count, self.p, dest.p) }\n  @inlinable public func log2_() { log2(self) }\n  @inlinable public func logb ()->Self { return new_call(logb) }\n  @inlinable public func logb(_ dest:Self) { Element.logb(count, self.p, dest.p) }\n  @inlinable public func logb_() { logb(self) }\n  @inlinable public func nearbyint ()->Self { return new_call(nearbyint) }\n  @inlinable public func nearbyint(_ dest:Self) { Element.nearbyint(count, self.p, dest.p) }\n  @inlinable public func nearbyint_() { nearbyint(self) }\n  @inlinable public func rint ()->Self { return new_call(rint) }\n  @inlinable public func rint(_ dest:Self) { Element.rint(count, self.p, dest.p) }\n  @inlinable public func rint_() { rint(self) }\n  @inlinable public func sin ()->Self { return new_call(sin) }\n  @inlinable public func sin(_ dest:Self) { Element.sin(count, self.p, dest.p) }\n  @inlinable public func sin_() { sin(self) }\n  @inlinable public func sinh ()->Self { return new_call(sinh) }\n  @inlinable public func sinh(_ dest:Self) { Element.sinh(count, self.p, dest.p) }\n  @inlinable public func sinh_() { sinh(self) }\n  @inlinable public func tan ()->Self { return new_call(tan) }\n  @inlinable public func tan(_ dest:Self) { Element.tan(count, self.p, dest.p) }\n  @inlinable public func tan_() { tan(self) }\n  @inlinable public func tanh ()->Self { return new_call(tanh) }\n  @inlinable public func tanh(_ dest:Self) { Element.tanh(count, self.p, dest.p) }\n  @inlinable public func tanh_() { tanh(self) }\n  @inlinable public func tgamma ()->Self { return new_call(tgamma) }\n  @inlinable public func tgamma(_ dest:Self) { Element.tgamma(count, self.p, dest.p) }\n  @inlinable public func tgamma_() { tgamma(self) }\n\n  @inlinable public static func +  (lhs:Self, rhs:Self) -> Self { return lhs.add( rhs) }\n  @inlinable public static func += (lhs:Self, rhs:Self)         {        lhs.add_(rhs) }\n  @inlinable public static func +  (lhs:Self, rhs:Element) -> Self { return lhs.add( rhs) }\n  @inlinable public static func += (lhs:Self, rhs:Element)         {        lhs.add_(rhs) }\n  @inlinable public static func -  (lhs:Self, rhs:Self) -> Self { return lhs.sub( rhs) }\n  @inlinable public static func -= (lhs:Self, rhs:Self)         {        lhs.sub_(rhs) }\n  @inlinable public static func -  (lhs:Self, rhs:Element) -> Self { return lhs.sub( rhs) }\n  @inlinable public static func -= (lhs:Self, rhs:Element)         {        lhs.sub_(rhs) }\n  @inlinable public static func *  (lhs:Self, rhs:Self) -> Self { return lhs.mul( rhs) }\n  @inlinable public static func *= (lhs:Self, rhs:Self)         {        lhs.mul_(rhs) }\n  @inlinable public static func *  (lhs:Self, rhs:Element) -> Self { return lhs.mul( rhs) }\n  @inlinable public static func *= (lhs:Self, rhs:Element)         {        lhs.mul_(rhs) }\n  @inlinable public static func /  (lhs:Self, rhs:Self) -> Self { return lhs.div( rhs) }\n  @inlinable public static func /= (lhs:Self, rhs:Self)         {        lhs.div_(rhs) }\n  @inlinable public static func /  (lhs:Self, rhs:Element) -> Self { return lhs.div( rhs) }\n  @inlinable public static func /= (lhs:Self, rhs:Element)         {        lhs.div_(rhs) }\n\n  @inlinable public static func +  (lhs:Element, rhs:Self) -> Self { return rhs.add(  lhs) }\n  @inlinable public static func -  (lhs:Element, rhs:Self) -> Self { return rhs.subRev(  lhs) }\n  @inlinable public static func *  (lhs:Element, rhs:Self) -> Self { return rhs.mul(  lhs) }\n  @inlinable public static func /  (lhs:Element, rhs:Self) -> Self { return rhs.divRev(  lhs) }\n}\n\n"
  },
  {
    "path": "Sources/BaseMath/FloatVector.swift.gyb",
    "content": "import Foundation\n\n%{ import sys; sys.path.append('../..'); from mathfuncs import * }%\n\nextension SupportsBasicMath {\n% for f in binfs:\n  @inlinable public static func ${f}(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT,  _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].${f}(pSrc2[i]) } }\n  @inlinable public static func ${f}(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].${f}(val     ) } }\n% end\n% for f in unaryfs:\n  @inlinable public static func ${f}(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].${f}() } }\n% end\n}\n\npublic protocol FloatVector: BaseVector where Element:SupportsBasicMath {\n  func sum(_ f:UnaryF)->Element\n  func sum(_ f:BinaryF, _ b:Self)->Element\n  func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element\n\n% for f in binfs:\n  func ${f}(_ b: Self, _ dest:Self)\n  func ${f}_(_ b:Self)\n% end # f\n\n% for f in unaryfs:\n  func ${f}(_ dest:Self)\n  func ${f}_()\n% end # f\n\n% for f in unaryfs:\n  func sum${f}()->Element\n% end # f\n\n  func sum() -> Element\n}\n\nextension FloatVector {\n  @usableFromInline var storeKey:String { get { return \"FloatVector\\(Element.self)\" } }\n  @usableFromInline var tempStore:Self { get {\n    if let r = Thread.current.threadDictionary[storeKey] as? Self {\n      if (r.count == count) { return r }\n    }\n    return Thread.setToTLS(Self(count), storeKey)\n  }}\n\n  @inlinable public func sum(_ f:UnaryF)->Element {\n    self.map(f, tempStore)\n    return tempStore.sum()\n  }\n  @inlinable public func sum(_ f:BinaryF, _ b:Self)->Element {\n    self.map(f, b, tempStore)\n    return tempStore.sum()\n  }\n  @inlinable public func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element {\n    self.map(f, b, c, tempStore)\n    return tempStore.sum()\n  }\n\n  @inlinable public func new_call(_ f:(Self)         ->()              )->Self { let res = new(); f(      res); return res }\n  @inlinable public func new_call(_ f:(Self, Self)   ->(), _ b:Self    )->Self { let res = new(); f(b,    res); return res }\n  @inlinable public func new_call<T>(_ f:(T, Self)   ->(), _ b:T       )->Self { let res = new(); f(b,    res); return res }\n  @inlinable public func new_call<T>(_ f:(T, T, Self)->(), _ b:T, _ c:T)->Self { let res = new(); f(b, c, res); return res }\n  @inlinable public func new_call<T>(_ f:(T, Self)->(), _ b:T, n:Int   )->Self { let res = new(n); f(b, res);   return res }\n  @inlinable public func new_call<T>(_ f:(T, T, Self)->(), _ b:T, _ c:T, n:Int)->Self { let res = new(n); f(b, c, res); return res }\n\n  @inlinable public func sum() -> Element { return Element.sum(p, numericCast(c)) }\n\n% for f in unaryfs:\n  @inlinable public func sum${f}()->Element { return Element.sum${f}(p, numericCast(c)) }\n% end # f\n  @inlinable public func sumsqr()->Element { return Element.sumsqr(p, numericCast(c)) }\n\n% for f in binfs:\n  % for t in 'Self','Element':\n  %{ c = 'b' if t=='Element' else 'b.p' }%\n  @inlinable public func ${f} (_ b:${t})->Self { return new_call(${f}, b) }\n  @inlinable public func ${f} (_ b:${t}, _ dest:Self) { Element.${f}(count, self.p, ${c}, dest.p) }\n  @inlinable public func ${f}_(_ b:${t}) { ${f}(b, self) }\n  % end\n% end # f\n\n% for f in unaryfs:\n  @inlinable public func ${f} ()->Self { return new_call(${f}) }\n  @inlinable public func ${f}(_ dest:Self) { Element.${f}(count, self.p, dest.p) }\n  @inlinable public func ${f}_() { ${f}(self) }\n% end # f\n\n% for f,op in zip(op_fs,ops):\n  % for t in 'Self','Element':\n  @inlinable public static func ${op}  (lhs:Self, rhs:${t}) -> Self { return lhs.${f}( rhs) }\n  @inlinable public static func ${op}= (lhs:Self, rhs:${t})         {        lhs.${f}_(rhs) }\n  % end\n% end # op,f\n\n% for f,op in zip('add subRev mul divRev'.split(),ops):\n  @inlinable public static func ${op}  (lhs:Element, rhs:Self) -> Self { return rhs.${f}(  lhs) }\n% end # op,f\n}\n\n"
  },
  {
    "path": "Sources/BaseMath/Storage.swift",
    "content": "import Foundation\n\nextension Array where Element:SignedNumeric {\n  public init(_ count:Int) { self.init(repeating:0, count:count) }\n  public func copy() -> Array {\n    var a = (self as NSCopying).copy(with: nil) as! Array\n    // HACK: force a copy. Must be a better way...\n    a[0] = a[0]\n    return a\n  }\n  public var p:UnsafeMutablePointer<Element> {get {return UnsafeMutablePointer(mutating: self)}}\n}\n\nextension Array: BaseVector  where Element:SignedNumeric { }\nextension Array: FloatVector where Element:SupportsBasicMath { }\n\npublic protocol ComposedStorage {\n  associatedtype Storage:MutableCollection,CustomStringConvertible where Storage.Index==Int\n  typealias Index=Int\n\n  var data:Storage {get set}\n  var endIndex:Int {get}\n  subscript(i:Int)->Storage.Element {get set}\n}\npublic extension ComposedStorage {\n  subscript(i:Int)->Storage.Element { get {return data[i]} set {data[i] = newValue} }\n  var endIndex: Int { return data.count }\n}\n\nextension UnsafeMutableBufferPointer {\n  public init(_ count:Int) {\n    let sz = MemoryLayout<Element>.stride\n    let raw = UnsafeMutableRawBufferPointer.allocate(byteCount: sz*count, alignment: 64)\n    self.init(rebasing: raw.bindMemory(to: Element.self)[0...])\n  }\n  public init(_ array:Array<Element>) {\n    self.init(array.count)\n    _ = initialize(from:array)\n  }\n  public var p:UnsafeMutablePointer<Element> {get {return baseAddress!}}\n  public func copy()->UnsafeMutableBufferPointer { return .init(Array(self)) }\n}\n\nextension UnsafeMutableBufferPointer: BaseVector,ExpressibleByArrayLiteral,Equatable,CustomStringConvertible\n    where Element:SignedNumeric {\n  public typealias ArrayLiteralElement=Element\n}\nextension UnsafeMutableBufferPointer: FloatVector where Element:SupportsBasicMath { }\n\npublic final class AlignedStorage<T:SignedNumeric>: BaseVector,ComposedStorage {\n  public typealias Element=T\n  public var data:UnsafeMutableBufferPointer<T>\n\n  public init(_ data: UnsafeMutableBufferPointer<T>) {self.data=data}\n  public convenience init(_ count:Int)      { self.init(UnsafeMutableBufferPointer(count)) }\n  public convenience init(_ array:Array<T>) { self.init(UnsafeMutableBufferPointer(array)) }\n\n  deinit { UnsafeMutableRawBufferPointer(data).deallocate() }\n\n  public var p:MutPtrT {get {return data.p}}\n  public func copy()->Self { return .init(data.copy()) }\n}\n\nextension AlignedStorage:FloatVector where T:SupportsBasicMath {}\n\n"
  },
  {
    "path": "Sources/BaseMath/Utils.swift",
    "content": "import Foundation\nimport CoreFoundation\n\npublic func benchmarkTime(f: ()->()) -> Double {\n  f() // warmup\n  let start = CFAbsoluteTimeGetCurrent()\n  for _ in 0..<1 {f()}\n  return (CFAbsoluteTimeGetCurrent()-start)*1000\n}\n\npublic func benchmark(title:String, f:()->()) {\n  let time = benchmarkTime(f:f)\n  print(\"\\(title): \\(time.string(3)) ms\")\n}\n\nextension Thread {\n  static func setToTLS<T>(_ value: T, _ key: String)->T {\n    Thread.current.threadDictionary[key] = value\n    return value\n  }\n}\n\n"
  },
  {
    "path": "Sources/CBaseMath/CBaseMath.cpp",
    "content": "#include \"include/CBaseMath.h\"\n\n\n#include <cmath>\n\nusing namespace std; \n\n\nOVERLOADABLE float smSum(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += pSrc[i]; }\n  return r;\n}\n\nOVERLOADABLE float smSum_sqr(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }\n  return r;\n}\n\nOVERLOADABLE float smSum_abs(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += abs(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_abs(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = abs(pSrc[i]); }\n}\nOVERLOADABLE float smSum_sqrt(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += sqrt(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_sqrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = sqrt(pSrc[i]); }\n}\nOVERLOADABLE float smSum_acos(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += acos(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_acos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = acos(pSrc[i]); }\n}\nOVERLOADABLE float smSum_acosh(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += acosh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_acosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = acosh(pSrc[i]); }\n}\nOVERLOADABLE float smSum_asin(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += asin(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_asin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = asin(pSrc[i]); }\n}\nOVERLOADABLE float smSum_asinh(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += asinh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_asinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = asinh(pSrc[i]); }\n}\nOVERLOADABLE float smSum_atan(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += atan(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_atan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = atan(pSrc[i]); }\n}\nOVERLOADABLE float smSum_atanh(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += atanh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_atanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = atanh(pSrc[i]); }\n}\nOVERLOADABLE float smSum_cbrt(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += cbrt(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_cbrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = cbrt(pSrc[i]); }\n}\nOVERLOADABLE float smSum_cos(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += cos(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_cos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = cos(pSrc[i]); }\n}\nOVERLOADABLE float smSum_cosh(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += cosh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_cosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = cosh(pSrc[i]); }\n}\nOVERLOADABLE float smSum_erf(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += erf(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_erf(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = erf(pSrc[i]); }\n}\nOVERLOADABLE float smSum_erfc(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += erfc(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_erfc(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = erfc(pSrc[i]); }\n}\nOVERLOADABLE float smSum_exp(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += exp(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_exp(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = exp(pSrc[i]); }\n}\nOVERLOADABLE float smSum_exp2(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += exp2(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_exp2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = exp2(pSrc[i]); }\n}\nOVERLOADABLE float smSum_expm1(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += expm1(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_expm1(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = expm1(pSrc[i]); }\n}\nOVERLOADABLE float smSum_log(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log(pSrc[i]); }\n}\nOVERLOADABLE float smSum_log10(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log10(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log10(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log10(pSrc[i]); }\n}\nOVERLOADABLE float smSum_log1p(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log1p(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log1p(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log1p(pSrc[i]); }\n}\nOVERLOADABLE float smSum_log2(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log2(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log2(pSrc[i]); }\n}\nOVERLOADABLE float smSum_logb(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += logb(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_logb(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = logb(pSrc[i]); }\n}\nOVERLOADABLE float smSum_nearbyint(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += nearbyint(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_nearbyint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = nearbyint(pSrc[i]); }\n}\nOVERLOADABLE float smSum_rint(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += rint(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_rint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = rint(pSrc[i]); }\n}\nOVERLOADABLE float smSum_sin(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += sin(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_sin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = sin(pSrc[i]); }\n}\nOVERLOADABLE float smSum_sinh(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += sinh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_sinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = sinh(pSrc[i]); }\n}\nOVERLOADABLE float smSum_tan(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += tan(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_tan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = tan(pSrc[i]); }\n}\nOVERLOADABLE float smSum_tanh(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += tanh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_tanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = tanh(pSrc[i]); }\n}\nOVERLOADABLE float smSum_tgamma(const float* __restrict__ pSrc, const int len) {\n  float r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += tgamma(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_tgamma(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = tgamma(pSrc[i]); }\n}\n\n\nOVERLOADABLE double smSum(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += pSrc[i]; }\n  return r;\n}\n\nOVERLOADABLE double smSum_sqr(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }\n  return r;\n}\n\nOVERLOADABLE double smSum_abs(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += abs(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_abs(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = abs(pSrc[i]); }\n}\nOVERLOADABLE double smSum_sqrt(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += sqrt(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_sqrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = sqrt(pSrc[i]); }\n}\nOVERLOADABLE double smSum_acos(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += acos(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_acos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = acos(pSrc[i]); }\n}\nOVERLOADABLE double smSum_acosh(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += acosh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_acosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = acosh(pSrc[i]); }\n}\nOVERLOADABLE double smSum_asin(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += asin(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_asin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = asin(pSrc[i]); }\n}\nOVERLOADABLE double smSum_asinh(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += asinh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_asinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = asinh(pSrc[i]); }\n}\nOVERLOADABLE double smSum_atan(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += atan(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_atan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = atan(pSrc[i]); }\n}\nOVERLOADABLE double smSum_atanh(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += atanh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_atanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = atanh(pSrc[i]); }\n}\nOVERLOADABLE double smSum_cbrt(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += cbrt(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_cbrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = cbrt(pSrc[i]); }\n}\nOVERLOADABLE double smSum_cos(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += cos(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_cos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = cos(pSrc[i]); }\n}\nOVERLOADABLE double smSum_cosh(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += cosh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_cosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = cosh(pSrc[i]); }\n}\nOVERLOADABLE double smSum_erf(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += erf(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_erf(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = erf(pSrc[i]); }\n}\nOVERLOADABLE double smSum_erfc(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += erfc(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_erfc(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = erfc(pSrc[i]); }\n}\nOVERLOADABLE double smSum_exp(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += exp(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_exp(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = exp(pSrc[i]); }\n}\nOVERLOADABLE double smSum_exp2(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += exp2(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_exp2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = exp2(pSrc[i]); }\n}\nOVERLOADABLE double smSum_expm1(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += expm1(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_expm1(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = expm1(pSrc[i]); }\n}\nOVERLOADABLE double smSum_log(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log(pSrc[i]); }\n}\nOVERLOADABLE double smSum_log10(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log10(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log10(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log10(pSrc[i]); }\n}\nOVERLOADABLE double smSum_log1p(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log1p(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log1p(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log1p(pSrc[i]); }\n}\nOVERLOADABLE double smSum_log2(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += log2(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_log2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = log2(pSrc[i]); }\n}\nOVERLOADABLE double smSum_logb(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += logb(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_logb(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = logb(pSrc[i]); }\n}\nOVERLOADABLE double smSum_nearbyint(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += nearbyint(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_nearbyint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = nearbyint(pSrc[i]); }\n}\nOVERLOADABLE double smSum_rint(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += rint(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_rint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = rint(pSrc[i]); }\n}\nOVERLOADABLE double smSum_sin(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += sin(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_sin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = sin(pSrc[i]); }\n}\nOVERLOADABLE double smSum_sinh(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += sinh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_sinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = sinh(pSrc[i]); }\n}\nOVERLOADABLE double smSum_tan(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += tan(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_tan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = tan(pSrc[i]); }\n}\nOVERLOADABLE double smSum_tanh(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += tanh(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_tanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = tanh(pSrc[i]); }\n}\nOVERLOADABLE double smSum_tgamma(const double* __restrict__ pSrc, const int len) {\n  double r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += tgamma(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_tgamma(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = tgamma(pSrc[i]); }\n}\n\n\n"
  },
  {
    "path": "Sources/CBaseMath/CBaseMath.cpp.gyb",
    "content": "#include \"include/CBaseMath.h\"\n\n%{ import sys; sys.path.append('../..'); from mathfuncs import * }%\n\n#include <cmath>\n\nusing namespace std; \n\n% for t,s in zip(ctypes,['f','']):\n\nOVERLOADABLE ${t} smSum(const ${t}* __restrict__ pSrc, const int len) {\n  ${t} r = 0;\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += pSrc[i]; }\n  return r;\n}\n\nOVERLOADABLE ${t} smSum_sqr(const ${t}* __restrict__ pSrc, const int len) {\n  ${t} r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }\n  return r;\n}\n\n  % for f in unaryfs:\nOVERLOADABLE ${t} smSum_${f}(const ${t}* __restrict__ pSrc, const int len) {\n  ${t} r = 0;\n  #pragma ivdep\n  #pragma clang loop interleave_count(8)\n  for (int i=0; i<len; ++i) { r += ${f}(pSrc[i]); }\n  return r;\n}\n\nOVERLOADABLE void sm_${f}(const ${t}* __restrict__ pSrc, ${t}* __restrict__ pDst, const int len) {\n  #pragma ivdep\n  for (int i=0; i<len; ++i) { pDst[i] = ${f}(pSrc[i]); }\n}\n  % end # f\n\n% end # t\n\n"
  },
  {
    "path": "Sources/CBaseMath/CDistribution.cpp",
    "content": "\n#include \"include/CDistribution.h\"\n#include <random>\n#include <cmath>\n\nusing namespace std; \n\n\nstruct _inner_mt19937:mt19937 {};\nmt19937C mt19937_create() {\n  mt19937C r = {(_inner_mt19937*) new mt19937(random_device()())};\n  return r;\n}\nOVERLOADABLE void destroy(mt19937C v) { delete(v.p); }\n\n\nstruct _inner_knuth_b:knuth_b {};\nknuth_bC knuth_b_create() {\n  knuth_bC r = {(_inner_knuth_b*) new knuth_b(random_device()())};\n  return r;\n}\nOVERLOADABLE void destroy(knuth_bC v) { delete(v.p); }\n\n\nstruct _inner_bernoulli_distribution:bernoulli_distribution {};\nbernoulli_distributionC bernoulli_distribution_create(double p) {\n  bernoulli_distributionC r = {(_inner_bernoulli_distribution*) new bernoulli_distribution(p)};\n  return r;\n}\nOVERLOADABLE void destroy(bernoulli_distributionC v) { delete(v.p); }\n\n\nstruct _inner_uniform_int_distributionlong:uniform_int_distribution<long> {};\nOVERLOADABLE uniform_int_distributionlongC uniform_int_distribution_create(long a,long b, long _) {\n  uniform_int_distributionlongC r = {(_inner_uniform_int_distributionlong*) new uniform_int_distribution<long>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(uniform_int_distributionlongC v) { delete(v.p); }\n\n\nstruct _inner_uniform_int_distributionint:uniform_int_distribution<int> {};\nOVERLOADABLE uniform_int_distributionintC uniform_int_distribution_create(int a,int b, int _) {\n  uniform_int_distributionintC r = {(_inner_uniform_int_distributionint*) new uniform_int_distribution<int>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(uniform_int_distributionintC v) { delete(v.p); }\n\nOVERLOADABLE long call(uniform_int_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE int call(uniform_int_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_binomial_distributionlong:binomial_distribution<long> {};\nOVERLOADABLE binomial_distributionlongC binomial_distribution_create(long t, double p, long _) {\n  binomial_distributionlongC r = {(_inner_binomial_distributionlong*) new binomial_distribution<long>(t,p)};\n  return r;\n}\nOVERLOADABLE void destroy(binomial_distributionlongC v) { delete(v.p); }\n\n\nstruct _inner_binomial_distributionint:binomial_distribution<int> {};\nOVERLOADABLE binomial_distributionintC binomial_distribution_create(int t, double p, int _) {\n  binomial_distributionintC r = {(_inner_binomial_distributionint*) new binomial_distribution<int>(t,p)};\n  return r;\n}\nOVERLOADABLE void destroy(binomial_distributionintC v) { delete(v.p); }\n\nOVERLOADABLE long call(binomial_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE int call(binomial_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_negative_binomial_distributionlong:negative_binomial_distribution<long> {};\nOVERLOADABLE negative_binomial_distributionlongC negative_binomial_distribution_create(long k, double p, long _) {\n  negative_binomial_distributionlongC r = {(_inner_negative_binomial_distributionlong*) new negative_binomial_distribution<long>(k,p)};\n  return r;\n}\nOVERLOADABLE void destroy(negative_binomial_distributionlongC v) { delete(v.p); }\n\n\nstruct _inner_negative_binomial_distributionint:negative_binomial_distribution<int> {};\nOVERLOADABLE negative_binomial_distributionintC negative_binomial_distribution_create(int k, double p, int _) {\n  negative_binomial_distributionintC r = {(_inner_negative_binomial_distributionint*) new negative_binomial_distribution<int>(k,p)};\n  return r;\n}\nOVERLOADABLE void destroy(negative_binomial_distributionintC v) { delete(v.p); }\n\nOVERLOADABLE long call(negative_binomial_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE int call(negative_binomial_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_geometric_distributionlong:geometric_distribution<long> {};\nOVERLOADABLE geometric_distributionlongC geometric_distribution_create(double p, long _) {\n  geometric_distributionlongC r = {(_inner_geometric_distributionlong*) new geometric_distribution<long>(p)};\n  return r;\n}\nOVERLOADABLE void destroy(geometric_distributionlongC v) { delete(v.p); }\n\n\nstruct _inner_geometric_distributionint:geometric_distribution<int> {};\nOVERLOADABLE geometric_distributionintC geometric_distribution_create(double p, int _) {\n  geometric_distributionintC r = {(_inner_geometric_distributionint*) new geometric_distribution<int>(p)};\n  return r;\n}\nOVERLOADABLE void destroy(geometric_distributionintC v) { delete(v.p); }\n\nOVERLOADABLE long call(geometric_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE int call(geometric_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_poisson_distributionlong:poisson_distribution<long> {};\nOVERLOADABLE poisson_distributionlongC poisson_distribution_create(double mean, long _) {\n  poisson_distributionlongC r = {(_inner_poisson_distributionlong*) new poisson_distribution<long>(mean)};\n  return r;\n}\nOVERLOADABLE void destroy(poisson_distributionlongC v) { delete(v.p); }\n\n\nstruct _inner_poisson_distributionint:poisson_distribution<int> {};\nOVERLOADABLE poisson_distributionintC poisson_distribution_create(double mean, int _) {\n  poisson_distributionintC r = {(_inner_poisson_distributionint*) new poisson_distribution<int>(mean)};\n  return r;\n}\nOVERLOADABLE void destroy(poisson_distributionintC v) { delete(v.p); }\n\nOVERLOADABLE long call(poisson_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE int call(poisson_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_discrete_distributionlong:discrete_distribution<long> {};\nOVERLOADABLE discrete_distributionlongC discrete_distribution_create(double* start, double* end, long _) {\n  discrete_distributionlongC r = {(_inner_discrete_distributionlong*) new discrete_distribution<long>(start,end)};\n  return r;\n}\nOVERLOADABLE void destroy(discrete_distributionlongC v) { delete(v.p); }\n\n\nstruct _inner_discrete_distributionint:discrete_distribution<int> {};\nOVERLOADABLE discrete_distributionintC discrete_distribution_create(double* start, double* end, int _) {\n  discrete_distributionintC r = {(_inner_discrete_distributionint*) new discrete_distribution<int>(start,end)};\n  return r;\n}\nOVERLOADABLE void destroy(discrete_distributionintC v) { delete(v.p); }\n\nOVERLOADABLE long call(discrete_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE int call(discrete_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_uniform_real_distributionfloat:uniform_real_distribution<float> {};\nOVERLOADABLE uniform_real_distributionfloatC uniform_real_distribution_create(float a,float b, float _) {\n  uniform_real_distributionfloatC r = {(_inner_uniform_real_distributionfloat*) new uniform_real_distribution<float>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(uniform_real_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_uniform_real_distributiondouble:uniform_real_distribution<double> {};\nOVERLOADABLE uniform_real_distributiondoubleC uniform_real_distribution_create(double a,double b, double _) {\n  uniform_real_distributiondoubleC r = {(_inner_uniform_real_distributiondouble*) new uniform_real_distribution<double>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(uniform_real_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(uniform_real_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(uniform_real_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_exponential_distributionfloat:exponential_distribution<float> {};\nOVERLOADABLE exponential_distributionfloatC exponential_distribution_create(float l, float _) {\n  exponential_distributionfloatC r = {(_inner_exponential_distributionfloat*) new exponential_distribution<float>(l)};\n  return r;\n}\nOVERLOADABLE void destroy(exponential_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_exponential_distributiondouble:exponential_distribution<double> {};\nOVERLOADABLE exponential_distributiondoubleC exponential_distribution_create(double l, double _) {\n  exponential_distributiondoubleC r = {(_inner_exponential_distributiondouble*) new exponential_distribution<double>(l)};\n  return r;\n}\nOVERLOADABLE void destroy(exponential_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(exponential_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(exponential_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_gamma_distributionfloat:gamma_distribution<float> {};\nOVERLOADABLE gamma_distributionfloatC gamma_distribution_create(float a,float b, float _) {\n  gamma_distributionfloatC r = {(_inner_gamma_distributionfloat*) new gamma_distribution<float>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(gamma_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_gamma_distributiondouble:gamma_distribution<double> {};\nOVERLOADABLE gamma_distributiondoubleC gamma_distribution_create(double a,double b, double _) {\n  gamma_distributiondoubleC r = {(_inner_gamma_distributiondouble*) new gamma_distribution<double>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(gamma_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(gamma_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(gamma_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_weibull_distributionfloat:weibull_distribution<float> {};\nOVERLOADABLE weibull_distributionfloatC weibull_distribution_create(float a,float b, float _) {\n  weibull_distributionfloatC r = {(_inner_weibull_distributionfloat*) new weibull_distribution<float>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(weibull_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_weibull_distributiondouble:weibull_distribution<double> {};\nOVERLOADABLE weibull_distributiondoubleC weibull_distribution_create(double a,double b, double _) {\n  weibull_distributiondoubleC r = {(_inner_weibull_distributiondouble*) new weibull_distribution<double>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(weibull_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(weibull_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(weibull_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_normal_distributionfloat:normal_distribution<float> {};\nOVERLOADABLE normal_distributionfloatC normal_distribution_create(float mean,float stddev, float _) {\n  normal_distributionfloatC r = {(_inner_normal_distributionfloat*) new normal_distribution<float>(mean,stddev)};\n  return r;\n}\nOVERLOADABLE void destroy(normal_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_normal_distributiondouble:normal_distribution<double> {};\nOVERLOADABLE normal_distributiondoubleC normal_distribution_create(double mean,double stddev, double _) {\n  normal_distributiondoubleC r = {(_inner_normal_distributiondouble*) new normal_distribution<double>(mean,stddev)};\n  return r;\n}\nOVERLOADABLE void destroy(normal_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(normal_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(normal_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_lognormal_distributionfloat:lognormal_distribution<float> {};\nOVERLOADABLE lognormal_distributionfloatC lognormal_distribution_create(float m,float s, float _) {\n  lognormal_distributionfloatC r = {(_inner_lognormal_distributionfloat*) new lognormal_distribution<float>(m,s)};\n  return r;\n}\nOVERLOADABLE void destroy(lognormal_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_lognormal_distributiondouble:lognormal_distribution<double> {};\nOVERLOADABLE lognormal_distributiondoubleC lognormal_distribution_create(double m,double s, double _) {\n  lognormal_distributiondoubleC r = {(_inner_lognormal_distributiondouble*) new lognormal_distribution<double>(m,s)};\n  return r;\n}\nOVERLOADABLE void destroy(lognormal_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(lognormal_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(lognormal_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_chi_squared_distributionfloat:chi_squared_distribution<float> {};\nOVERLOADABLE chi_squared_distributionfloatC chi_squared_distribution_create(float n, float _) {\n  chi_squared_distributionfloatC r = {(_inner_chi_squared_distributionfloat*) new chi_squared_distribution<float>(n)};\n  return r;\n}\nOVERLOADABLE void destroy(chi_squared_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_chi_squared_distributiondouble:chi_squared_distribution<double> {};\nOVERLOADABLE chi_squared_distributiondoubleC chi_squared_distribution_create(double n, double _) {\n  chi_squared_distributiondoubleC r = {(_inner_chi_squared_distributiondouble*) new chi_squared_distribution<double>(n)};\n  return r;\n}\nOVERLOADABLE void destroy(chi_squared_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(chi_squared_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(chi_squared_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_cauchy_distributionfloat:cauchy_distribution<float> {};\nOVERLOADABLE cauchy_distributionfloatC cauchy_distribution_create(float a,float b, float _) {\n  cauchy_distributionfloatC r = {(_inner_cauchy_distributionfloat*) new cauchy_distribution<float>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(cauchy_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_cauchy_distributiondouble:cauchy_distribution<double> {};\nOVERLOADABLE cauchy_distributiondoubleC cauchy_distribution_create(double a,double b, double _) {\n  cauchy_distributiondoubleC r = {(_inner_cauchy_distributiondouble*) new cauchy_distribution<double>(a,b)};\n  return r;\n}\nOVERLOADABLE void destroy(cauchy_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(cauchy_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(cauchy_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_fisher_f_distributionfloat:fisher_f_distribution<float> {};\nOVERLOADABLE fisher_f_distributionfloatC fisher_f_distribution_create(float m,float n, float _) {\n  fisher_f_distributionfloatC r = {(_inner_fisher_f_distributionfloat*) new fisher_f_distribution<float>(m,n)};\n  return r;\n}\nOVERLOADABLE void destroy(fisher_f_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_fisher_f_distributiondouble:fisher_f_distribution<double> {};\nOVERLOADABLE fisher_f_distributiondoubleC fisher_f_distribution_create(double m,double n, double _) {\n  fisher_f_distributiondoubleC r = {(_inner_fisher_f_distributiondouble*) new fisher_f_distribution<double>(m,n)};\n  return r;\n}\nOVERLOADABLE void destroy(fisher_f_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(fisher_f_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(fisher_f_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_student_t_distributionfloat:student_t_distribution<float> {};\nOVERLOADABLE student_t_distributionfloatC student_t_distribution_create(float n, float _) {\n  student_t_distributionfloatC r = {(_inner_student_t_distributionfloat*) new student_t_distribution<float>(n)};\n  return r;\n}\nOVERLOADABLE void destroy(student_t_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_student_t_distributiondouble:student_t_distribution<double> {};\nOVERLOADABLE student_t_distributiondoubleC student_t_distribution_create(double n, double _) {\n  student_t_distributiondoubleC r = {(_inner_student_t_distributiondouble*) new student_t_distribution<double>(n)};\n  return r;\n}\nOVERLOADABLE void destroy(student_t_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(student_t_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(student_t_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_piecewise_constant_distributionfloat:piecewise_constant_distribution<float> {};\nOVERLOADABLE piecewise_constant_distributionfloatC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, float _) {\n  piecewise_constant_distributionfloatC r = {(_inner_piecewise_constant_distributionfloat*) new piecewise_constant_distribution<float>(start_i,end_i,start_w)};\n  return r;\n}\nOVERLOADABLE void destroy(piecewise_constant_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_piecewise_constant_distributiondouble:piecewise_constant_distribution<double> {};\nOVERLOADABLE piecewise_constant_distributiondoubleC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, double _) {\n  piecewise_constant_distributiondoubleC r = {(_inner_piecewise_constant_distributiondouble*) new piecewise_constant_distribution<double>(start_i,end_i,start_w)};\n  return r;\n}\nOVERLOADABLE void destroy(piecewise_constant_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(piecewise_constant_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(piecewise_constant_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n\nstruct _inner_piecewise_linear_distributionfloat:piecewise_linear_distribution<float> {};\nOVERLOADABLE piecewise_linear_distributionfloatC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, float _) {\n  piecewise_linear_distributionfloatC r = {(_inner_piecewise_linear_distributionfloat*) new piecewise_linear_distribution<float>(start_i,end_i,start_w)};\n  return r;\n}\nOVERLOADABLE void destroy(piecewise_linear_distributionfloatC v) { delete(v.p); }\n\n\nstruct _inner_piecewise_linear_distributiondouble:piecewise_linear_distribution<double> {};\nOVERLOADABLE piecewise_linear_distributiondoubleC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, double _) {\n  piecewise_linear_distributiondoubleC r = {(_inner_piecewise_linear_distributiondouble*) new piecewise_linear_distribution<double>(start_i,end_i,start_w)};\n  return r;\n}\nOVERLOADABLE void destroy(piecewise_linear_distributiondoubleC v) { delete(v.p); }\n\nOVERLOADABLE float call(piecewise_linear_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}\nOVERLOADABLE double call(piecewise_linear_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}\n \n"
  },
  {
    "path": "Sources/CBaseMath/CDistribution.cpp.gyb",
    "content": "%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%\n\n#include \"include/CDistribution.h\"\n#include <random>\n#include <cmath>\n\nusing namespace std; \n\n% for t in gen_types+dist_types:\n${t.cpp_impl()}\n% end\n \n"
  },
  {
    "path": "Sources/CBaseMath/include/CBaseMath.h",
    "content": "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OVERLOADABLE __attribute__((overloadable))\n#include <stdbool.h>\n#include \"CDistribution.h\"\n\nOVERLOADABLE float smSum(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE float smSum_sqr(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE float smSum_abs(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_abs(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_sqrt(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_sqrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_acos(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_acos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_acosh(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_acosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_asin(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_asin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_asinh(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_asinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_atan(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_atan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_atanh(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_atanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_cbrt(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_cbrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_cos(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_cos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_cosh(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_cosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_erf(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_erf(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_erfc(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_erfc(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_exp(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_exp(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_exp2(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_exp2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_expm1(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_expm1(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_log(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_log10(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log10(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_log1p(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log1p(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_log2(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_logb(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_logb(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_nearbyint(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_nearbyint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_rint(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_rint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_sin(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_sin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_sinh(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_sinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_tan(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_tan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_tanh(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_tanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE float smSum_tgamma(const float* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_tgamma(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE double smSum_sqr(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE double smSum_abs(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_abs(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_sqrt(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_sqrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_acos(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_acos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_acosh(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_acosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_asin(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_asin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_asinh(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_asinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_atan(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_atan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_atanh(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_atanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_cbrt(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_cbrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_cos(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_cos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_cosh(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_cosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_erf(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_erf(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_erfc(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_erfc(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_exp(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_exp(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_exp2(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_exp2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_expm1(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_expm1(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_log(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_log10(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log10(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_log1p(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log1p(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_log2(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_log2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_logb(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_logb(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_nearbyint(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_nearbyint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_rint(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_rint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_sin(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_sin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_sinh(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_sinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_tan(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_tan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_tanh(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_tanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\nOVERLOADABLE double smSum_tgamma(const double* __restrict__ pSrc, const int len) ;\nOVERLOADABLE void sm_tgamma(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;\n\n#ifdef __cplusplus\n}\n#endif\n\n"
  },
  {
    "path": "Sources/CBaseMath/include/CBaseMath.h.gyb",
    "content": "%{ import sys; sys.path.append('../../..'); from cpp_template import * }%\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OVERLOADABLE __attribute__((overloadable))\n#include <stdbool.h>\n#include \"CDistribution.h\"\n\n${ make_header(__file__) }\n\n#ifdef __cplusplus\n}\n#endif\n\n"
  },
  {
    "path": "Sources/CBaseMath/include/CDistribution.h",
    "content": "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OVERLOADABLE __attribute__((overloadable))\n#include <stdbool.h>\n\n\ntypedef struct _inner_uniform_int_distributionlong _inner_uniform_int_distributionlong;\ntypedef struct uniform_int_distributionlongC uniform_int_distributionlongC;\nstruct uniform_int_distributionlongC {_inner_uniform_int_distributionlong* p;};\n\n\ntypedef struct _inner_uniform_int_distributionint _inner_uniform_int_distributionint;\ntypedef struct uniform_int_distributionintC uniform_int_distributionintC;\nstruct uniform_int_distributionintC {_inner_uniform_int_distributionint* p;};\n\n\ntypedef struct _inner_binomial_distributionlong _inner_binomial_distributionlong;\ntypedef struct binomial_distributionlongC binomial_distributionlongC;\nstruct binomial_distributionlongC {_inner_binomial_distributionlong* p;};\n\n\ntypedef struct _inner_binomial_distributionint _inner_binomial_distributionint;\ntypedef struct binomial_distributionintC binomial_distributionintC;\nstruct binomial_distributionintC {_inner_binomial_distributionint* p;};\n\n\ntypedef struct _inner_negative_binomial_distributionlong _inner_negative_binomial_distributionlong;\ntypedef struct negative_binomial_distributionlongC negative_binomial_distributionlongC;\nstruct negative_binomial_distributionlongC {_inner_negative_binomial_distributionlong* p;};\n\n\ntypedef struct _inner_negative_binomial_distributionint _inner_negative_binomial_distributionint;\ntypedef struct negative_binomial_distributionintC negative_binomial_distributionintC;\nstruct negative_binomial_distributionintC {_inner_negative_binomial_distributionint* p;};\n\n\ntypedef struct _inner_geometric_distributionlong _inner_geometric_distributionlong;\ntypedef struct geometric_distributionlongC geometric_distributionlongC;\nstruct geometric_distributionlongC {_inner_geometric_distributionlong* p;};\n\n\ntypedef struct _inner_geometric_distributionint _inner_geometric_distributionint;\ntypedef struct geometric_distributionintC geometric_distributionintC;\nstruct geometric_distributionintC {_inner_geometric_distributionint* p;};\n\n\ntypedef struct _inner_poisson_distributionlong _inner_poisson_distributionlong;\ntypedef struct poisson_distributionlongC poisson_distributionlongC;\nstruct poisson_distributionlongC {_inner_poisson_distributionlong* p;};\n\n\ntypedef struct _inner_poisson_distributionint _inner_poisson_distributionint;\ntypedef struct poisson_distributionintC poisson_distributionintC;\nstruct poisson_distributionintC {_inner_poisson_distributionint* p;};\n\n\ntypedef struct _inner_discrete_distributionlong _inner_discrete_distributionlong;\ntypedef struct discrete_distributionlongC discrete_distributionlongC;\nstruct discrete_distributionlongC {_inner_discrete_distributionlong* p;};\n\n\ntypedef struct _inner_discrete_distributionint _inner_discrete_distributionint;\ntypedef struct discrete_distributionintC discrete_distributionintC;\nstruct discrete_distributionintC {_inner_discrete_distributionint* p;};\n\n\ntypedef struct _inner_uniform_real_distributionfloat _inner_uniform_real_distributionfloat;\ntypedef struct uniform_real_distributionfloatC uniform_real_distributionfloatC;\nstruct uniform_real_distributionfloatC {_inner_uniform_real_distributionfloat* p;};\n\n\ntypedef struct _inner_uniform_real_distributiondouble _inner_uniform_real_distributiondouble;\ntypedef struct uniform_real_distributiondoubleC uniform_real_distributiondoubleC;\nstruct uniform_real_distributiondoubleC {_inner_uniform_real_distributiondouble* p;};\n\n\ntypedef struct _inner_exponential_distributionfloat _inner_exponential_distributionfloat;\ntypedef struct exponential_distributionfloatC exponential_distributionfloatC;\nstruct exponential_distributionfloatC {_inner_exponential_distributionfloat* p;};\n\n\ntypedef struct _inner_exponential_distributiondouble _inner_exponential_distributiondouble;\ntypedef struct exponential_distributiondoubleC exponential_distributiondoubleC;\nstruct exponential_distributiondoubleC {_inner_exponential_distributiondouble* p;};\n\n\ntypedef struct _inner_gamma_distributionfloat _inner_gamma_distributionfloat;\ntypedef struct gamma_distributionfloatC gamma_distributionfloatC;\nstruct gamma_distributionfloatC {_inner_gamma_distributionfloat* p;};\n\n\ntypedef struct _inner_gamma_distributiondouble _inner_gamma_distributiondouble;\ntypedef struct gamma_distributiondoubleC gamma_distributiondoubleC;\nstruct gamma_distributiondoubleC {_inner_gamma_distributiondouble* p;};\n\n\ntypedef struct _inner_weibull_distributionfloat _inner_weibull_distributionfloat;\ntypedef struct weibull_distributionfloatC weibull_distributionfloatC;\nstruct weibull_distributionfloatC {_inner_weibull_distributionfloat* p;};\n\n\ntypedef struct _inner_weibull_distributiondouble _inner_weibull_distributiondouble;\ntypedef struct weibull_distributiondoubleC weibull_distributiondoubleC;\nstruct weibull_distributiondoubleC {_inner_weibull_distributiondouble* p;};\n\n\ntypedef struct _inner_normal_distributionfloat _inner_normal_distributionfloat;\ntypedef struct normal_distributionfloatC normal_distributionfloatC;\nstruct normal_distributionfloatC {_inner_normal_distributionfloat* p;};\n\n\ntypedef struct _inner_normal_distributiondouble _inner_normal_distributiondouble;\ntypedef struct normal_distributiondoubleC normal_distributiondoubleC;\nstruct normal_distributiondoubleC {_inner_normal_distributiondouble* p;};\n\n\ntypedef struct _inner_lognormal_distributionfloat _inner_lognormal_distributionfloat;\ntypedef struct lognormal_distributionfloatC lognormal_distributionfloatC;\nstruct lognormal_distributionfloatC {_inner_lognormal_distributionfloat* p;};\n\n\ntypedef struct _inner_lognormal_distributiondouble _inner_lognormal_distributiondouble;\ntypedef struct lognormal_distributiondoubleC lognormal_distributiondoubleC;\nstruct lognormal_distributiondoubleC {_inner_lognormal_distributiondouble* p;};\n\n\ntypedef struct _inner_chi_squared_distributionfloat _inner_chi_squared_distributionfloat;\ntypedef struct chi_squared_distributionfloatC chi_squared_distributionfloatC;\nstruct chi_squared_distributionfloatC {_inner_chi_squared_distributionfloat* p;};\n\n\ntypedef struct _inner_chi_squared_distributiondouble _inner_chi_squared_distributiondouble;\ntypedef struct chi_squared_distributiondoubleC chi_squared_distributiondoubleC;\nstruct chi_squared_distributiondoubleC {_inner_chi_squared_distributiondouble* p;};\n\n\ntypedef struct _inner_cauchy_distributionfloat _inner_cauchy_distributionfloat;\ntypedef struct cauchy_distributionfloatC cauchy_distributionfloatC;\nstruct cauchy_distributionfloatC {_inner_cauchy_distributionfloat* p;};\n\n\ntypedef struct _inner_cauchy_distributiondouble _inner_cauchy_distributiondouble;\ntypedef struct cauchy_distributiondoubleC cauchy_distributiondoubleC;\nstruct cauchy_distributiondoubleC {_inner_cauchy_distributiondouble* p;};\n\n\ntypedef struct _inner_fisher_f_distributionfloat _inner_fisher_f_distributionfloat;\ntypedef struct fisher_f_distributionfloatC fisher_f_distributionfloatC;\nstruct fisher_f_distributionfloatC {_inner_fisher_f_distributionfloat* p;};\n\n\ntypedef struct _inner_fisher_f_distributiondouble _inner_fisher_f_distributiondouble;\ntypedef struct fisher_f_distributiondoubleC fisher_f_distributiondoubleC;\nstruct fisher_f_distributiondoubleC {_inner_fisher_f_distributiondouble* p;};\n\n\ntypedef struct _inner_student_t_distributionfloat _inner_student_t_distributionfloat;\ntypedef struct student_t_distributionfloatC student_t_distributionfloatC;\nstruct student_t_distributionfloatC {_inner_student_t_distributionfloat* p;};\n\n\ntypedef struct _inner_student_t_distributiondouble _inner_student_t_distributiondouble;\ntypedef struct student_t_distributiondoubleC student_t_distributiondoubleC;\nstruct student_t_distributiondoubleC {_inner_student_t_distributiondouble* p;};\n\n\ntypedef struct _inner_piecewise_constant_distributionfloat _inner_piecewise_constant_distributionfloat;\ntypedef struct piecewise_constant_distributionfloatC piecewise_constant_distributionfloatC;\nstruct piecewise_constant_distributionfloatC {_inner_piecewise_constant_distributionfloat* p;};\n\n\ntypedef struct _inner_piecewise_constant_distributiondouble _inner_piecewise_constant_distributiondouble;\ntypedef struct piecewise_constant_distributiondoubleC piecewise_constant_distributiondoubleC;\nstruct piecewise_constant_distributiondoubleC {_inner_piecewise_constant_distributiondouble* p;};\n\n\ntypedef struct _inner_piecewise_linear_distributionfloat _inner_piecewise_linear_distributionfloat;\ntypedef struct piecewise_linear_distributionfloatC piecewise_linear_distributionfloatC;\nstruct piecewise_linear_distributionfloatC {_inner_piecewise_linear_distributionfloat* p;};\n\n\ntypedef struct _inner_piecewise_linear_distributiondouble _inner_piecewise_linear_distributiondouble;\ntypedef struct piecewise_linear_distributiondoubleC piecewise_linear_distributiondoubleC;\nstruct piecewise_linear_distributiondoubleC {_inner_piecewise_linear_distributiondouble* p;};\n\n\ntypedef struct _inner_mt19937 _inner_mt19937;\ntypedef struct mt19937C mt19937C;\nstruct mt19937C {_inner_mt19937* p;};\n\n\ntypedef struct _inner_knuth_b _inner_knuth_b;\ntypedef struct knuth_bC knuth_bC;\nstruct knuth_bC {_inner_knuth_b* p;};\n\n\ntypedef struct _inner_bernoulli_distribution _inner_bernoulli_distribution;\ntypedef struct bernoulli_distributionC bernoulli_distributionC;\nstruct bernoulli_distributionC {_inner_bernoulli_distribution* p;};\n\n\nmt19937C mt19937_create() ;\nOVERLOADABLE void destroy(mt19937C v) ;\nknuth_bC knuth_b_create() ;\nOVERLOADABLE void destroy(knuth_bC v) ;\nbernoulli_distributionC bernoulli_distribution_create(double p) ;\nOVERLOADABLE void destroy(bernoulli_distributionC v) ;\nOVERLOADABLE uniform_int_distributionlongC uniform_int_distribution_create(long a,long b, long _) ;\nOVERLOADABLE void destroy(uniform_int_distributionlongC v) ;\nOVERLOADABLE uniform_int_distributionintC uniform_int_distribution_create(int a,int b, int _) ;\nOVERLOADABLE void destroy(uniform_int_distributionintC v) ;\nOVERLOADABLE long call(uniform_int_distributionlongC p,mt19937C g) ;\nOVERLOADABLE int call(uniform_int_distributionintC p,mt19937C g) ;\nOVERLOADABLE binomial_distributionlongC binomial_distribution_create(long t, double p, long _) ;\nOVERLOADABLE void destroy(binomial_distributionlongC v) ;\nOVERLOADABLE binomial_distributionintC binomial_distribution_create(int t, double p, int _) ;\nOVERLOADABLE void destroy(binomial_distributionintC v) ;\nOVERLOADABLE long call(binomial_distributionlongC p,mt19937C g) ;\nOVERLOADABLE int call(binomial_distributionintC p,mt19937C g) ;\nOVERLOADABLE negative_binomial_distributionlongC negative_binomial_distribution_create(long k, double p, long _) ;\nOVERLOADABLE void destroy(negative_binomial_distributionlongC v) ;\nOVERLOADABLE negative_binomial_distributionintC negative_binomial_distribution_create(int k, double p, int _) ;\nOVERLOADABLE void destroy(negative_binomial_distributionintC v) ;\nOVERLOADABLE long call(negative_binomial_distributionlongC p,mt19937C g) ;\nOVERLOADABLE int call(negative_binomial_distributionintC p,mt19937C g) ;\nOVERLOADABLE geometric_distributionlongC geometric_distribution_create(double p, long _) ;\nOVERLOADABLE void destroy(geometric_distributionlongC v) ;\nOVERLOADABLE geometric_distributionintC geometric_distribution_create(double p, int _) ;\nOVERLOADABLE void destroy(geometric_distributionintC v) ;\nOVERLOADABLE long call(geometric_distributionlongC p,mt19937C g) ;\nOVERLOADABLE int call(geometric_distributionintC p,mt19937C g) ;\nOVERLOADABLE poisson_distributionlongC poisson_distribution_create(double mean, long _) ;\nOVERLOADABLE void destroy(poisson_distributionlongC v) ;\nOVERLOADABLE poisson_distributionintC poisson_distribution_create(double mean, int _) ;\nOVERLOADABLE void destroy(poisson_distributionintC v) ;\nOVERLOADABLE long call(poisson_distributionlongC p,mt19937C g) ;\nOVERLOADABLE int call(poisson_distributionintC p,mt19937C g) ;\nOVERLOADABLE discrete_distributionlongC discrete_distribution_create(double* start, double* end, long _) ;\nOVERLOADABLE void destroy(discrete_distributionlongC v) ;\nOVERLOADABLE discrete_distributionintC discrete_distribution_create(double* start, double* end, int _) ;\nOVERLOADABLE void destroy(discrete_distributionintC v) ;\nOVERLOADABLE long call(discrete_distributionlongC p,mt19937C g) ;\nOVERLOADABLE int call(discrete_distributionintC p,mt19937C g) ;\nOVERLOADABLE uniform_real_distributionfloatC uniform_real_distribution_create(float a,float b, float _) ;\nOVERLOADABLE void destroy(uniform_real_distributionfloatC v) ;\nOVERLOADABLE uniform_real_distributiondoubleC uniform_real_distribution_create(double a,double b, double _) ;\nOVERLOADABLE void destroy(uniform_real_distributiondoubleC v) ;\nOVERLOADABLE float call(uniform_real_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(uniform_real_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE exponential_distributionfloatC exponential_distribution_create(float l, float _) ;\nOVERLOADABLE void destroy(exponential_distributionfloatC v) ;\nOVERLOADABLE exponential_distributiondoubleC exponential_distribution_create(double l, double _) ;\nOVERLOADABLE void destroy(exponential_distributiondoubleC v) ;\nOVERLOADABLE float call(exponential_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(exponential_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE gamma_distributionfloatC gamma_distribution_create(float a,float b, float _) ;\nOVERLOADABLE void destroy(gamma_distributionfloatC v) ;\nOVERLOADABLE gamma_distributiondoubleC gamma_distribution_create(double a,double b, double _) ;\nOVERLOADABLE void destroy(gamma_distributiondoubleC v) ;\nOVERLOADABLE float call(gamma_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(gamma_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE weibull_distributionfloatC weibull_distribution_create(float a,float b, float _) ;\nOVERLOADABLE void destroy(weibull_distributionfloatC v) ;\nOVERLOADABLE weibull_distributiondoubleC weibull_distribution_create(double a,double b, double _) ;\nOVERLOADABLE void destroy(weibull_distributiondoubleC v) ;\nOVERLOADABLE float call(weibull_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(weibull_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE normal_distributionfloatC normal_distribution_create(float mean,float stddev, float _) ;\nOVERLOADABLE void destroy(normal_distributionfloatC v) ;\nOVERLOADABLE normal_distributiondoubleC normal_distribution_create(double mean,double stddev, double _) ;\nOVERLOADABLE void destroy(normal_distributiondoubleC v) ;\nOVERLOADABLE float call(normal_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(normal_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE lognormal_distributionfloatC lognormal_distribution_create(float m,float s, float _) ;\nOVERLOADABLE void destroy(lognormal_distributionfloatC v) ;\nOVERLOADABLE lognormal_distributiondoubleC lognormal_distribution_create(double m,double s, double _) ;\nOVERLOADABLE void destroy(lognormal_distributiondoubleC v) ;\nOVERLOADABLE float call(lognormal_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(lognormal_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE chi_squared_distributionfloatC chi_squared_distribution_create(float n, float _) ;\nOVERLOADABLE void destroy(chi_squared_distributionfloatC v) ;\nOVERLOADABLE chi_squared_distributiondoubleC chi_squared_distribution_create(double n, double _) ;\nOVERLOADABLE void destroy(chi_squared_distributiondoubleC v) ;\nOVERLOADABLE float call(chi_squared_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(chi_squared_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE cauchy_distributionfloatC cauchy_distribution_create(float a,float b, float _) ;\nOVERLOADABLE void destroy(cauchy_distributionfloatC v) ;\nOVERLOADABLE cauchy_distributiondoubleC cauchy_distribution_create(double a,double b, double _) ;\nOVERLOADABLE void destroy(cauchy_distributiondoubleC v) ;\nOVERLOADABLE float call(cauchy_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(cauchy_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE fisher_f_distributionfloatC fisher_f_distribution_create(float m,float n, float _) ;\nOVERLOADABLE void destroy(fisher_f_distributionfloatC v) ;\nOVERLOADABLE fisher_f_distributiondoubleC fisher_f_distribution_create(double m,double n, double _) ;\nOVERLOADABLE void destroy(fisher_f_distributiondoubleC v) ;\nOVERLOADABLE float call(fisher_f_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(fisher_f_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE student_t_distributionfloatC student_t_distribution_create(float n, float _) ;\nOVERLOADABLE void destroy(student_t_distributionfloatC v) ;\nOVERLOADABLE student_t_distributiondoubleC student_t_distribution_create(double n, double _) ;\nOVERLOADABLE void destroy(student_t_distributiondoubleC v) ;\nOVERLOADABLE float call(student_t_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(student_t_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE piecewise_constant_distributionfloatC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, float _) ;\nOVERLOADABLE void destroy(piecewise_constant_distributionfloatC v) ;\nOVERLOADABLE piecewise_constant_distributiondoubleC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, double _) ;\nOVERLOADABLE void destroy(piecewise_constant_distributiondoubleC v) ;\nOVERLOADABLE float call(piecewise_constant_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(piecewise_constant_distributiondoubleC p,mt19937C g) ;\nOVERLOADABLE piecewise_linear_distributionfloatC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, float _) ;\nOVERLOADABLE void destroy(piecewise_linear_distributionfloatC v) ;\nOVERLOADABLE piecewise_linear_distributiondoubleC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, double _) ;\nOVERLOADABLE void destroy(piecewise_linear_distributiondoubleC v) ;\nOVERLOADABLE float call(piecewise_linear_distributionfloatC p,mt19937C g) ;\nOVERLOADABLE double call(piecewise_linear_distributiondoubleC p,mt19937C g) ;\n\n#ifdef __cplusplus\n}\n#endif\n\n"
  },
  {
    "path": "Sources/CBaseMath/include/CDistribution.h.gyb",
    "content": "%{ import sys; sys.path.append('../../..'); from cpp_template import *; from cpp_types import * }%\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OVERLOADABLE __attribute__((overloadable))\n#include <stdbool.h>\n\n% for t in all_types:\n${t.cpp_decl()}\n% end\n\n${ make_header(__file__) }\n\n#ifdef __cplusplus\n}\n#endif\n\n"
  },
  {
    "path": "Sources/bench/main.swift",
    "content": "import Foundation\nimport CBaseMath\nimport BaseMath\n\nprotocol RealType:BinaryFloatingPoint {}\nextension Float: RealType { }\nextension Double: RealType { }\n\n/*\nfunc sin_<T:RealType>(_ a:T)->T {\n  return sin(a)\n}\nlet s = sin_(0.3)\nprint(s)\n*/\n\nprotocol IntType:SignedNumeric {\n  associatedtype BinomialDistributionC:DistributionC\n  typealias U = BinomialDistributionC.Element\n  typealias BinomialDistribution=Distribution<BinomialDistributionC>\n  static func binomial_distribution_create(_ t:Self,_ p:Double)->BinomialDistributionC\n}\nextension IntType {\n  public static func binomial_distribution(_ t:Self,_ p:Double)->BinomialDistribution {\n    return BinomialDistribution(Self.binomial_distribution_create(t,p), mt19937.stored)\n  }\n}\nextension Int32: IntType {\n  public typealias BinomialDistributionC=binomial_distributionintC\n  public static func binomial_distribution_create(_ t:Int32,_ p:Double)->BinomialDistributionC {\n    return CBaseMath.binomial_distribution_create(t,p,.init())\n  }\n}\nextension Int: IntType {\n  public typealias BinomialDistributionC=binomial_distributionlongC\n  public static func binomial_distribution_create(_ t:Int,_ p:Double)->BinomialDistributionC {\n    return CBaseMath.binomial_distribution_create(t,p,.init())\n  }\n}\n\nfunc gen_binomial<T:IntType>(_ t:T, _ p:Double)->T.U {\n  let d = T.binomial_distribution(t,p)\n  return d[]\n}\n\nlet r = gen_binomial(3,0.5)\nprint(r)\n\nlet arr = Int.discrete_distribution([40, 10, 10, 40])[10000]\nlet counts = arr.reduce(into: [:]) { $0[$1, default:0] += 1 }\ncounts.sorted(by:<).forEach { print(\"\\($0) generated \\($1) times\") }\n\nlet dist01 = Int.uniform_int_distribution(1,6);       print(dist01[])\nlet dist02 = Int32.uniform_int_distribution(10,60);   print(dist02[])\nlet dist03 = Float.uniform_real_distribution(0,1);    print(dist03[])\nlet dist04 = Double.uniform_real_distribution(1,2);   print(dist04[])\nlet dist06 = Int.binomial_distribution(100,0.5);      print(dist06[])\nlet dist07 = Int.negative_binomial_distribution(5,2); print(dist07[])\nlet dist08 = Int.geometric_distribution(0.5);         print(dist08[])\nlet dist09 = Int.poisson_distribution(5);             print(dist09[])\nlet dist10 = Double.exponential_distribution(3.5);    print(dist10[])\nlet dist11 = Float.gamma_distribution(2,3.5);         print(dist11[])\nlet dist12 = Float.weibull_distribution(2,3.5);       print(dist12[])\nlet dist13 = Float.normal_distribution(1,3.5);        print(dist13[])\nlet dist14 = Double.lognormal_distribution(2,5.5);    print(dist14[])\nlet dist15 = Double.chi_squared_distribution(5.5);    print(dist15[])\nlet dist16 = Double.cauchy_distribution(2.1,3.5);     print(dist16[])\nlet dist17 = Float.fisher_f_distribution(2.1,3.5);    print(dist17[])\nlet dist18 = Float.student_t_distribution(15);        print(dist18[])\n\nprint(\"***\")\nlet dist19 = Int.discrete_distribution([1.5,2,6]);                          print(dist19[])\nlet dist20 = Float.piecewise_constant_distribution([0,1,10,15], [1,0,1]);   print(dist20[])\nlet dist21 = Float.piecewise_constant_distribution([0,5,10,15], [0,1,1,0]); print(dist21[])\n\nprint(\"***\")\nlet v1 = dist01[20];             print(v1); print(type(of:v1))\nlet v2 = dist01.gen_aligned(20); print(v2); print(type(of:v2))\nlet v3 = dist01.gen_pointer(20); print(v3); print(type(of:v3))\n\nprint(\"========\")\n//public typealias E=Double\npublic typealias E=Float\npublic let size = 1000000\npublic var ar1 = Array<E>(repeating:1, count:size)\nar1[3] = 1.2;ar1[5] = 0.2\npublic var ar2 = Array<E>(repeating:0, count:size)\npublic var a1:E=0\n\nbenchmark(title:\"reduce sum\") {a1 = ar1.reduce(0.0, +)}\nprint(a1)\nbenchmark(title:\"loop sum\") { a1 = 0; for i in 0..<size {a1+=ar1[i]} }\nprint(a1)\nbenchmark(title:\"pointer sum\") {\n  let p1 = ar1.p\n  a1 = 0; for i in 0..<size {a1+=p1[i]}\n}\nprint(a1)\nbenchmark(title:\"C sum\") {a1 = smSum(ar1.p, ar1.c)}\nprint(a1)\n\nlet p = ar1.p\nlet p2 = ar2.p\nlet c = Int32(ar1.c)\n\nbenchmark(title:\"swift add\") { for i in 0..<ar1.count {ar2[i]=ar1[i]+2.0} }\nprint(ar2.sum())\nbenchmark(title:\"swift ptr add\") {\n  let (p1,p2) = (ar1.p,ar2.p)\n  for i in 0..<ar1.count {p2[i]=p1[i]+2.0}\n}\nprint(ar2.sum())\nbenchmark(title:\"C add\") {sm_add_float(ar1.p, 2.0, ar2.p, ar1.c)}\nprint(ar2.sum())\nbenchmark(title:\"map add\") { ar1.map({$0+2.0}, ar2) }\nprint(ar2.sum())\nbenchmark(title:\"lib\") { ar1.add(2.0, ar2) }\nprint(ar2.sum())\n\nbenchmark(title:\"swift sin\") { for i in 0..<ar1.count {ar2[i]=sin(ar1[i])} }\nprint(ar2.sum())\nbenchmark(title:\"swift ptr sin\") {\n  let (p1,p2) = (ar1.p,ar2.p)\n  for i in 0..<ar1.count {p2[i]=sin(p1[i])} \n}\nprint(ar2.sum())\nbenchmark(title:\"C sin\") {sm_sin_float(ar1.p, ar2.p, ar1.c)}\nprint(ar2.sum())\n\nprint(\"func reduce\")\n@inlinable public func absO(_ a:Float)->Float {return E.sqr(a)}\nbenchmark(title:\"lib sum(sqr)\") {a1 = ar1.sum(Float.sqr)}\nprint(a1)\nbenchmark(title:\"reduce sumsqr\") {a1 = ar1.reduce(0.0, {$0+Float.sqr($1)})}\nprint(a1)\nbenchmark(title:\"c sumsqr\") {a1 = smSum_sqr_float(ar1.p, ar1.c)}\nprint(a1)\nbenchmark(title:\"lib sumsqr\") {a1 = ar1.sumsqr()}\nprint(a1)\n"
  },
  {
    "path": "Tests/BaseMathTests/BaseMathTests.swift",
    "content": "import XCTest\n@testable import BaseMath\n\nprotocol TestProtocol {\n  associatedtype T:FloatVector\n  typealias E=T.Element\n  var v1:T {get}\n  var v2:T {get}\n  var z:E {get}\n}\n\nclass BaseMathTestsFloat: XCTestCase,TestProtocol {\n  typealias T=Array<Float>\n\n  let v1:T = [1.0, -2,  3, 0]\n  let v2:T = [0.5, 12, -2, 1]\n  let z:E = 0.0\n}\nclass BaseMathTestsDouble: XCTestCase,TestProtocol {\n  typealias T=Array<Double>\n\n  let v1:T = [1.0, -2,  3, 0]\n  let v2:T = [0.5, 12, -2, 1]\n  let z:E = 0.0\n}\n\nextension TestProtocol {\n  func testSum() {\n    let exp = v1.reduce(z, +)\n    XCTAssertEqual(v1.sum(), exp)\n  }\n\n  func testAbs() {\n    let exp = T(v1.map {abs($0)})\n    let r1 = v1.abs()\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.abs(r2)\n    XCTAssertEqual(r2, exp)\n    v1.abs_()\n    XCTAssertEqual(v1, exp)\n  }\n\n  func testAdd() {\n    let exp = T(zip(v1,v2).map(+))\n    let r1 = v1.add(v2)\n    XCTAssertEqual(r1, exp, \"add(v2)\")\n    let r2 = v1.copy()\n    v1.add(v2, r2)\n    XCTAssertEqual(r2, exp, \"add(v2,r2)\")\n    let r3 = v1 + v2\n    XCTAssertEqual(r3, exp, \"+\")\n    let r4 = v1.copy()\n    r4.add_(v2)\n    XCTAssertEqual(r4, exp, \"add_\")\n    let r5 = v1.copy()\n    r5 += v2\n    XCTAssertEqual(r5, exp, \"+=\")\n  }\n\n  func testDiv() {\n    let v:E = 2.0\n    let exp = T(v1.map {$0/v})\n    let r1 = v1.div(v)\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.div(v, r2)\n    XCTAssertEqual(r2, exp)\n    let r3 = v1 / v\n    XCTAssertEqual(r3, exp)\n    let r4 = v1.copy()\n    r4.div_(v)\n    XCTAssertEqual(r4, exp)\n    let r5 = v1.copy()\n    r5 /= v\n    XCTAssertEqual(r5, exp)\n  }\n\n  func testSubRev() {\n    let v:E = 2.0\n    let exp = T(v1.map {v-$0})\n    let r1 = v1.subRev(v)\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.subRev(v, r2)\n    XCTAssertEqual(r2, exp)\n    let r3 = v - v1 \n    XCTAssertEqual(r3, exp)\n    let r4 = v1.copy()\n    r4.subRev_(v)\n    XCTAssertEqual(r4, exp)\n  }\n\n  func testPow() {\n    let exp = T(zip(v1,v2).map({$0.pow($1)}))\n    let r1 = v1.pow(v2)\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.pow(v2, r2)\n    XCTAssertEqual(r2, exp)\n    v1.pow_(v2)\n    XCTAssertEqual(v1, exp)\n  }\n\n  func testSumSqr() {\n    let exp = v1.reduce(z, {$0 + $1*$1})\n    XCTAssertEqual(v1.sum(E.sqr), exp)\n    XCTAssertEqual(v1.sumsqr(), exp)\n  }\n\n}\n\n"
  },
  {
    "path": "Tests/BaseMathTests/BaseMathTests.swift.gyb",
    "content": "import XCTest\n@testable import BaseMath\n\nprotocol TestProtocol {\n  associatedtype T:FloatVector\n  typealias E=T.Element\n  var v1:T {get}\n  var v2:T {get}\n  var z:E {get}\n}\n\n% for t in ('Float', 'Double'):\nclass BaseMathTests${t}: XCTestCase,TestProtocol {\n  typealias T=Array<${t}>\n\n  let v1:T = [1.0, -2,  3, 0]\n  let v2:T = [0.5, 12, -2, 1]\n  let z:E = 0.0\n}\n% end\n\nextension TestProtocol {\n  func testSum() {\n    let exp = v1.reduce(z, +)\n    XCTAssertEqual(v1.sum(), exp)\n  }\n\n  func testAbs() {\n    let exp = T(v1.map {abs($0)})\n    let r1 = v1.abs()\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.abs(r2)\n    XCTAssertEqual(r2, exp)\n    v1.abs_()\n    XCTAssertEqual(v1, exp)\n  }\n\n  func testAdd() {\n    let exp = T(zip(v1,v2).map(+))\n    let r1 = v1.add(v2)\n    XCTAssertEqual(r1, exp, \"add(v2)\")\n    let r2 = v1.copy()\n    v1.add(v2, r2)\n    XCTAssertEqual(r2, exp, \"add(v2,r2)\")\n    let r3 = v1 + v2\n    XCTAssertEqual(r3, exp, \"+\")\n    let r4 = v1.copy()\n    r4.add_(v2)\n    XCTAssertEqual(r4, exp, \"add_\")\n    let r5 = v1.copy()\n    r5 += v2\n    XCTAssertEqual(r5, exp, \"+=\")\n  }\n\n  func testDiv() {\n    let v:E = 2.0\n    let exp = T(v1.map {$0/v})\n    let r1 = v1.div(v)\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.div(v, r2)\n    XCTAssertEqual(r2, exp)\n    let r3 = v1 / v\n    XCTAssertEqual(r3, exp)\n    let r4 = v1.copy()\n    r4.div_(v)\n    XCTAssertEqual(r4, exp)\n    let r5 = v1.copy()\n    r5 /= v\n    XCTAssertEqual(r5, exp)\n  }\n\n  func testSubRev() {\n    let v:E = 2.0\n    let exp = T(v1.map {v-$0})\n    let r1 = v1.subRev(v)\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.subRev(v, r2)\n    XCTAssertEqual(r2, exp)\n    let r3 = v - v1 \n    XCTAssertEqual(r3, exp)\n    let r4 = v1.copy()\n    r4.subRev_(v)\n    XCTAssertEqual(r4, exp)\n  }\n\n  func testPow() {\n    let exp = T(zip(v1,v2).map({$0.pow($1)}))\n    let r1 = v1.pow(v2)\n    XCTAssertEqual(r1, exp)\n    let r2 = v1.copy()\n    v1.pow(v2, r2)\n    XCTAssertEqual(r2, exp)\n    v1.pow_(v2)\n    XCTAssertEqual(v1, exp)\n  }\n\n  func testSumSqr() {\n    let exp = v1.reduce(z, {$0 + $1*$1})\n    XCTAssertEqual(v1.sum(E.sqr), exp)\n    XCTAssertEqual(v1.sumsqr(), exp)\n  }\n\n}\n\n"
  },
  {
    "path": "Tests/LinuxMain.swift",
    "content": "import XCTest\n@testable import BaseMathTests\n\n\nextension BaseMathTestsFloat {\n  static var allTests : [(String, (BaseMathTestsFloat)->()->())] {\n    return [\n      (\"testSum\", testSum),\n      (\"testAbs\", testAbs),\n      (\"testAdd\", testAdd),\n      (\"testDiv\", testDiv),\n      (\"testSubRev\", testSubRev),\n      (\"testPow\", testPow),\n      (\"testSumSqr\", testSumSqr),\n    ]\n  }\n}\nextension BaseMathTestsDouble {\n  static var allTests : [(String, (BaseMathTestsDouble)->()->())] {\n    return [\n      (\"testSum\", testSum),\n      (\"testAbs\", testAbs),\n      (\"testAdd\", testAdd),\n      (\"testDiv\", testDiv),\n      (\"testSubRev\", testSubRev),\n      (\"testPow\", testPow),\n      (\"testSumSqr\", testSumSqr),\n    ]\n  }\n}\n\nXCTMain([\n  testCase(BaseMathTestsFloat.allTests),\n  testCase(BaseMathTestsDouble.allTests),\n])\n\n"
  },
  {
    "path": "Tests/LinuxMain.swift.gyb",
    "content": "import XCTest\n@testable import BaseMathTests\n\n%{\nimport re\nlines = open('BaseMathTests/BaseMathTests.swift.gyb', 'r').readlines()\ntests = [o.strip() for o in lines if re.search('func test', o)]\nnames = [re.search(r'func (test\\w*)\\(', o).group(1) for o in tests]\ntypes = ('Float', 'Double')\n}%\n\n% for t in types:\nextension BaseMathTests${t} {\n  static var allTests : [(String, (BaseMathTests${t})->()->())] {\n    return [\n  % for n in names:\n      (\"${n}\", ${n}),\n  % end # n\n    ]\n  }\n}\n% end # t\n\nXCTMain([\n% for t in types:\n  testCase(BaseMathTests${t}.allTests),\n% end # t\n])\n\n"
  },
  {
    "path": "c2swift.py",
    "content": "from pdb import set_trace\nimport re\n\ndef lower1(s): return s[:1].lower() + s[1:]\n\nfloat_swift = ['Float', 'Double']\nfloat_c = ['float', 'double']\nint_swift = ['Int', 'Int32']\nint_c = ['long', 'int']\nfloat_types = list(zip(float_swift,float_c))\nint_types = list(zip(int_swift,int_c))\n\ntype_replace = {'double':'Double', 'float':'Float', 'int':'Int32', 'long':'Int',\n                'void':'Void', '#':'#', '':''}\ntype_replace_rev = {v:k for k,v in type_replace.items()}\n\ndef word(name): return fr'(?P<{name}>[\\w#]+)'\nparam_re = re.compile(fr'(?P<const>const *)?{word(\"t\")} *(?P<ptr>\\*?) *{word(\"name\")}(?P<arr> *\\[\\])?')\n\ndef parse_type(s):\n    m = param_re.search(s)\n    if not m: raise Exception(f\"Failed to parse: {s}\")\n    name = m.group('name')\n    is_ptr = m.group('ptr') or m.group('arr')\n    t = m.group('t')\n    t = type_replace.get(t,t)\n    if is_ptr:\n        if t=='Void': t = 'UnsafeRawPointer'\n        else:\n            p_type ='UnsafePointer' if m.group('const') else 'UnsafeMutablePointer'\n            t = f\"{p_type}<{t}>\"\n    return (name,t)\n\ndef parse_types(s):\n    if not s: return {}\n    s = re.split(r',\\s*', s)\n    return dict([parse_type(o) for o in s])\n\ndef test_parse() :\n    in1 = \"const long n,const float a[], double r[],  const int N, const float *ex, # f\"\n    ex1 = dict([(\"n\",\"Int\"), (\"a\",\"UnsafePointer<Float>\"), (\"r\",\"UnsafeMutablePointer<Double>\"), (\"N\",\"Int32\"),\n           (\"ex\",\"UnsafePointer<Float>\"), (\"f\",\"#\")])\n\n    res = parse_types(in1)\n    for r,exp in zip(res.items(),ex1.items()):\n        assert r == exp, f'{r}\\n{exp}'\n\n    print(\"done\")\n\nif __name__=='__main__': test_parse()\n\n"
  },
  {
    "path": "cpp_template.py",
    "content": "import re,pathlib,os\nfrom pdb import set_trace\nfrom c2swift import *\n\ndef make_header(fn):\n    fn = os.path.basename(fn).split('.')[0]\n    lines = []\n    for l in open(f\"../{fn}.cpp\").readlines():\n        if '//internal' in l: continue\n        s = re.search(r'^typedef', l)\n        if s: lines.append(l)\n        s = re.search(r'^(\\w.*?){', l)\n        if s and not l.startswith('struct'): lines.append(s.group(1)+';')\n    return \"\\n\".join(lines)\n\nclass cpp:\n    def __init__(self, typ, p1, p2=None, gens=None, module='MISSING'):\n        if not gens: gens=['']\n        self.typ,self.p1,self.p2,self.gens,self.module = typ,p1,p2,gens,module\n        self.ps = parse_types(p1)\n        self.pswift = \",\".join([f\"_ {n}:{t}\" for n,t in self.ps.items()])\n        if self.p2 is None: self.p2 = \",\".join(self.ps.keys())\n        self.funcs = []\n        self.swift_type = 'CppTypePtr'\n\n    def cpp_impl_(self, g):\n        suf = f'<{g}>' if g else ''\n        xargs = f', {g} _' if g else ''\n        over = 'OVERLOADABLE ' if g else ''\n        t,p1,p2 = self.typ,self.p1,self.p2\n        return f\"\"\"\nstruct _inner_{t}{g}:{t}{suf} {{}};\n{over}{t}{g}C {t}_create({p1}{xargs}) {{\n  {t}{g}C r = {{(_inner_{t}{g}*) new {t}{suf}({p2})}};\n  return r;\n}}\nOVERLOADABLE void destroy({t}{g}C v) {{ delete(v.p); }}\n\"\"\".replace('#', g)\n\n    def cpp_impl(self):\n        res = [self.cpp_impl_(g) for g in self.gens]\n        for func in self.funcs: res += self.cpp_func(*func)\n        return '\\n'.join(res)\n\n    def cpp_decl_(self,g):\n        t = self.typ\n        return f\"\"\"\ntypedef struct _inner_{t}{g} _inner_{t}{g};\ntypedef struct {t}{g}C {t}{g}C;\nstruct {t}{g}C {{_inner_{t}{g}* p;}};\n\"\"\"\n\n    @property\n    def generics(self):\n        return [(type_replace.get(o,o),o) for o in self.gens]\n\n    def cpp_decl(self):\n        res = [self.cpp_decl_(g) for g in self.gens]\n        return '\\n'.join(res)\n\n    def cpp_func_(self,f,a1,a2,g):\n        over = 'OVERLOADABLE ' if g else ''\n        return f\"{over}{f}({self.typ}{g}C p{a1}) {{return p.p->{a2};}}\".replace('#', g)\n\n    def cpp_func(self,f,a1,a2=None):\n        if a1: a1=','+a1\n        res = [self.cpp_func_(f,a1,a2,g) for g in self.gens]\n        return res\n\n    #o.add_func('# call', 'mt19937C g', 'operator()(*g.p)')\n    def add_func(self, *func): self.funcs.append(func)\n\n    def swift_func_(self,f,a1, a2, g):\n        ps = parse_types(a1)\n        p1 = ','.join([f\"_ {k}:{v}\" for k,v in ps.items()])\n        p2 = \",\".join(ps.keys())\n        f,ret = list(parse_types(f).items())[0]\n        if ret=='#': ret=type_replace.get(g,g)\n        if p2: p2=','+p2\n        return f\"public func {f}({p1})->{ret} {{ return {self.module}.{f}(self{p2}) }}\"\n                #public func call(_ g:mt19937C)->{g} {{ return CBaseMath.call(self, g) }}\n\n    def swift_(self, g):\n        funcs = [self.swift_func_(*func,g) for func in self.funcs]\n        funcs = '\\n'.join(funcs)\n        return f\"\"\"\nextension {self.typ}{g}C:{self.swift_type} {{\n  public func delete() {{destroy(self)}}\n  {funcs}\n}}\n\"\"\"\n\n    def swift(self):\n        res = [self.swift_(g) for g in self.gens]\n        return '\\n'.join(res)\n\n"
  },
  {
    "path": "cpp_types.py",
    "content": "from cpp_template import *\n\ngen_types = [\n  cpp(\"mt19937\", \"\", \"random_device()()\"),\n  cpp(\"knuth_b\", \"\", \"random_device()()\"),\n  cpp(\"bernoulli_distribution\", \"double p\"),\n]\nint_dist = [\n  cpp(\"uniform_int_distribution\", \"# a,# b\"),\n  cpp(\"binomial_distribution\", \"# t, double p\"),\n  cpp(\"negative_binomial_distribution\", \"# k, double p\"),\n  cpp(\"geometric_distribution\", \"double p\"),\n  cpp(\"poisson_distribution\", \"double mean\"),\n  cpp(\"discrete_distribution\", \"double* start, double* end\"),\n]\nfor o in int_dist: o.gens = int_c\nreal_dist = [\n  cpp(\"uniform_real_distribution\", \"# a,# b\"),\n  cpp(\"exponential_distribution\", \"# l\"),\n  cpp(\"gamma_distribution\", \"# a,# b\"),\n  cpp(\"weibull_distribution\", \"# a,# b\"),\n  cpp(\"normal_distribution\", \"# mean,# stddev\"),\n  cpp(\"lognormal_distribution\", \"# m,# s\"),\n  cpp(\"chi_squared_distribution\", \"# n\"),\n  cpp(\"cauchy_distribution\", \"# a,# b\"),\n  cpp(\"fisher_f_distribution\", \"# m,# n\"),\n  cpp(\"student_t_distribution\", \"# n\"),\n  cpp(\"piecewise_constant_distribution\", \"double* start_i, double* end_i, double* start_w\"),\n  cpp(\"piecewise_linear_distribution\", \"double* start_i, double* end_i, double* start_w\"),\n]\nfor o in real_dist: o.gens = float_c\ndist_types = int_dist+real_dist\nall_types = dist_types+gen_types\nfor o in all_types: o.module = 'CBaseMath'\n\nfor o in dist_types:\n    o.swift_type = 'DistributionC'\n    o.add_func('# call', 'mt19937C g', 'operator()(*g.p)')\n\n"
  },
  {
    "path": "mathfuncs.py",
    "content": "funcs1 = ['min', 'max']\n# unary functions\nfuncs2 = \"\"\"sqrt acos acosh asin asinh atan atanh cbrt cos cosh erf erfc exp exp2 expm1 log log10 log1p log2 logb\nnearbyint rint sin sinh tan tanh tgamma\"\"\".split()\n# binary functions\nfuncs3 = \"pow atan2 copysign fdim fmax fmin hypot nextafter\".split()\ntypes =  ['Float','Double']\nctypes = ['float','double']\n\nop_fs = 'add sub mul div'.split()\nops = '+-*/'\nunaryfs =  ['abs' ]+funcs2\nbinfs = op_fs+['subRev','divRev']+funcs1+funcs3\n\n"
  }
]