sincmaths
A Kotlin multi-platform implementation of 2D matrix with signal processing capabilities
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.1%) to scientific vocabulary
Repository
A Kotlin multi-platform implementation of 2D matrix with signal processing capabilities
Basic Info
- Host: GitHub
- Owner: GallVp
- License: mit
- Language: Kotlin
- Default Branch: main
- Homepage: https://gallvp.github.io/sincmaths/
- Size: 2.51 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
- Releases: 2
Metadata Files
README.md
SincMaths
SincMaths is a Kotlin Multiplatform library which provides a 2D matrix SincMatrix to
facilitate translation of signal processing code written in Octave/MATLAB to mobile applications.
Originally written for the Gait&Balance app.
See docs for a comprehensive list of functions.
Key implementation aspects:
- Stores data in row-major format as opposed to column-major format used by Octave/MATLAB
- Uses ejml-simple for Android side optimisations
- Uses Apple Accelerate for iOS side optimisations
- Uses rafat/wavelib to provide wavelet-based demonising
- Uses codeplea/tinyexpr to provide Octave/MATLAB style indexing
Examples
Initialisation
```kotlin val matrixA = matrixFrom("[1, 2, 3; 4, 5, 6]") val matrixB = matrixFrom("[1, 2, 3, 4]") val matrixC = matrixFrom("[5;6;7;8;9;10]") val matrixD = matrixFrom("1:10") val matrixE = matrixFrom("-1.5:-1:-7.9")
val matrixF = matrixOf(2, 10, 1..20) val matrixG = colVectorOf(1.0, 0.5, 2.9, 10.1, 15.4) ```
Indexing
```kotlin val matrixM: SincMatrix = (1..110).asSincMatrix(11, 10)
val matrixA = matrixM["1:5,4:7"] val matrixB = matrixM["1:end,end:-1:end-1"]
val matrixC = matrixM[3, 3] val matrixD = matrixM[1]
val matrixE = matrixM[1..4]
val matrixF = matrixM.get { endR, endC, allR, allC -> Pair(allR, 4..7) } // same as matrixM[":,4:7"] ```
Implementation of acf from MATLAB Central
Reference: https://au.mathworks.com/matlabcentral/fileexchange/30540-autocorrelation-function-acf
```kotlin fun SincMatrix.acf(numLags: Int): SincMatrix {
require(this.isVector) { "This function works only for vectors" }
require(numLags < this.numel) {
"No. of lags should be smaller than the length of the vector"
}
val zeroMeanVector = this - this.mean().scalar
val convSum = zeroMeanVector.conv(bVector = zeroMeanVector.flip())
val scale = 1.0 / zeroMeanVector.dot(zeroMeanVector).scalar
val scaledConvSum = convSum * scale
val acfElements = this.numel + 1..this.numel + numLags
return if (this.isRow) {
scaledConvSum[this.rowIndicesRange, acfElements]
} else {
scaledConvSum[acfElements, this.colIndicesRange]
}
} ```
Usage
Kotlin Project: MavenCentral
Note: This library does not work with
iosSimulatorArm64target. Android tests have to be performed on an emulator or a connected device, otherwise, the underlying JAVA JNI libraries fail to load.
Add dependency:
kotlin
implementation("io.github.gallvp:sincmathsmp:0.3")
Try a test:
kotlin
expect(5050.0) {
matrixFrom("1:100").sum().scalar
}
Swift Project: CocoaPods
Note: Global functions such as
matrixFromare converted into open class functions asSincMatrixInitKt.matrixFrom. Use 'Jump to Definition' on 'SincMaths' to locate the class and function definitions.
Clone this project and add it to your project's Podfile:
pod
pod 'SincMaths', :path => '/path/to/cloned/sincmaths/sincmathsmp'
Import it in your project and try a test:
```swift import SincMaths
XCTAssertEqual( SincMatrixInitKt.matrixFrom(script: "1:100").sum(dim: 1).scalar, 5050.0 ) ```
Owner
- Name: Usman Rashid
- Login: GallVp
- Kind: user
- Location: Auckland
- Repositories: 2
- Profile: https://github.com/GallVp
Bioinformatics Developer at The New Zealand Institute for Plant and Food Research.
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Rashid" given-names: "Usman" orcid: "https://orcid.org/0000-0002-1109-5493" title: "SincMaths: A Kotlin multi-platform implementation of 2D matrix with signal processing capabilities" version: 0.3 date-released: 2023-12-30 url: "https://github.com/GallVp/sincmaths" doi: 10.5281/zenodo.10457067
GitHub Events
Total
Last Year
Dependencies
- actions/checkout v4 composite