SE-0246 Generic Math(s) Functions
by
Shigure Shimotori
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
SE-0246: GENERIC MATH(S) FUNCTIONS OTEMACHI.SWIFT #3
Slide 2
Slide 2 text
SE-0246: GENERIC MATH(S) FUNCTIONS ࣗݾհ ▸ S_Shimotori ▸ ඍੵઢܗͰ͖ͳ͔ͬͨΑ…
Slide 3
Slide 3 text
SE-0246: GENERIC MATH(S) FUNCTIONS
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
ֶͬΆ͍ܭࢉ͕ ͍Ζ͍ΖͰ͖Δ༧ײʂʂʂʂ
Slide 6
Slide 6 text
SE-0246: GENERIC MATH(S) FUNCTIONS ࠓ͢͜ͱ ▸ SE-0246ͷ༰ ▸ with modificationsͬͯͳʹ ▸ Ϟδϡʔϧ໊Ͳ͏͢Δ ▸ logؔͷ໊લͲ͏͢Δ
Slide 7
Slide 7 text
SE-0246ͷ༰
Slide 8
Slide 8 text
SE-0246: GENERIC MATH(S) FUNCTIONS SE-0246ͷϞνϕ ▸ C mathϥΠϒϥϦͷݺͼग़͕͠Πέͯͳ͍ ▸ Darwin͔GNU C͔Ͱimportʹذ͕ൃੜ͢Δ ▸ protocol (Binary)FloatingPoint͕Πέͯͳ͍ ▸ CGFloat, Double, Float, Float80 \in BinaryFloatingPoint ▸ ͜ͷprotocolΛͬͯܭࢉΛߟ͑Δͷෆศ
Slide 9
Slide 9 text
SE-0246: GENERIC MATH(S) FUNCTIONS SE-0246ͰఏҊ͞Εͨ͜ͱ ▸ protocol ElementaryFunctionsͱprotocol RealΛ࡞Δ ▸ ॳؔηοτ \subset ࣮ؔηοτ ▸ staticؔͷ͔ͨͪͰܭࢉͰ͖ΔΑ͏ʹ͢Δprotocol ▸ ͜ΕͰࠓޙͬͱ֦ு͍͚ͯ͠Δͧʂ ▸ ෳૉͱ͔SIMDͱ͔ ▸ IEEE 754ͷ࣮͓͢͢ΊؔΛίϯϓ͢Δͱ͔
Slide 10
Slide 10 text
SE-0246: GENERIC MATH(S) FUNCTIONS ৽چൺֱ - SINؔΛ͏ // 今のSwift let value: CGFloat = 0 sin(value) // SE-0246 // extension CGFloat: ElementaryFunction CGFloat.sin(0)
Slide 11
Slide 11 text
SE-0246: GENERIC MATH(S) FUNCTIONS ৽چൺֱ - SIGMOIDؔΛఆٛ͢Δ // エラー。全浮動小数点数型を一括で扱えない func sigmoid(_ x: T) -> T { return 1/(1 + exp(-x)) } // SE-0246ならElementaryFunctionsと一言書けばよくなる func sigmoid(_ x: T) -> T { return 1/(1 + T.exp(-x)) } σ(x) = 1 1 + e−x ※γάϞΠυؔ
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
WITH MODIFICATION ͬͯͳʹ
Slide 15
Slide 15 text
SE-0246: GENERIC MATH(S) FUNCTIONS ACCEPTED **WITH MODIFICATIONS** ▸ Կ͔ٞΛͨ͠ܗ͕͋Δʂ
Slide 16
Slide 16 text
SE-0246: GENERIC MATH(S) FUNCTIONS ACCEPT͞ΕΔ·Ͱʹมߋ͞Εͨ͜ͱ ▸ Ұ෦ͷ͕ؔॳ͔ؔΒ࣮ؔߦ͖ʹ͞Εͨ ▸ atan2ඇ࣮ΛҾʹऔΒͳ͍ ▸ erf, erfc, gamma, logGammaҰ෦ڥͰ͑ͳ͍͠ɺਖ਼֬ʹ ॳؔ͡Όͳ͍ ▸ ࣮ؔʹՃ: hypot ▸ ໊લۭؒͷมߋ ▸ ؔΛ“Math”Լʹ·ͱΊΑ͏ͱࢥ͚ͬͯͨͲΊͨ
Slide 17
Slide 17 text
Ϟδϡʔϧ Ͳ͏͢Δ
Slide 18
Slide 18 text
SE-0246: GENERIC MATH(S) FUNCTIONS ϞδϡʔϧͲ͏͢Δ ▸ MathϞδϡʔϧͰimportΛղܾ͢ΔͭΓ…ͩͬͨ ▸ αʔυύʔςΟϥΠϒϥϦͰ͢ͰʹMathͷ໊Λ͍ͬͯΔ ▸ SwiftϞδϡʔϧʹ͢ͰʹmathͬΆ͍͕ؔ͋Δ ↓ ͱΓ͋͑ͣࠓճSwiftʹಥͬࠐΉ͚ͩʹ͠Α͏ͥʂ
Slide 19
Slide 19 text
LOGؔͷ໊લ Ͳ͏͢Δ
Slide 20
Slide 20 text
SE-0246: GENERIC MATH(S) FUNCTIONS ֤ݴޠͷରؔͷ໊લ ࣗવର ৗ༻ର ΧελϜ Swift log log10 N/A log log10 N/A java.lang.Math log log10 N/A kotlin.math ln log10 log
Slide 21
Slide 21 text
SE-0246: GENERIC MATH(S) FUNCTIONS ͰɺͲ͏ͯ͠SWIFTLNͰͳ͘LOGʹͨ͠ͷ ▸ C++͕ͦ͏͔ͩΒ ▸ lnͩͱ໊લ͕͗͢Δ͔Β ▸ inͱฆΒΘ͍͔͠Β { x in ln(x) } { x in log(x) }
Slide 22
Slide 22 text
·ͱΊ
Slide 23
Slide 23 text
SE-0246: GENERIC MATH(S) FUNCTIONS SE-0246͜Μͳײ͡ʂ ▸ ͍Ζ͍Ζͳܭࢉ͕Ͱ͖ΔΑ͏ʹͳΔΑ ▸ ࠓޙ͞ΒʹͰ͖Δ͜ͱ͕૿͑ͦ͏ͩΑ ▸ ࣮͚ͬͦͨ͘͞͠ͲޓੑςετʁͰࣦഊ͔ͨ͠Βෆे
Slide 24
Slide 24 text
SE-0246: GENERIC MATH(S) FUNCTIONS ࢀߟจݙͱ͔ͦ͏͍͏ͷ ▸ swift-evolution/0246-mathable.md at master · apple/swift-evolution ▸ Math functions for Swift by stephentyrone · Pull Request #23140 · apple/swift ▸ Revert SE-0246 by stephentyrone · Pull Request #23800 · apple/swift ▸ SE-0246: Generic Math(s) Functions - Proposal Reviews - Swift Forums ▸ [Accepted with Modifications] SE-0246: Generic Math Functions - Announcements - Swift Forums ▸ Generic “math functions” - Pitches - Swift Forums ▸ apple/swift-source-compat-suite: The infrastructure and project index comprising the Swift source compatibility suite.
Slide 25
Slide 25 text
SE-0246: GENERIC MATH(S) FUNCTIONS ࢀߟจݙͱ͔ͦ͏͍͏ͷ ▸ 754-2008 - IEEE Standard for Floating-Point Arithmetic - IEEE Standard ▸ (math.h) - C++ Reference ▸ Math (Java SE 12 & JDK 12 ) ▸ kotlin.math - Kotlin Programming Language