{"action":"created","issue":{"url":"https://api.github.com/repos/schwa/SwiftGraphics/issues/72","labels_url":"https://api.github.com/repos/schwa/SwiftGraphics/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/schwa/SwiftGraphics/issues/72/comments","events_url":"https://api.github.com/repos/schwa/SwiftGraphics/issues/72/events","html_url":"https://github.com/schwa/SwiftGraphics/issues/72","id":101204884,"number":72,"title":"Matrix Multiplication Data Type Bugs","user":{"login":"bartcone","id":1988098,"avatar_url":"https://avatars.githubusercontent.com/u/1988098?v=3","gravatar_id":"","url":"https://api.github.com/users/bartcone","html_url":"https://github.com/bartcone","followers_url":"https://api.github.com/users/bartcone/followers","following_url":"https://api.github.com/users/bartcone/following{/other_user}","gists_url":"https://api.github.com/users/bartcone/gists{/gist_id}","starred_url":"https://api.github.com/users/bartcone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartcone/subscriptions","organizations_url":"https://api.github.com/users/bartcone/orgs","repos_url":"https://api.github.com/users/bartcone/repos","events_url":"https://api.github.com/users/bartcone/events{/privacy}","received_events_url":"https://api.github.com/users/bartcone/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-15T19:52:26Z","updated_at":"2015-08-15T20:09:16Z","closed_at":null,"body":"When starting work on #49 I noticed the Matrix test was failing for the *64-bit* arch on *iOS*. \r\n\r\nAfter looking at the code, the assertion for iOS 64-bit was never triggered.\r\n\r\n```swift\r\nassert(sizeof(Float) == sizeof(CGFloat))\r\n```\r\n\r\nbut it should be asserting every single time because `sizeof(Float)` is always `4` and `CGFloat` varies based on the word size. \r\n\r\nIn our case, we're 64-bit arch and `sizeof(CGFloat)` == `8`, but again the assertion never asserted.\r\n\r\nAfter being puzzled for a bit, I glanced at the `SwiftGraphics_iOS` build scheme and found that the `Test` build configuration setting was set to use the `Release` build config, so no assert.\r\n\r\nBelow is the full snippet for context.\r\n\r\n```swift\r\npublic func * (lhs:Matrix, rhs:Matrix) -> Matrix {\r\n    let resultRows = lhs.rows\r\n    let resultColumns = rhs.columns\r\n    var resultData = NSMutableData(length:resultRows * resultColumns * sizeof(CGFloat))!\r\n\r\n#if os(OSX)\r\n    assert(sizeof(Double) == sizeof(CGFloat))\r\n    let resultPointer = UnsafeMutablePointer <Double> (resultData.mutableBytes)\r\n    vDSP_mmulD(UnsafePointer <Double> (lhs.pointer), lhs.stride, UnsafePointer <Double> (rhs.pointer), rhs.stride, resultPointer, 1, vDSP_Length(lhs.rows), vDSP_Length(rhs.columns), vDSP_Length(lhs.columns))\r\n    return Matrix(data:resultData, columns:resultColumns, rows:resultRows, stride:1)\r\n#elseif os(iOS) && (arch(arm64) || arch(x86_64))\r\n    assert(sizeof(Float) == sizeof(CGFloat))\r\n    let resultPointer = UnsafeMutablePointer <Float> (resultData.mutableBytes)\r\n    vDSP_mmul(UnsafePointer <Float> (lhs.pointer), lhs.stride, UnsafePointer <Float> (rhs.pointer), rhs.stride, resultPointer, 1, vDSP_Length(lhs.rows), vDSP_Length(rhs.columns), vDSP_Length(lhs.columns))\r\n    return Matrix(data:resultData, columns:resultColumns, rows:resultRows, stride:1)\r\n#else\r\n    // Reported as https://github.com/schwa/SwiftGraphics/issues/49\r\n    // See: http://stackoverflow.com/questions/26519169/matrix-multiplication-in-swift-using-accelerate-framework-32-bit-vs-64-bit\r\n    // See cblas_sgemm\r\n\r\n    preconditionFailure(\"vDSP_mmul not defined for i386 Simulator\")\r\n#endif\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/schwa/SwiftGraphics/issues/comments/131440540","html_url":"https://github.com/schwa/SwiftGraphics/issues/72#issuecomment-131440540","issue_url":"https://api.github.com/repos/schwa/SwiftGraphics/issues/72","id":131440540,"user":{"login":"bartcone","id":1988098,"avatar_url":"https://avatars.githubusercontent.com/u/1988098?v=3","gravatar_id":"","url":"https://api.github.com/users/bartcone","html_url":"https://github.com/bartcone","followers_url":"https://api.github.com/users/bartcone/followers","following_url":"https://api.github.com/users/bartcone/following{/other_user}","gists_url":"https://api.github.com/users/bartcone/gists{/gist_id}","starred_url":"https://api.github.com/users/bartcone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartcone/subscriptions","organizations_url":"https://api.github.com/users/bartcone/orgs","repos_url":"https://api.github.com/users/bartcone/repos","events_url":"https://api.github.com/users/bartcone/events{/privacy}","received_events_url":"https://api.github.com/users/bartcone/received_events","type":"User","site_admin":false},"created_at":"2015-08-15T20:09:16Z","updated_at":"2015-08-15T20:09:16Z","body":"Yeah that should work. Probably just create a completely new UnitTest-Release build config or something with asserts enabled.."}}