attaswift / bigint Goto Github PK
View Code? Open in Web Editor NEWArbitrary-precision arithmetic in pure Swift
License: MIT License
Arbitrary-precision arithmetic in pure Swift
License: MIT License
BigInt
should be able to serialize itself into a two's complement binary representation, no?
There are some changes in Swift 4.1 that result in a breaking change for BigInt, it seems.
Compile Swift Module 'BigInt' (22 sources)
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'BidirectionalCollection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:16:17: note: candidate has non-matching type '<Self> (before: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(before i: Self.Index) -> Self.Index
^
Swift.BidirectionalCollection:36:17: note: protocol requires function 'index(before:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(before i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'Collection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:10:17: note: candidate has non-matching type '<Self> (after: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, Iterator = IndexingIterator<BigUInt.Words>, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(after i: Self.Index) -> Self.Index
^
Swift.Collection:589:17: note: protocol requires function 'index(after:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(after i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'BidirectionalCollection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:16:17: note: candidate has non-matching type '<Self> (before: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(before i: Self.Index) -> Self.Index
^
Swift.BidirectionalCollection:36:17: note: protocol requires function 'index(before:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(before i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'Collection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:10:17: note: candidate has non-matching type '<Self> (after: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, Iterator = IndexingIterator<BigUInt.Words>, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(after i: Self.Index) -> Self.Index
^
Swift.Collection:589:17: note: protocol requires function 'index(after:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(after i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'BidirectionalCollection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:16:17: note: candidate has non-matching type '<Self> (before: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(before i: Self.Index) -> Self.Index
^
Swift.BidirectionalCollection:36:17: note: protocol requires function 'index(before:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(before i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'Collection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:10:17: note: candidate has non-matching type '<Self> (after: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, Iterator = IndexingIterator<BigUInt.Words>, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(after i: Self.Index) -> Self.Index
^
Swift.Collection:589:17: note: protocol requires function 'index(after:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(after i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'BidirectionalCollection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:16:17: note: candidate has non-matching type '<Self> (before: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(before i: Self.Index) -> Self.Index
^
Swift.BidirectionalCollection:36:17: note: protocol requires function 'index(before:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(before i: Self.Index) -> Self.Index
^
/Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039/sources/Words and Bits.swift:90:19: error: type 'BigUInt.Words' does not conform to protocol 'Collection'
public struct Words: RandomAccessCollection {
^
Swift.RandomAccessCollection:10:17: note: candidate has non-matching type '<Self> (after: Self.Index) -> Self.Index' [with Element = BigUInt.Words.Element, Index = BigUInt.Words.Index, Iterator = IndexingIterator<BigUInt.Words>, SubSequence = BigUInt.Words.SubSequence, Indices = BigUInt.Words.Indices]
public func index(after i: Self.Index) -> Self.Index
^
Swift.Collection:589:17: note: protocol requires function 'index(after:)' with type '(BigUInt.Words.Index) -> BigUInt.Words.Index' (aka '(Int) -> Int'); do you want to add a stub?
public func index(after i: Self.Index) -> Self.Index
^
I know that it's a bit early now, but being able to compile with Xcode 9 (and Swift 3.2) would be really cool (since code completion and the editor in general is SO much nicer in the new Xcode).
Please do pod trunk push
:)
I have an admittedly niche scenario, where some parts of my project pull in BigInt
via Carthage, but others use CocoaPods.
Carthage picks up DYLIB_COMPATIBILITY_VERSION
set in BigInt.xcodeproj
with BUILD_NUMBER
from your xcconfig, but CocoaPods doesn't use the xcodeproj in your repo. So the mismatched DYLIB_COMPATIBILITY_VERSION
values in the various load commands causes a runtime crash in one of my apps.
There are some options for making the build outputs of both package managers more similar:
spec.pod_target_xcconfig = { "DYLIB_COMPATIBILITY_VERSION" => "<build-number>"}
You'd probably want to automate injecting the xcconfig's value into that; less ideally, you'd need to manually update it in both places each release.
DYLIB_COMPATIBILITY_VERSION
at all in your xcodeproj, so that you get the same build output from Carthage that you get from CocoaPods today, with a value of 1
.I'm currently working around this issue with a post_install
hook that sets the same value, hardcoded to the value I look up in your releases.
π I'm totally fine with this issue being closed as #wontfix because this really comes down to the difference in how the package managers work, not just your library. Anyways, thank you for your time and for your code!
After upgrading from 2.1.2 to 3.0.0 (and upgrading from Xcode 8.3.3 to 9.0), I am getting the error "Value of type 'BigUInt' has no member 'reduce'".
I see that 'reduce' is still mentioned in the example in project readme, but has it been removed from the library?
#it ain't working. I can't import BigInt. no such module, xcode 7.3.1
Hello, first of all, thank you for amazing work on the library!
Is it possible to push changes to cocoapods repo? We'd like to update our dependencies with Swift 5
version.
Thank you
i found crash if send invalid data to BigInt.
i think shouldn't use force unwrap inside your method and check value before use.
/// Initialize a new big integer from a decimal number represented by a string literal of arbitrary length.
/// The string must contain only decimal digits.
public init(stringLiteral value: StringLiteralType) {
self = BigInt(value, radix: 10)!
}
Because I'm working on the RandomKitBigInt extension, I feel as though having the randomInteger()
functions of BigUInt
is slightly repetitive.
If removed, this would be a breaking change. However, the switch should be pretty seamless for library users.
The functions don't conflict, so there's no real problem with keeping them in the next major version of BigInt.
I'm trying to convert the result of dividing two BigInt values into Decimal. For example, I'm trying to represent 10 / 1,000 into Decimal (i.e. 0.01). How can that be achieved?
I like the idea of a ShiftOperations
protocol that's essentially a cousin of BitwiseOperations
. However, I feel as though the ShiftOperations
protocol is outside of the scope of BigInt
.
I made a separate module that simply contains this protocol. I make good use of it in nvzqz/RandomKit@4fdd456. Perhaps BigInt can import this module to satisfy that protocol?
If that isn't the direction you'd want to go, I feel as though ShiftOperations
should at least have an internal
access level rather than public
because it is only used by BigDigit
.
The initializer assumes to have a big endian UInt8 array and the makeBytes
function creates a big endian UInt8 array
when l use the func in swift4, it shows error "Value of type 'BigUInt.Word' (aka 'UInt') has no member 'makeBytes'" and "Argument labels '(bytes:)' do not match any available overloads" . But l don't know how to solve the problem
Originally posted by @Ybrin in #39 (comment)
Obviously the code is a bit outdated and doesn't compile anymore. I tried to fix it myself, but inserting a few UInt casts and "bitat:" didn't succeed.
It would be very nice if the dependency of Siphash could be removed and replaced by the hasher you built into the Swift stdlib. Thanks for this great piece of software.
Since swift 4, the standard library implements ".multipliedFullWidth(by: ) -> (, )" and an equivalent for division. The use of this might improve performance
include by carthage
in cartfile: github "attaswift/BigInt" ~> 3.0
yld: Library not loaded: @rpath/SipHash.framework/SipHash
Referenced from: /Users//Library/Developer/CoreSimulator/Devices/0A76CB65-0F98-4808-99A4-2C0B940D4C4F/data/Containers/Bundle/Application/153658BC-FB63-4CCA-B9F0-1E7AAE8ED4D5//Frameworks/BigInt.framework/BigInt
Reason: image not found
(lldb)
Hi @lorentey β I feel a bit uneasy making releases on this repo, but I did draft a new release with the latest bug fixes:
https://github.com/attaswift/BigInt/releases/tag/untagged-1100ee6296e800ded71d
I am not sure what the process is for releasing and pushing to cocoapods, etc, so I am leaving it like so. I am happy to learn and do it myself, but I didn't want to overstep my bounds here...
Hey! Thanks for this amazing BigInt
lib! I am curious if there has been any benchmark vs https://developer.apple.com/documentation/accelerate/veclib/vbignum ? Otherwise I might do a PR with some unit tests doing a benchmark - if at all interesting?
The new version (3.0.0) of BigInt doesn't compile on Xcode 9, are there any chance for support swift 3.2 ?
is there anyway of converting a BigUInt to [UInt8]?
Hi,
Please can you publish this version to CocoaPods?
Thanks! Great project and updates :)
Matt
macOS 10.15.7
Xcode 12.3 RC
Using Carthage
$ carthage update
*** Fetching BigInt
*** Checking out BigInt at "v5.2.1"
*** xcodebuild output can be found in /var/folders/76/q9_yh34j5wd23ksxl7b70ssm0000gn/T/carthage-xcodebuild.sNVTfc.log
*** Building scheme "BigInt-macOS" in BigInt.xcworkspace
*** Building scheme "BigInt-tvOS" in BigInt.xcworkspace
Build Failed
Task failed with exit code 1:
/usr/bin/xcrun lipo -create /Users/joejoe/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/BigInt/v5.2.1/Build/Intermediates.noindex/ArchiveIntermediates/BigInt-tvOS/IntermediateBuildFilesPath/UninstalledProducts/appletvos/BigInt.framework/BigInt /Users/joejoe/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/BigInt/v5.2.1/Build/Products/Release-appletvsimulator/BigInt.framework/BigInt -output /Users/joejoe/Documents/CodeProjects/MyProject1/Carthage/Build/tvOS/BigInt.framework/BigInt
This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/76/q9_yh34j5wd23ksxl7b70ssm0000gn/T/carthage-xcodebuild.sNVTfc.log
When I try to run the above command manually, I get this:
/usr/bin/xcrun lipo -create /Users/joejoe/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/BigInt/v5.2.1/Build/Intermediates.noindex/ArchiveIntermediates/BigInt-tvOS/IntermediateBuildFilesPath/UninstalledProducts/appletvos/BigInt.framework/BigInt /Users/joejoe/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/BigInt/v5.2.1/Build/Products/Release-appletvsimulator/BigInt.framework/BigInt -output /Users/joejoe/Documents/CodeProjects/MyProject1/Carthage/Build/tvOS/BigInt.framework/BigInt
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/joejoe/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/BigInt/v5.2.1/Build/Intermediates.noindex/ArchiveIntermediates/BigInt-tvOS/IntermediateBuildFilesPath/UninstalledProducts/appletvos/BigInt.framework/BigInt and /Users/joejoe/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/BigInt/v5.2.1/Build/Products/Release-appletvsimulator/BigInt.framework/BigInt have the same architectures (arm64) and can't be in the same fat output file
The last line in the log file carthage-xcodebuild.sNVTfc.log
noted above says "*** BUILD SUCCEEDED ***"
Not sure what's going on here. This is my first Xcode project and I just installed Carthage 10m ago.
Howdy.
I'm curious if some of the initializers should be deprecated:
For BigInt:
public init?<T>(exactly source: T) where T : BinaryInteger {
self.init(source)
}
This optional initializer should never return nil, as any value that can be represented by a BinaryInteger can be represented as a BigInt, as BigInt has a wider possible range than any fixed-size integer type.
public init<T>(clamping source: T) where T : BinaryInteger {
self.init(source)
}
Similarly, clamping is not needed, as BigInt has the needed range to cover any fixed-width BinaryInteger type.
public init<T>(truncatingIfNeeded source: T) where T : BinaryInteger {
self.init(source)
}
Truncating doesn't seem to apply to the case of initializing a BigInt from another Integer value
For BigUInt:
public init<T: BinaryInteger>(truncatingIfNeeded source: T) {
self.init(words: source.words)
}
As for BigInt, it seems there won't be a case where truncating would be needed.
public init?<T: BinaryInteger>(exactly source: T) {
guard source >= (0 as T) else { return nil }
if source.bitWidth <= 2 * Word.bitWidth {
var it = source.words.makeIterator()
self.init(low: it.next() ?? 0, high: it.next() ?? 0)
precondition(it.next() == nil, "Length of BinaryInteger.words is greater than its bitWidth")
}
else {
self.init(words: source.words)
}
}
public init<T: BinaryInteger>(_ source: T) {
precondition(source >= (0 as T), "BigUInt cannot represent negative values")
self.init(exactly: source)!
}
With this pair of initializers, the first, optional initializer seems like it would correctly return nil for negative values, and an exact value for a non-negative argument. The second initializer, however, gives the same results, with the code crashing if a negative value is used. Perhaps they could be consolidated into a single optional initializer without precondition.
Below exponential calculation (2048 bits) is taking around 5s whereas same calculation using Android native BigInteger is taking around 100ms.
let N = BigUInt("AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73", radix: 16)!
let g = BigUInt(2)
let a = BigUInt("601e4cdbc9ceadbd116fff9331c689b03d9770f5d4da80f8e0fe826f01104e9bb52d68a7bc38519d77d0463f4bc67cf9d13588e03324c7c79a6931dfc3d5b4b3b4014ec08820be1af9f9a056350ccaada53f063568671bd717217be2f90e948d037e00ea348f1bb4f99ca16ca4f11a889529afe80229127b10e85001c6654fbdb805f1122dc1b10679334228ab86ab65a3192f0368ca21f45e966e65adab6bf752844828b25923ad98da909c1b2ffae21625ce6095f0d15601475edd44a7a6979a48339f0265fabe7cb864a56e583c35f838eaa00e676658df7e091a5a3cf346f4df3ce65ed5633b7bb3ea7c2dec982a4ec9c7c6ad9eb3da33cf635ed6094c24", radix: 16)!
let start = Date()
let A = g.power(a, modulus: N)
print("Elapsed time: \(Date().timeIntervalSince(start))")
Hi
I want something like pow(0.5, 1000). How is this possible using BigInt
extension BigInt {
public func serialize() -> Data {
var array = Array(BigUInt.init(self.magnitude).serialize())
if array.count > 0 {
if self.sign == BigInt.Sign.plus {
if array[0] >= 128 {
array.insert(0, at: 0)
}
} else if self.sign == BigInt.Sign.minus {
if array[0] <= 127 {
array.insert(255, at: 0)
}
}
}
return Data.init(bytes: array)
}
public init(_ data: Data) {
var dataArray = Array(data)
var sign: BigInt.Sign = BigInt.Sign.plus
if dataArray.count > 0 {
if dataArray[0] >= 128 {
sign = BigInt.Sign.minus
if dataArray.count > 1 {
if dataArray[0] == 255, dataArray.count > 1 {
dataArray.remove(at: 0)
} else {
dataArray[0] = UInt8(256 - Int(dataArray[0]))
}
}
}
}
let magnitude = BigUInt.init(Data.init(bytes: dataArray))
self .init(sign: sign, magnitude: magnitude)
}
}
hello,
Thank you for open source this Arbitrary-precision arithmetic.
When I use this to test paillier algorithm computational overhead, this function
func power(exponent: BigUInt, modulus: BigUInt) -> BigUInt{}
, the Java modPower computational overhead about 45ms but this function about 2.7s, cause some distortion.
The overhead test code at here: https://github.com/SummonY/Paillier_iOS
Can you help to optimize this function?
Thanks,
Summon Yang
I just instrumented my code and BigInt division seems to be a bottleneck with 32 byte division. Wondering if it's possible to use a faster algorithm? A quick google returns some promising results:
http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Hasselstrom2003.pdf
https://en.wikipedia.org/wiki/Division_algorithm#Large-integer_methods
Have you benchmarked alternatives previously?
generate-docs.sh is being included in the framework bundle.
This causes a failed validation when preparing for an app store upload.
is generate-docs.sh really needed int the bundle?
Would it be possible to comply to the semVer semantic scheme for versioning so that the swift package manager can be used?
(https://github.com/apple/swift-package-manager/blob/master/Documentation/Reference.md#version)
(http://semver.org)
many thx!
Will a function be added to cast a BigInt to a byte array like in Java's BigInteger?
I can't download 1.3 with cocoapods, whenever I build my xcode workspace, it says "no such module bigint"
Hi.
Can you, please, publish the new version to CocoaPods (v5).
Thank you!
This is a minor point which doesn't affect functionality at all, but does slightly affect the API documentation, and it confused me for a little while.
In BigInt/Comparable.swift, it's extension BigUInt: Comparable
, but extension BigInt
(with no conformances listed). Both extensions define <
and ==
, and in fact both types are Comparable. It took me a little while to figure out how.
(BigInt/BigUInt -> SignedInteger/UnsignedInteger -> BinaryInteger -> Strideable -> Comparable)
Declaring BigUInt: Comparable
is technically redundant. (It's a nice reminder, though, that this type is Comparable.) It would be less confusing if either both types were marked Comparable
, or neither were. Thanks!
In the product definition there are two products named "BigInt". As seen on the latest snapshot of Swift and this bug, this is probably an invalid declaration.
swift package show-dependencies
.
βββ Cryptor<https://github.com/IBM-Swift/[email protected].21>
β βββ CommonCrypto<https://github.com/IBM-Swift/[email protected].5>
βββ BigInt<https://github.com/attaswift/[email protected].1>
βββ SipHash<https://github.com/attaswift/[email protected].0>
'BigInt' /Users/bouke/Library/Mobile Documents/com~apple~CloudDocs/Developer/SRP/.build/checkouts/BigInt.git--5127040856227023039: warning: Ignoring duplicate product 'BigInt' (static)
After upgrading from 2.1.2 to 3.0.0 (and upgrading from Xcode 8.3.3 to 9.0), I am getting the error "Cannot assign to property: 'kind' setter is inaccessible, Cannot assign to property: 'storage' setter is inaccessible".
It is better for you that change "private" to βfileprivateβ because the code you input always show as error on laptop.
Hi,
Any plan to support big double? Say, to count division up to n digit precision. You know, like digit of pi calculation but more natural.
Thank you.
-Bee
Hi there, i saw that you made a release 5.1 for BigInt.
Unfortunately, it does not seem to be available via cocoapods.
None of your spec sources contain a spec satisfying the dependency:
BigInt (= 5.1.0)
Could you push it to cocoapods?
Hello,
Currently I'm using BigInit 2.1 with Xcode 8.3 and Swift 3.2 without any problem. However, after upgrading to BigInt 2.1.2 with Xcode 9.2 and Swift 3.2, I got the following error
Can you help to take a look to see if it's a known issue or if something wrong in my configuration?
Last but not least, thanks a lot for writing a great lib to work with big integer.
There is an issue with pod spec for version 2.1.2, it contains SipHash dependency with version ~> 1.1 which means version 1.2 on pod update, but version 1.2 is for swift 4.0.
Edit:
it's an issue till version 2.1.0 included
I am developing machine learning models on Ubuntu 18.04 using the Swift for Tensorflow v0.11 toolchain.
$ which swift
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)
Target: x86_64-unknown-linux-gnu
$ swift build
swift-frontend: /swift-base/swift/lib/AST/GenericSignature.cpp:251: static swift::CanGenericSignature swift::CanGenericSignature::getCanonical(TypeArrayView<swift::GenericTypeParamType>, ArrayRef<swift::Requirement>, bool): Assertion `isCanonicalAnchor(secondType)' failed.
Stack dump:
0. Program arguments: /home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend -frontend -c /home/xander/dev/BigInt/Sources/Addition.swift /home/xander/dev/BigInt/Sources/BigInt.swift /home/xander/dev/BigInt/Sources/BigUInt.swift /home/xander/dev/BigInt/Sources/Bitwise Ops.swift /home/xander/dev/BigInt/Sources/Codable.swift /home/xander/dev/BigInt/Sources/Comparable.swift -primary-file /home/xander/dev/BigInt/Sources/Data Conversion.swift -primary-file /home/xander/dev/BigInt/Sources/Division.swift -primary-file /home/xander/dev/BigInt/Sources/Exponentiation.swift -primary-file /home/xander/dev/BigInt/Sources/Floating Point Conversion.swift -primary-file /home/xander/dev/BigInt/Sources/GCD.swift -primary-file /home/xander/dev/BigInt/Sources/Hashable.swift /home/xander/dev/BigInt/Sources/Integer Conversion.swift /home/xander/dev/BigInt/Sources/Multiplication.swift /home/xander/dev/BigInt/Sources/Prime Test.swift /home/xander/dev/BigInt/Sources/Random.swift /home/xander/dev/BigInt/Sources/Shifts.swift /home/xander/dev/BigInt/Sources/Square Root.swift /home/xander/dev/BigInt/Sources/Strideable.swift /home/xander/dev/BigInt/Sources/String Conversion.swift /home/xander/dev/BigInt/Sources/Subtraction.swift /home/xander/dev/BigInt/Sources/Words and Bits.swift -supplementary-output-file-map /tmp/supplementaryOutputs-9577c2 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -parse-as-library -module-name BigInt -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Division.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Exponentiation.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Floating Point Conversion.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/GCD.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Hashable.swift.o -index-store-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
1. Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)
2. While evaluating request TypeCheckSourceFileRequest(source_file "/home/xander/dev/BigInt/Sources/Division.swift")
3. While type-checking extension of FixedWidthInteger (at /home/xander/dev/BigInt/Sources/Division.swift:11:1)
4. While type-checking declaration 0x8acfa30 (at /home/xander/dev/BigInt/Sources/Division.swift:12:13)
5. While evaluating request PatternBindingEntryRequest((unknown decl), 0)
6. While evaluating request PatternTypeRequest((pattern @ 0x8acf618))
7. While canonicalizing generic signature <Ο_0_0 where Ο_0_0 : FixedWidthInteger, Ο_0_0 == Ο_0_0.Magnitude, Ο_0_0.Magnitude == Ο_0_0.Magnitude.Magnitude.Magnitude> in requirement #2
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x5214dc4]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x52129be]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x521509c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7f6d86e128a0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f6d856b4f47]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f6d856b68b1]
/lib/x86_64-linux-gnu/libc.so.6(+0x3042a)[0x7f6d856a642a]
/lib/x86_64-linux-gnu/libc.so.6(+0x304a2)[0x7f6d856a64a2]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193f72e]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193e98d]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193e87c]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193fb27]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x18805a5]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x1418ecf]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a2636]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13f4788]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a8cb7]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a87b6]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a1f61]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a1f34]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x1400212]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x137a793]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x137a4af]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x136cc71]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d180f]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d0871]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d3fab]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d0871]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d07a1]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142b995]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142cc70]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142c9a7]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142c8b1]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142b6de]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142b6b4]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x63d3c9]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x63d296]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x4fd485]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x490dd8]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f6d85697b97]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x49098a]
This occurs on all the tags I tried: v5.1.0
,v5.2.0
, v5.0.0
, and v4.0.0
.
Note that I do not have this issue on the previous version of Swift for Tensorflow, v0.10. This issue is new to v0.11.
Note also that I do not have this issue when building on macOS 10.15.6 with Swift for Tensorflow v0.11 when linking against the Xcode 12 beta macOS SDK.
Note also that this does not occur with the official Swift v5.3 development snapshot for Ubuntu 18.04:
$ which swift
/home/xander/swift-5.3-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM 3fa9679add, Swift d24649a4d6)
Target: x86_64-unknown-linux-gnu
It appears to be specific to Ubuntu 18.04 + Swift for Tensorflow v0.11. Issue I filed against the Swift for Tensorflow project: tensorflow/swift#522.
I can't run on Xcode 10.2 and Swift
Hi! I'd like to use Your library for the RSA algorithm (for the university), but Your example always returns nil.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.