Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k-arindam/swiftnp
A Swift library inspired by NumPy, focused on efficient numerical computation, array operations, and linear algebra for iOS and macOS development.
https://github.com/k-arindam/swiftnp
array-operation ios linear-algebra macos numerical-computation numpy swift
Last synced: about 1 month ago
JSON representation
A Swift library inspired by NumPy, focused on efficient numerical computation, array operations, and linear algebra for iOS and macOS development.
- Host: GitHub
- URL: https://github.com/k-arindam/swiftnp
- Owner: k-arindam
- License: mit
- Created: 2024-10-08T07:28:14.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-11-25T19:19:07.000Z (about 2 months ago)
- Last Synced: 2024-12-19T23:14:57.860Z (about 1 month ago)
- Topics: array-operation, ios, linear-algebra, macos, numerical-computation, numpy, swift
- Language: Swift
- Homepage: https://swiftnp.karindam.in
- Size: 2.11 MB
- Stars: 41
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![Banner](assets/banner.png)
# SwiftNP
SwiftNP is a Swift package for numerical computing inspired by the popular Python library, NumPy. It provides support for multi-dimensional arrays (NDArray), along with basic operations on these arrays, such as reshaping, element-wise operations, and more.
## Features
- Multi-dimensional arrays (`NDArray`)
- Support for various numeric types (e.g., `Int`, `Float`, `Double`, etc.)
- Basic array operations (reshape, element-wise operations, etc.)
- Extensible architecture for additional numerical computing functionality## Installation
### Swift Package Manager
Add the following to your `Package.swift` file:
```swift
dependencies: [
.package(url: "https://github.com/k-arindam/SwiftNP", from: "0.0.7")
]
```Then, include SwiftNP as a dependency in your target:
```swift
.target(
name: "YourTarget",
dependencies: ["SwiftNP"]),
```Import SwiftNP
In any Swift file where you want to use SwiftNP:
```swift
import SwiftNP
```## Usage
### Creating an NDArray
You can create a multi-dimensional array by specifying the shape and default values:
```swift
let array = SNP.ones(shape: [1, 3, 512, 512])
```### Basic Array Operations
SwiftNP supports element-wise operations, reshaping, and much more:
```swift
let reshapedArray = array.reshape([1, 9])
```### Data Types
SwiftNP supports a wide range of numeric data types. You can specify the data type when creating an NDArray:
```swift
let floatArray = NDArray(shape: [2, 2], dtype: .float64, defaultValue: 21.0)
```## License
This project is licensed under the MIT License. See the LICENSE file for details.
*Banner generated by [ChatGPT](https://chat.openai.com/)*