fastMatMR

R bindings to fast_matrix_market for reading and writing .mtx files

https://github.com/ropensci/fastmatmr

Science Score: 54.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
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.7%) to scientific vocabulary

Keywords

cpp17 matrix-market matrix-market-format r-cpp11 r-package
Last synced: 6 months ago · JSON representation ·

Repository

R bindings to fast_matrix_market for reading and writing .mtx files

Basic Info
Statistics
  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • Open Issues: 11
  • Releases: 4
Topics
cpp17 matrix-market matrix-market-format r-cpp11 r-package
Created over 2 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog Contributing License Citation Codeowners Codemeta

README.Rmd

---
output: github_document
---

# `fastMatMR` 


[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/fastMatMR)](https://cran.r-project.org/package=fastMatMR)
[![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/606_status.svg)](https://github.com/ropensci/software-review/issues/606)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
![runiverse-name](https://ropensci.r-universe.dev/badges/:name)
![runiverse-package](https://ropensci.r-universe.dev/badges/fastMatMR)
[![DOI](https://zenodo.org/badge/685246044.svg)](https://zenodo.org/badge/latestdoi/685246044)
[![R-CMD-check](https://github.com/ropensci/fastMatMR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/fastMatMR/actions/workflows/R-CMD-check.yaml)
[![pkgcheck](https://github.com/ropensci/fastMatMR/workflows/pkgcheck/badge.svg)](https://github.com/ropensci/fastMatMR/actions?query=workflow%3Apkgcheck)


## About

`fastMatMR` provides R bindings for reading and writing to [Matrix Market
files](https://math.nist.gov/MatrixMarket/formats.html) using the
high-performance [fast_matrix_market C++
library](https://github.com/alugowski/fast_matrix_market) (version 1.7.4).

## Why?

[Matrix Market files](https://math.nist.gov/MatrixMarket/formats.html) are
crucial to much of the data-science ecosystem. The `fastMatMR` package focuses
on high-performance read and write operations for Matrix Market files, serving
as a key tool for data extraction in computational and data science pipelines.

The target audience and scientific applications primarily include data
scientists or researchers developing numerical methods who may wish to either
test standard NIST (National Institute of Standards and Technology) which
include:

> comparative studies of algorithms for numerical linear algebra, featuring
> nearly 500 sparse matrices from a variety of applications, as well as matrix
> generation tools and services.

Additionally, being able to use the matrix market file format, means it is
easier to interface `R` analysis with those in `Python` (e.g. `SciPy` uses the
same underlying `C++` library). These files can also be used with the [Tensor
Algebra Compiler](http://tensor-compiler.org/docs/tensors.html) (TACO).

### Features

- **Extended Support**: `fastMatMR` supports standard R vectors, matrices, as
  well as `Matrix` sparse objects.

- **Performance**: The package is a thin wrapper around one of the fastest C++
  libraries for reading and writing `.mtx` files.

- **Correctness**: Unlike `Matrix`, roundtripping with `NA` and `NaN` values
  works by coercing to `NaN` instead of to arbitrarily high numbers.

We have vignettes for both
[read](https://docs.ropensci.org/fastMatMR/articles/fmm_read_bench.html) and
[write](https://docs.ropensci.org/fastMatMR/articles/fmm_write_bench.html)
operations to demonstrate the performance claims.

#### Alternatives and statement of need

- The `Matrix` package allows reading and writing sparse matrices in the `.mtx`
  (matrix market) format.
  + However, for `.mtx` files, it can only handles sparse matrices for writing
  and reading.
  + Round-tripping (writing and subsequently reading) data with `NA` and `NaN`
    values produces arbitrarily high numbers instead of preserving `NaN` /
    handling `NA`

## Installation

### CRAN

For the latest `CRAN` version:

```{r eval=FALSE}
install.packages("fastMatMR")
```

### R-Universe

For the latest development version of `fastMatMR`:

```{r eval=FALSE}
install.packages("fastMatMR",
                 repos = "https://ropensci.r-universe.dev")
```

### Development Git

For the latest commit, one can use:

```{r eval=FALSE}
# install.packages("devtools")
devtools::install_github("ropensci/fastMatMR")
```

## Quick Example

```{r eval=FALSE}
library(fastMatMR)
spmat <- Matrix::Matrix(c(1, 0, 3, 2), nrow = 2, sparse = TRUE)
write_fmm(spmat, "sparse.mtx")
fmm_to_sparse_Matrix("sparse.mtx")
```

The resulting `.mtx` file is language agnostic, and can even be read back in
`python` as an example:

```bash
pip install fast_matrix_market
python -c 'import fast_matrix_market as fmm; print(fmm.read_array_or_coo("sparse.mtx"))'
((array([1., 3., 2.]), (array([0, 0, 1], dtype=int32), array([0, 1, 1], dtype=int32))), (2, 2))
python -c 'import fast_matrix_market as fmm; print(fmm.read_array("sparse.mtx"))'
array([[1., 3.],
       [0., 2.]])
```

Similarly, `fastMatMR` supports writing and reading from other `R` objects (e.g.
standard R vectors and matrices), as seen in the [getting started
vignette](https://docs.ropensci.org/fastMatMR/articles/fastMatMR.html).

## Contributing

Contributions are very welcome. Please see the [Contribution
Guide](https://docs.ropensci.org/fastMatMR/CONTRIBUTING.html) and our [Code of
Conduct](https://ropensci.org/code-of-conduct/).

## License

This project is licensed under the [MIT License](https://docs.ropensci.org/fastMatMR/LICENSE.html).

### Logo

The logo was generated via a non-commercial use prompt on hotpot.ai, both
[blue](https://hotpot.ai/s/art-generator/8-TNiwRilbBFnQHwK), and
[green](https://hotpot.ai/s/art-generator/8-E2dBngG5nRiwCeL), as a riff on the
[NIST Matrix Market logo](https://math.nist.gov/MatrixMarket/). The text was
added in a presentation software (WPS Presentation). Hexagonal cropping was
accomplished in a [hexb](http://hexb.in/) compatible design [using
hexsticker](https://github.com/fridex/hexsticker).

Owner

  • Name: rOpenSci
  • Login: ropensci
  • Kind: organization
  • Email: info@ropensci.org
  • Location: Berkeley, CA

Citation (CITATION.cff)

cff-version: 1.1.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: Goswami
    given-names: Rohit
    orcid: https://orcid.org/0000-0002-2393-8056
title: ropensci/fastMatMR: v0.0.1.0: `fastMatMR` Writer
version: v0.0.1.0
date-released: 2023-08-31

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "identifier": "fastMatMR",
  "description": "An interface to the 'fast_matrix_market' 'C++' library, this package offers efficient read and write operations for Matrix Market files in R. It supports both sparse and dense matrix formats. Peer-reviewed at ROpenSci (<https://github.com/ropensci/software-review/issues/606>).",
  "name": "fastMatMR: High-Performance Matrix Market File Operations",
  "codeRepository": "https://github.com/ropensci/fastMatMR",
  "issueTracker": "https://github.com/ropensci/fastMatMR/issues",
  "license": "https://spdx.org/licenses/MIT",
  "version": "1.2.5",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 4.3.1 (2023-06-16)",
  "provider": {
    "@id": "https://cran.r-project.org",
    "@type": "Organization",
    "name": "Comprehensive R Archive Network (CRAN)",
    "url": "https://cran.r-project.org"
  },
  "author": [
    {
      "@type": "Person",
      "givenName": "Rohit",
      "familyName": "Goswami",
      "email": "rgoswami@ieee.org",
      "@id": "https://orcid.org/0000-0002-2393-8056"
    }
  ],
  "contributor": [
    {
      "@type": "Person",
      "givenName": "Adam",
      "familyName": "Lugowski",
      "email": "alugowski@gmail.com",
      "@id": "https://orcid.org/0009-0004-0922-4067"
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Rohit",
      "familyName": "Goswami",
      "email": "rgoswami@ieee.org",
      "@id": "https://orcid.org/0000-0002-2393-8056"
    }
  ],
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "ggplot2",
      "name": "ggplot2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=ggplot2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=knitr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "Matrix",
      "name": "Matrix",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=Matrix"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "microbenchmark",
      "name": "microbenchmark",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=microbenchmark"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "rmarkdown",
      "name": "rmarkdown",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rmarkdown"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat",
      "version": ">= 3.0.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=testthat"
    }
  ],
  "softwareRequirements": {
    "SystemRequirements": "C++17"
  },
  "fileSize": "36699.405KB",
  "releaseNotes": "https://github.com/ropensci/fastMatMR/blob/master/NEWS.md",
  "readme": "https://github.com/ropensci/fastMatMR/blob/main/README.md",
  "contIntegration": [
    "https://github.com/ropensci/fastMatMR/actions/workflows/R-CMD-check.yaml",
    "https://github.com/ropensci/fastMatMR/actions?query=workflow%3Apkgcheck"
  ],
  "developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html#stable",
  "review": {
    "@type": "Review",
    "url": "https://github.com/ropensci/software-review/issues/606",
    "provider": "https://ropensci.org"
  },
  "keywords": [
    "cpp17",
    "matrix-market",
    "matrix-market-format",
    "r-package",
    "r-cpp11"
  ],
  "relatedLink": "https://CRAN.R-project.org/package=fastMatMR"
}

GitHub Events

Total
Last Year

Packages

  • Total packages: 1
  • Total downloads:
    • cran 310 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: fastMatMR

High-Performance Matrix Market File Operations

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 310 Last month
Rankings
Stargazers count: 22.0%
Forks count: 27.9%
Dependent packages count: 28.9%
Dependent repos count: 36.9%
Average: 40.5%
Downloads: 86.8%
Maintainers (1)
Last synced: 10 months ago