Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Complex.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
DD6F08BE24001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08BD24001B9A00749359 /* ComplexOverflowingArithmetic.swift */; };
DD6F08BF24001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08BD24001B9A00749359 /* ComplexOverflowingArithmetic.swift */; };
DD6F08C024001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08BD24001B9A00749359 /* ComplexOverflowingArithmetic.swift */; };
DD6F08C124001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08BD24001B9A00749359 /* ComplexOverflowingArithmetic.swift */; };
DD6F08C324001CD400749359 /* ComplexOverflowingArithmeticTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08C224001CD400749359 /* ComplexOverflowingArithmeticTests.swift */; };
DD6F08C424001CD400749359 /* ComplexOverflowingArithmeticTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08C224001CD400749359 /* ComplexOverflowingArithmeticTests.swift */; };
DD6F08C524001CD400749359 /* ComplexOverflowingArithmeticTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08C224001CD400749359 /* ComplexOverflowingArithmeticTests.swift */; };
DD6F08CD240077C300749359 /* TestingBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08CC240077C300749359 /* TestingBase.swift */; };
DD6F08CE240077C300749359 /* TestingBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08CC240077C300749359 /* TestingBase.swift */; };
DD6F08CF240077C300749359 /* TestingBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F08CC240077C300749359 /* TestingBase.swift */; };
Expand Down Expand Up @@ -149,6 +156,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
DD6F08BD24001B9A00749359 /* ComplexOverflowingArithmetic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComplexOverflowingArithmetic.swift; sourceTree = "<group>"; };
DD6F08C224001CD400749359 /* ComplexOverflowingArithmeticTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComplexOverflowingArithmeticTests.swift; sourceTree = "<group>"; };
DD6F08CC240077C300749359 /* TestingBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingBase.swift; sourceTree = "<group>"; };
DD6F08D02400808300749359 /* codecov.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = codecov.yml; sourceTree = "<group>"; };
DDB8120623F59B760079FEB5 /* Complex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Complex.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -310,6 +319,7 @@
DD6F08CC240077C300749359 /* TestingBase.swift */,
DDB8121023F5AEB10079FEB5 /* ComplexTests.swift */,
DDB8126623F7B7F40079FEB5 /* ComplexArithmeticTests.swift */,
DD6F08C224001CD400749359 /* ComplexOverflowingArithmeticTests.swift */,
DDB8122023F656AC0079FEB5 /* FunctionsTests.swift */,
DDB8128523FB1A430079FEB5 /* FunctionsTests.swift.gyb */,
DDFEEC4323EF13910096015C /* ComplexTests-Info.plist */,
Expand Down Expand Up @@ -347,8 +357,9 @@
children = (
DDB8120623F59B760079FEB5 /* Complex.swift */,
DDB8126123F7B1C90079FEB5 /* ComplexArithmetic.swift */,
DDB8126F23FA2C210079FEB5 /* Functions.swift.gyb */,
DD6F08BD24001B9A00749359 /* ComplexOverflowingArithmetic.swift */,
DDB8120B23F5A8E80079FEB5 /* Functions.swift */,
DDB8126F23FA2C210079FEB5 /* Functions.swift.gyb */,
DDB8125823F707EE0079FEB5 /* Operators.swift */,
);
path = Complex;
Expand Down Expand Up @@ -698,6 +709,7 @@
DDB8125923F707EE0079FEB5 /* Operators.swift in Sources */,
DDB8120723F59B760079FEB5 /* Complex.swift in Sources */,
DDB8120C23F5A8E80079FEB5 /* Functions.swift in Sources */,
DD6F08BE24001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -707,6 +719,7 @@
files = (
DDB8126723F7B7F40079FEB5 /* ComplexArithmeticTests.swift in Sources */,
DD6F08CD240077C300749359 /* TestingBase.swift in Sources */,
DD6F08C324001CD400749359 /* ComplexOverflowingArithmeticTests.swift in Sources */,
DDB8121123F5AEB10079FEB5 /* ComplexTests.swift in Sources */,
DDB8122123F656AC0079FEB5 /* FunctionsTests.swift in Sources */,
);
Expand All @@ -720,6 +733,7 @@
DDB8125A23F707EE0079FEB5 /* Operators.swift in Sources */,
DDB8120823F59B760079FEB5 /* Complex.swift in Sources */,
DDB8120D23F5A8E80079FEB5 /* Functions.swift in Sources */,
DD6F08BF24001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -729,6 +743,7 @@
files = (
DDB8126823F7B7F40079FEB5 /* ComplexArithmeticTests.swift in Sources */,
DD6F08CE240077C300749359 /* TestingBase.swift in Sources */,
DD6F08C424001CD400749359 /* ComplexOverflowingArithmeticTests.swift in Sources */,
DDB8121223F5AEB10079FEB5 /* ComplexTests.swift in Sources */,
DDB8122223F656AC0079FEB5 /* FunctionsTests.swift in Sources */,
);
Expand All @@ -742,6 +757,7 @@
DDB8125B23F707EE0079FEB5 /* Operators.swift in Sources */,
DDB8120923F59B760079FEB5 /* Complex.swift in Sources */,
DDB8120E23F5A8E80079FEB5 /* Functions.swift in Sources */,
DD6F08C024001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -751,6 +767,7 @@
files = (
DDB8126923F7B7F40079FEB5 /* ComplexArithmeticTests.swift in Sources */,
DD6F08CF240077C300749359 /* TestingBase.swift in Sources */,
DD6F08C524001CD400749359 /* ComplexOverflowingArithmeticTests.swift in Sources */,
DDB8121323F5AEB10079FEB5 /* ComplexTests.swift in Sources */,
DDB8122323F656AC0079FEB5 /* FunctionsTests.swift in Sources */,
);
Expand All @@ -764,6 +781,7 @@
DDB8125C23F707EE0079FEB5 /* Operators.swift in Sources */,
DDB8120A23F59B760079FEB5 /* Complex.swift in Sources */,
DDB8120F23F5A8E80079FEB5 /* Functions.swift in Sources */,
DD6F08C124001B9A00749359 /* ComplexOverflowingArithmetic.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Complex
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Platform](https://img.shields.io/cocoapods/p/Complex.svg)](https://cocoapods.org/pods/Complex)
[![Build](https://travis-ci.com/SomeRandomiOSDev/Complex.svg?branch=master)](https://travis-ci.com/SomeRandomiOSDev/Complex)
![Swift](https://github.com/SomeRandomiOSDev/Complex/workflows/Swift/badge.svg)
[![Code Coverage](https://codecov.io/gh/SomeRandomiOSDev/Complex/branch/master/graph/badge.svg)](https://codecov.io/gh/SomeRandomiOSDev/Complex)
[![Codacy](https://api.codacy.com/project/badge/Grade/8ad52c117e4a46d9aa4699d22fc0bf49)](https://app.codacy.com/app/SomeRandomiOSDev/Complex?utm_source=github.com&utm_medium=referral&utm_content=SomeRandomiOSDev/Complex&utm_campaign=Badge_Grade_Dashboard)

Expand Down
59 changes: 0 additions & 59 deletions Sources/Complex/ComplexArithmetic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,6 @@ extension Complex where Scalar: FixedWidthInteger {
}
}

extension Complex where Scalar: FixedWidthInteger {

@_transparent
public func addingReportingOverflow(_ rhs: Complex<Scalar>) -> (partialValue: Complex<Scalar>, overflow: Bool) {
let real = self.real.addingReportingOverflow(rhs.real)
let imaginary = self.imaginary.addingReportingOverflow(rhs.imaginary)
let overflow = real.overflow || imaginary.overflow

return (partialValue: Complex<Scalar>(real: real.partialValue, imaginary: imaginary.partialValue), overflow: overflow)
}

@_transparent
public func subtractingReportingOverflow(_ rhs: Complex<Scalar>) -> (partialValue: Complex<Scalar>, overflow: Bool) {
let real = self.real.subtractingReportingOverflow(rhs.real)
let imaginary = self.imaginary.subtractingReportingOverflow(rhs.imaginary)
let overflow = real.overflow || imaginary.overflow

return (partialValue: Complex<Scalar>(real: real.partialValue, imaginary: imaginary.partialValue), overflow: overflow)
}
}

// MARK: - Multiplication

extension Complex {
Expand Down Expand Up @@ -297,25 +276,6 @@ extension Complex where Scalar: FixedWidthInteger {
}
}

extension Complex where Scalar: FixedWidthInteger {

@_transparent
public func componentwiseMultipliedFullWidth(by rhs: Complex<Scalar>) -> (high: Complex<Scalar>, low: Complex<Scalar.Magnitude>) {
let real = self.real.multipliedFullWidth(by: rhs.real)
let imaginary = self.imaginary.multipliedFullWidth(by: rhs.imaginary)

return (high: Complex<Scalar>(real: real.high, imaginary: imaginary.high), low: Complex<Scalar.Magnitude>(real: real.low, imaginary: imaginary.low))
}

@_transparent
public func componentwiseMultipliedReportingOverflow(by rhs: Complex<Scalar>) -> (partialValue: Complex<Scalar>, overflow: Bool) {
let real = self.real.multipliedReportingOverflow(by: rhs.real)
let imaginary = self.imaginary.multipliedReportingOverflow(by: rhs.imaginary)

return (partialValue: Complex<Scalar>(real: real.partialValue, imaginary: imaginary.partialValue), overflow: real.overflow || imaginary.overflow)
}
}

// MARK: - Division (BinaryInteger)

extension Complex where Scalar: BinaryInteger {
Expand Down Expand Up @@ -415,22 +375,3 @@ extension Complex where Scalar: FloatingPoint {
lhs = lhs ./ rhs
}
}

extension Complex where Scalar: FixedWidthInteger {

@_transparent
public func componentwiseDividedReportingOverflow(by rhs: Complex<Scalar>) -> (partialValue: Complex<Scalar>, overflow: Bool) {
let real = self.real.dividedReportingOverflow(by: rhs.real)
let imaginary = self.imaginary.dividedReportingOverflow(by: rhs.imaginary)

return (partialValue: Complex<Scalar>(real: real.partialValue, imaginary: imaginary.partialValue), overflow: real.overflow || imaginary.overflow)
}

@_transparent
public func componentwiseDividingFullWidth(_ dividend: (high: Complex<Scalar>, low: Complex<Scalar.Magnitude>)) -> (quotient: Complex<Scalar>, remainder: Complex<Scalar>) {
let real = self.real.dividingFullWidth((high: dividend.high.real, low: dividend.low.real))
let imaginary = self.imaginary.dividingFullWidth((high: dividend.high.imaginary, low: dividend.low.imaginary))

return (quotient: Complex<Scalar>(real: real.quotient, imaginary: imaginary.quotient), remainder: Complex<Scalar>(real: real.remainder, imaginary: imaginary.remainder))
}
}
Loading