Repository: jph00/BaseMath
Branch: master
Commit: 5fd3d82b6f34
Files: 32
Total size: 186.2 KB
Directory structure:
gitextract_0zz0z5lm/
├── .gitignore
├── Makefile
├── Package.swift
├── README.md
├── Sources/
│ ├── BaseMath/
│ │ ├── BaseMath.swift
│ │ ├── BaseMath.swift.gyb
│ │ ├── BaseRand.swift
│ │ ├── BaseRand.swift.gyb
│ │ ├── BaseVector.swift
│ │ ├── CBaseRand.swift
│ │ ├── CBaseRand.swift.gyb
│ │ ├── FloatVector.swift
│ │ ├── FloatVector.swift.gyb
│ │ ├── Storage.swift
│ │ └── Utils.swift
│ ├── CBaseMath/
│ │ ├── CBaseMath.cpp
│ │ ├── CBaseMath.cpp.gyb
│ │ ├── CDistribution.cpp
│ │ ├── CDistribution.cpp.gyb
│ │ └── include/
│ │ ├── CBaseMath.h
│ │ ├── CBaseMath.h.gyb
│ │ ├── CDistribution.h
│ │ └── CDistribution.h.gyb
│ └── bench/
│ └── main.swift
├── Tests/
│ ├── BaseMathTests/
│ │ ├── BaseMathTests.swift
│ │ └── BaseMathTests.swift.gyb
│ ├── LinuxMain.swift
│ └── LinuxMain.swift.gyb
├── c2swift.py
├── cpp_template.py
├── cpp_types.py
└── mathfuncs.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.so
*.dylib
Darwin/
Darwin.tgz
Linux/
Linux.tgz
*.swp
intel64/
__pycache__
.DS_Store
/.build
/Packages
/*.xcodeproj
================================================
FILE: Makefile
================================================
ifeq ($(mode),)
mode := debug
endif
link_args := -Xswiftc -Ounchecked $(addprefix -Xcc ,-O2 -ffast-math -ffp-contract=fast -march=native)
gybs := $(shell find Sources Tests -type f -name '*.gyb')
conv_gybs := $(patsubst %.gyb,%,$(gybs))
sources := $(conv_gybs) $(shell find Sources Tests -type f -name '*.swift')
sources := $(sources) $(shell find Sources Tests -type f -name '*.cpp')
headers := $(sources) $(shell find Sources Tests -type f -name '*.hpp')
sources := $(sources) $(shell find Sources Tests -type f -name '*.c')
headers := $(sources) $(shell find Sources Tests -type f -name '*.h')
sources := $(sources) $(headers)
yaml := ./.build/${mode}.yaml
run_args := -c $(mode) $(link_args)
all: $(yaml)
run: $(yaml)
$(prefix) swift run $(run_args)
test: $(yaml)
$(prefix) swift test $(run_args)
$(yaml): gyb
swift build -v $(run_args)
Tests/LinuxMain.swift: Tests/BaseMathTests/BaseMathTests.swift
gyb: $(sources)
%.swift: %.swift.gyb
gyb --line-directive '' -o $@ $<
%.c: %.c.gyb
gyb --line-directive '' -o $@ $<
%.h: %.h.gyb
gyb --line-directive '' -o $@ $<
%.cpp: %.cpp.gyb
gyb --line-directive '' -o $@ $<
%.hpp: %.hpp.gyb
gyb --line-directive '' -o $@ $<
Sources/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
Sources/CBaseMath/include/CBaseMath.h: Sources/CBaseMath/CBaseMath.cpp
Sources/CBaseMath/include/CBaseRandom.h: Sources/CBaseMath/CBaseRandom.cpp
.PHONY: clean
clean:
rm -rf .build $(conv_gybs)
================================================
FILE: Package.swift
================================================
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "BaseMath",
products: [
.library( name: "BaseMath", targets: ["BaseMath"]),
],
targets: [
.target( name: "CBaseMath"),
.target( name: "BaseMath", dependencies: ["CBaseMath"]),
.testTarget( name: "BaseMathTests", dependencies: ["BaseMath"]),
.target( name: "bench", dependencies: ["BaseMath"]),
]
)
================================================
FILE: README.md
================================================
# BaseMath
Basic 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):
- Binary functions,: `sqr`, `abs`, `min`, `max`, `pow`, `atan2`, `copysign`, `fdim`, `fmax`, `fmin`, `hypot`, `nextafter`, `add`, `sub`, `mul`, `div`, `subRev`, `divRev`
- 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`
Use it with Swift Package Manager by adding to your `Package.swift`:
dependencies: [
.package(url:"https://github.com/jph00/BaseMath.git", from: "1.0.0"),
]
For reasonable performance, compile with `make` (which is also required if you make changes to the `gyb` templates) or use:
swift build -Xswiftc -Ounchecked -Xcc -ffast-math -Xcc -O2 -Xcc -march=native
This 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.
Math 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`.
Because 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`.
To 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.
After `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).
See 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).
================================================
FILE: Sources/BaseMath/BaseMath.swift
================================================
import Foundation
import CBaseMath
extension BinaryFloatingPoint where Self: CVarArg {
public func string(_ digits:Int) -> String { return String(format: "%.\(digits)f", self) }
}
precedencegroup ExponentiationPrecedence { associativity: right higherThan: MultiplicationPrecedence }
infix operator ^^: ExponentiationPrecedence
public extension Numeric {
typealias Element=Self
typealias PtrT = UnsafePointer<Element>
typealias MutPtrT = UnsafeMutablePointer<Element>
}
public protocol SupportsBasicMath:BinaryFloatingPoint {
init(_ value: Self)
init()
var nsNumber:NSNumber {get}
func add(_ b: Self) -> Self
func sub(_ b: Self) -> Self
func mul(_ b: Self) -> Self
func div(_ b: Self) -> Self
func subRev(_ b: Self) -> Self
func divRev(_ b: Self) -> Self
func min(_ b: Self) -> Self
func max(_ b: Self) -> Self
func pow(_ b: Self) -> Self
func atan2(_ b: Self) -> Self
func copysign(_ b: Self) -> Self
func fdim(_ b: Self) -> Self
func fmax(_ b: Self) -> Self
func fmin(_ b: Self) -> Self
func hypot(_ b: Self) -> Self
func nextafter(_ b: Self) -> Self
func sqrt() -> Self
func acos() -> Self
func acosh() -> Self
func asin() -> Self
func asinh() -> Self
func atan() -> Self
func atanh() -> Self
func cbrt() -> Self
func cos() -> Self
func cosh() -> Self
func erf() -> Self
func erfc() -> Self
func exp() -> Self
func exp2() -> Self
func expm1() -> Self
func log() -> Self
func log10() -> Self
func log1p() -> Self
func log2() -> Self
func logb() -> Self
func nearbyint() -> Self
func rint() -> Self
func sin() -> Self
func sinh() -> Self
func tan() -> Self
func tanh() -> Self
func tgamma() -> Self
static func sqr(_ a:Self) -> Self
func sqr() -> Self
func abs() -> Self
static func sum(_ a:PtrT, _ n:Int32) -> Element
static func sumabs(_ a:PtrT, _ n:Int32)->Element
static func sumsqrt(_ a:PtrT, _ n:Int32)->Element
static func sumacos(_ a:PtrT, _ n:Int32)->Element
static func sumacosh(_ a:PtrT, _ n:Int32)->Element
static func sumasin(_ a:PtrT, _ n:Int32)->Element
static func sumasinh(_ a:PtrT, _ n:Int32)->Element
static func sumatan(_ a:PtrT, _ n:Int32)->Element
static func sumatanh(_ a:PtrT, _ n:Int32)->Element
static func sumcbrt(_ a:PtrT, _ n:Int32)->Element
static func sumcos(_ a:PtrT, _ n:Int32)->Element
static func sumcosh(_ a:PtrT, _ n:Int32)->Element
static func sumerf(_ a:PtrT, _ n:Int32)->Element
static func sumerfc(_ a:PtrT, _ n:Int32)->Element
static func sumexp(_ a:PtrT, _ n:Int32)->Element
static func sumexp2(_ a:PtrT, _ n:Int32)->Element
static func sumexpm1(_ a:PtrT, _ n:Int32)->Element
static func sumlog(_ a:PtrT, _ n:Int32)->Element
static func sumlog10(_ a:PtrT, _ n:Int32)->Element
static func sumlog1p(_ a:PtrT, _ n:Int32)->Element
static func sumlog2(_ a:PtrT, _ n:Int32)->Element
static func sumlogb(_ a:PtrT, _ n:Int32)->Element
static func sumnearbyint(_ a:PtrT, _ n:Int32)->Element
static func sumrint(_ a:PtrT, _ n:Int32)->Element
static func sumsin(_ a:PtrT, _ n:Int32)->Element
static func sumsinh(_ a:PtrT, _ n:Int32)->Element
static func sumtan(_ a:PtrT, _ n:Int32)->Element
static func sumtanh(_ a:PtrT, _ n:Int32)->Element
static func sumtgamma(_ a:PtrT, _ n:Int32)->Element
static func sumsqr(_ a:PtrT, _ n:Int32)->Element
static func ^^(x:Self, a:Self) -> Self
}
extension Float : SupportsBasicMath {
public var nsNumber:NSNumber { return NSNumber(value: self) }
@inlinable public func add(_ b: Float) -> Float {return self + b}
@inlinable public func sub(_ b: Float) -> Float {return self - b}
@inlinable public func mul(_ b: Float) -> Float {return self * b}
@inlinable public func div(_ b: Float) -> Float {return self / b}
@inlinable public static func sqr(_ a:Float) -> Float {return a * a }
@inlinable public func sqr( ) -> Float {return self*self}
@inlinable public func subRev(_ b: Float) -> Float {return b - self}
@inlinable public func divRev(_ b: Float) -> Float {return b / self}
@inlinable public func sqrt() -> Float {return Foundation.sqrt(self)}
@inlinable public func acos() -> Float {return Foundation.acos(self)}
@inlinable public func acosh() -> Float {return Foundation.acosh(self)}
@inlinable public func asin() -> Float {return Foundation.asin(self)}
@inlinable public func asinh() -> Float {return Foundation.asinh(self)}
@inlinable public func atan() -> Float {return Foundation.atan(self)}
@inlinable public func atanh() -> Float {return Foundation.atanh(self)}
@inlinable public func cbrt() -> Float {return Foundation.cbrt(self)}
@inlinable public func cos() -> Float {return Foundation.cos(self)}
@inlinable public func cosh() -> Float {return Foundation.cosh(self)}
@inlinable public func erf() -> Float {return Foundation.erf(self)}
@inlinable public func erfc() -> Float {return Foundation.erfc(self)}
@inlinable public func exp() -> Float {return Foundation.exp(self)}
@inlinable public func exp2() -> Float {return Foundation.exp2(self)}
@inlinable public func expm1() -> Float {return Foundation.expm1(self)}
@inlinable public func log() -> Float {return Foundation.log(self)}
@inlinable public func log10() -> Float {return Foundation.log10(self)}
@inlinable public func log1p() -> Float {return Foundation.log1p(self)}
@inlinable public func log2() -> Float {return Foundation.log2(self)}
@inlinable public func logb() -> Float {return Foundation.logb(self)}
@inlinable public func nearbyint() -> Float {return Foundation.nearbyint(self)}
@inlinable public func rint() -> Float {return Foundation.rint(self)}
@inlinable public func sin() -> Float {return Foundation.sin(self)}
@inlinable public func sinh() -> Float {return Foundation.sinh(self)}
@inlinable public func tan() -> Float {return Foundation.tan(self)}
@inlinable public func tanh() -> Float {return Foundation.tanh(self)}
@inlinable public func tgamma() -> Float {return Foundation.tgamma(self)}
@inlinable public func min(_ b: Float) -> Float {return Swift.min(self, b)}
@inlinable public func max(_ b: Float) -> Float {return Swift.max(self, b)}
@inlinable public func abs() -> Float {return Swift.abs(self)}
@inlinable public func pow(_ b: Float) -> Float {return Foundation.pow(self, b)}
@inlinable public func atan2(_ b: Float) -> Float {return Foundation.atan2(self, b)}
@inlinable public func copysign(_ b: Float) -> Float {return Foundation.copysign(self, b)}
@inlinable public func fdim(_ b: Float) -> Float {return Foundation.fdim(self, b)}
@inlinable public func fmax(_ b: Float) -> Float {return Foundation.fmax(self, b)}
@inlinable public func fmin(_ b: Float) -> Float {return Foundation.fmin(self, b)}
@inlinable public func hypot(_ b: Float) -> Float {return Foundation.hypot(self, b)}
@inlinable public func nextafter(_ b: Float) -> Float {return Foundation.nextafter(self, b)}
@inlinable public static func sum(_ a:PtrT, _ n:Int32) -> Element { return smSum(a, n) }
@inlinable public static func sumabs(_ a:PtrT, _ n:Int32)->Element { return smSum_abs(a, n) }
@inlinable public static func sumsqrt(_ a:PtrT, _ n:Int32)->Element { return smSum_sqrt(a, n) }
@inlinable public static func sumacos(_ a:PtrT, _ n:Int32)->Element { return smSum_acos(a, n) }
@inlinable public static func sumacosh(_ a:PtrT, _ n:Int32)->Element { return smSum_acosh(a, n) }
@inlinable public static func sumasin(_ a:PtrT, _ n:Int32)->Element { return smSum_asin(a, n) }
@inlinable public static func sumasinh(_ a:PtrT, _ n:Int32)->Element { return smSum_asinh(a, n) }
@inlinable public static func sumatan(_ a:PtrT, _ n:Int32)->Element { return smSum_atan(a, n) }
@inlinable public static func sumatanh(_ a:PtrT, _ n:Int32)->Element { return smSum_atanh(a, n) }
@inlinable public static func sumcbrt(_ a:PtrT, _ n:Int32)->Element { return smSum_cbrt(a, n) }
@inlinable public static func sumcos(_ a:PtrT, _ n:Int32)->Element { return smSum_cos(a, n) }
@inlinable public static func sumcosh(_ a:PtrT, _ n:Int32)->Element { return smSum_cosh(a, n) }
@inlinable public static func sumerf(_ a:PtrT, _ n:Int32)->Element { return smSum_erf(a, n) }
@inlinable public static func sumerfc(_ a:PtrT, _ n:Int32)->Element { return smSum_erfc(a, n) }
@inlinable public static func sumexp(_ a:PtrT, _ n:Int32)->Element { return smSum_exp(a, n) }
@inlinable public static func sumexp2(_ a:PtrT, _ n:Int32)->Element { return smSum_exp2(a, n) }
@inlinable public static func sumexpm1(_ a:PtrT, _ n:Int32)->Element { return smSum_expm1(a, n) }
@inlinable public static func sumlog(_ a:PtrT, _ n:Int32)->Element { return smSum_log(a, n) }
@inlinable public static func sumlog10(_ a:PtrT, _ n:Int32)->Element { return smSum_log10(a, n) }
@inlinable public static func sumlog1p(_ a:PtrT, _ n:Int32)->Element { return smSum_log1p(a, n) }
@inlinable public static func sumlog2(_ a:PtrT, _ n:Int32)->Element { return smSum_log2(a, n) }
@inlinable public static func sumlogb(_ a:PtrT, _ n:Int32)->Element { return smSum_logb(a, n) }
@inlinable public static func sumnearbyint(_ a:PtrT, _ n:Int32)->Element { return smSum_nearbyint(a, n) }
@inlinable public static func sumrint(_ a:PtrT, _ n:Int32)->Element { return smSum_rint(a, n) }
@inlinable public static func sumsin(_ a:PtrT, _ n:Int32)->Element { return smSum_sin(a, n) }
@inlinable public static func sumsinh(_ a:PtrT, _ n:Int32)->Element { return smSum_sinh(a, n) }
@inlinable public static func sumtan(_ a:PtrT, _ n:Int32)->Element { return smSum_tan(a, n) }
@inlinable public static func sumtanh(_ a:PtrT, _ n:Int32)->Element { return smSum_tanh(a, n) }
@inlinable public static func sumtgamma(_ a:PtrT, _ n:Int32)->Element { return smSum_tgamma(a, n) }
@inlinable public static func sumsqr(_ a:PtrT, _ n:Int32)->Element { return smSum_sqr(a, n) }
public static func ^^(x:Float, a:Float) -> Float { return x.pow(a) }
}
extension Double : SupportsBasicMath {
public var nsNumber:NSNumber { return NSNumber(value: self) }
@inlinable public func add(_ b: Double) -> Double {return self + b}
@inlinable public func sub(_ b: Double) -> Double {return self - b}
@inlinable public func mul(_ b: Double) -> Double {return self * b}
@inlinable public func div(_ b: Double) -> Double {return self / b}
@inlinable public static func sqr(_ a:Double) -> Double {return a * a }
@inlinable public func sqr( ) -> Double {return self*self}
@inlinable public func subRev(_ b: Double) -> Double {return b - self}
@inlinable public func divRev(_ b: Double) -> Double {return b / self}
@inlinable public func sqrt() -> Double {return Foundation.sqrt(self)}
@inlinable public func acos() -> Double {return Foundation.acos(self)}
@inlinable public func acosh() -> Double {return Foundation.acosh(self)}
@inlinable public func asin() -> Double {return Foundation.asin(self)}
@inlinable public func asinh() -> Double {return Foundation.asinh(self)}
@inlinable public func atan() -> Double {return Foundation.atan(self)}
@inlinable public func atanh() -> Double {return Foundation.atanh(self)}
@inlinable public func cbrt() -> Double {return Foundation.cbrt(self)}
@inlinable public func cos() -> Double {return Foundation.cos(self)}
@inlinable public func cosh() -> Double {return Foundation.cosh(self)}
@inlinable public func erf() -> Double {return Foundation.erf(self)}
@inlinable public func erfc() -> Double {return Foundation.erfc(self)}
@inlinable public func exp() -> Double {return Foundation.exp(self)}
@inlinable public func exp2() -> Double {return Foundation.exp2(self)}
@inlinable public func expm1() -> Double {return Foundation.expm1(self)}
@inlinable public func log() -> Double {return Foundation.log(self)}
@inlinable public func log10() -> Double {return Foundation.log10(self)}
@inlinable public func log1p() -> Double {return Foundation.log1p(self)}
@inlinable public func log2() -> Double {return Foundation.log2(self)}
@inlinable public func logb() -> Double {return Foundation.logb(self)}
@inlinable public func nearbyint() -> Double {return Foundation.nearbyint(self)}
@inlinable public func rint() -> Double {return Foundation.rint(self)}
@inlinable public func sin() -> Double {return Foundation.sin(self)}
@inlinable public func sinh() -> Double {return Foundation.sinh(self)}
@inlinable public func tan() -> Double {return Foundation.tan(self)}
@inlinable public func tanh() -> Double {return Foundation.tanh(self)}
@inlinable public func tgamma() -> Double {return Foundation.tgamma(self)}
@inlinable public func min(_ b: Double) -> Double {return Swift.min(self, b)}
@inlinable public func max(_ b: Double) -> Double {return Swift.max(self, b)}
@inlinable public func abs() -> Double {return Swift.abs(self)}
@inlinable public func pow(_ b: Double) -> Double {return Foundation.pow(self, b)}
@inlinable public func atan2(_ b: Double) -> Double {return Foundation.atan2(self, b)}
@inlinable public func copysign(_ b: Double) -> Double {return Foundation.copysign(self, b)}
@inlinable public func fdim(_ b: Double) -> Double {return Foundation.fdim(self, b)}
@inlinable public func fmax(_ b: Double) -> Double {return Foundation.fmax(self, b)}
@inlinable public func fmin(_ b: Double) -> Double {return Foundation.fmin(self, b)}
@inlinable public func hypot(_ b: Double) -> Double {return Foundation.hypot(self, b)}
@inlinable public func nextafter(_ b: Double) -> Double {return Foundation.nextafter(self, b)}
@inlinable public static func sum(_ a:PtrT, _ n:Int32) -> Element { return smSum(a, n) }
@inlinable public static func sumabs(_ a:PtrT, _ n:Int32)->Element { return smSum_abs(a, n) }
@inlinable public static func sumsqrt(_ a:PtrT, _ n:Int32)->Element { return smSum_sqrt(a, n) }
@inlinable public static func sumacos(_ a:PtrT, _ n:Int32)->Element { return smSum_acos(a, n) }
@inlinable public static func sumacosh(_ a:PtrT, _ n:Int32)->Element { return smSum_acosh(a, n) }
@inlinable public static func sumasin(_ a:PtrT, _ n:Int32)->Element { return smSum_asin(a, n) }
@inlinable public static func sumasinh(_ a:PtrT, _ n:Int32)->Element { return smSum_asinh(a, n) }
@inlinable public static func sumatan(_ a:PtrT, _ n:Int32)->Element { return smSum_atan(a, n) }
@inlinable public static func sumatanh(_ a:PtrT, _ n:Int32)->Element { return smSum_atanh(a, n) }
@inlinable public static func sumcbrt(_ a:PtrT, _ n:Int32)->Element { return smSum_cbrt(a, n) }
@inlinable public static func sumcos(_ a:PtrT, _ n:Int32)->Element { return smSum_cos(a, n) }
@inlinable public static func sumcosh(_ a:PtrT, _ n:Int32)->Element { return smSum_cosh(a, n) }
@inlinable public static func sumerf(_ a:PtrT, _ n:Int32)->Element { return smSum_erf(a, n) }
@inlinable public static func sumerfc(_ a:PtrT, _ n:Int32)->Element { return smSum_erfc(a, n) }
@inlinable public static func sumexp(_ a:PtrT, _ n:Int32)->Element { return smSum_exp(a, n) }
@inlinable public static func sumexp2(_ a:PtrT, _ n:Int32)->Element { return smSum_exp2(a, n) }
@inlinable public static func sumexpm1(_ a:PtrT, _ n:Int32)->Element { return smSum_expm1(a, n) }
@inlinable public static func sumlog(_ a:PtrT, _ n:Int32)->Element { return smSum_log(a, n) }
@inlinable public static func sumlog10(_ a:PtrT, _ n:Int32)->Element { return smSum_log10(a, n) }
@inlinable public static func sumlog1p(_ a:PtrT, _ n:Int32)->Element { return smSum_log1p(a, n) }
@inlinable public static func sumlog2(_ a:PtrT, _ n:Int32)->Element { return smSum_log2(a, n) }
@inlinable public static func sumlogb(_ a:PtrT, _ n:Int32)->Element { return smSum_logb(a, n) }
@inlinable public static func sumnearbyint(_ a:PtrT, _ n:Int32)->Element { return smSum_nearbyint(a, n) }
@inlinable public static func sumrint(_ a:PtrT, _ n:Int32)->Element { return smSum_rint(a, n) }
@inlinable public static func sumsin(_ a:PtrT, _ n:Int32)->Element { return smSum_sin(a, n) }
@inlinable public static func sumsinh(_ a:PtrT, _ n:Int32)->Element { return smSum_sinh(a, n) }
@inlinable public static func sumtan(_ a:PtrT, _ n:Int32)->Element { return smSum_tan(a, n) }
@inlinable public static func sumtanh(_ a:PtrT, _ n:Int32)->Element { return smSum_tanh(a, n) }
@inlinable public static func sumtgamma(_ a:PtrT, _ n:Int32)->Element { return smSum_tgamma(a, n) }
@inlinable public static func sumsqr(_ a:PtrT, _ n:Int32)->Element { return smSum_sqr(a, n) }
public static func ^^(x:Double, a:Double) -> Double { return x.pow(a) }
}
================================================
FILE: Sources/BaseMath/BaseMath.swift.gyb
================================================
import Foundation
import CBaseMath
%{ import sys; sys.path.append('../..'); from mathfuncs import * }%
extension BinaryFloatingPoint where Self: CVarArg {
public func string(_ digits:Int) -> String { return String(format: "%.\(digits)f", self) }
}
precedencegroup ExponentiationPrecedence { associativity: right higherThan: MultiplicationPrecedence }
infix operator ^^: ExponentiationPrecedence
public extension Numeric {
typealias Element=Self
typealias PtrT = UnsafePointer<Element>
typealias MutPtrT = UnsafeMutablePointer<Element>
}
public protocol SupportsBasicMath:BinaryFloatingPoint {
init(_ value: Self)
init()
var nsNumber:NSNumber {get}
% for f in binfs:
func ${f}(_ b: Self) -> Self
% end # f
% for f in funcs2:
func ${f}() -> Self
% end # f
static func sqr(_ a:Self) -> Self
func sqr() -> Self
func abs() -> Self
static func sum(_ a:PtrT, _ n:Int32) -> Element
% for f in unaryfs:
static func sum${f}(_ a:PtrT, _ n:Int32)->Element
% end
static func sumsqr(_ a:PtrT, _ n:Int32)->Element
static func ^^(x:Self, a:Self) -> Self
}
% for t in types:
extension ${t} : SupportsBasicMath {
public var nsNumber:NSNumber { return NSNumber(value: self) }
% for f,op in zip(op_fs,ops):
@inlinable public func ${f}(_ b: ${t}) -> ${t} {return self ${op} b}
% end # f,op
@inlinable public static func sqr(_ a:${t}) -> ${t} {return a * a }
@inlinable public func sqr( ) -> ${t} {return self*self}
@inlinable public func subRev(_ b: ${t}) -> ${t} {return b - self}
@inlinable public func divRev(_ b: ${t}) -> ${t} {return b / self}
% for f in funcs2:
@inlinable public func ${f}() -> ${t} {return Foundation.${f}(self)}
% end # f
@inlinable public func min(_ b: ${t}) -> ${t} {return Swift.min(self, b)}
@inlinable public func max(_ b: ${t}) -> ${t} {return Swift.max(self, b)}
@inlinable public func abs() -> ${t} {return Swift.abs(self)}
% for f in funcs3:
@inlinable public func ${f}(_ b: ${t}) -> ${t} {return Foundation.${f}(self, b)}
% end # f
@inlinable public static func sum(_ a:PtrT, _ n:Int32) -> Element { return smSum(a, n) }
% for f in unaryfs:
@inlinable public static func sum${f}(_ a:PtrT, _ n:Int32)->Element { return smSum_${f}(a, n) }
% end
@inlinable public static func sumsqr(_ a:PtrT, _ n:Int32)->Element { return smSum_sqr(a, n) }
public static func ^^(x:${t}, a:${t}) -> ${t} { return x.pow(a) }
}
% end # t
================================================
FILE: Sources/BaseMath/BaseRand.swift
================================================
import Foundation
import CBaseMath
public protocol Initable { init() }
extension Float:Initable {}
extension Double:Initable {}
extension Int:Initable {}
extension Int32:Initable {}
extension Bool:Initable {}
public protocol CppTypePtr {
func delete()
}
public class CppType<T:CppTypePtr> {
public let p:T
init(_ p:T) {self.p=p}
deinit {p.delete()}
}
public class mt19937:CppType<mt19937C> {
public convenience init() { self.init(CBaseMath.mt19937_create()) }
@usableFromInline static var storeKey:String { get { return "mt19937" } }
public static var stored:mt19937 { get {
if let r = Thread.current.threadDictionary[storeKey] as? mt19937 { return r }
return Thread.setToTLS(mt19937(), storeKey)
}}
}
public protocol DistributionC:CppTypePtr {
associatedtype Element:SignedNumeric
func call(_ g:mt19937C)->Element
}
public class Distribution<T:DistributionC>:CppType<T>,Nullary {
public typealias Element=T.Element
public var g:mt19937
public init(_ p:T, _ g:mt19937) {self.g=g; super.init(p) }
@inlinable public subscript()->Element { return p.call(g.p) }
public subscript(n:Int)->[Element] { return gen_array(n) }
public func gen_array(_ n:Int)->[Element] {
return [Element].fill(self, n)
}
public func gen_aligned(_ n:Int)->AlignedStorage<Element> {
return AlignedStorage<Element>.fill(self, n)
}
public func gen_pointer(_ n:Int)->UnsafeMutableBufferPointer<Element> {
return UnsafeMutableBufferPointer<Element>.fill(self, n)
}
}
public final class uniform_int_distribution_Int:Distribution<uniform_int_distributionlongC> {
public init(_ g_:mt19937 , _ a:Int,_ b:Int) { super.init(uniform_int_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Int,_ b:Int) { self.init(mt19937.stored, a,b) }
}
extension Int {
public static func uniform_int_distribution(_ g_:mt19937 , _ a:Int,_ b:Int)->uniform_int_distribution_Int {return uniform_int_distribution_Int(g_, a,b)}
public static func uniform_int_distribution(_ a:Int,_ b:Int)->uniform_int_distribution_Int {return uniform_int_distribution_Int(a,b)}
}
public final class uniform_int_distribution_Int32:Distribution<uniform_int_distributionintC> {
public init(_ g_:mt19937 , _ a:Int32,_ b:Int32) { super.init(uniform_int_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Int32,_ b:Int32) { self.init(mt19937.stored, a,b) }
}
extension Int32 {
public static func uniform_int_distribution(_ g_:mt19937 , _ a:Int32,_ b:Int32)->uniform_int_distribution_Int32 {return uniform_int_distribution_Int32(g_, a,b)}
public static func uniform_int_distribution(_ a:Int32,_ b:Int32)->uniform_int_distribution_Int32 {return uniform_int_distribution_Int32(a,b)}
}
public final class binomial_distribution_Int:Distribution<binomial_distributionlongC> {
public init(_ g_:mt19937 , _ t:Int,_ p:Double) { super.init(binomial_distribution_create(t,p, Element.init()), g_) }
public convenience init(_ t:Int,_ p:Double) { self.init(mt19937.stored, t,p) }
}
extension Int {
public static func binomial_distribution(_ g_:mt19937 , _ t:Int,_ p:Double)->binomial_distribution_Int {return binomial_distribution_Int(g_, t,p)}
public static func binomial_distribution(_ t:Int,_ p:Double)->binomial_distribution_Int {return binomial_distribution_Int(t,p)}
}
public final class binomial_distribution_Int32:Distribution<binomial_distributionintC> {
public init(_ g_:mt19937 , _ t:Int32,_ p:Double) { super.init(binomial_distribution_create(t,p, Element.init()), g_) }
public convenience init(_ t:Int32,_ p:Double) { self.init(mt19937.stored, t,p) }
}
extension Int32 {
public static func binomial_distribution(_ g_:mt19937 , _ t:Int32,_ p:Double)->binomial_distribution_Int32 {return binomial_distribution_Int32(g_, t,p)}
public static func binomial_distribution(_ t:Int32,_ p:Double)->binomial_distribution_Int32 {return binomial_distribution_Int32(t,p)}
}
public final class negative_binomial_distribution_Int:Distribution<negative_binomial_distributionlongC> {
public init(_ g_:mt19937 , _ k:Int,_ p:Double) { super.init(negative_binomial_distribution_create(k,p, Element.init()), g_) }
public convenience init(_ k:Int,_ p:Double) { self.init(mt19937.stored, k,p) }
}
extension Int {
public static func negative_binomial_distribution(_ g_:mt19937 , _ k:Int,_ p:Double)->negative_binomial_distribution_Int {return negative_binomial_distribution_Int(g_, k,p)}
public static func negative_binomial_distribution(_ k:Int,_ p:Double)->negative_binomial_distribution_Int {return negative_binomial_distribution_Int(k,p)}
}
public final class negative_binomial_distribution_Int32:Distribution<negative_binomial_distributionintC> {
public init(_ g_:mt19937 , _ k:Int32,_ p:Double) { super.init(negative_binomial_distribution_create(k,p, Element.init()), g_) }
public convenience init(_ k:Int32,_ p:Double) { self.init(mt19937.stored, k,p) }
}
extension Int32 {
public static func negative_binomial_distribution(_ g_:mt19937 , _ k:Int32,_ p:Double)->negative_binomial_distribution_Int32 {return negative_binomial_distribution_Int32(g_, k,p)}
public static func negative_binomial_distribution(_ k:Int32,_ p:Double)->negative_binomial_distribution_Int32 {return negative_binomial_distribution_Int32(k,p)}
}
public final class geometric_distribution_Int:Distribution<geometric_distributionlongC> {
public init(_ g_:mt19937 , _ p:Double) { super.init(geometric_distribution_create(p, Element.init()), g_) }
public convenience init(_ p:Double) { self.init(mt19937.stored, p) }
}
extension Int {
public static func geometric_distribution(_ g_:mt19937 , _ p:Double)->geometric_distribution_Int {return geometric_distribution_Int(g_, p)}
public static func geometric_distribution(_ p:Double)->geometric_distribution_Int {return geometric_distribution_Int(p)}
}
public final class geometric_distribution_Int32:Distribution<geometric_distributionintC> {
public init(_ g_:mt19937 , _ p:Double) { super.init(geometric_distribution_create(p, Element.init()), g_) }
public convenience init(_ p:Double) { self.init(mt19937.stored, p) }
}
extension Int32 {
public static func geometric_distribution(_ g_:mt19937 , _ p:Double)->geometric_distribution_Int32 {return geometric_distribution_Int32(g_, p)}
public static func geometric_distribution(_ p:Double)->geometric_distribution_Int32 {return geometric_distribution_Int32(p)}
}
public final class poisson_distribution_Int:Distribution<poisson_distributionlongC> {
public init(_ g_:mt19937 , _ mean:Double) { super.init(poisson_distribution_create(mean, Element.init()), g_) }
public convenience init(_ mean:Double) { self.init(mt19937.stored, mean) }
}
extension Int {
public static func poisson_distribution(_ g_:mt19937 , _ mean:Double)->poisson_distribution_Int {return poisson_distribution_Int(g_, mean)}
public static func poisson_distribution(_ mean:Double)->poisson_distribution_Int {return poisson_distribution_Int(mean)}
}
public final class poisson_distribution_Int32:Distribution<poisson_distributionintC> {
public init(_ g_:mt19937 , _ mean:Double) { super.init(poisson_distribution_create(mean, Element.init()), g_) }
public convenience init(_ mean:Double) { self.init(mt19937.stored, mean) }
}
extension Int32 {
public static func poisson_distribution(_ g_:mt19937 , _ mean:Double)->poisson_distribution_Int32 {return poisson_distribution_Int32(g_, mean)}
public static func poisson_distribution(_ mean:Double)->poisson_distribution_Int32 {return poisson_distribution_Int32(mean)}
}
public final class discrete_distribution_Int:Distribution<discrete_distributionlongC> {
public init(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { super.init(discrete_distribution_create(start,end, Element.init()), g_) }
public convenience init(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start,end) }
}
extension Int {
public static func discrete_distribution(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int {return discrete_distribution_Int(g_, start,end)}
public static func discrete_distribution(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int {return discrete_distribution_Int(start,end)}
}
public final class discrete_distribution_Int32:Distribution<discrete_distributionintC> {
public init(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { super.init(discrete_distribution_create(start,end, Element.init()), g_) }
public convenience init(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>) { self.init(mt19937.stored, start,end) }
}
extension Int32 {
public static func discrete_distribution(_ g_:mt19937 , _ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int32 {return discrete_distribution_Int32(g_, start,end)}
public static func discrete_distribution(_ start:UnsafeMutablePointer<Double>,_ end:UnsafeMutablePointer<Double>)->discrete_distribution_Int32 {return discrete_distribution_Int32(start,end)}
}
public final class uniform_real_distribution_Float:Distribution<uniform_real_distributionfloatC> {
public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(uniform_real_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }
}
extension Float {
public static func uniform_real_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->uniform_real_distribution_Float {return uniform_real_distribution_Float(g_, a,b)}
public static func uniform_real_distribution(_ a:Float,_ b:Float)->uniform_real_distribution_Float {return uniform_real_distribution_Float(a,b)}
}
public final class uniform_real_distribution_Double:Distribution<uniform_real_distributiondoubleC> {
public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(uniform_real_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }
}
extension Double {
public static func uniform_real_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->uniform_real_distribution_Double {return uniform_real_distribution_Double(g_, a,b)}
public static func uniform_real_distribution(_ a:Double,_ b:Double)->uniform_real_distribution_Double {return uniform_real_distribution_Double(a,b)}
}
public final class exponential_distribution_Float:Distribution<exponential_distributionfloatC> {
public init(_ g_:mt19937 , _ l:Float) { super.init(exponential_distribution_create(l, Element.init()), g_) }
public convenience init(_ l:Float) { self.init(mt19937.stored, l) }
}
extension Float {
public static func exponential_distribution(_ g_:mt19937 , _ l:Float)->exponential_distribution_Float {return exponential_distribution_Float(g_, l)}
public static func exponential_distribution(_ l:Float)->exponential_distribution_Float {return exponential_distribution_Float(l)}
}
public final class exponential_distribution_Double:Distribution<exponential_distributiondoubleC> {
public init(_ g_:mt19937 , _ l:Double) { super.init(exponential_distribution_create(l, Element.init()), g_) }
public convenience init(_ l:Double) { self.init(mt19937.stored, l) }
}
extension Double {
public static func exponential_distribution(_ g_:mt19937 , _ l:Double)->exponential_distribution_Double {return exponential_distribution_Double(g_, l)}
public static func exponential_distribution(_ l:Double)->exponential_distribution_Double {return exponential_distribution_Double(l)}
}
public final class gamma_distribution_Float:Distribution<gamma_distributionfloatC> {
public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(gamma_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }
}
extension Float {
public static func gamma_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->gamma_distribution_Float {return gamma_distribution_Float(g_, a,b)}
public static func gamma_distribution(_ a:Float,_ b:Float)->gamma_distribution_Float {return gamma_distribution_Float(a,b)}
}
public final class gamma_distribution_Double:Distribution<gamma_distributiondoubleC> {
public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(gamma_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }
}
extension Double {
public static func gamma_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->gamma_distribution_Double {return gamma_distribution_Double(g_, a,b)}
public static func gamma_distribution(_ a:Double,_ b:Double)->gamma_distribution_Double {return gamma_distribution_Double(a,b)}
}
public final class weibull_distribution_Float:Distribution<weibull_distributionfloatC> {
public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(weibull_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }
}
extension Float {
public static func weibull_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->weibull_distribution_Float {return weibull_distribution_Float(g_, a,b)}
public static func weibull_distribution(_ a:Float,_ b:Float)->weibull_distribution_Float {return weibull_distribution_Float(a,b)}
}
public final class weibull_distribution_Double:Distribution<weibull_distributiondoubleC> {
public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(weibull_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }
}
extension Double {
public static func weibull_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->weibull_distribution_Double {return weibull_distribution_Double(g_, a,b)}
public static func weibull_distribution(_ a:Double,_ b:Double)->weibull_distribution_Double {return weibull_distribution_Double(a,b)}
}
public final class normal_distribution_Float:Distribution<normal_distributionfloatC> {
public init(_ g_:mt19937 , _ mean:Float,_ stddev:Float) { super.init(normal_distribution_create(mean,stddev, Element.init()), g_) }
public convenience init(_ mean:Float,_ stddev:Float) { self.init(mt19937.stored, mean,stddev) }
}
extension Float {
public static func normal_distribution(_ g_:mt19937 , _ mean:Float,_ stddev:Float)->normal_distribution_Float {return normal_distribution_Float(g_, mean,stddev)}
public static func normal_distribution(_ mean:Float,_ stddev:Float)->normal_distribution_Float {return normal_distribution_Float(mean,stddev)}
}
public final class normal_distribution_Double:Distribution<normal_distributiondoubleC> {
public init(_ g_:mt19937 , _ mean:Double,_ stddev:Double) { super.init(normal_distribution_create(mean,stddev, Element.init()), g_) }
public convenience init(_ mean:Double,_ stddev:Double) { self.init(mt19937.stored, mean,stddev) }
}
extension Double {
public static func normal_distribution(_ g_:mt19937 , _ mean:Double,_ stddev:Double)->normal_distribution_Double {return normal_distribution_Double(g_, mean,stddev)}
public static func normal_distribution(_ mean:Double,_ stddev:Double)->normal_distribution_Double {return normal_distribution_Double(mean,stddev)}
}
public final class lognormal_distribution_Float:Distribution<lognormal_distributionfloatC> {
public init(_ g_:mt19937 , _ m:Float,_ s:Float) { super.init(lognormal_distribution_create(m,s, Element.init()), g_) }
public convenience init(_ m:Float,_ s:Float) { self.init(mt19937.stored, m,s) }
}
extension Float {
public static func lognormal_distribution(_ g_:mt19937 , _ m:Float,_ s:Float)->lognormal_distribution_Float {return lognormal_distribution_Float(g_, m,s)}
public static func lognormal_distribution(_ m:Float,_ s:Float)->lognormal_distribution_Float {return lognormal_distribution_Float(m,s)}
}
public final class lognormal_distribution_Double:Distribution<lognormal_distributiondoubleC> {
public init(_ g_:mt19937 , _ m:Double,_ s:Double) { super.init(lognormal_distribution_create(m,s, Element.init()), g_) }
public convenience init(_ m:Double,_ s:Double) { self.init(mt19937.stored, m,s) }
}
extension Double {
public static func lognormal_distribution(_ g_:mt19937 , _ m:Double,_ s:Double)->lognormal_distribution_Double {return lognormal_distribution_Double(g_, m,s)}
public static func lognormal_distribution(_ m:Double,_ s:Double)->lognormal_distribution_Double {return lognormal_distribution_Double(m,s)}
}
public final class chi_squared_distribution_Float:Distribution<chi_squared_distributionfloatC> {
public init(_ g_:mt19937 , _ n:Float) { super.init(chi_squared_distribution_create(n, Element.init()), g_) }
public convenience init(_ n:Float) { self.init(mt19937.stored, n) }
}
extension Float {
public static func chi_squared_distribution(_ g_:mt19937 , _ n:Float)->chi_squared_distribution_Float {return chi_squared_distribution_Float(g_, n)}
public static func chi_squared_distribution(_ n:Float)->chi_squared_distribution_Float {return chi_squared_distribution_Float(n)}
}
public final class chi_squared_distribution_Double:Distribution<chi_squared_distributiondoubleC> {
public init(_ g_:mt19937 , _ n:Double) { super.init(chi_squared_distribution_create(n, Element.init()), g_) }
public convenience init(_ n:Double) { self.init(mt19937.stored, n) }
}
extension Double {
public static func chi_squared_distribution(_ g_:mt19937 , _ n:Double)->chi_squared_distribution_Double {return chi_squared_distribution_Double(g_, n)}
public static func chi_squared_distribution(_ n:Double)->chi_squared_distribution_Double {return chi_squared_distribution_Double(n)}
}
public final class cauchy_distribution_Float:Distribution<cauchy_distributionfloatC> {
public init(_ g_:mt19937 , _ a:Float,_ b:Float) { super.init(cauchy_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Float,_ b:Float) { self.init(mt19937.stored, a,b) }
}
extension Float {
public static func cauchy_distribution(_ g_:mt19937 , _ a:Float,_ b:Float)->cauchy_distribution_Float {return cauchy_distribution_Float(g_, a,b)}
public static func cauchy_distribution(_ a:Float,_ b:Float)->cauchy_distribution_Float {return cauchy_distribution_Float(a,b)}
}
public final class cauchy_distribution_Double:Distribution<cauchy_distributiondoubleC> {
public init(_ g_:mt19937 , _ a:Double,_ b:Double) { super.init(cauchy_distribution_create(a,b, Element.init()), g_) }
public convenience init(_ a:Double,_ b:Double) { self.init(mt19937.stored, a,b) }
}
extension Double {
public static func cauchy_distribution(_ g_:mt19937 , _ a:Double,_ b:Double)->cauchy_distribution_Double {return cauchy_distribution_Double(g_, a,b)}
public static func cauchy_distribution(_ a:Double,_ b:Double)->cauchy_distribution_Double {return cauchy_distribution_Double(a,b)}
}
public final class fisher_f_distribution_Float:Distribution<fisher_f_distributionfloatC> {
public init(_ g_:mt19937 , _ m:Float,_ n:Float) { super.init(fisher_f_distribution_create(m,n, Element.init()), g_) }
public convenience init(_ m:Float,_ n:Float) { self.init(mt19937.stored, m,n) }
}
extension Float {
public static func fisher_f_distribution(_ g_:mt19937 , _ m:Float,_ n:Float)->fisher_f_distribution_Float {return fisher_f_distribution_Float(g_, m,n)}
public static func fisher_f_distribution(_ m:Float,_ n:Float)->fisher_f_distribution_Float {return fisher_f_distribution_Float(m,n)}
}
public final class fisher_f_distribution_Double:Distribution<fisher_f_distributiondoubleC> {
public init(_ g_:mt19937 , _ m:Double,_ n:Double) { super.init(fisher_f_distribution_create(m,n, Element.init()), g_) }
public convenience init(_ m:Double,_ n:Double) { self.init(mt19937.stored, m,n) }
}
extension Double {
public static func fisher_f_distribution(_ g_:mt19937 , _ m:Double,_ n:Double)->fisher_f_distribution_Double {return fisher_f_distribution_Double(g_, m,n)}
public static func fisher_f_distribution(_ m:Double,_ n:Double)->fisher_f_distribution_Double {return fisher_f_distribution_Double(m,n)}
}
public final class student_t_distribution_Float:Distribution<student_t_distributionfloatC> {
public init(_ g_:mt19937 , _ n:Float) { super.init(student_t_distribution_create(n, Element.init()), g_) }
public convenience init(_ n:Float) { self.init(mt19937.stored, n) }
}
extension Float {
public static func student_t_distribution(_ g_:mt19937 , _ n:Float)->student_t_distribution_Float {return student_t_distribution_Float(g_, n)}
public static func student_t_distribution(_ n:Float)->student_t_distribution_Float {return student_t_distribution_Float(n)}
}
public final class student_t_distribution_Double:Distribution<student_t_distributiondoubleC> {
public init(_ g_:mt19937 , _ n:Double) { super.init(student_t_distribution_create(n, Element.init()), g_) }
public convenience init(_ n:Double) { self.init(mt19937.stored, n) }
}
extension Double {
public static func student_t_distribution(_ g_:mt19937 , _ n:Double)->student_t_distribution_Double {return student_t_distribution_Double(g_, n)}
public static func student_t_distribution(_ n:Double)->student_t_distribution_Double {return student_t_distribution_Double(n)}
}
public final class piecewise_constant_distribution_Float:Distribution<piecewise_constant_distributionfloatC> {
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_) }
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) }
}
extension Float {
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)}
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)}
}
public final class piecewise_constant_distribution_Double:Distribution<piecewise_constant_distributiondoubleC> {
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_) }
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) }
}
extension Double {
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)}
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)}
}
public final class piecewise_linear_distribution_Float:Distribution<piecewise_linear_distributionfloatC> {
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_) }
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) }
}
extension Float {
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)}
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)}
}
public final class piecewise_linear_distribution_Double:Distribution<piecewise_linear_distributiondoubleC> {
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_) }
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) }
}
extension Double {
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)}
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)}
}
extension Int {
public static func discrete_distribution(_ d_s:[Double])->discrete_distribution_Int {
return discrete_distribution(d_s.p, d_s.p+d_s.count)
}
}
extension Int32 {
public static func discrete_distribution(_ d_s:[Double])->discrete_distribution_Int32 {
return discrete_distribution(d_s.p, d_s.p+d_s.count)
}
}
extension Float {
public static func piecewise_constant_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_constant_distribution_Float {
return piecewise_constant_distribution(i_s.p, i_s.p+i_s.count, w_s.p)
}
public static func piecewise_linear_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_linear_distribution_Float {
return piecewise_linear_distribution(i_s.p, i_s.p+i_s.count, w_s.p)
}
}
extension Double {
public static func piecewise_constant_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_constant_distribution_Double {
return piecewise_constant_distribution(i_s.p, i_s.p+i_s.count, w_s.p)
}
public static func piecewise_linear_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_linear_distribution_Double {
return piecewise_linear_distribution(i_s.p, i_s.p+i_s.count, w_s.p)
}
}
================================================
FILE: Sources/BaseMath/BaseRand.swift.gyb
================================================
import Foundation
import CBaseMath
%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%
public protocol Initable { init() }
% for t in float_swift+int_swift+['Bool']:
extension ${t}:Initable {}
% end
public protocol CppTypePtr {
func delete()
}
public class CppType<T:CppTypePtr> {
public let p:T
init(_ p:T) {self.p=p}
deinit {p.delete()}
}
public class mt19937:CppType<mt19937C> {
public convenience init() { self.init(CBaseMath.mt19937_create()) }
@usableFromInline static var storeKey:String { get { return "mt19937" } }
public static var stored:mt19937 { get {
if let r = Thread.current.threadDictionary[storeKey] as? mt19937 { return r }
return Thread.setToTLS(mt19937(), storeKey)
}}
}
public protocol DistributionC:CppTypePtr {
associatedtype Element:SignedNumeric
func call(_ g:mt19937C)->Element
}
public class Distribution<T:DistributionC>:CppType<T>,Nullary {
public typealias Element=T.Element
public var g:mt19937
public init(_ p:T, _ g:mt19937) {self.g=g; super.init(p) }
@inlinable public subscript()->Element { return p.call(g.p) }
public subscript(n:Int)->[Element] { return gen_array(n) }
public func gen_array(_ n:Int)->[Element] {
return [Element].fill(self, n)
}
public func gen_aligned(_ n:Int)->AlignedStorage<Element> {
return AlignedStorage<Element>.fill(self, n)
}
public func gen_pointer(_ n:Int)->UnsafeMutableBufferPointer<Element> {
return UnsafeMutableBufferPointer<Element>.fill(self, n)
}
}
% for o,gs,gc in [(o,*gen) for o in dist_types for gen in o.generics]:
%{
n = o.typ
p1 = o.pswift.replace('#',gs)
p2 = o.p2
sep = "," if p1 else ""
}%
public final class ${n}_${gs}:Distribution<${n}${gc}C> {
public init(_ g_:mt19937 ${sep} ${p1}) { super.init(${n}_create(${p2}, Element.init()), g_) }
public convenience init(${p1}) { self.init(mt19937.stored, ${p2}) }
}
% if not gs:
/*
% end # gs
extension ${gs} {
public static func ${n}(_ g_:mt19937 ${sep} ${p1})->${n}_${gs} {return ${n}_${gs}(g_, ${p2})}
public static func ${n}(${p1})->${n}_${gs} {return ${n}_${gs}(${p2})}
}
% if not gs:
*/
% end # gs
% end # o
% for t in int_swift:
extension ${t} {
public static func discrete_distribution(_ d_s:[Double])->discrete_distribution_${t} {
return discrete_distribution(d_s.p, d_s.p+d_s.count)
}
}
% end
% for t in float_swift:
extension ${t} {
public static func piecewise_constant_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_constant_distribution_${t} {
return piecewise_constant_distribution(i_s.p, i_s.p+i_s.count, w_s.p)
}
public static func piecewise_linear_distribution(_ i_s:[Double], _ w_s:[Double])->piecewise_linear_distribution_${t} {
return piecewise_linear_distribution(i_s.p, i_s.p+i_s.count, w_s.p)
}
}
% end
================================================
FILE: Sources/BaseMath/BaseVector.swift
================================================
import Foundation
public protocol Nullary {
associatedtype Element:SignedNumeric
subscript()->Element {get}
}
public protocol BaseVector:
RandomAccessCollection, MutableCollection, ExpressibleByArrayLiteral, Equatable, CustomStringConvertible
where Index==Int, Element:SignedNumeric {
typealias PtrT = UnsafePointer<Element>
typealias MutPtrT = UnsafeMutablePointer<Element>
typealias NullaryF = ()->(Element)
typealias UnaryF = (Element)->(Element)
typealias BinaryF = (Element,Element)->(Element)
typealias TernaryF = (Element,Element,Element)->(Element)
init(_ data:[Element])
init(_ count:Int)
func new(_ size:Int)->Self
func copy()->Self
var p:MutPtrT {get}
static func fill<T:Nullary>(_ f:T, _ n:Int)->Self where T.Element==Self.Element
static func fill(_ f:NullaryF, _ n:Int)->Self
func fill<T:Nullary>(_ f:T) where T.Element==Self.Element
func fill(_ f:NullaryF)
func map(_ f:UnaryF, _ dest: Self)
func map(_ f:BinaryF, _ b:Self, _ dest: Self)
func map(_ f:TernaryF, _ b:Self, _ c:Self, _ dest: Self)
}
extension BaseVector {
public init(arrayLiteral data: Element...) { self.init(data) }
public var indices: Range<Int> { return 0..<endIndex }
public var startIndex: Int { return 0 }
@inlinable public func new(_ size:Int)->Self { return .init(size) }
@inlinable public func new() -> Self { return new(count) }
@inlinable public var c:Int32 {get {return numericCast(count)}}
@inlinable public static func ==(lhs:Self, rhs:Self) -> Bool { return lhs.elementsEqual(rhs) }
@inlinable public static func ==(lhs:[Element], rhs:Self) -> Bool { return self.init(lhs) == rhs }
@inlinable public static func ==(lhs:Self, rhs:[Element]) -> Bool { return lhs == self.init(rhs) }
public var description: String { return "\(Array(self))" }
@inlinable public static func fill<T:Nullary>(_ f:T, _ n:Int)->Self where T.Element==Self.Element {
let res = Self(n); res.fill(f); return res
}
@inlinable public static func fill(_ f:NullaryF, _ n:Int)->Self {
let res = Self(n); res.fill(f); return res
}
@inlinable public func fill<T:Nullary>(_ f:T) where T.Element==Self.Element {
let pDest = p; let n = count
for i in 0..<n {pDest[i] = f[]}
}
@inlinable public func fill(_ f:NullaryF) {
let pDest = p; let n = count
for i in 0..<n {pDest[i] = f()}
}
@inlinable public func map(_ f:UnaryF, _ dest:Self) {
let pSrc = p; let pDest = dest.p; let n = count
for i in 0..<n {pDest[i] = f(pSrc[i])}
}
@inlinable public func map(_ f:BinaryF, _ b:Self, _ dest: Self) {
let pSrc = p; let pB = b.p; let pDest = dest.p; let n = count
for i in 0..<n {pDest[i] = f(pSrc[i], pB[i])}
}
@inlinable public func map(_ f:TernaryF, _ b:Self, _ c:Self, _ dest: Self) {
let pSrc = p; let pB = b.p; let pC = c.p; let pDest = dest.p; let n = count
for i in 0..<n {pDest[i] = f(pSrc[i], pB[i], pC[i])}
}
}
================================================
FILE: Sources/BaseMath/CBaseRand.swift
================================================
import Foundation
import CBaseMath
extension uniform_int_distributionlongC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }
}
extension uniform_int_distributionintC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }
}
extension binomial_distributionlongC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }
}
extension binomial_distributionintC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }
}
extension negative_binomial_distributionlongC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }
}
extension negative_binomial_distributionintC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }
}
extension geometric_distributionlongC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }
}
extension geometric_distributionintC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }
}
extension poisson_distributionlongC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }
}
extension poisson_distributionintC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }
}
extension discrete_distributionlongC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int { return CBaseMath.call(self,g) }
}
extension discrete_distributionintC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Int32 { return CBaseMath.call(self,g) }
}
extension uniform_real_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension uniform_real_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension exponential_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension exponential_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension gamma_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension gamma_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension weibull_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension weibull_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension normal_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension normal_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension lognormal_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension lognormal_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension chi_squared_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension chi_squared_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension cauchy_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension cauchy_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension fisher_f_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension fisher_f_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension student_t_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension student_t_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension piecewise_constant_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension piecewise_constant_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension piecewise_linear_distributionfloatC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Float { return CBaseMath.call(self,g) }
}
extension piecewise_linear_distributiondoubleC:DistributionC {
public func delete() {destroy(self)}
public func call(_ g:mt19937C)->Double { return CBaseMath.call(self,g) }
}
extension mt19937C:CppTypePtr {
public func delete() {destroy(self)}
}
extension knuth_bC:CppTypePtr {
public func delete() {destroy(self)}
}
extension bernoulli_distributionC:CppTypePtr {
public func delete() {destroy(self)}
}
================================================
FILE: Sources/BaseMath/CBaseRand.swift.gyb
================================================
%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%
import Foundation
import CBaseMath
% for o in all_types:
${o.swift()}
% end
================================================
FILE: Sources/BaseMath/FloatVector.swift
================================================
import Foundation
extension SupportsBasicMath {
@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]) } }
@inlinable public static func add(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].add(val ) } }
@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]) } }
@inlinable public static func sub(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sub(val ) } }
@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]) } }
@inlinable public static func mul(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].mul(val ) } }
@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]) } }
@inlinable public static func div(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].div(val ) } }
@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]) } }
@inlinable public static func subRev(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].subRev(val ) } }
@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]) } }
@inlinable public static func divRev(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].divRev(val ) } }
@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]) } }
@inlinable public static func min(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].min(val ) } }
@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]) } }
@inlinable public static func max(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].max(val ) } }
@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]) } }
@inlinable public static func pow(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].pow(val ) } }
@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]) } }
@inlinable public static func atan2(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atan2(val ) } }
@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]) } }
@inlinable public static func copysign(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].copysign(val ) } }
@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]) } }
@inlinable public static func fdim(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fdim(val ) } }
@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]) } }
@inlinable public static func fmax(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fmax(val ) } }
@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]) } }
@inlinable public static func fmin(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].fmin(val ) } }
@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]) } }
@inlinable public static func hypot(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].hypot(val ) } }
@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]) } }
@inlinable public static func nextafter(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].nextafter(val ) } }
@inlinable public static func abs(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].abs() } }
@inlinable public static func sqrt(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sqrt() } }
@inlinable public static func acos(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].acos() } }
@inlinable public static func acosh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].acosh() } }
@inlinable public static func asin(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].asin() } }
@inlinable public static func asinh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].asinh() } }
@inlinable public static func atan(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atan() } }
@inlinable public static func atanh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].atanh() } }
@inlinable public static func cbrt(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].cbrt() } }
@inlinable public static func cos(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].cos() } }
@inlinable public static func cosh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].cosh() } }
@inlinable public static func erf(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].erf() } }
@inlinable public static func erfc(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].erfc() } }
@inlinable public static func exp(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].exp() } }
@inlinable public static func exp2(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].exp2() } }
@inlinable public static func expm1(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].expm1() } }
@inlinable public static func log(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log() } }
@inlinable public static func log10(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log10() } }
@inlinable public static func log1p(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log1p() } }
@inlinable public static func log2(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].log2() } }
@inlinable public static func logb(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].logb() } }
@inlinable public static func nearbyint(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].nearbyint() } }
@inlinable public static func rint(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].rint() } }
@inlinable public static func sin(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sin() } }
@inlinable public static func sinh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].sinh() } }
@inlinable public static func tan(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].tan() } }
@inlinable public static func tanh(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].tanh() } }
@inlinable public static func tgamma(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].tgamma() } }
}
public protocol FloatVector: BaseVector where Element:SupportsBasicMath {
func sum(_ f:UnaryF)->Element
func sum(_ f:BinaryF, _ b:Self)->Element
func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element
func add(_ b: Self, _ dest:Self)
func add_(_ b:Self)
func sub(_ b: Self, _ dest:Self)
func sub_(_ b:Self)
func mul(_ b: Self, _ dest:Self)
func mul_(_ b:Self)
func div(_ b: Self, _ dest:Self)
func div_(_ b:Self)
func subRev(_ b: Self, _ dest:Self)
func subRev_(_ b:Self)
func divRev(_ b: Self, _ dest:Self)
func divRev_(_ b:Self)
func min(_ b: Self, _ dest:Self)
func min_(_ b:Self)
func max(_ b: Self, _ dest:Self)
func max_(_ b:Self)
func pow(_ b: Self, _ dest:Self)
func pow_(_ b:Self)
func atan2(_ b: Self, _ dest:Self)
func atan2_(_ b:Self)
func copysign(_ b: Self, _ dest:Self)
func copysign_(_ b:Self)
func fdim(_ b: Self, _ dest:Self)
func fdim_(_ b:Self)
func fmax(_ b: Self, _ dest:Self)
func fmax_(_ b:Self)
func fmin(_ b: Self, _ dest:Self)
func fmin_(_ b:Self)
func hypot(_ b: Self, _ dest:Self)
func hypot_(_ b:Self)
func nextafter(_ b: Self, _ dest:Self)
func nextafter_(_ b:Self)
func abs(_ dest:Self)
func abs_()
func sqrt(_ dest:Self)
func sqrt_()
func acos(_ dest:Self)
func acos_()
func acosh(_ dest:Self)
func acosh_()
func asin(_ dest:Self)
func asin_()
func asinh(_ dest:Self)
func asinh_()
func atan(_ dest:Self)
func atan_()
func atanh(_ dest:Self)
func atanh_()
func cbrt(_ dest:Self)
func cbrt_()
func cos(_ dest:Self)
func cos_()
func cosh(_ dest:Self)
func cosh_()
func erf(_ dest:Self)
func erf_()
func erfc(_ dest:Self)
func erfc_()
func exp(_ dest:Self)
func exp_()
func exp2(_ dest:Self)
func exp2_()
func expm1(_ dest:Self)
func expm1_()
func log(_ dest:Self)
func log_()
func log10(_ dest:Self)
func log10_()
func log1p(_ dest:Self)
func log1p_()
func log2(_ dest:Self)
func log2_()
func logb(_ dest:Self)
func logb_()
func nearbyint(_ dest:Self)
func nearbyint_()
func rint(_ dest:Self)
func rint_()
func sin(_ dest:Self)
func sin_()
func sinh(_ dest:Self)
func sinh_()
func tan(_ dest:Self)
func tan_()
func tanh(_ dest:Self)
func tanh_()
func tgamma(_ dest:Self)
func tgamma_()
func sumabs()->Element
func sumsqrt()->Element
func sumacos()->Element
func sumacosh()->Element
func sumasin()->Element
func sumasinh()->Element
func sumatan()->Element
func sumatanh()->Element
func sumcbrt()->Element
func sumcos()->Element
func sumcosh()->Element
func sumerf()->Element
func sumerfc()->Element
func sumexp()->Element
func sumexp2()->Element
func sumexpm1()->Element
func sumlog()->Element
func sumlog10()->Element
func sumlog1p()->Element
func sumlog2()->Element
func sumlogb()->Element
func sumnearbyint()->Element
func sumrint()->Element
func sumsin()->Element
func sumsinh()->Element
func sumtan()->Element
func sumtanh()->Element
func sumtgamma()->Element
func sum() -> Element
}
extension FloatVector {
@usableFromInline var storeKey:String { get { return "FloatVector\(Element.self)" } }
@usableFromInline var tempStore:Self { get {
if let r = Thread.current.threadDictionary[storeKey] as? Self {
if (r.count == count) { return r }
}
return Thread.setToTLS(Self(count), storeKey)
}}
@inlinable public func sum(_ f:UnaryF)->Element {
self.map(f, tempStore)
return tempStore.sum()
}
@inlinable public func sum(_ f:BinaryF, _ b:Self)->Element {
self.map(f, b, tempStore)
return tempStore.sum()
}
@inlinable public func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element {
self.map(f, b, c, tempStore)
return tempStore.sum()
}
@inlinable public func new_call(_ f:(Self) ->() )->Self { let res = new(); f( res); return res }
@inlinable public func new_call(_ f:(Self, Self) ->(), _ b:Self )->Self { let res = new(); f(b, res); return res }
@inlinable public func new_call<T>(_ f:(T, Self) ->(), _ b:T )->Self { let res = new(); f(b, res); return res }
@inlinable public func new_call<T>(_ f:(T, T, Self)->(), _ b:T, _ c:T)->Self { let res = new(); f(b, c, res); return res }
@inlinable public func new_call<T>(_ f:(T, Self)->(), _ b:T, n:Int )->Self { let res = new(n); f(b, res); return res }
@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 }
@inlinable public func sum() -> Element { return Element.sum(p, numericCast(c)) }
@inlinable public func sumabs()->Element { return Element.sumabs(p, numericCast(c)) }
@inlinable public func sumsqrt()->Element { return Element.sumsqrt(p, numericCast(c)) }
@inlinable public func sumacos()->Element { return Element.sumacos(p, numericCast(c)) }
@inlinable public func sumacosh()->Element { return Element.sumacosh(p, numericCast(c)) }
@inlinable public func sumasin()->Element { return Element.sumasin(p, numericCast(c)) }
@inlinable public func sumasinh()->Element { return Element.sumasinh(p, numericCast(c)) }
@inlinable public func sumatan()->Element { return Element.sumatan(p, numericCast(c)) }
@inlinable public func sumatanh()->Element { return Element.sumatanh(p, numericCast(c)) }
@inlinable public func sumcbrt()->Element { return Element.sumcbrt(p, numericCast(c)) }
@inlinable public func sumcos()->Element { return Element.sumcos(p, numericCast(c)) }
@inlinable public func sumcosh()->Element { return Element.sumcosh(p, numericCast(c)) }
@inlinable public func sumerf()->Element { return Element.sumerf(p, numericCast(c)) }
@inlinable public func sumerfc()->Element { return Element.sumerfc(p, numericCast(c)) }
@inlinable public func sumexp()->Element { return Element.sumexp(p, numericCast(c)) }
@inlinable public func sumexp2()->Element { return Element.sumexp2(p, numericCast(c)) }
@inlinable public func sumexpm1()->Element { return Element.sumexpm1(p, numericCast(c)) }
@inlinable public func sumlog()->Element { return Element.sumlog(p, numericCast(c)) }
@inlinable public func sumlog10()->Element { return Element.sumlog10(p, numericCast(c)) }
@inlinable public func sumlog1p()->Element { return Element.sumlog1p(p, numericCast(c)) }
@inlinable public func sumlog2()->Element { return Element.sumlog2(p, numericCast(c)) }
@inlinable public func sumlogb()->Element { return Element.sumlogb(p, numericCast(c)) }
@inlinable public func sumnearbyint()->Element { return Element.sumnearbyint(p, numericCast(c)) }
@inlinable public func sumrint()->Element { return Element.sumrint(p, numericCast(c)) }
@inlinable public func sumsin()->Element { return Element.sumsin(p, numericCast(c)) }
@inlinable public func sumsinh()->Element { return Element.sumsinh(p, numericCast(c)) }
@inlinable public func sumtan()->Element { return Element.sumtan(p, numericCast(c)) }
@inlinable public func sumtanh()->Element { return Element.sumtanh(p, numericCast(c)) }
@inlinable public func sumtgamma()->Element { return Element.sumtgamma(p, numericCast(c)) }
@inlinable public func sumsqr()->Element { return Element.sumsqr(p, numericCast(c)) }
@inlinable public func add (_ b:Self)->Self { return new_call(add, b) }
@inlinable public func add (_ b:Self, _ dest:Self) { Element.add(count, self.p, b.p, dest.p) }
@inlinable public func add_(_ b:Self) { add(b, self) }
@inlinable public func add (_ b:Element)->Self { return new_call(add, b) }
@inlinable public func add (_ b:Element, _ dest:Self) { Element.add(count, self.p, b, dest.p) }
@inlinable public func add_(_ b:Element) { add(b, self) }
@inlinable public func sub (_ b:Self)->Self { return new_call(sub, b) }
@inlinable public func sub (_ b:Self, _ dest:Self) { Element.sub(count, self.p, b.p, dest.p) }
@inlinable public func sub_(_ b:Self) { sub(b, self) }
@inlinable public func sub (_ b:Element)->Self { return new_call(sub, b) }
@inlinable public func sub (_ b:Element, _ dest:Self) { Element.sub(count, self.p, b, dest.p) }
@inlinable public func sub_(_ b:Element) { sub(b, self) }
@inlinable public func mul (_ b:Self)->Self { return new_call(mul, b) }
@inlinable public func mul (_ b:Self, _ dest:Self) { Element.mul(count, self.p, b.p, dest.p) }
@inlinable public func mul_(_ b:Self) { mul(b, self) }
@inlinable public func mul (_ b:Element)->Self { return new_call(mul, b) }
@inlinable public func mul (_ b:Element, _ dest:Self) { Element.mul(count, self.p, b, dest.p) }
@inlinable public func mul_(_ b:Element) { mul(b, self) }
@inlinable public func div (_ b:Self)->Self { return new_call(div, b) }
@inlinable public func div (_ b:Self, _ dest:Self) { Element.div(count, self.p, b.p, dest.p) }
@inlinable public func div_(_ b:Self) { div(b, self) }
@inlinable public func div (_ b:Element)->Self { return new_call(div, b) }
@inlinable public func div (_ b:Element, _ dest:Self) { Element.div(count, self.p, b, dest.p) }
@inlinable public func div_(_ b:Element) { div(b, self) }
@inlinable public func subRev (_ b:Self)->Self { return new_call(subRev, b) }
@inlinable public func subRev (_ b:Self, _ dest:Self) { Element.subRev(count, self.p, b.p, dest.p) }
@inlinable public func subRev_(_ b:Self) { subRev(b, self) }
@inlinable public func subRev (_ b:Element)->Self { return new_call(subRev, b) }
@inlinable public func subRev (_ b:Element, _ dest:Self) { Element.subRev(count, self.p, b, dest.p) }
@inlinable public func subRev_(_ b:Element) { subRev(b, self) }
@inlinable public func divRev (_ b:Self)->Self { return new_call(divRev, b) }
@inlinable public func divRev (_ b:Self, _ dest:Self) { Element.divRev(count, self.p, b.p, dest.p) }
@inlinable public func divRev_(_ b:Self) { divRev(b, self) }
@inlinable public func divRev (_ b:Element)->Self { return new_call(divRev, b) }
@inlinable public func divRev (_ b:Element, _ dest:Self) { Element.divRev(count, self.p, b, dest.p) }
@inlinable public func divRev_(_ b:Element) { divRev(b, self) }
@inlinable public func min (_ b:Self)->Self { return new_call(min, b) }
@inlinable public func min (_ b:Self, _ dest:Self) { Element.min(count, self.p, b.p, dest.p) }
@inlinable public func min_(_ b:Self) { min(b, self) }
@inlinable public func min (_ b:Element)->Self { return new_call(min, b) }
@inlinable public func min (_ b:Element, _ dest:Self) { Element.min(count, self.p, b, dest.p) }
@inlinable public func min_(_ b:Element) { min(b, self) }
@inlinable public func max (_ b:Self)->Self { return new_call(max, b) }
@inlinable public func max (_ b:Self, _ dest:Self) { Element.max(count, self.p, b.p, dest.p) }
@inlinable public func max_(_ b:Self) { max(b, self) }
@inlinable public func max (_ b:Element)->Self { return new_call(max, b) }
@inlinable public func max (_ b:Element, _ dest:Self) { Element.max(count, self.p, b, dest.p) }
@inlinable public func max_(_ b:Element) { max(b, self) }
@inlinable public func pow (_ b:Self)->Self { return new_call(pow, b) }
@inlinable public func pow (_ b:Self, _ dest:Self) { Element.pow(count, self.p, b.p, dest.p) }
@inlinable public func pow_(_ b:Self) { pow(b, self) }
@inlinable public func pow (_ b:Element)->Self { return new_call(pow, b) }
@inlinable public func pow (_ b:Element, _ dest:Self) { Element.pow(count, self.p, b, dest.p) }
@inlinable public func pow_(_ b:Element) { pow(b, self) }
@inlinable public func atan2 (_ b:Self)->Self { return new_call(atan2, b) }
@inlinable public func atan2 (_ b:Self, _ dest:Self) { Element.atan2(count, self.p, b.p, dest.p) }
@inlinable public func atan2_(_ b:Self) { atan2(b, self) }
@inlinable public func atan2 (_ b:Element)->Self { return new_call(atan2, b) }
@inlinable public func atan2 (_ b:Element, _ dest:Self) { Element.atan2(count, self.p, b, dest.p) }
@inlinable public func atan2_(_ b:Element) { atan2(b, self) }
@inlinable public func copysign (_ b:Self)->Self { return new_call(copysign, b) }
@inlinable public func copysign (_ b:Self, _ dest:Self) { Element.copysign(count, self.p, b.p, dest.p) }
@inlinable public func copysign_(_ b:Self) { copysign(b, self) }
@inlinable public func copysign (_ b:Element)->Self { return new_call(copysign, b) }
@inlinable public func copysign (_ b:Element, _ dest:Self) { Element.copysign(count, self.p, b, dest.p) }
@inlinable public func copysign_(_ b:Element) { copysign(b, self) }
@inlinable public func fdim (_ b:Self)->Self { return new_call(fdim, b) }
@inlinable public func fdim (_ b:Self, _ dest:Self) { Element.fdim(count, self.p, b.p, dest.p) }
@inlinable public func fdim_(_ b:Self) { fdim(b, self) }
@inlinable public func fdim (_ b:Element)->Self { return new_call(fdim, b) }
@inlinable public func fdim (_ b:Element, _ dest:Self) { Element.fdim(count, self.p, b, dest.p) }
@inlinable public func fdim_(_ b:Element) { fdim(b, self) }
@inlinable public func fmax (_ b:Self)->Self { return new_call(fmax, b) }
@inlinable public func fmax (_ b:Self, _ dest:Self) { Element.fmax(count, self.p, b.p, dest.p) }
@inlinable public func fmax_(_ b:Self) { fmax(b, self) }
@inlinable public func fmax (_ b:Element)->Self { return new_call(fmax, b) }
@inlinable public func fmax (_ b:Element, _ dest:Self) { Element.fmax(count, self.p, b, dest.p) }
@inlinable public func fmax_(_ b:Element) { fmax(b, self) }
@inlinable public func fmin (_ b:Self)->Self { return new_call(fmin, b) }
@inlinable public func fmin (_ b:Self, _ dest:Self) { Element.fmin(count, self.p, b.p, dest.p) }
@inlinable public func fmin_(_ b:Self) { fmin(b, self) }
@inlinable public func fmin (_ b:Element)->Self { return new_call(fmin, b) }
@inlinable public func fmin (_ b:Element, _ dest:Self) { Element.fmin(count, self.p, b, dest.p) }
@inlinable public func fmin_(_ b:Element) { fmin(b, self) }
@inlinable public func hypot (_ b:Self)->Self { return new_call(hypot, b) }
@inlinable public func hypot (_ b:Self, _ dest:Self) { Element.hypot(count, self.p, b.p, dest.p) }
@inlinable public func hypot_(_ b:Self) { hypot(b, self) }
@inlinable public func hypot (_ b:Element)->Self { return new_call(hypot, b) }
@inlinable public func hypot (_ b:Element, _ dest:Self) { Element.hypot(count, self.p, b, dest.p) }
@inlinable public func hypot_(_ b:Element) { hypot(b, self) }
@inlinable public func nextafter (_ b:Self)->Self { return new_call(nextafter, b) }
@inlinable public func nextafter (_ b:Self, _ dest:Self) { Element.nextafter(count, self.p, b.p, dest.p) }
@inlinable public func nextafter_(_ b:Self) { nextafter(b, self) }
@inlinable public func nextafter (_ b:Element)->Self { return new_call(nextafter, b) }
@inlinable public func nextafter (_ b:Element, _ dest:Self) { Element.nextafter(count, self.p, b, dest.p) }
@inlinable public func nextafter_(_ b:Element) { nextafter(b, self) }
@inlinable public func abs ()->Self { return new_call(abs) }
@inlinable public func abs(_ dest:Self) { Element.abs(count, self.p, dest.p) }
@inlinable public func abs_() { abs(self) }
@inlinable public func sqrt ()->Self { return new_call(sqrt) }
@inlinable public func sqrt(_ dest:Self) { Element.sqrt(count, self.p, dest.p) }
@inlinable public func sqrt_() { sqrt(self) }
@inlinable public func acos ()->Self { return new_call(acos) }
@inlinable public func acos(_ dest:Self) { Element.acos(count, self.p, dest.p) }
@inlinable public func acos_() { acos(self) }
@inlinable public func acosh ()->Self { return new_call(acosh) }
@inlinable public func acosh(_ dest:Self) { Element.acosh(count, self.p, dest.p) }
@inlinable public func acosh_() { acosh(self) }
@inlinable public func asin ()->Self { return new_call(asin) }
@inlinable public func asin(_ dest:Self) { Element.asin(count, self.p, dest.p) }
@inlinable public func asin_() { asin(self) }
@inlinable public func asinh ()->Self { return new_call(asinh) }
@inlinable public func asinh(_ dest:Self) { Element.asinh(count, self.p, dest.p) }
@inlinable public func asinh_() { asinh(self) }
@inlinable public func atan ()->Self { return new_call(atan) }
@inlinable public func atan(_ dest:Self) { Element.atan(count, self.p, dest.p) }
@inlinable public func atan_() { atan(self) }
@inlinable public func atanh ()->Self { return new_call(atanh) }
@inlinable public func atanh(_ dest:Self) { Element.atanh(count, self.p, dest.p) }
@inlinable public func atanh_() { atanh(self) }
@inlinable public func cbrt ()->Self { return new_call(cbrt) }
@inlinable public func cbrt(_ dest:Self) { Element.cbrt(count, self.p, dest.p) }
@inlinable public func cbrt_() { cbrt(self) }
@inlinable public func cos ()->Self { return new_call(cos) }
@inlinable public func cos(_ dest:Self) { Element.cos(count, self.p, dest.p) }
@inlinable public func cos_() { cos(self) }
@inlinable public func cosh ()->Self { return new_call(cosh) }
@inlinable public func cosh(_ dest:Self) { Element.cosh(count, self.p, dest.p) }
@inlinable public func cosh_() { cosh(self) }
@inlinable public func erf ()->Self { return new_call(erf) }
@inlinable public func erf(_ dest:Self) { Element.erf(count, self.p, dest.p) }
@inlinable public func erf_() { erf(self) }
@inlinable public func erfc ()->Self { return new_call(erfc) }
@inlinable public func erfc(_ dest:Self) { Element.erfc(count, self.p, dest.p) }
@inlinable public func erfc_() { erfc(self) }
@inlinable public func exp ()->Self { return new_call(exp) }
@inlinable public func exp(_ dest:Self) { Element.exp(count, self.p, dest.p) }
@inlinable public func exp_() { exp(self) }
@inlinable public func exp2 ()->Self { return new_call(exp2) }
@inlinable public func exp2(_ dest:Self) { Element.exp2(count, self.p, dest.p) }
@inlinable public func exp2_() { exp2(self) }
@inlinable public func expm1 ()->Self { return new_call(expm1) }
@inlinable public func expm1(_ dest:Self) { Element.expm1(count, self.p, dest.p) }
@inlinable public func expm1_() { expm1(self) }
@inlinable public func log ()->Self { return new_call(log) }
@inlinable public func log(_ dest:Self) { Element.log(count, self.p, dest.p) }
@inlinable public func log_() { log(self) }
@inlinable public func log10 ()->Self { return new_call(log10) }
@inlinable public func log10(_ dest:Self) { Element.log10(count, self.p, dest.p) }
@inlinable public func log10_() { log10(self) }
@inlinable public func log1p ()->Self { return new_call(log1p) }
@inlinable public func log1p(_ dest:Self) { Element.log1p(count, self.p, dest.p) }
@inlinable public func log1p_() { log1p(self) }
@inlinable public func log2 ()->Self { return new_call(log2) }
@inlinable public func log2(_ dest:Self) { Element.log2(count, self.p, dest.p) }
@inlinable public func log2_() { log2(self) }
@inlinable public func logb ()->Self { return new_call(logb) }
@inlinable public func logb(_ dest:Self) { Element.logb(count, self.p, dest.p) }
@inlinable public func logb_() { logb(self) }
@inlinable public func nearbyint ()->Self { return new_call(nearbyint) }
@inlinable public func nearbyint(_ dest:Self) { Element.nearbyint(count, self.p, dest.p) }
@inlinable public func nearbyint_() { nearbyint(self) }
@inlinable public func rint ()->Self { return new_call(rint) }
@inlinable public func rint(_ dest:Self) { Element.rint(count, self.p, dest.p) }
@inlinable public func rint_() { rint(self) }
@inlinable public func sin ()->Self { return new_call(sin) }
@inlinable public func sin(_ dest:Self) { Element.sin(count, self.p, dest.p) }
@inlinable public func sin_() { sin(self) }
@inlinable public func sinh ()->Self { return new_call(sinh) }
@inlinable public func sinh(_ dest:Self) { Element.sinh(count, self.p, dest.p) }
@inlinable public func sinh_() { sinh(self) }
@inlinable public func tan ()->Self { return new_call(tan) }
@inlinable public func tan(_ dest:Self) { Element.tan(count, self.p, dest.p) }
@inlinable public func tan_() { tan(self) }
@inlinable public func tanh ()->Self { return new_call(tanh) }
@inlinable public func tanh(_ dest:Self) { Element.tanh(count, self.p, dest.p) }
@inlinable public func tanh_() { tanh(self) }
@inlinable public func tgamma ()->Self { return new_call(tgamma) }
@inlinable public func tgamma(_ dest:Self) { Element.tgamma(count, self.p, dest.p) }
@inlinable public func tgamma_() { tgamma(self) }
@inlinable public static func + (lhs:Self, rhs:Self) -> Self { return lhs.add( rhs) }
@inlinable public static func += (lhs:Self, rhs:Self) { lhs.add_(rhs) }
@inlinable public static func + (lhs:Self, rhs:Element) -> Self { return lhs.add( rhs) }
@inlinable public static func += (lhs:Self, rhs:Element) { lhs.add_(rhs) }
@inlinable public static func - (lhs:Self, rhs:Self) -> Self { return lhs.sub( rhs) }
@inlinable public static func -= (lhs:Self, rhs:Self) { lhs.sub_(rhs) }
@inlinable public static func - (lhs:Self, rhs:Element) -> Self { return lhs.sub( rhs) }
@inlinable public static func -= (lhs:Self, rhs:Element) { lhs.sub_(rhs) }
@inlinable public static func * (lhs:Self, rhs:Self) -> Self { return lhs.mul( rhs) }
@inlinable public static func *= (lhs:Self, rhs:Self) { lhs.mul_(rhs) }
@inlinable public static func * (lhs:Self, rhs:Element) -> Self { return lhs.mul( rhs) }
@inlinable public static func *= (lhs:Self, rhs:Element) { lhs.mul_(rhs) }
@inlinable public static func / (lhs:Self, rhs:Self) -> Self { return lhs.div( rhs) }
@inlinable public static func /= (lhs:Self, rhs:Self) { lhs.div_(rhs) }
@inlinable public static func / (lhs:Self, rhs:Element) -> Self { return lhs.div( rhs) }
@inlinable public static func /= (lhs:Self, rhs:Element) { lhs.div_(rhs) }
@inlinable public static func + (lhs:Element, rhs:Self) -> Self { return rhs.add( lhs) }
@inlinable public static func - (lhs:Element, rhs:Self) -> Self { return rhs.subRev( lhs) }
@inlinable public static func * (lhs:Element, rhs:Self) -> Self { return rhs.mul( lhs) }
@inlinable public static func / (lhs:Element, rhs:Self) -> Self { return rhs.divRev( lhs) }
}
================================================
FILE: Sources/BaseMath/FloatVector.swift.gyb
================================================
import Foundation
%{ import sys; sys.path.append('../..'); from mathfuncs import * }%
extension SupportsBasicMath {
% for f in binfs:
@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]) } }
@inlinable public static func ${f}(_ n:Int, _ pSrc:PtrT, _ val:Element, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].${f}(val ) } }
% end
% for f in unaryfs:
@inlinable public static func ${f}(_ n:Int, _ pSrc:PtrT, _ pDst:MutPtrT) { for i in 0..<n { pDst[i] = pSrc[i].${f}() } }
% end
}
public protocol FloatVector: BaseVector where Element:SupportsBasicMath {
func sum(_ f:UnaryF)->Element
func sum(_ f:BinaryF, _ b:Self)->Element
func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element
% for f in binfs:
func ${f}(_ b: Self, _ dest:Self)
func ${f}_(_ b:Self)
% end # f
% for f in unaryfs:
func ${f}(_ dest:Self)
func ${f}_()
% end # f
% for f in unaryfs:
func sum${f}()->Element
% end # f
func sum() -> Element
}
extension FloatVector {
@usableFromInline var storeKey:String { get { return "FloatVector\(Element.self)" } }
@usableFromInline var tempStore:Self { get {
if let r = Thread.current.threadDictionary[storeKey] as? Self {
if (r.count == count) { return r }
}
return Thread.setToTLS(Self(count), storeKey)
}}
@inlinable public func sum(_ f:UnaryF)->Element {
self.map(f, tempStore)
return tempStore.sum()
}
@inlinable public func sum(_ f:BinaryF, _ b:Self)->Element {
self.map(f, b, tempStore)
return tempStore.sum()
}
@inlinable public func sum(_ f:TernaryF, _ b:Self, _ c:Self)->Element {
self.map(f, b, c, tempStore)
return tempStore.sum()
}
@inlinable public func new_call(_ f:(Self) ->() )->Self { let res = new(); f( res); return res }
@inlinable public func new_call(_ f:(Self, Self) ->(), _ b:Self )->Self { let res = new(); f(b, res); return res }
@inlinable public func new_call<T>(_ f:(T, Self) ->(), _ b:T )->Self { let res = new(); f(b, res); return res }
@inlinable public func new_call<T>(_ f:(T, T, Self)->(), _ b:T, _ c:T)->Self { let res = new(); f(b, c, res); return res }
@inlinable public func new_call<T>(_ f:(T, Self)->(), _ b:T, n:Int )->Self { let res = new(n); f(b, res); return res }
@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 }
@inlinable public func sum() -> Element { return Element.sum(p, numericCast(c)) }
% for f in unaryfs:
@inlinable public func sum${f}()->Element { return Element.sum${f}(p, numericCast(c)) }
% end # f
@inlinable public func sumsqr()->Element { return Element.sumsqr(p, numericCast(c)) }
% for f in binfs:
% for t in 'Self','Element':
%{ c = 'b' if t=='Element' else 'b.p' }%
@inlinable public func ${f} (_ b:${t})->Self { return new_call(${f}, b) }
@inlinable public func ${f} (_ b:${t}, _ dest:Self) { Element.${f}(count, self.p, ${c}, dest.p) }
@inlinable public func ${f}_(_ b:${t}) { ${f}(b, self) }
% end
% end # f
% for f in unaryfs:
@inlinable public func ${f} ()->Self { return new_call(${f}) }
@inlinable public func ${f}(_ dest:Self) { Element.${f}(count, self.p, dest.p) }
@inlinable public func ${f}_() { ${f}(self) }
% end # f
% for f,op in zip(op_fs,ops):
% for t in 'Self','Element':
@inlinable public static func ${op} (lhs:Self, rhs:${t}) -> Self { return lhs.${f}( rhs) }
@inlinable public static func ${op}= (lhs:Self, rhs:${t}) { lhs.${f}_(rhs) }
% end
% end # op,f
% for f,op in zip('add subRev mul divRev'.split(),ops):
@inlinable public static func ${op} (lhs:Element, rhs:Self) -> Self { return rhs.${f}( lhs) }
% end # op,f
}
================================================
FILE: Sources/BaseMath/Storage.swift
================================================
import Foundation
extension Array where Element:SignedNumeric {
public init(_ count:Int) { self.init(repeating:0, count:count) }
public func copy() -> Array {
var a = (self as NSCopying).copy(with: nil) as! Array
// HACK: force a copy. Must be a better way...
a[0] = a[0]
return a
}
public var p:UnsafeMutablePointer<Element> {get {return UnsafeMutablePointer(mutating: self)}}
}
extension Array: BaseVector where Element:SignedNumeric { }
extension Array: FloatVector where Element:SupportsBasicMath { }
public protocol ComposedStorage {
associatedtype Storage:MutableCollection,CustomStringConvertible where Storage.Index==Int
typealias Index=Int
var data:Storage {get set}
var endIndex:Int {get}
subscript(i:Int)->Storage.Element {get set}
}
public extension ComposedStorage {
subscript(i:Int)->Storage.Element { get {return data[i]} set {data[i] = newValue} }
var endIndex: Int { return data.count }
}
extension UnsafeMutableBufferPointer {
public init(_ count:Int) {
let sz = MemoryLayout<Element>.stride
let raw = UnsafeMutableRawBufferPointer.allocate(byteCount: sz*count, alignment: 64)
self.init(rebasing: raw.bindMemory(to: Element.self)[0...])
}
public init(_ array:Array<Element>) {
self.init(array.count)
_ = initialize(from:array)
}
public var p:UnsafeMutablePointer<Element> {get {return baseAddress!}}
public func copy()->UnsafeMutableBufferPointer { return .init(Array(self)) }
}
extension UnsafeMutableBufferPointer: BaseVector,ExpressibleByArrayLiteral,Equatable,CustomStringConvertible
where Element:SignedNumeric {
public typealias ArrayLiteralElement=Element
}
extension UnsafeMutableBufferPointer: FloatVector where Element:SupportsBasicMath { }
public final class AlignedStorage<T:SignedNumeric>: BaseVector,ComposedStorage {
public typealias Element=T
public var data:UnsafeMutableBufferPointer<T>
public init(_ data: UnsafeMutableBufferPointer<T>) {self.data=data}
public convenience init(_ count:Int) { self.init(UnsafeMutableBufferPointer(count)) }
public convenience init(_ array:Array<T>) { self.init(UnsafeMutableBufferPointer(array)) }
deinit { UnsafeMutableRawBufferPointer(data).deallocate() }
public var p:MutPtrT {get {return data.p}}
public func copy()->Self { return .init(data.copy()) }
}
extension AlignedStorage:FloatVector where T:SupportsBasicMath {}
================================================
FILE: Sources/BaseMath/Utils.swift
================================================
import Foundation
import CoreFoundation
public func benchmarkTime(f: ()->()) -> Double {
f() // warmup
let start = CFAbsoluteTimeGetCurrent()
for _ in 0..<1 {f()}
return (CFAbsoluteTimeGetCurrent()-start)*1000
}
public func benchmark(title:String, f:()->()) {
let time = benchmarkTime(f:f)
print("\(title): \(time.string(3)) ms")
}
extension Thread {
static func setToTLS<T>(_ value: T, _ key: String)->T {
Thread.current.threadDictionary[key] = value
return value
}
}
================================================
FILE: Sources/CBaseMath/CBaseMath.cpp
================================================
#include "include/CBaseMath.h"
#include <cmath>
using namespace std;
OVERLOADABLE float smSum(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]; }
return r;
}
OVERLOADABLE float smSum_sqr(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }
return r;
}
OVERLOADABLE float smSum_abs(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += abs(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_abs(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = abs(pSrc[i]); }
}
OVERLOADABLE float smSum_sqrt(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += sqrt(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_sqrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = sqrt(pSrc[i]); }
}
OVERLOADABLE float smSum_acos(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += acos(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_acos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = acos(pSrc[i]); }
}
OVERLOADABLE float smSum_acosh(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += acosh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_acosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = acosh(pSrc[i]); }
}
OVERLOADABLE float smSum_asin(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += asin(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_asin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = asin(pSrc[i]); }
}
OVERLOADABLE float smSum_asinh(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += asinh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_asinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = asinh(pSrc[i]); }
}
OVERLOADABLE float smSum_atan(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += atan(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_atan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = atan(pSrc[i]); }
}
OVERLOADABLE float smSum_atanh(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += atanh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_atanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = atanh(pSrc[i]); }
}
OVERLOADABLE float smSum_cbrt(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += cbrt(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_cbrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = cbrt(pSrc[i]); }
}
OVERLOADABLE float smSum_cos(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += cos(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_cos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = cos(pSrc[i]); }
}
OVERLOADABLE float smSum_cosh(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += cosh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_cosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = cosh(pSrc[i]); }
}
OVERLOADABLE float smSum_erf(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += erf(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_erf(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = erf(pSrc[i]); }
}
OVERLOADABLE float smSum_erfc(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += erfc(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_erfc(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = erfc(pSrc[i]); }
}
OVERLOADABLE float smSum_exp(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += exp(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_exp(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = exp(pSrc[i]); }
}
OVERLOADABLE float smSum_exp2(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += exp2(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_exp2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = exp2(pSrc[i]); }
}
OVERLOADABLE float smSum_expm1(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += expm1(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_expm1(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = expm1(pSrc[i]); }
}
OVERLOADABLE float smSum_log(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log(pSrc[i]); }
}
OVERLOADABLE float smSum_log10(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log10(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log10(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log10(pSrc[i]); }
}
OVERLOADABLE float smSum_log1p(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log1p(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log1p(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log1p(pSrc[i]); }
}
OVERLOADABLE float smSum_log2(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log2(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log2(pSrc[i]); }
}
OVERLOADABLE float smSum_logb(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += logb(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_logb(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = logb(pSrc[i]); }
}
OVERLOADABLE float smSum_nearbyint(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += nearbyint(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_nearbyint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = nearbyint(pSrc[i]); }
}
OVERLOADABLE float smSum_rint(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += rint(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_rint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = rint(pSrc[i]); }
}
OVERLOADABLE float smSum_sin(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += sin(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_sin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = sin(pSrc[i]); }
}
OVERLOADABLE float smSum_sinh(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += sinh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_sinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = sinh(pSrc[i]); }
}
OVERLOADABLE float smSum_tan(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += tan(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_tan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = tan(pSrc[i]); }
}
OVERLOADABLE float smSum_tanh(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += tanh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_tanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = tanh(pSrc[i]); }
}
OVERLOADABLE float smSum_tgamma(const float* __restrict__ pSrc, const int len) {
float r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += tgamma(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_tgamma(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = tgamma(pSrc[i]); }
}
OVERLOADABLE double smSum(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]; }
return r;
}
OVERLOADABLE double smSum_sqr(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }
return r;
}
OVERLOADABLE double smSum_abs(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += abs(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_abs(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = abs(pSrc[i]); }
}
OVERLOADABLE double smSum_sqrt(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += sqrt(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_sqrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = sqrt(pSrc[i]); }
}
OVERLOADABLE double smSum_acos(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += acos(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_acos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = acos(pSrc[i]); }
}
OVERLOADABLE double smSum_acosh(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += acosh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_acosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = acosh(pSrc[i]); }
}
OVERLOADABLE double smSum_asin(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += asin(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_asin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = asin(pSrc[i]); }
}
OVERLOADABLE double smSum_asinh(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += asinh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_asinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = asinh(pSrc[i]); }
}
OVERLOADABLE double smSum_atan(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += atan(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_atan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = atan(pSrc[i]); }
}
OVERLOADABLE double smSum_atanh(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += atanh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_atanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = atanh(pSrc[i]); }
}
OVERLOADABLE double smSum_cbrt(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += cbrt(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_cbrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = cbrt(pSrc[i]); }
}
OVERLOADABLE double smSum_cos(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += cos(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_cos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = cos(pSrc[i]); }
}
OVERLOADABLE double smSum_cosh(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += cosh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_cosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = cosh(pSrc[i]); }
}
OVERLOADABLE double smSum_erf(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += erf(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_erf(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = erf(pSrc[i]); }
}
OVERLOADABLE double smSum_erfc(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += erfc(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_erfc(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = erfc(pSrc[i]); }
}
OVERLOADABLE double smSum_exp(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += exp(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_exp(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = exp(pSrc[i]); }
}
OVERLOADABLE double smSum_exp2(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += exp2(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_exp2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = exp2(pSrc[i]); }
}
OVERLOADABLE double smSum_expm1(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += expm1(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_expm1(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = expm1(pSrc[i]); }
}
OVERLOADABLE double smSum_log(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log(pSrc[i]); }
}
OVERLOADABLE double smSum_log10(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log10(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log10(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log10(pSrc[i]); }
}
OVERLOADABLE double smSum_log1p(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log1p(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log1p(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log1p(pSrc[i]); }
}
OVERLOADABLE double smSum_log2(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += log2(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_log2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = log2(pSrc[i]); }
}
OVERLOADABLE double smSum_logb(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += logb(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_logb(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = logb(pSrc[i]); }
}
OVERLOADABLE double smSum_nearbyint(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += nearbyint(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_nearbyint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = nearbyint(pSrc[i]); }
}
OVERLOADABLE double smSum_rint(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += rint(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_rint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = rint(pSrc[i]); }
}
OVERLOADABLE double smSum_sin(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += sin(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_sin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = sin(pSrc[i]); }
}
OVERLOADABLE double smSum_sinh(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += sinh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_sinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = sinh(pSrc[i]); }
}
OVERLOADABLE double smSum_tan(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += tan(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_tan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = tan(pSrc[i]); }
}
OVERLOADABLE double smSum_tanh(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += tanh(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_tanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = tanh(pSrc[i]); }
}
OVERLOADABLE double smSum_tgamma(const double* __restrict__ pSrc, const int len) {
double r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += tgamma(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_tgamma(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = tgamma(pSrc[i]); }
}
================================================
FILE: Sources/CBaseMath/CBaseMath.cpp.gyb
================================================
#include "include/CBaseMath.h"
%{ import sys; sys.path.append('../..'); from mathfuncs import * }%
#include <cmath>
using namespace std;
% for t,s in zip(ctypes,['f','']):
OVERLOADABLE ${t} smSum(const ${t}* __restrict__ pSrc, const int len) {
${t} r = 0;
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]; }
return r;
}
OVERLOADABLE ${t} smSum_sqr(const ${t}* __restrict__ pSrc, const int len) {
${t} r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }
return r;
}
% for f in unaryfs:
OVERLOADABLE ${t} smSum_${f}(const ${t}* __restrict__ pSrc, const int len) {
${t} r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += ${f}(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_${f}(const ${t}* __restrict__ pSrc, ${t}* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = ${f}(pSrc[i]); }
}
% end # f
% end # t
================================================
FILE: Sources/CBaseMath/CDistribution.cpp
================================================
#include "include/CDistribution.h"
#include <random>
#include <cmath>
using namespace std;
struct _inner_mt19937:mt19937 {};
mt19937C mt19937_create() {
mt19937C r = {(_inner_mt19937*) new mt19937(random_device()())};
return r;
}
OVERLOADABLE void destroy(mt19937C v) { delete(v.p); }
struct _inner_knuth_b:knuth_b {};
knuth_bC knuth_b_create() {
knuth_bC r = {(_inner_knuth_b*) new knuth_b(random_device()())};
return r;
}
OVERLOADABLE void destroy(knuth_bC v) { delete(v.p); }
struct _inner_bernoulli_distribution:bernoulli_distribution {};
bernoulli_distributionC bernoulli_distribution_create(double p) {
bernoulli_distributionC r = {(_inner_bernoulli_distribution*) new bernoulli_distribution(p)};
return r;
}
OVERLOADABLE void destroy(bernoulli_distributionC v) { delete(v.p); }
struct _inner_uniform_int_distributionlong:uniform_int_distribution<long> {};
OVERLOADABLE uniform_int_distributionlongC uniform_int_distribution_create(long a,long b, long _) {
uniform_int_distributionlongC r = {(_inner_uniform_int_distributionlong*) new uniform_int_distribution<long>(a,b)};
return r;
}
OVERLOADABLE void destroy(uniform_int_distributionlongC v) { delete(v.p); }
struct _inner_uniform_int_distributionint:uniform_int_distribution<int> {};
OVERLOADABLE uniform_int_distributionintC uniform_int_distribution_create(int a,int b, int _) {
uniform_int_distributionintC r = {(_inner_uniform_int_distributionint*) new uniform_int_distribution<int>(a,b)};
return r;
}
OVERLOADABLE void destroy(uniform_int_distributionintC v) { delete(v.p); }
OVERLOADABLE long call(uniform_int_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE int call(uniform_int_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_binomial_distributionlong:binomial_distribution<long> {};
OVERLOADABLE binomial_distributionlongC binomial_distribution_create(long t, double p, long _) {
binomial_distributionlongC r = {(_inner_binomial_distributionlong*) new binomial_distribution<long>(t,p)};
return r;
}
OVERLOADABLE void destroy(binomial_distributionlongC v) { delete(v.p); }
struct _inner_binomial_distributionint:binomial_distribution<int> {};
OVERLOADABLE binomial_distributionintC binomial_distribution_create(int t, double p, int _) {
binomial_distributionintC r = {(_inner_binomial_distributionint*) new binomial_distribution<int>(t,p)};
return r;
}
OVERLOADABLE void destroy(binomial_distributionintC v) { delete(v.p); }
OVERLOADABLE long call(binomial_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE int call(binomial_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_negative_binomial_distributionlong:negative_binomial_distribution<long> {};
OVERLOADABLE negative_binomial_distributionlongC negative_binomial_distribution_create(long k, double p, long _) {
negative_binomial_distributionlongC r = {(_inner_negative_binomial_distributionlong*) new negative_binomial_distribution<long>(k,p)};
return r;
}
OVERLOADABLE void destroy(negative_binomial_distributionlongC v) { delete(v.p); }
struct _inner_negative_binomial_distributionint:negative_binomial_distribution<int> {};
OVERLOADABLE negative_binomial_distributionintC negative_binomial_distribution_create(int k, double p, int _) {
negative_binomial_distributionintC r = {(_inner_negative_binomial_distributionint*) new negative_binomial_distribution<int>(k,p)};
return r;
}
OVERLOADABLE void destroy(negative_binomial_distributionintC v) { delete(v.p); }
OVERLOADABLE long call(negative_binomial_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE int call(negative_binomial_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_geometric_distributionlong:geometric_distribution<long> {};
OVERLOADABLE geometric_distributionlongC geometric_distribution_create(double p, long _) {
geometric_distributionlongC r = {(_inner_geometric_distributionlong*) new geometric_distribution<long>(p)};
return r;
}
OVERLOADABLE void destroy(geometric_distributionlongC v) { delete(v.p); }
struct _inner_geometric_distributionint:geometric_distribution<int> {};
OVERLOADABLE geometric_distributionintC geometric_distribution_create(double p, int _) {
geometric_distributionintC r = {(_inner_geometric_distributionint*) new geometric_distribution<int>(p)};
return r;
}
OVERLOADABLE void destroy(geometric_distributionintC v) { delete(v.p); }
OVERLOADABLE long call(geometric_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE int call(geometric_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_poisson_distributionlong:poisson_distribution<long> {};
OVERLOADABLE poisson_distributionlongC poisson_distribution_create(double mean, long _) {
poisson_distributionlongC r = {(_inner_poisson_distributionlong*) new poisson_distribution<long>(mean)};
return r;
}
OVERLOADABLE void destroy(poisson_distributionlongC v) { delete(v.p); }
struct _inner_poisson_distributionint:poisson_distribution<int> {};
OVERLOADABLE poisson_distributionintC poisson_distribution_create(double mean, int _) {
poisson_distributionintC r = {(_inner_poisson_distributionint*) new poisson_distribution<int>(mean)};
return r;
}
OVERLOADABLE void destroy(poisson_distributionintC v) { delete(v.p); }
OVERLOADABLE long call(poisson_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE int call(poisson_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_discrete_distributionlong:discrete_distribution<long> {};
OVERLOADABLE discrete_distributionlongC discrete_distribution_create(double* start, double* end, long _) {
discrete_distributionlongC r = {(_inner_discrete_distributionlong*) new discrete_distribution<long>(start,end)};
return r;
}
OVERLOADABLE void destroy(discrete_distributionlongC v) { delete(v.p); }
struct _inner_discrete_distributionint:discrete_distribution<int> {};
OVERLOADABLE discrete_distributionintC discrete_distribution_create(double* start, double* end, int _) {
discrete_distributionintC r = {(_inner_discrete_distributionint*) new discrete_distribution<int>(start,end)};
return r;
}
OVERLOADABLE void destroy(discrete_distributionintC v) { delete(v.p); }
OVERLOADABLE long call(discrete_distributionlongC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE int call(discrete_distributionintC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_uniform_real_distributionfloat:uniform_real_distribution<float> {};
OVERLOADABLE uniform_real_distributionfloatC uniform_real_distribution_create(float a,float b, float _) {
uniform_real_distributionfloatC r = {(_inner_uniform_real_distributionfloat*) new uniform_real_distribution<float>(a,b)};
return r;
}
OVERLOADABLE void destroy(uniform_real_distributionfloatC v) { delete(v.p); }
struct _inner_uniform_real_distributiondouble:uniform_real_distribution<double> {};
OVERLOADABLE uniform_real_distributiondoubleC uniform_real_distribution_create(double a,double b, double _) {
uniform_real_distributiondoubleC r = {(_inner_uniform_real_distributiondouble*) new uniform_real_distribution<double>(a,b)};
return r;
}
OVERLOADABLE void destroy(uniform_real_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(uniform_real_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(uniform_real_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_exponential_distributionfloat:exponential_distribution<float> {};
OVERLOADABLE exponential_distributionfloatC exponential_distribution_create(float l, float _) {
exponential_distributionfloatC r = {(_inner_exponential_distributionfloat*) new exponential_distribution<float>(l)};
return r;
}
OVERLOADABLE void destroy(exponential_distributionfloatC v) { delete(v.p); }
struct _inner_exponential_distributiondouble:exponential_distribution<double> {};
OVERLOADABLE exponential_distributiondoubleC exponential_distribution_create(double l, double _) {
exponential_distributiondoubleC r = {(_inner_exponential_distributiondouble*) new exponential_distribution<double>(l)};
return r;
}
OVERLOADABLE void destroy(exponential_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(exponential_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(exponential_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_gamma_distributionfloat:gamma_distribution<float> {};
OVERLOADABLE gamma_distributionfloatC gamma_distribution_create(float a,float b, float _) {
gamma_distributionfloatC r = {(_inner_gamma_distributionfloat*) new gamma_distribution<float>(a,b)};
return r;
}
OVERLOADABLE void destroy(gamma_distributionfloatC v) { delete(v.p); }
struct _inner_gamma_distributiondouble:gamma_distribution<double> {};
OVERLOADABLE gamma_distributiondoubleC gamma_distribution_create(double a,double b, double _) {
gamma_distributiondoubleC r = {(_inner_gamma_distributiondouble*) new gamma_distribution<double>(a,b)};
return r;
}
OVERLOADABLE void destroy(gamma_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(gamma_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(gamma_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_weibull_distributionfloat:weibull_distribution<float> {};
OVERLOADABLE weibull_distributionfloatC weibull_distribution_create(float a,float b, float _) {
weibull_distributionfloatC r = {(_inner_weibull_distributionfloat*) new weibull_distribution<float>(a,b)};
return r;
}
OVERLOADABLE void destroy(weibull_distributionfloatC v) { delete(v.p); }
struct _inner_weibull_distributiondouble:weibull_distribution<double> {};
OVERLOADABLE weibull_distributiondoubleC weibull_distribution_create(double a,double b, double _) {
weibull_distributiondoubleC r = {(_inner_weibull_distributiondouble*) new weibull_distribution<double>(a,b)};
return r;
}
OVERLOADABLE void destroy(weibull_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(weibull_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(weibull_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_normal_distributionfloat:normal_distribution<float> {};
OVERLOADABLE normal_distributionfloatC normal_distribution_create(float mean,float stddev, float _) {
normal_distributionfloatC r = {(_inner_normal_distributionfloat*) new normal_distribution<float>(mean,stddev)};
return r;
}
OVERLOADABLE void destroy(normal_distributionfloatC v) { delete(v.p); }
struct _inner_normal_distributiondouble:normal_distribution<double> {};
OVERLOADABLE normal_distributiondoubleC normal_distribution_create(double mean,double stddev, double _) {
normal_distributiondoubleC r = {(_inner_normal_distributiondouble*) new normal_distribution<double>(mean,stddev)};
return r;
}
OVERLOADABLE void destroy(normal_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(normal_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(normal_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_lognormal_distributionfloat:lognormal_distribution<float> {};
OVERLOADABLE lognormal_distributionfloatC lognormal_distribution_create(float m,float s, float _) {
lognormal_distributionfloatC r = {(_inner_lognormal_distributionfloat*) new lognormal_distribution<float>(m,s)};
return r;
}
OVERLOADABLE void destroy(lognormal_distributionfloatC v) { delete(v.p); }
struct _inner_lognormal_distributiondouble:lognormal_distribution<double> {};
OVERLOADABLE lognormal_distributiondoubleC lognormal_distribution_create(double m,double s, double _) {
lognormal_distributiondoubleC r = {(_inner_lognormal_distributiondouble*) new lognormal_distribution<double>(m,s)};
return r;
}
OVERLOADABLE void destroy(lognormal_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(lognormal_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(lognormal_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_chi_squared_distributionfloat:chi_squared_distribution<float> {};
OVERLOADABLE chi_squared_distributionfloatC chi_squared_distribution_create(float n, float _) {
chi_squared_distributionfloatC r = {(_inner_chi_squared_distributionfloat*) new chi_squared_distribution<float>(n)};
return r;
}
OVERLOADABLE void destroy(chi_squared_distributionfloatC v) { delete(v.p); }
struct _inner_chi_squared_distributiondouble:chi_squared_distribution<double> {};
OVERLOADABLE chi_squared_distributiondoubleC chi_squared_distribution_create(double n, double _) {
chi_squared_distributiondoubleC r = {(_inner_chi_squared_distributiondouble*) new chi_squared_distribution<double>(n)};
return r;
}
OVERLOADABLE void destroy(chi_squared_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(chi_squared_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(chi_squared_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_cauchy_distributionfloat:cauchy_distribution<float> {};
OVERLOADABLE cauchy_distributionfloatC cauchy_distribution_create(float a,float b, float _) {
cauchy_distributionfloatC r = {(_inner_cauchy_distributionfloat*) new cauchy_distribution<float>(a,b)};
return r;
}
OVERLOADABLE void destroy(cauchy_distributionfloatC v) { delete(v.p); }
struct _inner_cauchy_distributiondouble:cauchy_distribution<double> {};
OVERLOADABLE cauchy_distributiondoubleC cauchy_distribution_create(double a,double b, double _) {
cauchy_distributiondoubleC r = {(_inner_cauchy_distributiondouble*) new cauchy_distribution<double>(a,b)};
return r;
}
OVERLOADABLE void destroy(cauchy_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(cauchy_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(cauchy_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_fisher_f_distributionfloat:fisher_f_distribution<float> {};
OVERLOADABLE fisher_f_distributionfloatC fisher_f_distribution_create(float m,float n, float _) {
fisher_f_distributionfloatC r = {(_inner_fisher_f_distributionfloat*) new fisher_f_distribution<float>(m,n)};
return r;
}
OVERLOADABLE void destroy(fisher_f_distributionfloatC v) { delete(v.p); }
struct _inner_fisher_f_distributiondouble:fisher_f_distribution<double> {};
OVERLOADABLE fisher_f_distributiondoubleC fisher_f_distribution_create(double m,double n, double _) {
fisher_f_distributiondoubleC r = {(_inner_fisher_f_distributiondouble*) new fisher_f_distribution<double>(m,n)};
return r;
}
OVERLOADABLE void destroy(fisher_f_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(fisher_f_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(fisher_f_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_student_t_distributionfloat:student_t_distribution<float> {};
OVERLOADABLE student_t_distributionfloatC student_t_distribution_create(float n, float _) {
student_t_distributionfloatC r = {(_inner_student_t_distributionfloat*) new student_t_distribution<float>(n)};
return r;
}
OVERLOADABLE void destroy(student_t_distributionfloatC v) { delete(v.p); }
struct _inner_student_t_distributiondouble:student_t_distribution<double> {};
OVERLOADABLE student_t_distributiondoubleC student_t_distribution_create(double n, double _) {
student_t_distributiondoubleC r = {(_inner_student_t_distributiondouble*) new student_t_distribution<double>(n)};
return r;
}
OVERLOADABLE void destroy(student_t_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(student_t_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(student_t_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_piecewise_constant_distributionfloat:piecewise_constant_distribution<float> {};
OVERLOADABLE piecewise_constant_distributionfloatC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, float _) {
piecewise_constant_distributionfloatC r = {(_inner_piecewise_constant_distributionfloat*) new piecewise_constant_distribution<float>(start_i,end_i,start_w)};
return r;
}
OVERLOADABLE void destroy(piecewise_constant_distributionfloatC v) { delete(v.p); }
struct _inner_piecewise_constant_distributiondouble:piecewise_constant_distribution<double> {};
OVERLOADABLE piecewise_constant_distributiondoubleC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, double _) {
piecewise_constant_distributiondoubleC r = {(_inner_piecewise_constant_distributiondouble*) new piecewise_constant_distribution<double>(start_i,end_i,start_w)};
return r;
}
OVERLOADABLE void destroy(piecewise_constant_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(piecewise_constant_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(piecewise_constant_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
struct _inner_piecewise_linear_distributionfloat:piecewise_linear_distribution<float> {};
OVERLOADABLE piecewise_linear_distributionfloatC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, float _) {
piecewise_linear_distributionfloatC r = {(_inner_piecewise_linear_distributionfloat*) new piecewise_linear_distribution<float>(start_i,end_i,start_w)};
return r;
}
OVERLOADABLE void destroy(piecewise_linear_distributionfloatC v) { delete(v.p); }
struct _inner_piecewise_linear_distributiondouble:piecewise_linear_distribution<double> {};
OVERLOADABLE piecewise_linear_distributiondoubleC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, double _) {
piecewise_linear_distributiondoubleC r = {(_inner_piecewise_linear_distributiondouble*) new piecewise_linear_distribution<double>(start_i,end_i,start_w)};
return r;
}
OVERLOADABLE void destroy(piecewise_linear_distributiondoubleC v) { delete(v.p); }
OVERLOADABLE float call(piecewise_linear_distributionfloatC p,mt19937C g) {return p.p->operator()(*g.p);}
OVERLOADABLE double call(piecewise_linear_distributiondoubleC p,mt19937C g) {return p.p->operator()(*g.p);}
================================================
FILE: Sources/CBaseMath/CDistribution.cpp.gyb
================================================
%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%
#include "include/CDistribution.h"
#include <random>
#include <cmath>
using namespace std;
% for t in gen_types+dist_types:
${t.cpp_impl()}
% end
================================================
FILE: Sources/CBaseMath/include/CBaseMath.h
================================================
#ifdef __cplusplus
extern "C" {
#endif
#define OVERLOADABLE __attribute__((overloadable))
#include <stdbool.h>
#include "CDistribution.h"
OVERLOADABLE float smSum(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE float smSum_sqr(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE float smSum_abs(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_abs(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_sqrt(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_sqrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_acos(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_acos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_acosh(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_acosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_asin(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_asin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_asinh(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_asinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_atan(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_atan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_atanh(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_atanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_cbrt(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_cbrt(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_cos(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_cos(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_cosh(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_cosh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_erf(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_erf(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_erfc(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_erfc(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_exp(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_exp(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_exp2(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_exp2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_expm1(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_expm1(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_log(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_log10(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log10(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_log1p(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log1p(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_log2(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log2(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_logb(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_logb(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_nearbyint(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_nearbyint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_rint(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_rint(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_sin(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_sin(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_sinh(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_sinh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_tan(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_tan(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_tanh(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_tanh(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE float smSum_tgamma(const float* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_tgamma(const float* __restrict__ pSrc, float* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE double smSum_sqr(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE double smSum_abs(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_abs(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_sqrt(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_sqrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_acos(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_acos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_acosh(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_acosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_asin(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_asin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_asinh(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_asinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_atan(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_atan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_atanh(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_atanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_cbrt(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_cbrt(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_cos(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_cos(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_cosh(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_cosh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_erf(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_erf(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_erfc(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_erfc(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_exp(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_exp(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_exp2(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_exp2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_expm1(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_expm1(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_log(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_log10(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log10(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_log1p(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log1p(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_log2(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_log2(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_logb(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_logb(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_nearbyint(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_nearbyint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_rint(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_rint(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_sin(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_sin(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_sinh(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_sinh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_tan(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_tan(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_tanh(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_tanh(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
OVERLOADABLE double smSum_tgamma(const double* __restrict__ pSrc, const int len) ;
OVERLOADABLE void sm_tgamma(const double* __restrict__ pSrc, double* __restrict__ pDst, const int len) ;
#ifdef __cplusplus
}
#endif
================================================
FILE: Sources/CBaseMath/include/CBaseMath.h.gyb
================================================
%{ import sys; sys.path.append('../../..'); from cpp_template import * }%
#ifdef __cplusplus
extern "C" {
#endif
#define OVERLOADABLE __attribute__((overloadable))
#include <stdbool.h>
#include "CDistribution.h"
${ make_header(__file__) }
#ifdef __cplusplus
}
#endif
================================================
FILE: Sources/CBaseMath/include/CDistribution.h
================================================
#ifdef __cplusplus
extern "C" {
#endif
#define OVERLOADABLE __attribute__((overloadable))
#include <stdbool.h>
typedef struct _inner_uniform_int_distributionlong _inner_uniform_int_distributionlong;
typedef struct uniform_int_distributionlongC uniform_int_distributionlongC;
struct uniform_int_distributionlongC {_inner_uniform_int_distributionlong* p;};
typedef struct _inner_uniform_int_distributionint _inner_uniform_int_distributionint;
typedef struct uniform_int_distributionintC uniform_int_distributionintC;
struct uniform_int_distributionintC {_inner_uniform_int_distributionint* p;};
typedef struct _inner_binomial_distributionlong _inner_binomial_distributionlong;
typedef struct binomial_distributionlongC binomial_distributionlongC;
struct binomial_distributionlongC {_inner_binomial_distributionlong* p;};
typedef struct _inner_binomial_distributionint _inner_binomial_distributionint;
typedef struct binomial_distributionintC binomial_distributionintC;
struct binomial_distributionintC {_inner_binomial_distributionint* p;};
typedef struct _inner_negative_binomial_distributionlong _inner_negative_binomial_distributionlong;
typedef struct negative_binomial_distributionlongC negative_binomial_distributionlongC;
struct negative_binomial_distributionlongC {_inner_negative_binomial_distributionlong* p;};
typedef struct _inner_negative_binomial_distributionint _inner_negative_binomial_distributionint;
typedef struct negative_binomial_distributionintC negative_binomial_distributionintC;
struct negative_binomial_distributionintC {_inner_negative_binomial_distributionint* p;};
typedef struct _inner_geometric_distributionlong _inner_geometric_distributionlong;
typedef struct geometric_distributionlongC geometric_distributionlongC;
struct geometric_distributionlongC {_inner_geometric_distributionlong* p;};
typedef struct _inner_geometric_distributionint _inner_geometric_distributionint;
typedef struct geometric_distributionintC geometric_distributionintC;
struct geometric_distributionintC {_inner_geometric_distributionint* p;};
typedef struct _inner_poisson_distributionlong _inner_poisson_distributionlong;
typedef struct poisson_distributionlongC poisson_distributionlongC;
struct poisson_distributionlongC {_inner_poisson_distributionlong* p;};
typedef struct _inner_poisson_distributionint _inner_poisson_distributionint;
typedef struct poisson_distributionintC poisson_distributionintC;
struct poisson_distributionintC {_inner_poisson_distributionint* p;};
typedef struct _inner_discrete_distributionlong _inner_discrete_distributionlong;
typedef struct discrete_distributionlongC discrete_distributionlongC;
struct discrete_distributionlongC {_inner_discrete_distributionlong* p;};
typedef struct _inner_discrete_distributionint _inner_discrete_distributionint;
typedef struct discrete_distributionintC discrete_distributionintC;
struct discrete_distributionintC {_inner_discrete_distributionint* p;};
typedef struct _inner_uniform_real_distributionfloat _inner_uniform_real_distributionfloat;
typedef struct uniform_real_distributionfloatC uniform_real_distributionfloatC;
struct uniform_real_distributionfloatC {_inner_uniform_real_distributionfloat* p;};
typedef struct _inner_uniform_real_distributiondouble _inner_uniform_real_distributiondouble;
typedef struct uniform_real_distributiondoubleC uniform_real_distributiondoubleC;
struct uniform_real_distributiondoubleC {_inner_uniform_real_distributiondouble* p;};
typedef struct _inner_exponential_distributionfloat _inner_exponential_distributionfloat;
typedef struct exponential_distributionfloatC exponential_distributionfloatC;
struct exponential_distributionfloatC {_inner_exponential_distributionfloat* p;};
typedef struct _inner_exponential_distributiondouble _inner_exponential_distributiondouble;
typedef struct exponential_distributiondoubleC exponential_distributiondoubleC;
struct exponential_distributiondoubleC {_inner_exponential_distributiondouble* p;};
typedef struct _inner_gamma_distributionfloat _inner_gamma_distributionfloat;
typedef struct gamma_distributionfloatC gamma_distributionfloatC;
struct gamma_distributionfloatC {_inner_gamma_distributionfloat* p;};
typedef struct _inner_gamma_distributiondouble _inner_gamma_distributiondouble;
typedef struct gamma_distributiondoubleC gamma_distributiondoubleC;
struct gamma_distributiondoubleC {_inner_gamma_distributiondouble* p;};
typedef struct _inner_weibull_distributionfloat _inner_weibull_distributionfloat;
typedef struct weibull_distributionfloatC weibull_distributionfloatC;
struct weibull_distributionfloatC {_inner_weibull_distributionfloat* p;};
typedef struct _inner_weibull_distributiondouble _inner_weibull_distributiondouble;
typedef struct weibull_distributiondoubleC weibull_distributiondoubleC;
struct weibull_distributiondoubleC {_inner_weibull_distributiondouble* p;};
typedef struct _inner_normal_distributionfloat _inner_normal_distributionfloat;
typedef struct normal_distributionfloatC normal_distributionfloatC;
struct normal_distributionfloatC {_inner_normal_distributionfloat* p;};
typedef struct _inner_normal_distributiondouble _inner_normal_distributiondouble;
typedef struct normal_distributiondoubleC normal_distributiondoubleC;
struct normal_distributiondoubleC {_inner_normal_distributiondouble* p;};
typedef struct _inner_lognormal_distributionfloat _inner_lognormal_distributionfloat;
typedef struct lognormal_distributionfloatC lognormal_distributionfloatC;
struct lognormal_distributionfloatC {_inner_lognormal_distributionfloat* p;};
typedef struct _inner_lognormal_distributiondouble _inner_lognormal_distributiondouble;
typedef struct lognormal_distributiondoubleC lognormal_distributiondoubleC;
struct lognormal_distributiondoubleC {_inner_lognormal_distributiondouble* p;};
typedef struct _inner_chi_squared_distributionfloat _inner_chi_squared_distributionfloat;
typedef struct chi_squared_distributionfloatC chi_squared_distributionfloatC;
struct chi_squared_distributionfloatC {_inner_chi_squared_distributionfloat* p;};
typedef struct _inner_chi_squared_distributiondouble _inner_chi_squared_distributiondouble;
typedef struct chi_squared_distributiondoubleC chi_squared_distributiondoubleC;
struct chi_squared_distributiondoubleC {_inner_chi_squared_distributiondouble* p;};
typedef struct _inner_cauchy_distributionfloat _inner_cauchy_distributionfloat;
typedef struct cauchy_distributionfloatC cauchy_distributionfloatC;
struct cauchy_distributionfloatC {_inner_cauchy_distributionfloat* p;};
typedef struct _inner_cauchy_distributiondouble _inner_cauchy_distributiondouble;
typedef struct cauchy_distributiondoubleC cauchy_distributiondoubleC;
struct cauchy_distributiondoubleC {_inner_cauchy_distributiondouble* p;};
typedef struct _inner_fisher_f_distributionfloat _inner_fisher_f_distributionfloat;
typedef struct fisher_f_distributionfloatC fisher_f_distributionfloatC;
struct fisher_f_distributionfloatC {_inner_fisher_f_distributionfloat* p;};
typedef struct _inner_fisher_f_distributiondouble _inner_fisher_f_distributiondouble;
typedef struct fisher_f_distributiondoubleC fisher_f_distributiondoubleC;
struct fisher_f_distributiondoubleC {_inner_fisher_f_distributiondouble* p;};
typedef struct _inner_student_t_distributionfloat _inner_student_t_distributionfloat;
typedef struct student_t_distributionfloatC student_t_distributionfloatC;
struct student_t_distributionfloatC {_inner_student_t_distributionfloat* p;};
typedef struct _inner_student_t_distributiondouble _inner_student_t_distributiondouble;
typedef struct student_t_distributiondoubleC student_t_distributiondoubleC;
struct student_t_distributiondoubleC {_inner_student_t_distributiondouble* p;};
typedef struct _inner_piecewise_constant_distributionfloat _inner_piecewise_constant_distributionfloat;
typedef struct piecewise_constant_distributionfloatC piecewise_constant_distributionfloatC;
struct piecewise_constant_distributionfloatC {_inner_piecewise_constant_distributionfloat* p;};
typedef struct _inner_piecewise_constant_distributiondouble _inner_piecewise_constant_distributiondouble;
typedef struct piecewise_constant_distributiondoubleC piecewise_constant_distributiondoubleC;
struct piecewise_constant_distributiondoubleC {_inner_piecewise_constant_distributiondouble* p;};
typedef struct _inner_piecewise_linear_distributionfloat _inner_piecewise_linear_distributionfloat;
typedef struct piecewise_linear_distributionfloatC piecewise_linear_distributionfloatC;
struct piecewise_linear_distributionfloatC {_inner_piecewise_linear_distributionfloat* p;};
typedef struct _inner_piecewise_linear_distributiondouble _inner_piecewise_linear_distributiondouble;
typedef struct piecewise_linear_distributiondoubleC piecewise_linear_distributiondoubleC;
struct piecewise_linear_distributiondoubleC {_inner_piecewise_linear_distributiondouble* p;};
typedef struct _inner_mt19937 _inner_mt19937;
typedef struct mt19937C mt19937C;
struct mt19937C {_inner_mt19937* p;};
typedef struct _inner_knuth_b _inner_knuth_b;
typedef struct knuth_bC knuth_bC;
struct knuth_bC {_inner_knuth_b* p;};
typedef struct _inner_bernoulli_distribution _inner_bernoulli_distribution;
typedef struct bernoulli_distributionC bernoulli_distributionC;
struct bernoulli_distributionC {_inner_bernoulli_distribution* p;};
mt19937C mt19937_create() ;
OVERLOADABLE void destroy(mt19937C v) ;
knuth_bC knuth_b_create() ;
OVERLOADABLE void destroy(knuth_bC v) ;
bernoulli_distributionC bernoulli_distribution_create(double p) ;
OVERLOADABLE void destroy(bernoulli_distributionC v) ;
OVERLOADABLE uniform_int_distributionlongC uniform_int_distribution_create(long a,long b, long _) ;
OVERLOADABLE void destroy(uniform_int_distributionlongC v) ;
OVERLOADABLE uniform_int_distributionintC uniform_int_distribution_create(int a,int b, int _) ;
OVERLOADABLE void destroy(uniform_int_distributionintC v) ;
OVERLOADABLE long call(uniform_int_distributionlongC p,mt19937C g) ;
OVERLOADABLE int call(uniform_int_distributionintC p,mt19937C g) ;
OVERLOADABLE binomial_distributionlongC binomial_distribution_create(long t, double p, long _) ;
OVERLOADABLE void destroy(binomial_distributionlongC v) ;
OVERLOADABLE binomial_distributionintC binomial_distribution_create(int t, double p, int _) ;
OVERLOADABLE void destroy(binomial_distributionintC v) ;
OVERLOADABLE long call(binomial_distributionlongC p,mt19937C g) ;
OVERLOADABLE int call(binomial_distributionintC p,mt19937C g) ;
OVERLOADABLE negative_binomial_distributionlongC negative_binomial_distribution_create(long k, double p, long _) ;
OVERLOADABLE void destroy(negative_binomial_distributionlongC v) ;
OVERLOADABLE negative_binomial_distributionintC negative_binomial_distribution_create(int k, double p, int _) ;
OVERLOADABLE void destroy(negative_binomial_distributionintC v) ;
OVERLOADABLE long call(negative_binomial_distributionlongC p,mt19937C g) ;
OVERLOADABLE int call(negative_binomial_distributionintC p,mt19937C g) ;
OVERLOADABLE geometric_distributionlongC geometric_distribution_create(double p, long _) ;
OVERLOADABLE void destroy(geometric_distributionlongC v) ;
OVERLOADABLE geometric_distributionintC geometric_distribution_create(double p, int _) ;
OVERLOADABLE void destroy(geometric_distributionintC v) ;
OVERLOADABLE long call(geometric_distributionlongC p,mt19937C g) ;
OVERLOADABLE int call(geometric_distributionintC p,mt19937C g) ;
OVERLOADABLE poisson_distributionlongC poisson_distribution_create(double mean, long _) ;
OVERLOADABLE void destroy(poisson_distributionlongC v) ;
OVERLOADABLE poisson_distributionintC poisson_distribution_create(double mean, int _) ;
OVERLOADABLE void destroy(poisson_distributionintC v) ;
OVERLOADABLE long call(poisson_distributionlongC p,mt19937C g) ;
OVERLOADABLE int call(poisson_distributionintC p,mt19937C g) ;
OVERLOADABLE discrete_distributionlongC discrete_distribution_create(double* start, double* end, long _) ;
OVERLOADABLE void destroy(discrete_distributionlongC v) ;
OVERLOADABLE discrete_distributionintC discrete_distribution_create(double* start, double* end, int _) ;
OVERLOADABLE void destroy(discrete_distributionintC v) ;
OVERLOADABLE long call(discrete_distributionlongC p,mt19937C g) ;
OVERLOADABLE int call(discrete_distributionintC p,mt19937C g) ;
OVERLOADABLE uniform_real_distributionfloatC uniform_real_distribution_create(float a,float b, float _) ;
OVERLOADABLE void destroy(uniform_real_distributionfloatC v) ;
OVERLOADABLE uniform_real_distributiondoubleC uniform_real_distribution_create(double a,double b, double _) ;
OVERLOADABLE void destroy(uniform_real_distributiondoubleC v) ;
OVERLOADABLE float call(uniform_real_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(uniform_real_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE exponential_distributionfloatC exponential_distribution_create(float l, float _) ;
OVERLOADABLE void destroy(exponential_distributionfloatC v) ;
OVERLOADABLE exponential_distributiondoubleC exponential_distribution_create(double l, double _) ;
OVERLOADABLE void destroy(exponential_distributiondoubleC v) ;
OVERLOADABLE float call(exponential_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(exponential_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE gamma_distributionfloatC gamma_distribution_create(float a,float b, float _) ;
OVERLOADABLE void destroy(gamma_distributionfloatC v) ;
OVERLOADABLE gamma_distributiondoubleC gamma_distribution_create(double a,double b, double _) ;
OVERLOADABLE void destroy(gamma_distributiondoubleC v) ;
OVERLOADABLE float call(gamma_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(gamma_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE weibull_distributionfloatC weibull_distribution_create(float a,float b, float _) ;
OVERLOADABLE void destroy(weibull_distributionfloatC v) ;
OVERLOADABLE weibull_distributiondoubleC weibull_distribution_create(double a,double b, double _) ;
OVERLOADABLE void destroy(weibull_distributiondoubleC v) ;
OVERLOADABLE float call(weibull_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(weibull_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE normal_distributionfloatC normal_distribution_create(float mean,float stddev, float _) ;
OVERLOADABLE void destroy(normal_distributionfloatC v) ;
OVERLOADABLE normal_distributiondoubleC normal_distribution_create(double mean,double stddev, double _) ;
OVERLOADABLE void destroy(normal_distributiondoubleC v) ;
OVERLOADABLE float call(normal_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(normal_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE lognormal_distributionfloatC lognormal_distribution_create(float m,float s, float _) ;
OVERLOADABLE void destroy(lognormal_distributionfloatC v) ;
OVERLOADABLE lognormal_distributiondoubleC lognormal_distribution_create(double m,double s, double _) ;
OVERLOADABLE void destroy(lognormal_distributiondoubleC v) ;
OVERLOADABLE float call(lognormal_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(lognormal_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE chi_squared_distributionfloatC chi_squared_distribution_create(float n, float _) ;
OVERLOADABLE void destroy(chi_squared_distributionfloatC v) ;
OVERLOADABLE chi_squared_distributiondoubleC chi_squared_distribution_create(double n, double _) ;
OVERLOADABLE void destroy(chi_squared_distributiondoubleC v) ;
OVERLOADABLE float call(chi_squared_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(chi_squared_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE cauchy_distributionfloatC cauchy_distribution_create(float a,float b, float _) ;
OVERLOADABLE void destroy(cauchy_distributionfloatC v) ;
OVERLOADABLE cauchy_distributiondoubleC cauchy_distribution_create(double a,double b, double _) ;
OVERLOADABLE void destroy(cauchy_distributiondoubleC v) ;
OVERLOADABLE float call(cauchy_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(cauchy_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE fisher_f_distributionfloatC fisher_f_distribution_create(float m,float n, float _) ;
OVERLOADABLE void destroy(fisher_f_distributionfloatC v) ;
OVERLOADABLE fisher_f_distributiondoubleC fisher_f_distribution_create(double m,double n, double _) ;
OVERLOADABLE void destroy(fisher_f_distributiondoubleC v) ;
OVERLOADABLE float call(fisher_f_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(fisher_f_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE student_t_distributionfloatC student_t_distribution_create(float n, float _) ;
OVERLOADABLE void destroy(student_t_distributionfloatC v) ;
OVERLOADABLE student_t_distributiondoubleC student_t_distribution_create(double n, double _) ;
OVERLOADABLE void destroy(student_t_distributiondoubleC v) ;
OVERLOADABLE float call(student_t_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(student_t_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE piecewise_constant_distributionfloatC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, float _) ;
OVERLOADABLE void destroy(piecewise_constant_distributionfloatC v) ;
OVERLOADABLE piecewise_constant_distributiondoubleC piecewise_constant_distribution_create(double* start_i, double* end_i, double* start_w, double _) ;
OVERLOADABLE void destroy(piecewise_constant_distributiondoubleC v) ;
OVERLOADABLE float call(piecewise_constant_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(piecewise_constant_distributiondoubleC p,mt19937C g) ;
OVERLOADABLE piecewise_linear_distributionfloatC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, float _) ;
OVERLOADABLE void destroy(piecewise_linear_distributionfloatC v) ;
OVERLOADABLE piecewise_linear_distributiondoubleC piecewise_linear_distribution_create(double* start_i, double* end_i, double* start_w, double _) ;
OVERLOADABLE void destroy(piecewise_linear_distributiondoubleC v) ;
OVERLOADABLE float call(piecewise_linear_distributionfloatC p,mt19937C g) ;
OVERLOADABLE double call(piecewise_linear_distributiondoubleC p,mt19937C g) ;
#ifdef __cplusplus
}
#endif
================================================
FILE: Sources/CBaseMath/include/CDistribution.h.gyb
================================================
%{ import sys; sys.path.append('../../..'); from cpp_template import *; from cpp_types import * }%
#ifdef __cplusplus
extern "C" {
#endif
#define OVERLOADABLE __attribute__((overloadable))
#include <stdbool.h>
% for t in all_types:
${t.cpp_decl()}
% end
${ make_header(__file__) }
#ifdef __cplusplus
}
#endif
================================================
FILE: Sources/bench/main.swift
================================================
import Foundation
import CBaseMath
import BaseMath
protocol RealType:BinaryFloatingPoint {}
extension Float: RealType { }
extension Double: RealType { }
/*
func sin_<T:RealType>(_ a:T)->T {
return sin(a)
}
let s = sin_(0.3)
print(s)
*/
protocol IntType:SignedNumeric {
associatedtype BinomialDistributionC:DistributionC
typealias U = BinomialDistributionC.Element
typealias BinomialDistribution=Distribution<BinomialDistributionC>
static func binomial_distribution_create(_ t:Self,_ p:Double)->BinomialDistributionC
}
extension IntType {
public static func binomial_distribution(_ t:Self,_ p:Double)->BinomialDistribution {
return BinomialDistribution(Self.binomial_distribution_create(t,p), mt19937.stored)
}
}
extension Int32: IntType {
public typealias BinomialDistributionC=binomial_distributionintC
public static func binomial_distribution_create(_ t:Int32,_ p:Double)->BinomialDistributionC {
return CBaseMath.binomial_distribution_create(t,p,.init())
}
}
extension Int: IntType {
public typealias BinomialDistributionC=binomial_distributionlongC
public static func binomial_distribution_create(_ t:Int,_ p:Double)->BinomialDistributionC {
return CBaseMath.binomial_distribution_create(t,p,.init())
}
}
func gen_binomial<T:IntType>(_ t:T, _ p:Double)->T.U {
let d = T.binomial_distribution(t,p)
return d[]
}
let r = gen_binomial(3,0.5)
print(r)
let arr = Int.discrete_distribution([40, 10, 10, 40])[10000]
let counts = arr.reduce(into: [:]) { $0[$1, default:0] += 1 }
counts.sorted(by:<).forEach { print("\($0) generated \($1) times") }
let dist01 = Int.uniform_int_distribution(1,6); print(dist01[])
let dist02 = Int32.uniform_int_distribution(10,60); print(dist02[])
let dist03 = Float.uniform_real_distribution(0,1); print(dist03[])
let dist04 = Double.uniform_real_distribution(1,2); print(dist04[])
let dist06 = Int.binomial_distribution(100,0.5); print(dist06[])
let dist07 = Int.negative_binomial_distribution(5,2); print(dist07[])
let dist08 = Int.geometric_distribution(0.5); print(dist08[])
let dist09 = Int.poisson_distribution(5); print(dist09[])
let dist10 = Double.exponential_distribution(3.5); print(dist10[])
let dist11 = Float.gamma_distribution(2,3.5); print(dist11[])
let dist12 = Float.weibull_distribution(2,3.5); print(dist12[])
let dist13 = Float.normal_distribution(1,3.5); print(dist13[])
let dist14 = Double.lognormal_distribution(2,5.5); print(dist14[])
let dist15 = Double.chi_squared_distribution(5.5); print(dist15[])
let dist16 = Double.cauchy_distribution(2.1,3.5); print(dist16[])
let dist17 = Float.fisher_f_distribution(2.1,3.5); print(dist17[])
let dist18 = Float.student_t_distribution(15); print(dist18[])
print("***")
let dist19 = Int.discrete_distribution([1.5,2,6]); print(dist19[])
let dist20 = Float.piecewise_constant_distribution([0,1,10,15], [1,0,1]); print(dist20[])
let dist21 = Float.piecewise_constant_distribution([0,5,10,15], [0,1,1,0]); print(dist21[])
print("***")
let v1 = dist01[20]; print(v1); print(type(of:v1))
let v2 = dist01.gen_aligned(20); print(v2); print(type(of:v2))
let v3 = dist01.gen_pointer(20); print(v3); print(type(of:v3))
print("========")
//public typealias E=Double
public typealias E=Float
public let size = 1000000
public var ar1 = Array<E>(repeating:1, count:size)
ar1[3] = 1.2;ar1[5] = 0.2
public var ar2 = Array<E>(repeating:0, count:size)
public var a1:E=0
benchmark(title:"reduce sum") {a1 = ar1.reduce(0.0, +)}
print(a1)
benchmark(title:"loop sum") { a1 = 0; for i in 0..<size {a1+=ar1[i]} }
print(a1)
benchmark(title:"pointer sum") {
let p1 = ar1.p
a1 = 0; for i in 0..<size {a1+=p1[i]}
}
print(a1)
benchmark(title:"C sum") {a1 = smSum(ar1.p, ar1.c)}
print(a1)
let p = ar1.p
let p2 = ar2.p
let c = Int32(ar1.c)
benchmark(title:"swift add") { for i in 0..<ar1.count {ar2[i]=ar1[i]+2.0} }
print(ar2.sum())
benchmark(title:"swift ptr add") {
let (p1,p2) = (ar1.p,ar2.p)
for i in 0..<ar1.count {p2[i]=p1[i]+2.0}
}
print(ar2.sum())
benchmark(title:"C add") {sm_add_float(ar1.p, 2.0, ar2.p, ar1.c)}
print(ar2.sum())
benchmark(title:"map add") { ar1.map({$0+2.0}, ar2) }
print(ar2.sum())
benchmark(title:"lib") { ar1.add(2.0, ar2) }
print(ar2.sum())
benchmark(title:"swift sin") { for i in 0..<ar1.count {ar2[i]=sin(ar1[i])} }
print(ar2.sum())
benchmark(title:"swift ptr sin") {
let (p1,p2) = (ar1.p,ar2.p)
for i in 0..<ar1.count {p2[i]=sin(p1[i])}
}
print(ar2.sum())
benchmark(title:"C sin") {sm_sin_float(ar1.p, ar2.p, ar1.c)}
print(ar2.sum())
print("func reduce")
@inlinable public func absO(_ a:Float)->Float {return E.sqr(a)}
benchmark(title:"lib sum(sqr)") {a1 = ar1.sum(Float.sqr)}
print(a1)
benchmark(title:"reduce sumsqr") {a1 = ar1.reduce(0.0, {$0+Float.sqr($1)})}
print(a1)
benchmark(title:"c sumsqr") {a1 = smSum_sqr_float(ar1.p, ar1.c)}
print(a1)
benchmark(title:"lib sumsqr") {a1 = ar1.sumsqr()}
print(a1)
================================================
FILE: Tests/BaseMathTests/BaseMathTests.swift
================================================
import XCTest
@testable import BaseMath
protocol TestProtocol {
associatedtype T:FloatVector
typealias E=T.Element
var v1:T {get}
var v2:T {get}
var z:E {get}
}
class BaseMathTestsFloat: XCTestCase,TestProtocol {
typealias T=Array<Float>
let v1:T = [1.0, -2, 3, 0]
let v2:T = [0.5, 12, -2, 1]
let z:E = 0.0
}
class BaseMathTestsDouble: XCTestCase,TestProtocol {
typealias T=Array<Double>
let v1:T = [1.0, -2, 3, 0]
let v2:T = [0.5, 12, -2, 1]
let z:E = 0.0
}
extension TestProtocol {
func testSum() {
let exp = v1.reduce(z, +)
XCTAssertEqual(v1.sum(), exp)
}
func testAbs() {
let exp = T(v1.map {abs($0)})
let r1 = v1.abs()
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.abs(r2)
XCTAssertEqual(r2, exp)
v1.abs_()
XCTAssertEqual(v1, exp)
}
func testAdd() {
let exp = T(zip(v1,v2).map(+))
let r1 = v1.add(v2)
XCTAssertEqual(r1, exp, "add(v2)")
let r2 = v1.copy()
v1.add(v2, r2)
XCTAssertEqual(r2, exp, "add(v2,r2)")
let r3 = v1 + v2
XCTAssertEqual(r3, exp, "+")
let r4 = v1.copy()
r4.add_(v2)
XCTAssertEqual(r4, exp, "add_")
let r5 = v1.copy()
r5 += v2
XCTAssertEqual(r5, exp, "+=")
}
func testDiv() {
let v:E = 2.0
let exp = T(v1.map {$0/v})
let r1 = v1.div(v)
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.div(v, r2)
XCTAssertEqual(r2, exp)
let r3 = v1 / v
XCTAssertEqual(r3, exp)
let r4 = v1.copy()
r4.div_(v)
XCTAssertEqual(r4, exp)
let r5 = v1.copy()
r5 /= v
XCTAssertEqual(r5, exp)
}
func testSubRev() {
let v:E = 2.0
let exp = T(v1.map {v-$0})
let r1 = v1.subRev(v)
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.subRev(v, r2)
XCTAssertEqual(r2, exp)
let r3 = v - v1
XCTAssertEqual(r3, exp)
let r4 = v1.copy()
r4.subRev_(v)
XCTAssertEqual(r4, exp)
}
func testPow() {
let exp = T(zip(v1,v2).map({$0.pow($1)}))
let r1 = v1.pow(v2)
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.pow(v2, r2)
XCTAssertEqual(r2, exp)
v1.pow_(v2)
XCTAssertEqual(v1, exp)
}
func testSumSqr() {
let exp = v1.reduce(z, {$0 + $1*$1})
XCTAssertEqual(v1.sum(E.sqr), exp)
XCTAssertEqual(v1.sumsqr(), exp)
}
}
================================================
FILE: Tests/BaseMathTests/BaseMathTests.swift.gyb
================================================
import XCTest
@testable import BaseMath
protocol TestProtocol {
associatedtype T:FloatVector
typealias E=T.Element
var v1:T {get}
var v2:T {get}
var z:E {get}
}
% for t in ('Float', 'Double'):
class BaseMathTests${t}: XCTestCase,TestProtocol {
typealias T=Array<${t}>
let v1:T = [1.0, -2, 3, 0]
let v2:T = [0.5, 12, -2, 1]
let z:E = 0.0
}
% end
extension TestProtocol {
func testSum() {
let exp = v1.reduce(z, +)
XCTAssertEqual(v1.sum(), exp)
}
func testAbs() {
let exp = T(v1.map {abs($0)})
let r1 = v1.abs()
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.abs(r2)
XCTAssertEqual(r2, exp)
v1.abs_()
XCTAssertEqual(v1, exp)
}
func testAdd() {
let exp = T(zip(v1,v2).map(+))
let r1 = v1.add(v2)
XCTAssertEqual(r1, exp, "add(v2)")
let r2 = v1.copy()
v1.add(v2, r2)
XCTAssertEqual(r2, exp, "add(v2,r2)")
let r3 = v1 + v2
XCTAssertEqual(r3, exp, "+")
let r4 = v1.copy()
r4.add_(v2)
XCTAssertEqual(r4, exp, "add_")
let r5 = v1.copy()
r5 += v2
XCTAssertEqual(r5, exp, "+=")
}
func testDiv() {
let v:E = 2.0
let exp = T(v1.map {$0/v})
let r1 = v1.div(v)
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.div(v, r2)
XCTAssertEqual(r2, exp)
let r3 = v1 / v
XCTAssertEqual(r3, exp)
let r4 = v1.copy()
r4.div_(v)
XCTAssertEqual(r4, exp)
let r5 = v1.copy()
r5 /= v
XCTAssertEqual(r5, exp)
}
func testSubRev() {
let v:E = 2.0
let exp = T(v1.map {v-$0})
let r1 = v1.subRev(v)
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.subRev(v, r2)
XCTAssertEqual(r2, exp)
let r3 = v - v1
XCTAssertEqual(r3, exp)
let r4 = v1.copy()
r4.subRev_(v)
XCTAssertEqual(r4, exp)
}
func testPow() {
let exp = T(zip(v1,v2).map({$0.pow($1)}))
let r1 = v1.pow(v2)
XCTAssertEqual(r1, exp)
let r2 = v1.copy()
v1.pow(v2, r2)
XCTAssertEqual(r2, exp)
v1.pow_(v2)
XCTAssertEqual(v1, exp)
}
func testSumSqr() {
let exp = v1.reduce(z, {$0 + $1*$1})
XCTAssertEqual(v1.sum(E.sqr), exp)
XCTAssertEqual(v1.sumsqr(), exp)
}
}
================================================
FILE: Tests/LinuxMain.swift
================================================
import XCTest
@testable import BaseMathTests
extension BaseMathTestsFloat {
static var allTests : [(String, (BaseMathTestsFloat)->()->())] {
return [
("testSum", testSum),
("testAbs", testAbs),
("testAdd", testAdd),
("testDiv", testDiv),
("testSubRev", testSubRev),
("testPow", testPow),
("testSumSqr", testSumSqr),
]
}
}
extension BaseMathTestsDouble {
static var allTests : [(String, (BaseMathTestsDouble)->()->())] {
return [
("testSum", testSum),
("testAbs", testAbs),
("testAdd", testAdd),
("testDiv", testDiv),
("testSubRev", testSubRev),
("testPow", testPow),
("testSumSqr", testSumSqr),
]
}
}
XCTMain([
testCase(BaseMathTestsFloat.allTests),
testCase(BaseMathTestsDouble.allTests),
])
================================================
FILE: Tests/LinuxMain.swift.gyb
================================================
import XCTest
@testable import BaseMathTests
%{
import re
lines = open('BaseMathTests/BaseMathTests.swift.gyb', 'r').readlines()
tests = [o.strip() for o in lines if re.search('func test', o)]
names = [re.search(r'func (test\w*)\(', o).group(1) for o in tests]
types = ('Float', 'Double')
}%
% for t in types:
extension BaseMathTests${t} {
static var allTests : [(String, (BaseMathTests${t})->()->())] {
return [
% for n in names:
("${n}", ${n}),
% end # n
]
}
}
% end # t
XCTMain([
% for t in types:
testCase(BaseMathTests${t}.allTests),
% end # t
])
================================================
FILE: c2swift.py
================================================
from pdb import set_trace
import re
def lower1(s): return s[:1].lower() + s[1:]
float_swift = ['Float', 'Double']
float_c = ['float', 'double']
int_swift = ['Int', 'Int32']
int_c = ['long', 'int']
float_types = list(zip(float_swift,float_c))
int_types = list(zip(int_swift,int_c))
type_replace = {'double':'Double', 'float':'Float', 'int':'Int32', 'long':'Int',
'void':'Void', '#':'#', '':''}
type_replace_rev = {v:k for k,v in type_replace.items()}
def word(name): return fr'(?P<{name}>[\w#]+)'
param_re = re.compile(fr'(?P<const>const *)?{word("t")} *(?P<ptr>\*?) *{word("name")}(?P<arr> *\[\])?')
def parse_type(s):
m = param_re.search(s)
if not m: raise Exception(f"Failed to parse: {s}")
name = m.group('name')
is_ptr = m.group('ptr') or m.group('arr')
t = m.group('t')
t = type_replace.get(t,t)
if is_ptr:
if t=='Void': t = 'UnsafeRawPointer'
else:
p_type ='UnsafePointer' if m.group('const') else 'UnsafeMutablePointer'
t = f"{p_type}<{t}>"
return (name,t)
def parse_types(s):
if not s: return {}
s = re.split(r',\s*', s)
return dict([parse_type(o) for o in s])
def test_parse() :
in1 = "const long n,const float a[], double r[], const int N, const float *ex, # f"
ex1 = dict([("n","Int"), ("a","UnsafePointer<Float>"), ("r","UnsafeMutablePointer<Double>"), ("N","Int32"),
("ex","UnsafePointer<Float>"), ("f","#")])
res = parse_types(in1)
for r,exp in zip(res.items(),ex1.items()):
assert r == exp, f'{r}\n{exp}'
print("done")
if __name__=='__main__': test_parse()
================================================
FILE: cpp_template.py
================================================
import re,pathlib,os
from pdb import set_trace
from c2swift import *
def make_header(fn):
fn = os.path.basename(fn).split('.')[0]
lines = []
for l in open(f"../{fn}.cpp").readlines():
if '//internal' in l: continue
s = re.search(r'^typedef', l)
if s: lines.append(l)
s = re.search(r'^(\w.*?){', l)
if s and not l.startswith('struct'): lines.append(s.group(1)+';')
return "\n".join(lines)
class cpp:
def __init__(self, typ, p1, p2=None, gens=None, module='MISSING'):
if not gens: gens=['']
self.typ,self.p1,self.p2,self.gens,self.module = typ,p1,p2,gens,module
self.ps = parse_types(p1)
self.pswift = ",".join([f"_ {n}:{t}" for n,t in self.ps.items()])
if self.p2 is None: self.p2 = ",".join(self.ps.keys())
self.funcs = []
self.swift_type = 'CppTypePtr'
def cpp_impl_(self, g):
suf = f'<{g}>' if g else ''
xargs = f', {g} _' if g else ''
over = 'OVERLOADABLE ' if g else ''
t,p1,p2 = self.typ,self.p1,self.p2
return f"""
struct _inner_{t}{g}:{t}{suf} {{}};
{over}{t}{g}C {t}_create({p1}{xargs}) {{
{t}{g}C r = {{(_inner_{t}{g}*) new {t}{suf}({p2})}};
return r;
}}
OVERLOADABLE void destroy({t}{g}C v) {{ delete(v.p); }}
""".replace('#', g)
def cpp_impl(self):
res = [self.cpp_impl_(g) for g in self.gens]
for func in self.funcs: res += self.cpp_func(*func)
return '\n'.join(res)
def cpp_decl_(self,g):
t = self.typ
return f"""
typedef struct _inner_{t}{g} _inner_{t}{g};
typedef struct {t}{g}C {t}{g}C;
struct {t}{g}C {{_inner_{t}{g}* p;}};
"""
@property
def generics(self):
return [(type_replace.get(o,o),o) for o in self.gens]
def cpp_decl(self):
res = [self.cpp_decl_(g) for g in self.gens]
return '\n'.join(res)
def cpp_func_(self,f,a1,a2,g):
over = 'OVERLOADABLE ' if g else ''
return f"{over}{f}({self.typ}{g}C p{a1}) {{return p.p->{a2};}}".replace('#', g)
def cpp_func(self,f,a1,a2=None):
if a1: a1=','+a1
res = [self.cpp_func_(f,a1,a2,g) for g in self.gens]
return res
#o.add_func('# call', 'mt19937C g', 'operator()(*g.p)')
def add_func(self, *func): self.funcs.append(func)
def swift_func_(self,f,a1, a2, g):
ps = parse_types(a1)
p1 = ','.join([f"_ {k}:{v}" for k,v in ps.items()])
p2 = ",".join(ps.keys())
f,ret = list(parse_types(f).items())[0]
if ret=='#': ret=type_replace.get(g,g)
if p2: p2=','+p2
return f"public func {f}({p1})->{ret} {{ return {self.module}.{f}(self{p2}) }}"
#public func call(_ g:mt19937C)->{g} {{ return CBaseMath.call(self, g) }}
def swift_(self, g):
funcs = [self.swift_func_(*func,g) for func in self.funcs]
funcs = '\n'.join(funcs)
return f"""
extension {self.typ}{g}C:{self.swift_type} {{
public func delete() {{destroy(self)}}
{funcs}
}}
"""
def swift(self):
res = [self.swift_(g) for g in self.gens]
return '\n'.join(res)
================================================
FILE: cpp_types.py
================================================
from cpp_template import *
gen_types = [
cpp("mt19937", "", "random_device()()"),
cpp("knuth_b", "", "random_device()()"),
cpp("bernoulli_distribution", "double p"),
]
int_dist = [
cpp("uniform_int_distribution", "# a,# b"),
cpp("binomial_distribution", "# t, double p"),
cpp("negative_binomial_distribution", "# k, double p"),
cpp("geometric_distribution", "double p"),
cpp("poisson_distribution", "double mean"),
cpp("discrete_distribution", "double* start, double* end"),
]
for o in int_dist: o.gens = int_c
real_dist = [
cpp("uniform_real_distribution", "# a,# b"),
cpp("exponential_distribution", "# l"),
cpp("gamma_distribution", "# a,# b"),
cpp("weibull_distribution", "# a,# b"),
cpp("normal_distribution", "# mean,# stddev"),
cpp("lognormal_distribution", "# m,# s"),
cpp("chi_squared_distribution", "# n"),
cpp("cauchy_distribution", "# a,# b"),
cpp("fisher_f_distribution", "# m,# n"),
cpp("student_t_distribution", "# n"),
cpp("piecewise_constant_distribution", "double* start_i, double* end_i, double* start_w"),
cpp("piecewise_linear_distribution", "double* start_i, double* end_i, double* start_w"),
]
for o in real_dist: o.gens = float_c
dist_types = int_dist+real_dist
all_types = dist_types+gen_types
for o in all_types: o.module = 'CBaseMath'
for o in dist_types:
o.swift_type = 'DistributionC'
o.add_func('# call', 'mt19937C g', 'operator()(*g.p)')
================================================
FILE: mathfuncs.py
================================================
funcs1 = ['min', 'max']
# unary functions
funcs2 = """sqrt 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""".split()
# binary functions
funcs3 = "pow atan2 copysign fdim fmax fmin hypot nextafter".split()
types = ['Float','Double']
ctypes = ['float','double']
op_fs = 'add sub mul div'.split()
ops = '+-*/'
unaryfs = ['abs' ]+funcs2
binfs = op_fs+['subRev','divRev']+funcs1+funcs3
gitextract_0zz0z5lm/ ├── .gitignore ├── Makefile ├── Package.swift ├── README.md ├── Sources/ │ ├── BaseMath/ │ │ ├── BaseMath.swift │ │ ├── BaseMath.swift.gyb │ │ ├── BaseRand.swift │ │ ├── BaseRand.swift.gyb │ │ ├── BaseVector.swift │ │ ├── CBaseRand.swift │ │ ├── CBaseRand.swift.gyb │ │ ├── FloatVector.swift │ │ ├── FloatVector.swift.gyb │ │ ├── Storage.swift │ │ └── Utils.swift │ ├── CBaseMath/ │ │ ├── CBaseMath.cpp │ │ ├── CBaseMath.cpp.gyb │ │ ├── CDistribution.cpp │ │ ├── CDistribution.cpp.gyb │ │ └── include/ │ │ ├── CBaseMath.h │ │ ├── CBaseMath.h.gyb │ │ ├── CDistribution.h │ │ └── CDistribution.h.gyb │ └── bench/ │ └── main.swift ├── Tests/ │ ├── BaseMathTests/ │ │ ├── BaseMathTests.swift │ │ └── BaseMathTests.swift.gyb │ ├── LinuxMain.swift │ └── LinuxMain.swift.gyb ├── c2swift.py ├── cpp_template.py ├── cpp_types.py └── mathfuncs.py
SYMBOL INDEX (405 symbols across 5 files)
FILE: Sources/CBaseMath/CBaseMath.cpp
function OVERLOADABLE (line 9) | OVERLOADABLE float smSum(const float* __restrict__ pSrc, const int len) {
function OVERLOADABLE (line 16) | OVERLOADABLE float smSum_sqr(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 24) | OVERLOADABLE float smSum_abs(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 32) | OVERLOADABLE void sm_abs(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 36) | OVERLOADABLE float smSum_sqrt(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 44) | OVERLOADABLE void sm_sqrt(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 48) | OVERLOADABLE float smSum_acos(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 56) | OVERLOADABLE void sm_acos(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 60) | OVERLOADABLE float smSum_acosh(const float* __restrict__ pSrc, const int...
function OVERLOADABLE (line 68) | OVERLOADABLE void sm_acosh(const float* __restrict__ pSrc, float* __rest...
function OVERLOADABLE (line 72) | OVERLOADABLE float smSum_asin(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 80) | OVERLOADABLE void sm_asin(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 84) | OVERLOADABLE float smSum_asinh(const float* __restrict__ pSrc, const int...
function OVERLOADABLE (line 92) | OVERLOADABLE void sm_asinh(const float* __restrict__ pSrc, float* __rest...
function OVERLOADABLE (line 96) | OVERLOADABLE float smSum_atan(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 104) | OVERLOADABLE void sm_atan(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 108) | OVERLOADABLE float smSum_atanh(const float* __restrict__ pSrc, const int...
function OVERLOADABLE (line 116) | OVERLOADABLE void sm_atanh(const float* __restrict__ pSrc, float* __rest...
function OVERLOADABLE (line 120) | OVERLOADABLE float smSum_cbrt(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 128) | OVERLOADABLE void sm_cbrt(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 132) | OVERLOADABLE float smSum_cos(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 140) | OVERLOADABLE void sm_cos(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 144) | OVERLOADABLE float smSum_cosh(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 152) | OVERLOADABLE void sm_cosh(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 156) | OVERLOADABLE float smSum_erf(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 164) | OVERLOADABLE void sm_erf(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 168) | OVERLOADABLE float smSum_erfc(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 176) | OVERLOADABLE void sm_erfc(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 180) | OVERLOADABLE float smSum_exp(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 188) | OVERLOADABLE void sm_exp(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 192) | OVERLOADABLE float smSum_exp2(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 200) | OVERLOADABLE void sm_exp2(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 204) | OVERLOADABLE float smSum_expm1(const float* __restrict__ pSrc, const int...
function OVERLOADABLE (line 212) | OVERLOADABLE void sm_expm1(const float* __restrict__ pSrc, float* __rest...
function OVERLOADABLE (line 216) | OVERLOADABLE float smSum_log(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 224) | OVERLOADABLE void sm_log(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 228) | OVERLOADABLE float smSum_log10(const float* __restrict__ pSrc, const int...
function OVERLOADABLE (line 236) | OVERLOADABLE void sm_log10(const float* __restrict__ pSrc, float* __rest...
function OVERLOADABLE (line 240) | OVERLOADABLE float smSum_log1p(const float* __restrict__ pSrc, const int...
function OVERLOADABLE (line 248) | OVERLOADABLE void sm_log1p(const float* __restrict__ pSrc, float* __rest...
function OVERLOADABLE (line 252) | OVERLOADABLE float smSum_log2(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 260) | OVERLOADABLE void sm_log2(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 264) | OVERLOADABLE float smSum_logb(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 272) | OVERLOADABLE void sm_logb(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 276) | OVERLOADABLE float smSum_nearbyint(const float* __restrict__ pSrc, const...
function OVERLOADABLE (line 284) | OVERLOADABLE void sm_nearbyint(const float* __restrict__ pSrc, float* __...
function OVERLOADABLE (line 288) | OVERLOADABLE float smSum_rint(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 296) | OVERLOADABLE void sm_rint(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 300) | OVERLOADABLE float smSum_sin(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 308) | OVERLOADABLE void sm_sin(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 312) | OVERLOADABLE float smSum_sinh(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 320) | OVERLOADABLE void sm_sinh(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 324) | OVERLOADABLE float smSum_tan(const float* __restrict__ pSrc, const int l...
function OVERLOADABLE (line 332) | OVERLOADABLE void sm_tan(const float* __restrict__ pSrc, float* __restri...
function OVERLOADABLE (line 336) | OVERLOADABLE float smSum_tanh(const float* __restrict__ pSrc, const int ...
function OVERLOADABLE (line 344) | OVERLOADABLE void sm_tanh(const float* __restrict__ pSrc, float* __restr...
function OVERLOADABLE (line 348) | OVERLOADABLE float smSum_tgamma(const float* __restrict__ pSrc, const in...
function OVERLOADABLE (line 356) | OVERLOADABLE void sm_tgamma(const float* __restrict__ pSrc, float* __res...
function OVERLOADABLE (line 362) | OVERLOADABLE double smSum(const double* __restrict__ pSrc, const int len) {
function OVERLOADABLE (line 369) | OVERLOADABLE double smSum_sqr(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 377) | OVERLOADABLE double smSum_abs(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 385) | OVERLOADABLE void sm_abs(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 389) | OVERLOADABLE double smSum_sqrt(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 397) | OVERLOADABLE void sm_sqrt(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 401) | OVERLOADABLE double smSum_acos(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 409) | OVERLOADABLE void sm_acos(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 413) | OVERLOADABLE double smSum_acosh(const double* __restrict__ pSrc, const i...
function OVERLOADABLE (line 421) | OVERLOADABLE void sm_acosh(const double* __restrict__ pSrc, double* __re...
function OVERLOADABLE (line 425) | OVERLOADABLE double smSum_asin(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 433) | OVERLOADABLE void sm_asin(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 437) | OVERLOADABLE double smSum_asinh(const double* __restrict__ pSrc, const i...
function OVERLOADABLE (line 445) | OVERLOADABLE void sm_asinh(const double* __restrict__ pSrc, double* __re...
function OVERLOADABLE (line 449) | OVERLOADABLE double smSum_atan(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 457) | OVERLOADABLE void sm_atan(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 461) | OVERLOADABLE double smSum_atanh(const double* __restrict__ pSrc, const i...
function OVERLOADABLE (line 469) | OVERLOADABLE void sm_atanh(const double* __restrict__ pSrc, double* __re...
function OVERLOADABLE (line 473) | OVERLOADABLE double smSum_cbrt(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 481) | OVERLOADABLE void sm_cbrt(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 485) | OVERLOADABLE double smSum_cos(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 493) | OVERLOADABLE void sm_cos(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 497) | OVERLOADABLE double smSum_cosh(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 505) | OVERLOADABLE void sm_cosh(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 509) | OVERLOADABLE double smSum_erf(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 517) | OVERLOADABLE void sm_erf(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 521) | OVERLOADABLE double smSum_erfc(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 529) | OVERLOADABLE void sm_erfc(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 533) | OVERLOADABLE double smSum_exp(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 541) | OVERLOADABLE void sm_exp(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 545) | OVERLOADABLE double smSum_exp2(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 553) | OVERLOADABLE void sm_exp2(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 557) | OVERLOADABLE double smSum_expm1(const double* __restrict__ pSrc, const i...
function OVERLOADABLE (line 565) | OVERLOADABLE void sm_expm1(const double* __restrict__ pSrc, double* __re...
function OVERLOADABLE (line 569) | OVERLOADABLE double smSum_log(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 577) | OVERLOADABLE void sm_log(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 581) | OVERLOADABLE double smSum_log10(const double* __restrict__ pSrc, const i...
function OVERLOADABLE (line 589) | OVERLOADABLE void sm_log10(const double* __restrict__ pSrc, double* __re...
function OVERLOADABLE (line 593) | OVERLOADABLE double smSum_log1p(const double* __restrict__ pSrc, const i...
function OVERLOADABLE (line 601) | OVERLOADABLE void sm_log1p(const double* __restrict__ pSrc, double* __re...
function OVERLOADABLE (line 605) | OVERLOADABLE double smSum_log2(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 613) | OVERLOADABLE void sm_log2(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 617) | OVERLOADABLE double smSum_logb(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 625) | OVERLOADABLE void sm_logb(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 629) | OVERLOADABLE double smSum_nearbyint(const double* __restrict__ pSrc, con...
function OVERLOADABLE (line 637) | OVERLOADABLE void sm_nearbyint(const double* __restrict__ pSrc, double* ...
function OVERLOADABLE (line 641) | OVERLOADABLE double smSum_rint(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 649) | OVERLOADABLE void sm_rint(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 653) | OVERLOADABLE double smSum_sin(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 661) | OVERLOADABLE void sm_sin(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 665) | OVERLOADABLE double smSum_sinh(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 673) | OVERLOADABLE void sm_sinh(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 677) | OVERLOADABLE double smSum_tan(const double* __restrict__ pSrc, const int...
function OVERLOADABLE (line 685) | OVERLOADABLE void sm_tan(const double* __restrict__ pSrc, double* __rest...
function OVERLOADABLE (line 689) | OVERLOADABLE double smSum_tanh(const double* __restrict__ pSrc, const in...
function OVERLOADABLE (line 697) | OVERLOADABLE void sm_tanh(const double* __restrict__ pSrc, double* __res...
function OVERLOADABLE (line 701) | OVERLOADABLE double smSum_tgamma(const double* __restrict__ pSrc, const ...
function OVERLOADABLE (line 709) | OVERLOADABLE void sm_tgamma(const double* __restrict__ pSrc, double* __r...
FILE: Sources/CBaseMath/CDistribution.cpp
type _inner_mt19937 (line 9) | struct _inner_mt19937:mt19937 {}
function mt19937C (line 10) | mt19937C mt19937_create() {
function OVERLOADABLE (line 14) | OVERLOADABLE void destroy(mt19937C v) { delete(v.p); }
type _inner_knuth_b (line 17) | struct _inner_knuth_b:knuth_b {}
function knuth_bC (line 18) | knuth_bC knuth_b_create() {
function OVERLOADABLE (line 22) | OVERLOADABLE void destroy(knuth_bC v) { delete(v.p); }
type _inner_bernoulli_distribution (line 25) | struct _inner_bernoulli_distribution:bernoulli_distribution {}
function bernoulli_distributionC (line 26) | bernoulli_distributionC bernoulli_distribution_create(double p) {
function OVERLOADABLE (line 30) | OVERLOADABLE void destroy(bernoulli_distributionC v) { delete(v.p); }
type _inner_uniform_int_distributionlong (line 33) | struct _inner_uniform_int_distributionlong:uniform_int_distribution<long...
function OVERLOADABLE (line 34) | OVERLOADABLE uniform_int_distributionlongC uniform_int_distribution_crea...
function OVERLOADABLE (line 38) | OVERLOADABLE void destroy(uniform_int_distributionlongC v) { delete(v.p); }
type _inner_uniform_int_distributionint (line 41) | struct _inner_uniform_int_distributionint:uniform_int_distribution<int> {}
function OVERLOADABLE (line 42) | OVERLOADABLE uniform_int_distributionintC uniform_int_distribution_creat...
function OVERLOADABLE (line 46) | OVERLOADABLE void destroy(uniform_int_distributionintC v) { delete(v.p); }
function call (line 48) | OVERLOADABLE long call(uniform_int_distributionlongC p,mt19937C g) {retu...
function OVERLOADABLE (line 49) | OVERLOADABLE int call(uniform_int_distributionintC p,mt19937C g) {return...
type _inner_binomial_distributionlong (line 51) | struct _inner_binomial_distributionlong:binomial_distribution<long> {}
function OVERLOADABLE (line 52) | OVERLOADABLE binomial_distributionlongC binomial_distribution_create(lon...
function OVERLOADABLE (line 56) | OVERLOADABLE void destroy(binomial_distributionlongC v) { delete(v.p); }
type _inner_binomial_distributionint (line 59) | struct _inner_binomial_distributionint:binomial_distribution<int> {}
function OVERLOADABLE (line 60) | OVERLOADABLE binomial_distributionintC binomial_distribution_create(int ...
function OVERLOADABLE (line 64) | OVERLOADABLE void destroy(binomial_distributionintC v) { delete(v.p); }
function call (line 66) | OVERLOADABLE long call(binomial_distributionlongC p,mt19937C g) {return ...
function OVERLOADABLE (line 67) | OVERLOADABLE int call(binomial_distributionintC p,mt19937C g) {return p....
type _inner_negative_binomial_distributionlong (line 69) | struct _inner_negative_binomial_distributionlong:negative_binomial_distr...
function OVERLOADABLE (line 70) | OVERLOADABLE negative_binomial_distributionlongC negative_binomial_distr...
function OVERLOADABLE (line 74) | OVERLOADABLE void destroy(negative_binomial_distributionlongC v) { delet...
type _inner_negative_binomial_distributionint (line 77) | struct _inner_negative_binomial_distributionint:negative_binomial_distri...
function OVERLOADABLE (line 78) | OVERLOADABLE negative_binomial_distributionintC negative_binomial_distri...
function OVERLOADABLE (line 82) | OVERLOADABLE void destroy(negative_binomial_distributionintC v) { delete...
function call (line 84) | OVERLOADABLE long call(negative_binomial_distributionlongC p,mt19937C g)...
function OVERLOADABLE (line 85) | OVERLOADABLE int call(negative_binomial_distributionintC p,mt19937C g) {...
type _inner_geometric_distributionlong (line 87) | struct _inner_geometric_distributionlong:geometric_distribution<long> {}
function OVERLOADABLE (line 88) | OVERLOADABLE geometric_distributionlongC geometric_distribution_create(d...
function OVERLOADABLE (line 92) | OVERLOADABLE void destroy(geometric_distributionlongC v) { delete(v.p); }
type _inner_geometric_distributionint (line 95) | struct _inner_geometric_distributionint:geometric_distribution<int> {}
function OVERLOADABLE (line 96) | OVERLOADABLE geometric_distributionintC geometric_distribution_create(do...
function OVERLOADABLE (line 100) | OVERLOADABLE void destroy(geometric_distributionintC v) { delete(v.p); }
function call (line 102) | OVERLOADABLE long call(geometric_distributionlongC p,mt19937C g) {return...
function OVERLOADABLE (line 103) | OVERLOADABLE int call(geometric_distributionintC p,mt19937C g) {return p...
type _inner_poisson_distributionlong (line 105) | struct _inner_poisson_distributionlong:poisson_distribution<long> {}
function OVERLOADABLE (line 106) | OVERLOADABLE poisson_distributionlongC poisson_distribution_create(doubl...
function OVERLOADABLE (line 110) | OVERLOADABLE void destroy(poisson_distributionlongC v) { delete(v.p); }
type _inner_poisson_distributionint (line 113) | struct _inner_poisson_distributionint:poisson_distribution<int> {}
function OVERLOADABLE (line 114) | OVERLOADABLE poisson_distributionintC poisson_distribution_create(double...
function OVERLOADABLE (line 118) | OVERLOADABLE void destroy(poisson_distributionintC v) { delete(v.p); }
function call (line 120) | OVERLOADABLE long call(poisson_distributionlongC p,mt19937C g) {return p...
function OVERLOADABLE (line 121) | OVERLOADABLE int call(poisson_distributionintC p,mt19937C g) {return p.p...
type _inner_discrete_distributionlong (line 123) | struct _inner_discrete_distributionlong:discrete_distribution<long> {}
function OVERLOADABLE (line 124) | OVERLOADABLE discrete_distributionlongC discrete_distribution_create(dou...
function OVERLOADABLE (line 128) | OVERLOADABLE void destroy(discrete_distributionlongC v) { delete(v.p); }
type _inner_discrete_distributionint (line 131) | struct _inner_discrete_distributionint:discrete_distribution<int> {}
function OVERLOADABLE (line 132) | OVERLOADABLE discrete_distributionintC discrete_distribution_create(doub...
function OVERLOADABLE (line 136) | OVERLOADABLE void destroy(discrete_distributionintC v) { delete(v.p); }
function call (line 138) | OVERLOADABLE long call(discrete_distributionlongC p,mt19937C g) {return ...
function OVERLOADABLE (line 139) | OVERLOADABLE int call(discrete_distributionintC p,mt19937C g) {return p....
type _inner_uniform_real_distributionfloat (line 141) | struct _inner_uniform_real_distributionfloat:uniform_real_distribution<f...
function OVERLOADABLE (line 142) | OVERLOADABLE uniform_real_distributionfloatC uniform_real_distribution_c...
function OVERLOADABLE (line 146) | OVERLOADABLE void destroy(uniform_real_distributionfloatC v) { delete(v....
type _inner_uniform_real_distributiondouble (line 149) | struct _inner_uniform_real_distributiondouble:uniform_real_distribution<...
function OVERLOADABLE (line 150) | OVERLOADABLE uniform_real_distributiondoubleC uniform_real_distribution_...
function OVERLOADABLE (line 154) | OVERLOADABLE void destroy(uniform_real_distributiondoubleC v) { delete(v...
function OVERLOADABLE (line 156) | OVERLOADABLE float call(uniform_real_distributionfloatC p,mt19937C g) {r...
function OVERLOADABLE (line 157) | OVERLOADABLE double call(uniform_real_distributiondoubleC p,mt19937C g) ...
type _inner_exponential_distributionfloat (line 159) | struct _inner_exponential_distributionfloat:exponential_distribution<flo...
function OVERLOADABLE (line 160) | OVERLOADABLE exponential_distributionfloatC exponential_distribution_cre...
function OVERLOADABLE (line 164) | OVERLOADABLE void destroy(exponential_distributionfloatC v) { delete(v.p...
type _inner_exponential_distributiondouble (line 167) | struct _inner_exponential_distributiondouble:exponential_distribution<do...
function OVERLOADABLE (line 168) | OVERLOADABLE exponential_distributiondoubleC exponential_distribution_cr...
function OVERLOADABLE (line 172) | OVERLOADABLE void destroy(exponential_distributiondoubleC v) { delete(v....
function OVERLOADABLE (line 174) | OVERLOADABLE float call(exponential_distributionfloatC p,mt19937C g) {re...
function OVERLOADABLE (line 175) | OVERLOADABLE double call(exponential_distributiondoubleC p,mt19937C g) {...
type _inner_gamma_distributionfloat (line 177) | struct _inner_gamma_distributionfloat:gamma_distribution<float> {}
function OVERLOADABLE (line 178) | OVERLOADABLE gamma_distributionfloatC gamma_distribution_create(float a,...
function OVERLOADABLE (line 182) | OVERLOADABLE void destroy(gamma_distributionfloatC v) { delete(v.p); }
type _inner_gamma_distributiondouble (line 185) | struct _inner_gamma_distributiondouble:gamma_distribution<double> {}
function OVERLOADABLE (line 186) | OVERLOADABLE gamma_distributiondoubleC gamma_distribution_create(double ...
function OVERLOADABLE (line 190) | OVERLOADABLE void destroy(gamma_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 192) | OVERLOADABLE float call(gamma_distributionfloatC p,mt19937C g) {return p...
function OVERLOADABLE (line 193) | OVERLOADABLE double call(gamma_distributiondoubleC p,mt19937C g) {return...
type _inner_weibull_distributionfloat (line 195) | struct _inner_weibull_distributionfloat:weibull_distribution<float> {}
function OVERLOADABLE (line 196) | OVERLOADABLE weibull_distributionfloatC weibull_distribution_create(floa...
function OVERLOADABLE (line 200) | OVERLOADABLE void destroy(weibull_distributionfloatC v) { delete(v.p); }
type _inner_weibull_distributiondouble (line 203) | struct _inner_weibull_distributiondouble:weibull_distribution<double> {}
function OVERLOADABLE (line 204) | OVERLOADABLE weibull_distributiondoubleC weibull_distribution_create(dou...
function OVERLOADABLE (line 208) | OVERLOADABLE void destroy(weibull_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 210) | OVERLOADABLE float call(weibull_distributionfloatC p,mt19937C g) {return...
function OVERLOADABLE (line 211) | OVERLOADABLE double call(weibull_distributiondoubleC p,mt19937C g) {retu...
type _inner_normal_distributionfloat (line 213) | struct _inner_normal_distributionfloat:normal_distribution<float> {}
function OVERLOADABLE (line 214) | OVERLOADABLE normal_distributionfloatC normal_distribution_create(float ...
function OVERLOADABLE (line 218) | OVERLOADABLE void destroy(normal_distributionfloatC v) { delete(v.p); }
type _inner_normal_distributiondouble (line 221) | struct _inner_normal_distributiondouble:normal_distribution<double> {}
function OVERLOADABLE (line 222) | OVERLOADABLE normal_distributiondoubleC normal_distribution_create(doubl...
function OVERLOADABLE (line 226) | OVERLOADABLE void destroy(normal_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 228) | OVERLOADABLE float call(normal_distributionfloatC p,mt19937C g) {return ...
function OVERLOADABLE (line 229) | OVERLOADABLE double call(normal_distributiondoubleC p,mt19937C g) {retur...
type _inner_lognormal_distributionfloat (line 231) | struct _inner_lognormal_distributionfloat:lognormal_distribution<float> {}
function OVERLOADABLE (line 232) | OVERLOADABLE lognormal_distributionfloatC lognormal_distribution_create(...
function OVERLOADABLE (line 236) | OVERLOADABLE void destroy(lognormal_distributionfloatC v) { delete(v.p); }
type _inner_lognormal_distributiondouble (line 239) | struct _inner_lognormal_distributiondouble:lognormal_distribution<double...
function OVERLOADABLE (line 240) | OVERLOADABLE lognormal_distributiondoubleC lognormal_distribution_create...
function OVERLOADABLE (line 244) | OVERLOADABLE void destroy(lognormal_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 246) | OVERLOADABLE float call(lognormal_distributionfloatC p,mt19937C g) {retu...
function OVERLOADABLE (line 247) | OVERLOADABLE double call(lognormal_distributiondoubleC p,mt19937C g) {re...
type _inner_chi_squared_distributionfloat (line 249) | struct _inner_chi_squared_distributionfloat:chi_squared_distribution<flo...
function OVERLOADABLE (line 250) | OVERLOADABLE chi_squared_distributionfloatC chi_squared_distribution_cre...
function OVERLOADABLE (line 254) | OVERLOADABLE void destroy(chi_squared_distributionfloatC v) { delete(v.p...
type _inner_chi_squared_distributiondouble (line 257) | struct _inner_chi_squared_distributiondouble:chi_squared_distribution<do...
function OVERLOADABLE (line 258) | OVERLOADABLE chi_squared_distributiondoubleC chi_squared_distribution_cr...
function OVERLOADABLE (line 262) | OVERLOADABLE void destroy(chi_squared_distributiondoubleC v) { delete(v....
function OVERLOADABLE (line 264) | OVERLOADABLE float call(chi_squared_distributionfloatC p,mt19937C g) {re...
function OVERLOADABLE (line 265) | OVERLOADABLE double call(chi_squared_distributiondoubleC p,mt19937C g) {...
type _inner_cauchy_distributionfloat (line 267) | struct _inner_cauchy_distributionfloat:cauchy_distribution<float> {}
function OVERLOADABLE (line 268) | OVERLOADABLE cauchy_distributionfloatC cauchy_distribution_create(float ...
function OVERLOADABLE (line 272) | OVERLOADABLE void destroy(cauchy_distributionfloatC v) { delete(v.p); }
type _inner_cauchy_distributiondouble (line 275) | struct _inner_cauchy_distributiondouble:cauchy_distribution<double> {}
function OVERLOADABLE (line 276) | OVERLOADABLE cauchy_distributiondoubleC cauchy_distribution_create(doubl...
function OVERLOADABLE (line 280) | OVERLOADABLE void destroy(cauchy_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 282) | OVERLOADABLE float call(cauchy_distributionfloatC p,mt19937C g) {return ...
function OVERLOADABLE (line 283) | OVERLOADABLE double call(cauchy_distributiondoubleC p,mt19937C g) {retur...
type _inner_fisher_f_distributionfloat (line 285) | struct _inner_fisher_f_distributionfloat:fisher_f_distribution<float> {}
function OVERLOADABLE (line 286) | OVERLOADABLE fisher_f_distributionfloatC fisher_f_distribution_create(fl...
function OVERLOADABLE (line 290) | OVERLOADABLE void destroy(fisher_f_distributionfloatC v) { delete(v.p); }
type _inner_fisher_f_distributiondouble (line 293) | struct _inner_fisher_f_distributiondouble:fisher_f_distribution<double> {}
function OVERLOADABLE (line 294) | OVERLOADABLE fisher_f_distributiondoubleC fisher_f_distribution_create(d...
function OVERLOADABLE (line 298) | OVERLOADABLE void destroy(fisher_f_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 300) | OVERLOADABLE float call(fisher_f_distributionfloatC p,mt19937C g) {retur...
function OVERLOADABLE (line 301) | OVERLOADABLE double call(fisher_f_distributiondoubleC p,mt19937C g) {ret...
type _inner_student_t_distributionfloat (line 303) | struct _inner_student_t_distributionfloat:student_t_distribution<float> {}
function OVERLOADABLE (line 304) | OVERLOADABLE student_t_distributionfloatC student_t_distribution_create(...
function OVERLOADABLE (line 308) | OVERLOADABLE void destroy(student_t_distributionfloatC v) { delete(v.p); }
type _inner_student_t_distributiondouble (line 311) | struct _inner_student_t_distributiondouble:student_t_distribution<double...
function OVERLOADABLE (line 312) | OVERLOADABLE student_t_distributiondoubleC student_t_distribution_create...
function OVERLOADABLE (line 316) | OVERLOADABLE void destroy(student_t_distributiondoubleC v) { delete(v.p); }
function OVERLOADABLE (line 318) | OVERLOADABLE float call(student_t_distributionfloatC p,mt19937C g) {retu...
function OVERLOADABLE (line 319) | OVERLOADABLE double call(student_t_distributiondoubleC p,mt19937C g) {re...
type _inner_piecewise_constant_distributionfloat (line 321) | struct _inner_piecewise_constant_distributionfloat:piecewise_constant_di...
function OVERLOADABLE (line 322) | OVERLOADABLE piecewise_constant_distributionfloatC piecewise_constant_di...
function OVERLOADABLE (line 326) | OVERLOADABLE void destroy(piecewise_constant_distributionfloatC v) { del...
type _inner_piecewise_constant_distributiondouble (line 329) | struct _inner_piecewise_constant_distributiondouble:piecewise_constant_d...
function OVERLOADABLE (line 330) | OVERLOADABLE piecewise_constant_distributiondoubleC piecewise_constant_d...
function OVERLOADABLE (line 334) | OVERLOADABLE void destroy(piecewise_constant_distributiondoubleC v) { de...
function OVERLOADABLE (line 336) | OVERLOADABLE float call(piecewise_constant_distributionfloatC p,mt19937C...
function OVERLOADABLE (line 337) | OVERLOADABLE double call(piecewise_constant_distributiondoubleC p,mt1993...
type _inner_piecewise_linear_distributionfloat (line 339) | struct _inner_piecewise_linear_distributionfloat:piecewise_linear_distri...
function OVERLOADABLE (line 340) | OVERLOADABLE piecewise_linear_distributionfloatC piecewise_linear_distri...
function OVERLOADABLE (line 344) | OVERLOADABLE void destroy(piecewise_linear_distributionfloatC v) { delet...
type _inner_piecewise_linear_distributiondouble (line 347) | struct _inner_piecewise_linear_distributiondouble:piecewise_linear_distr...
function OVERLOADABLE (line 348) | OVERLOADABLE piecewise_linear_distributiondoubleC piecewise_linear_distr...
function OVERLOADABLE (line 352) | OVERLOADABLE void destroy(piecewise_linear_distributiondoubleC v) { dele...
function OVERLOADABLE (line 354) | OVERLOADABLE float call(piecewise_linear_distributionfloatC p,mt19937C g...
function OVERLOADABLE (line 355) | OVERLOADABLE double call(piecewise_linear_distributiondoubleC p,mt19937C...
FILE: Sources/CBaseMath/include/CDistribution.h
type _inner_uniform_int_distributionlong (line 10) | typedef struct _inner_uniform_int_distributionlong _inner_uniform_int_di...
type uniform_int_distributionlongC (line 11) | typedef struct uniform_int_distributionlongC uniform_int_distributionlongC;
type uniform_int_distributionlongC (line 12) | struct uniform_int_distributionlongC {_inner_uniform_int_distributionlon...
type _inner_uniform_int_distributionint (line 15) | typedef struct _inner_uniform_int_distributionint _inner_uniform_int_dis...
type uniform_int_distributionintC (line 16) | typedef struct uniform_int_distributionintC uniform_int_distributionintC;
type uniform_int_distributionintC (line 17) | struct uniform_int_distributionintC {_inner_uniform_int_distributionint*...
type _inner_binomial_distributionlong (line 20) | typedef struct _inner_binomial_distributionlong _inner_binomial_distribu...
type binomial_distributionlongC (line 21) | typedef struct binomial_distributionlongC binomial_distributionlongC;
type binomial_distributionlongC (line 22) | struct binomial_distributionlongC {_inner_binomial_distributionlong* p;}
type _inner_binomial_distributionint (line 25) | typedef struct _inner_binomial_distributionint _inner_binomial_distribut...
type binomial_distributionintC (line 26) | typedef struct binomial_distributionintC binomial_distributionintC;
type binomial_distributionintC (line 27) | struct binomial_distributionintC {_inner_binomial_distributionint* p;}
type _inner_negative_binomial_distributionlong (line 30) | typedef struct _inner_negative_binomial_distributionlong _inner_negative...
type negative_binomial_distributionlongC (line 31) | typedef struct negative_binomial_distributionlongC negative_binomial_dis...
type negative_binomial_distributionlongC (line 32) | struct negative_binomial_distributionlongC {_inner_negative_binomial_dis...
type _inner_negative_binomial_distributionint (line 35) | typedef struct _inner_negative_binomial_distributionint _inner_negative_...
type negative_binomial_distributionintC (line 36) | typedef struct negative_binomial_distributionintC negative_binomial_dist...
type negative_binomial_distributionintC (line 37) | struct negative_binomial_distributionintC {_inner_negative_binomial_dist...
type _inner_geometric_distributionlong (line 40) | typedef struct _inner_geometric_distributionlong _inner_geometric_distri...
type geometric_distributionlongC (line 41) | typedef struct geometric_distributionlongC geometric_distributionlongC;
type geometric_distributionlongC (line 42) | struct geometric_distributionlongC {_inner_geometric_distributionlong* p;}
type _inner_geometric_distributionint (line 45) | typedef struct _inner_geometric_distributionint _inner_geometric_distrib...
type geometric_distributionintC (line 46) | typedef struct geometric_distributionintC geometric_distributionintC;
type geometric_distributionintC (line 47) | struct geometric_distributionintC {_inner_geometric_distributionint* p;}
type _inner_poisson_distributionlong (line 50) | typedef struct _inner_poisson_distributionlong _inner_poisson_distributi...
type poisson_distributionlongC (line 51) | typedef struct poisson_distributionlongC poisson_distributionlongC;
type poisson_distributionlongC (line 52) | struct poisson_distributionlongC {_inner_poisson_distributionlong* p;}
type _inner_poisson_distributionint (line 55) | typedef struct _inner_poisson_distributionint _inner_poisson_distributio...
type poisson_distributionintC (line 56) | typedef struct poisson_distributionintC poisson_distributionintC;
type poisson_distributionintC (line 57) | struct poisson_distributionintC {_inner_poisson_distributionint* p;}
type _inner_discrete_distributionlong (line 60) | typedef struct _inner_discrete_distributionlong _inner_discrete_distribu...
type discrete_distributionlongC (line 61) | typedef struct discrete_distributionlongC discrete_distributionlongC;
type discrete_distributionlongC (line 62) | struct discrete_distributionlongC {_inner_discrete_distributionlong* p;}
type _inner_discrete_distributionint (line 65) | typedef struct _inner_discrete_distributionint _inner_discrete_distribut...
type discrete_distributionintC (line 66) | typedef struct discrete_distributionintC discrete_distributionintC;
type discrete_distributionintC (line 67) | struct discrete_distributionintC {_inner_discrete_distributionint* p;}
type _inner_uniform_real_distributionfloat (line 70) | typedef struct _inner_uniform_real_distributionfloat _inner_uniform_real...
type uniform_real_distributionfloatC (line 71) | typedef struct uniform_real_distributionfloatC uniform_real_distribution...
type uniform_real_distributionfloatC (line 72) | struct uniform_real_distributionfloatC {_inner_uniform_real_distribution...
type _inner_uniform_real_distributiondouble (line 75) | typedef struct _inner_uniform_real_distributiondouble _inner_uniform_rea...
type uniform_real_distributiondoubleC (line 76) | typedef struct uniform_real_distributiondoubleC uniform_real_distributio...
type uniform_real_distributiondoubleC (line 77) | struct uniform_real_distributiondoubleC {_inner_uniform_real_distributio...
type _inner_exponential_distributionfloat (line 80) | typedef struct _inner_exponential_distributionfloat _inner_exponential_d...
type exponential_distributionfloatC (line 81) | typedef struct exponential_distributionfloatC exponential_distributionfl...
type exponential_distributionfloatC (line 82) | struct exponential_distributionfloatC {_inner_exponential_distributionfl...
type _inner_exponential_distributiondouble (line 85) | typedef struct _inner_exponential_distributiondouble _inner_exponential_...
type exponential_distributiondoubleC (line 86) | typedef struct exponential_distributiondoubleC exponential_distributiond...
type exponential_distributiondoubleC (line 87) | struct exponential_distributiondoubleC {_inner_exponential_distributiond...
type _inner_gamma_distributionfloat (line 90) | typedef struct _inner_gamma_distributionfloat _inner_gamma_distributionf...
type gamma_distributionfloatC (line 91) | typedef struct gamma_distributionfloatC gamma_distributionfloatC;
type gamma_distributionfloatC (line 92) | struct gamma_distributionfloatC {_inner_gamma_distributionfloat* p;}
type _inner_gamma_distributiondouble (line 95) | typedef struct _inner_gamma_distributiondouble _inner_gamma_distribution...
type gamma_distributiondoubleC (line 96) | typedef struct gamma_distributiondoubleC gamma_distributiondoubleC;
type gamma_distributiondoubleC (line 97) | struct gamma_distributiondoubleC {_inner_gamma_distributiondouble* p;}
type _inner_weibull_distributionfloat (line 100) | typedef struct _inner_weibull_distributionfloat _inner_weibull_distribut...
type weibull_distributionfloatC (line 101) | typedef struct weibull_distributionfloatC weibull_distributionfloatC;
type weibull_distributionfloatC (line 102) | struct weibull_distributionfloatC {_inner_weibull_distributionfloat* p;}
type _inner_weibull_distributiondouble (line 105) | typedef struct _inner_weibull_distributiondouble _inner_weibull_distribu...
type weibull_distributiondoubleC (line 106) | typedef struct weibull_distributiondoubleC weibull_distributiondoubleC;
type weibull_distributiondoubleC (line 107) | struct weibull_distributiondoubleC {_inner_weibull_distributiondouble* p;}
type _inner_normal_distributionfloat (line 110) | typedef struct _inner_normal_distributionfloat _inner_normal_distributio...
type normal_distributionfloatC (line 111) | typedef struct normal_distributionfloatC normal_distributionfloatC;
type normal_distributionfloatC (line 112) | struct normal_distributionfloatC {_inner_normal_distributionfloat* p;}
type _inner_normal_distributiondouble (line 115) | typedef struct _inner_normal_distributiondouble _inner_normal_distributi...
type normal_distributiondoubleC (line 116) | typedef struct normal_distributiondoubleC normal_distributiondoubleC;
type normal_distributiondoubleC (line 117) | struct normal_distributiondoubleC {_inner_normal_distributiondouble* p;}
type _inner_lognormal_distributionfloat (line 120) | typedef struct _inner_lognormal_distributionfloat _inner_lognormal_distr...
type lognormal_distributionfloatC (line 121) | typedef struct lognormal_distributionfloatC lognormal_distributionfloatC;
type lognormal_distributionfloatC (line 122) | struct lognormal_distributionfloatC {_inner_lognormal_distributionfloat*...
type _inner_lognormal_distributiondouble (line 125) | typedef struct _inner_lognormal_distributiondouble _inner_lognormal_dist...
type lognormal_distributiondoubleC (line 126) | typedef struct lognormal_distributiondoubleC lognormal_distributiondoubleC;
type lognormal_distributiondoubleC (line 127) | struct lognormal_distributiondoubleC {_inner_lognormal_distributiondoubl...
type _inner_chi_squared_distributionfloat (line 130) | typedef struct _inner_chi_squared_distributionfloat _inner_chi_squared_d...
type chi_squared_distributionfloatC (line 131) | typedef struct chi_squared_distributionfloatC chi_squared_distributionfl...
type chi_squared_distributionfloatC (line 132) | struct chi_squared_distributionfloatC {_inner_chi_squared_distributionfl...
type _inner_chi_squared_distributiondouble (line 135) | typedef struct _inner_chi_squared_distributiondouble _inner_chi_squared_...
type chi_squared_distributiondoubleC (line 136) | typedef struct chi_squared_distributiondoubleC chi_squared_distributiond...
type chi_squared_distributiondoubleC (line 137) | struct chi_squared_distributiondoubleC {_inner_chi_squared_distributiond...
type _inner_cauchy_distributionfloat (line 140) | typedef struct _inner_cauchy_distributionfloat _inner_cauchy_distributio...
type cauchy_distributionfloatC (line 141) | typedef struct cauchy_distributionfloatC cauchy_distributionfloatC;
type cauchy_distributionfloatC (line 142) | struct cauchy_distributionfloatC {_inner_cauchy_distributionfloat* p;}
type _inner_cauchy_distributiondouble (line 145) | typedef struct _inner_cauchy_distributiondouble _inner_cauchy_distributi...
type cauchy_distributiondoubleC (line 146) | typedef struct cauchy_distributiondoubleC cauchy_distributiondoubleC;
type cauchy_distributiondoubleC (line 147) | struct cauchy_distributiondoubleC {_inner_cauchy_distributiondouble* p;}
type _inner_fisher_f_distributionfloat (line 150) | typedef struct _inner_fisher_f_distributionfloat _inner_fisher_f_distrib...
type fisher_f_distributionfloatC (line 151) | typedef struct fisher_f_distributionfloatC fisher_f_distributionfloatC;
type fisher_f_distributionfloatC (line 152) | struct fisher_f_distributionfloatC {_inner_fisher_f_distributionfloat* p;}
type _inner_fisher_f_distributiondouble (line 155) | typedef struct _inner_fisher_f_distributiondouble _inner_fisher_f_distri...
type fisher_f_distributiondoubleC (line 156) | typedef struct fisher_f_distributiondoubleC fisher_f_distributiondoubleC;
type fisher_f_distributiondoubleC (line 157) | struct fisher_f_distributiondoubleC {_inner_fisher_f_distributiondouble*...
type _inner_student_t_distributionfloat (line 160) | typedef struct _inner_student_t_distributionfloat _inner_student_t_distr...
type student_t_distributionfloatC (line 161) | typedef struct student_t_distributionfloatC student_t_distributionfloatC;
type student_t_distributionfloatC (line 162) | struct student_t_distributionfloatC {_inner_student_t_distributionfloat*...
type _inner_student_t_distributiondouble (line 165) | typedef struct _inner_student_t_distributiondouble _inner_student_t_dist...
type student_t_distributiondoubleC (line 166) | typedef struct student_t_distributiondoubleC student_t_distributiondoubleC;
type student_t_distributiondoubleC (line 167) | struct student_t_distributiondoubleC {_inner_student_t_distributiondoubl...
type _inner_piecewise_constant_distributionfloat (line 170) | typedef struct _inner_piecewise_constant_distributionfloat _inner_piecew...
type piecewise_constant_distributionfloatC (line 171) | typedef struct piecewise_constant_distributionfloatC piecewise_constant_...
type piecewise_constant_distributionfloatC (line 172) | struct piecewise_constant_distributionfloatC {_inner_piecewise_constant_...
type _inner_piecewise_constant_distributiondouble (line 175) | typedef struct _inner_piecewise_constant_distributiondouble _inner_piece...
type piecewise_constant_distributiondoubleC (line 176) | typedef struct piecewise_constant_distributiondoubleC piecewise_constant...
type piecewise_constant_distributiondoubleC (line 177) | struct piecewise_constant_distributiondoubleC {_inner_piecewise_constant...
type _inner_piecewise_linear_distributionfloat (line 180) | typedef struct _inner_piecewise_linear_distributionfloat _inner_piecewis...
type piecewise_linear_distributionfloatC (line 181) | typedef struct piecewise_linear_distributionfloatC piecewise_linear_dist...
type piecewise_linear_distributionfloatC (line 182) | struct piecewise_linear_distributionfloatC {_inner_piecewise_linear_dist...
type _inner_piecewise_linear_distributiondouble (line 185) | typedef struct _inner_piecewise_linear_distributiondouble _inner_piecewi...
type piecewise_linear_distributiondoubleC (line 186) | typedef struct piecewise_linear_distributiondoubleC piecewise_linear_dis...
type piecewise_linear_distributiondoubleC (line 187) | struct piecewise_linear_distributiondoubleC {_inner_piecewise_linear_dis...
type _inner_mt19937 (line 190) | typedef struct _inner_mt19937 _inner_mt19937;
type mt19937C (line 191) | typedef struct mt19937C mt19937C;
type mt19937C (line 192) | struct mt19937C {_inner_mt19937* p;}
type _inner_knuth_b (line 195) | typedef struct _inner_knuth_b _inner_knuth_b;
type knuth_bC (line 196) | typedef struct knuth_bC knuth_bC;
type knuth_bC (line 197) | struct knuth_bC {_inner_knuth_b* p;}
type _inner_bernoulli_distribution (line 200) | typedef struct _inner_bernoulli_distribution _inner_bernoulli_distribution;
type bernoulli_distributionC (line 201) | typedef struct bernoulli_distributionC bernoulli_distributionC;
type bernoulli_distributionC (line 202) | struct bernoulli_distributionC {_inner_bernoulli_distribution* p;}
FILE: c2swift.py
function lower1 (line 4) | def lower1(s): return s[:1].lower() + s[1:]
function word (line 17) | def word(name): return fr'(?P<{name}>[\w#]+)'
function parse_type (line 20) | def parse_type(s):
function parse_types (line 34) | def parse_types(s):
function test_parse (line 39) | def test_parse() :
FILE: cpp_template.py
function make_header (line 5) | def make_header(fn):
class cpp (line 16) | class cpp:
method __init__ (line 17) | def __init__(self, typ, p1, p2=None, gens=None, module='MISSING'):
method cpp_impl_ (line 26) | def cpp_impl_(self, g):
method cpp_impl (line 40) | def cpp_impl(self):
method cpp_decl_ (line 45) | def cpp_decl_(self,g):
method generics (line 54) | def generics(self):
method cpp_decl (line 57) | def cpp_decl(self):
method cpp_func_ (line 61) | def cpp_func_(self,f,a1,a2,g):
method cpp_func (line 65) | def cpp_func(self,f,a1,a2=None):
method add_func (line 71) | def add_func(self, *func): self.funcs.append(func)
method swift_func_ (line 73) | def swift_func_(self,f,a1, a2, g):
method swift_ (line 83) | def swift_(self, g):
method swift (line 93) | def swift(self):
Condensed preview — 32 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (197K chars).
[
{
"path": ".gitignore",
"chars": 117,
"preview": "*.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",
"chars": 1610,
"preview": "ifeq ($(mode),)\nmode := debug\nendif\n\nlink_args := -Xswiftc -Ounchecked $(addprefix -Xcc ,-O2 -ffast-math -ffp-contract=f"
},
{
"path": "Package.swift",
"chars": 441,
"preview": "// swift-tools-version:4.2\n\nimport PackageDescription\n\nlet package = Package(\n name: \"BaseMath\",\n products: [\n "
},
{
"path": "README.md",
"chars": 2927,
"preview": "# BaseMath\n\nBasic math functions for float and double arrays in Swift for Mac or Linux, with no dependencies, via the `B"
},
{
"path": "Sources/BaseMath/BaseMath.swift",
"chars": 16600,
"preview": "import Foundation\nimport CBaseMath\n\n\nextension BinaryFloatingPoint where Self: CVarArg {\n public func string(_ digits:I"
},
{
"path": "Sources/BaseMath/BaseMath.swift.gyb",
"chars": 2449,
"preview": "import Foundation\nimport CBaseMath\n\n%{ import sys; sys.path.append('../..'); from mathfuncs import * }%\n\nextension Binar"
},
{
"path": "Sources/BaseMath/BaseRand.swift",
"chars": 27117,
"preview": "import Foundation\nimport CBaseMath\n\n\npublic protocol Initable { init() }\nextension Float:Initable {}\nextension Double:In"
},
{
"path": "Sources/BaseMath/BaseRand.swift.gyb",
"chars": 2819,
"preview": "import Foundation\nimport CBaseMath\n\n%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types "
},
{
"path": "Sources/BaseMath/BaseVector.swift",
"chars": 2922,
"preview": "import Foundation\n\npublic protocol Nullary {\n associatedtype Element:SignedNumeric\n subscript()->Element {get}\n}\n\npubl"
},
{
"path": "Sources/BaseMath/CBaseRand.swift",
"chars": 6505,
"preview": "\nimport Foundation\nimport CBaseMath\n\n\nextension uniform_int_distributionlongC:DistributionC {\n public func delete() {de"
},
{
"path": "Sources/BaseMath/CBaseRand.swift.gyb",
"chars": 175,
"preview": "%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%\n\nimport Foundation\nimpor"
},
{
"path": "Sources/BaseMath/FloatVector.swift",
"chars": 30493,
"preview": "import Foundation\n\n\nextension SupportsBasicMath {\n @inlinable public static func add(_ n:Int, _ pSrc:PtrT, _ pSrc2:PtrT"
},
{
"path": "Sources/BaseMath/FloatVector.swift.gyb",
"chars": 3803,
"preview": "import Foundation\n\n%{ import sys; sys.path.append('../..'); from mathfuncs import * }%\n\nextension SupportsBasicMath {\n% "
},
{
"path": "Sources/BaseMath/Storage.swift",
"chars": 2404,
"preview": "import Foundation\n\nextension Array where Element:SignedNumeric {\n public init(_ count:Int) { self.init(repeating:0, cou"
},
{
"path": "Sources/BaseMath/Utils.swift",
"chars": 497,
"preview": "import Foundation\nimport CoreFoundation\n\npublic func benchmarkTime(f: ()->()) -> Double {\n f() // warmup\n let start = "
},
{
"path": "Sources/CBaseMath/CBaseMath.cpp",
"chars": 23157,
"preview": "#include \"include/CBaseMath.h\"\n\n\n#include <cmath>\n\nusing namespace std; \n\n\nOVERLOADABLE float smSum(const float* __restr"
},
{
"path": "Sources/CBaseMath/CBaseMath.cpp.gyb",
"chars": 1017,
"preview": "#include \"include/CBaseMath.h\"\n\n%{ import sys; sys.path.append('../..'); from mathfuncs import * }%\n\n#include <cmath>\n\nu"
},
{
"path": "Sources/CBaseMath/CDistribution.cpp",
"chars": 18548,
"preview": "\n#include \"include/CDistribution.h\"\n#include <random>\n#include <cmath>\n\nusing namespace std; \n\n\nstruct _inner_mt19937:mt"
},
{
"path": "Sources/CBaseMath/CDistribution.cpp.gyb",
"chars": 248,
"preview": "%{ import sys; sys.path.append('../..'); from cpp_template import *; from cpp_types import * }%\n\n#include \"include/CDist"
},
{
"path": "Sources/CBaseMath/include/CBaseMath.h",
"chars": 10695,
"preview": "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OVERLOADABLE __attribute__((overloadable))\n#include <stdbool.h>\n#includ"
},
{
"path": "Sources/CBaseMath/include/CBaseMath.h.gyb",
"chars": 272,
"preview": "%{ import sys; sys.path.append('../../..'); from cpp_template import * }%\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#defi"
},
{
"path": "Sources/CBaseMath/include/CDistribution.h",
"chars": 18099,
"preview": "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OVERLOADABLE __attribute__((overloadable))\n#include <stdbool.h>\n\n\ntyped"
},
{
"path": "Sources/CBaseMath/include/CDistribution.h.gyb",
"chars": 315,
"preview": "%{ import sys; sys.path.append('../../..'); from cpp_template import *; from cpp_types import * }%\n\n#ifdef __cplusplus\ne"
},
{
"path": "Sources/bench/main.swift",
"chars": 4996,
"preview": "import Foundation\nimport CBaseMath\nimport BaseMath\n\nprotocol RealType:BinaryFloatingPoint {}\nextension Float: RealType {"
},
{
"path": "Tests/BaseMathTests/BaseMathTests.swift",
"chars": 2299,
"preview": "import XCTest\n@testable import BaseMath\n\nprotocol TestProtocol {\n associatedtype T:FloatVector\n typealias E=T.Element\n"
},
{
"path": "Tests/BaseMathTests/BaseMathTests.swift.gyb",
"chars": 2175,
"preview": "import XCTest\n@testable import BaseMath\n\nprotocol TestProtocol {\n associatedtype T:FloatVector\n typealias E=T.Element\n"
},
{
"path": "Tests/LinuxMain.swift",
"chars": 809,
"preview": "import XCTest\n@testable import BaseMathTests\n\n\nextension BaseMathTestsFloat {\n static var allTests : [(String, (BaseMat"
},
{
"path": "Tests/LinuxMain.swift.gyb",
"chars": 580,
"preview": "import XCTest\n@testable import BaseMathTests\n\n%{\nimport re\nlines = open('BaseMathTests/BaseMathTests.swift.gyb', 'r').re"
},
{
"path": "c2swift.py",
"chars": 1623,
"preview": "from pdb import set_trace\nimport re\n\ndef lower1(s): return s[:1].lower() + s[1:]\n\nfloat_swift = ['Float', 'Double']\nfloa"
},
{
"path": "cpp_template.py",
"chars": 3111,
"preview": "import re,pathlib,os\nfrom pdb import set_trace\nfrom c2swift import *\n\ndef make_header(fn):\n fn = os.path.basename(fn)"
},
{
"path": "cpp_types.py",
"chars": 1422,
"preview": "from cpp_template import *\n\ngen_types = [\n cpp(\"mt19937\", \"\", \"random_device()()\"),\n cpp(\"knuth_b\", \"\", \"random_device"
},
{
"path": "mathfuncs.py",
"chars": 475,
"preview": "funcs1 = ['min', 'max']\n# unary functions\nfuncs2 = \"\"\"sqrt acos acosh asin asinh atan atanh cbrt cos cosh erf erfc exp e"
}
]
About this extraction
This page contains the full source code of the jph00/BaseMath GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 32 files (186.2 KB), approximately 56.1k tokens, and a symbol index with 405 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.