diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 99c78ec..71ef29e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: norio-nomura/action-swiftlint@3.2.1 with: args: --strict @@ -14,26 +14,27 @@ jobs: strategy: matrix: swift-version: - - "5.9" + - "6.1" + - "6.2" runs-on: macos-latest steps: - - uses: actions/checkout@v4 - - uses: swift-actions/setup-swift@v1 + - uses: actions/checkout@v6 + - uses: swift-actions/setup-swift@v3 with: swift-version: ${{ matrix.swift-version }} - run: swift test iOS-build: runs-on: macos-latest steps: - - uses: actions/checkout@v4 - - run: xcodebuild -scheme NdArray -destination 'platform=iOS Simulator,name=iPhone 13' + - uses: actions/checkout@v6 + - run: xcodebuild -scheme NdArray -destination 'platform=iOS Simulator,name=iPhone 16' tvOS-build: runs-on: macos-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - run: xcodebuild -scheme NdArray -destination 'platform=tvOS Simulator,name=Apple TV' whatchOS-build: runs-on: macos-latest steps: - - uses: actions/checkout@v4 - - run: xcodebuild -scheme NdArray -destination 'platform=watchOS Simulator,name=Apple Watch Series 8 (45mm)' + - uses: actions/checkout@v6 + - run: xcodebuild -scheme NdArray -destination 'platform=watchOS Simulator,name=Apple Watch Series 11 (46mm)' diff --git a/.github/workflows/docc.yaml b/.github/workflows/docc.yaml index 82a0801..68fa159 100644 --- a/.github/workflows/docc.yaml +++ b/.github/workflows/docc.yaml @@ -9,19 +9,20 @@ jobs: generate-docs: runs-on: macos-latest steps: - - uses: actions/checkout@v4 - - uses: swift-actions/setup-swift@v1 + - uses: actions/checkout@v6 + - uses: swift-actions/setup-swift@v3 with: swift-version: "5.9" + - name: generate-documentation # https://apple.github.io/swift-docc-plugin/documentation/swiftdoccplugin/generating-documentation-for-hosting-online/ run: > - swift package - --allow-writing-to-directory ./docs - generate-documentation - --output-path ./docs - --hosting-base-path NdArray - --disable-indexing + swift package + --allow-writing-to-directory ./docs + generate-documentation + --output-path ./docs + --hosting-base-path NdArray + --disable-indexing --transform-for-static-hosting - name: generate theme-settings.json run: echo '' > theme-settings.json diff --git a/.gitignore b/.gitignore index d21d9e8..23f8975 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ DerivedData/ **.log **.bak + +.DS_Store diff --git a/Package.swift b/Package.swift index 4f51e85..2f2c329 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.4 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -11,16 +11,10 @@ let package = Package( name: "NdArray", targets: ["NdArray"]), ], - dependencies: { + dependencies: [ // https://apple.github.io/swift-docc-plugin/documentation/swiftdoccplugin/ - var deps: [PackageDescription.Package.Dependency] = [] - #if swift(>=5.6.0) - deps.append( - .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0") - ) - #endif - return deps - }(), + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.5"), + ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. diff --git a/README.md b/README.md index f659fa3..b4c7f58 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NdArray -[![Swift Version](https://img.shields.io/badge/swift-5.9-blue.svg)](https://swift.org) +[![Swift Version](https://img.shields.io/badge/swift-6.2-blue.svg)](https://swift.org) ![Platform](https://img.shields.io/badge/platform-macOS|iOS|tvOS|whatchOS-lightgray.svg) ![Build](https://github.com/dastrobu/NdArray/actions/workflows/ci.yaml/badge.svg) @@ -711,4 +711,4 @@ Some features would be nice to have at some time but currently out of scope. ## Docs -Read the generated [docs](https://dastrobu.github.io/NdArray/documentation/ndarray). \ No newline at end of file +Read the generated [docs](https://dastrobu.github.io/NdArray/documentation/ndarray). diff --git a/Sources/NdArray/NdArray.swift b/Sources/NdArray/NdArray.swift index 397d5c4..965754f 100644 --- a/Sources/NdArray/NdArray.swift +++ b/Sources/NdArray/NdArray.swift @@ -186,7 +186,11 @@ open class NdArray: CustomDebugStringConvertible, for i in 0...stride) + row.withUnsafeBufferPointer { p in + if let base = p.baseAddress { + memcpy(dataStart + i * strides[0], base, colCount * MemoryLayout.stride) + } + } } case .F: for i in 0..: CustomDebugStringConvertible, for j in 0...stride) + aij.withUnsafeBufferPointer { p in + if let base = p.baseAddress { + memcpy(dataStart + i * strides[0] + j * strides[1], base, kCount * MemoryLayout.stride) + } + } } } case .F: diff --git a/Sources/NdArray/matrix/Matrix.swift b/Sources/NdArray/matrix/Matrix.swift index d1c4612..f49d857 100644 --- a/Sources/NdArray/matrix/Matrix.swift +++ b/Sources/NdArray/matrix/Matrix.swift @@ -33,7 +33,11 @@ open class Matrix: NdArray, Sequence { for i in 0...stride) + row.withUnsafeBufferPointer { p in + if let base = p.baseAddress { + memcpy(dataStart + i * strides[0], base, colCount * MemoryLayout.stride) + } + } } case .F: for i in 0.. [XCTestCaseEntry] { - [ - testCase(NdArrayTests.allTests), - ] -} -#endif diff --git a/Tests/NdArrayTests/test_support.swift b/Tests/NdArrayTests/test_support.swift index a3c0b65..134fd09 100644 --- a/Tests/NdArrayTests/test_support.swift +++ b/Tests/NdArrayTests/test_support.swift @@ -8,7 +8,7 @@ import XCTest internal func XCTAssertEqual(_ expression1: @autoclosure () throws -> [T], _ expression2: @autoclosure () throws -> [T], accuracy: T, _ message: @autoclosure () -> String = "", - file: StaticString = #file, line: UInt = #line) rethrows where T: FloatingPoint { + file: StaticString = #filePath, line: UInt = #line) rethrows where T: FloatingPoint { let array1: [T] = try expression1() let array2: [T] = try expression2() XCTAssertEqual(array1.count, array2.count, file: file, line: line)