All Projects → xwu → Numericannex

xwu / Numericannex

Licence: mit
Numeric facilities for Swift

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Numericannex

Mlcourse.ai
Open Machine Learning Course
Stars: ✭ 7,963 (+12539.68%)
Mutual labels:  math
Phobos
The standard library of the D programming language
Stars: ✭ 1,038 (+1547.62%)
Mutual labels:  math
Roadmap
Stars: ✭ 57 (-9.52%)
Mutual labels:  math
Blog
About math, programming and procedural generation
Stars: ✭ 37 (-41.27%)
Mutual labels:  math
Jglm
Java OpenGL Mathematics Library
Stars: ✭ 44 (-30.16%)
Mutual labels:  math
Swift Numerics
Numerical APIs for Swift
Stars: ✭ 1,052 (+1569.84%)
Mutual labels:  math
Swiftmath
Cross-platform math library with SIMD support
Stars: ✭ 30 (-52.38%)
Mutual labels:  math
String Calc
PHP calculator library for mathematical terms (expressions) passed as strings
Stars: ✭ 60 (-4.76%)
Mutual labels:  math
Rich Text Editor
Math editor (http://digabi.github.io/rich-text-editor/)
Stars: ✭ 45 (-28.57%)
Mutual labels:  math
Vue Mathlive
Example of using the Vue wrapper for MathLive math editor
Stars: ✭ 52 (-17.46%)
Mutual labels:  math
Math books
📚 Математичный список полезных книг
Stars: ✭ 38 (-39.68%)
Mutual labels:  math
Prosemirror Math
Schema and plugins for "first-class" math support in ProseMirror!
Stars: ✭ 43 (-31.75%)
Mutual labels:  math
Sympy
A computer algebra system written in pure Python
Stars: ✭ 8,688 (+13690.48%)
Mutual labels:  math
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-42.86%)
Mutual labels:  math
Unity3d Curves
2D curves in polar and Cartesian coordinates, 3D curves, surfaces and fractals for the Unity3D game engine.
Stars: ✭ 59 (-6.35%)
Mutual labels:  math
Formulador
Render math formulas in 2D in your terminal!
Stars: ✭ 33 (-47.62%)
Mutual labels:  math
Sophus
C++ implementation of Lie Groups using Eigen.
Stars: ✭ 1,048 (+1563.49%)
Mutual labels:  math
Euler
Swift Custom Operators for Mathematical Notation
Stars: ✭ 1,123 (+1682.54%)
Mutual labels:  math
Yawysiwygee
Yet another what-you-see-is-what-you-get equation editor
Stars: ✭ 60 (-4.76%)
Mutual labels:  math
Sobol.jl
generation of Sobol low-discrepancy sequence (LDS) for the Julia language
Stars: ✭ 51 (-19.05%)
Mutual labels:  math

NumericAnnex
NumericAnnex

NumericAnnex supplements the numeric facilities provided in the Swift standard library.

Build Status codecov

Features

  • The exponentiation operator ** and the compound assignment operator **=.
  • Extension methods for BinaryInteger exponentiation, square root, cube root, greatest common divisor, and least common multiple.
  • Math, a protocol for signed numeric types that support elementary functions.
  • Real, a protocol for floating-point types that support elementary functions and a selection of special functions.
  • PRNG, a protocol for pseudo-random number generators.
  • Rational, a value type to represent rational values which supports division by zero.
  • Complex, a value type to represent complex values in Cartesian form.
  • Random and Random.Xoroshiro, two reference types implementing efficient pseudo-random number generators.

Note: This project is in the early stages of development and is not production-ready at this time.

Requirements

NumericAnnex requires Swift 4.1 (swift-4.1-branch) or Swift 4.2 (master). On Apple platforms, it also requires the Security framework for cryptographically secure random bytes.

Installation

After NumericAnnex has been cloned or downloaded locally, build the library using the command swift build (macOS) or swift build -Xcc -D_GNU_SOURCE (Linux). Run tests with the command swift test (macOS) or swift test -Xcc -D_GNU_SOURCE (Linux). An Xcode project can be generated with the command swift package generate-xcodeproj.

To add the package as a dependency using CocoaPods, insert the following line in your Podfile:

pod 'NumericAnnex', '~> 0.1.19'

Swift Package Manager can also be used to add the package as a dependency. See Swift documentation for details.

Basic Usage

import NumericAnnex

print(2 ** 3)
// Prints "8".

print(4.0 ** 5.0)
// Prints "1024.0".

print(Int.cbrt(8))
// Prints "2".

print(Double.cbrt(27.0))
// Prints "3.0".

var x: Ratio = 1 / 4
// Ratio is a type alias for Rational<Int>.

print(x.reciprocal())
// Prints "4".

x *= 8
print(x + x)
// Prints "4".

x = Ratio(Float.phi) // Golden ratio.
print(x)
// Prints "13573053/8388608".

var z: Complex64 = 42 * .i
// Complex64 is a type alias for Complex<Float>.

print(Complex.sqrt(z))
// Prints "4.58258 + 4.58258i".

z = .pi + .i * .log(2 - .sqrt(3))
print(Complex.cos(z).real)
// Prints "-2.0".

Documentation

All public protocols, types, and functions have been carefully documented in the code. See the formatted reference for details.

The project adheres to many design patterns found in the Swift standard library. For example, Math types provide methods such as cubeRoot() and tangent() just as FloatingPoint types provide methods such as squareRoot().

No free functions are declared in this library unless they overload existing ones in the Swift standard library. Instead, functions such as cbrt(_:) and tan(_:) are provided as static members. This avoids collisions with C standard library functions that you may wish to use. It also promotes clarity at the call site when the result of a complex operation differs from that of its real counterpart (e.g., Complex128.cbrt(-8) != -2).

Future Directions

  • Add more tests, including performance tests
  • Design and implement additional methods on PRNG

License

All original work is released under the MIT license. See LICENSE for details.

Portions of the complex square root and elementary transcendental functions use checks for special values adapted from libc++. Code in libc++ is dual-licensed under the MIT and UIUC/NCSA licenses.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].