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
19 changes: 10 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,35 @@ 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
macOS-test:
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)'
17 changes: 9 additions & 8 deletions .github/workflows/docc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ DerivedData/

**.log
**.bak

.DS_Store
14 changes: 4 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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).
Read the generated [docs](https://dastrobu.github.io/NdArray/documentation/ndarray).
12 changes: 10 additions & 2 deletions Sources/NdArray/NdArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ open class NdArray<T>: CustomDebugStringConvertible,
for i in 0..<rowCount {
let row = a[i]
precondition(row.count == colCount, "\(row.count) == \(colCount) at row \(i)")
memcpy(dataStart + i * strides[0], row, colCount * MemoryLayout<T>.stride)
row.withUnsafeBufferPointer { p in
if let base = p.baseAddress {
memcpy(dataStart + i * strides[0], base, colCount * MemoryLayout<T>.stride)
}
}
}
case .F:
for i in 0..<rowCount {
Expand Down Expand Up @@ -219,7 +223,11 @@ open class NdArray<T>: CustomDebugStringConvertible,
for j in 0..<jCount {
let aij = ai[j]
precondition(aij.count == kCount, "\(aij.count) == \(kCount) at index \(i), \(j)")
memcpy(dataStart + i * strides[0] + j * strides[1], aij, kCount * MemoryLayout<T>.stride)
aij.withUnsafeBufferPointer { p in
if let base = p.baseAddress {
memcpy(dataStart + i * strides[0] + j * strides[1], base, kCount * MemoryLayout<T>.stride)
}
}
}
}
case .F:
Expand Down
6 changes: 5 additions & 1 deletion Sources/NdArray/matrix/Matrix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ open class Matrix<T>: NdArray<T>, Sequence {
for i in 0..<rowCount {
let row = a[i]
precondition(row.count == colCount, "\(row.count) == \(colCount) at row \(i)")
memcpy(dataStart + i * strides[0], row, colCount * MemoryLayout<T>.stride)
row.withUnsafeBufferPointer { p in
if let base = p.baseAddress {
memcpy(dataStart + i * strides[0], base, colCount * MemoryLayout<T>.stride)
}
}
}
case .F:
for i in 0..<rowCount {
Expand Down
9 changes: 0 additions & 9 deletions Tests/NdArrayTests/XCTestManifests.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/NdArrayTests/test_support.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import XCTest
internal func XCTAssertEqual<T>(_ 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)
Expand Down
Loading