# kaneplusplus/bigmemory architecture

> Architecture diagram of the GitHub repository kaneplusplus/bigmemory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaneplusplus/bigmemory
- Repository: https://github.com/kaneplusplus/bigmemory

## Overview

bigmemory is an R package for creating, sharing, accessing, and manipulating large matrix-like objects, with a C++ accessor framework. The principal workflow is an R user creating or attaching a big.matrix, accessing or transforming its elements, and optionally persisting changes through file-backed storage. The graph reflects documented features and sampled native implementation; unsampled R definitions and operation wiring are represented only at the package-interface level.

Main entry points: [`inst/include/bigmemory/BigMatrix.h`](https://github.com/kaneplusplus/bigmemory/blob/master/inst/include/bigmemory/BigMatrix.h) (BigMatrix types), [`R/bigmemory.R`](https://github.com/kaneplusplus/bigmemory/blob/master/R/bigmemory.R) (Matrix API), [`src/RcppExports.cpp`](https://github.com/kaneplusplus/bigmemory/blob/master/src/RcppExports.cpp) (Rcpp entry points), [`src/bigmemory.cpp`](https://github.com/kaneplusplus/bigmemory/blob/master/src/bigmemory.cpp) (Matrix operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["R interface"]
  node_r_api["Matrix API<br/>[bigmemory.R]"]
  node_bindings["Native bindings<br/>[RcppExports.R]"]
end

subgraph group_native["Native operations"]
  node_native_bindings["Rcpp entry points<br/>[RcppExports.cpp]"]
  node_matrix_ops["Matrix operations<br/>[bigmemory.cpp]"]
  node_copy["Deep copy<br/>[deepcopy.cpp]"]
end

subgraph group_storage["Matrix storage"]
  node_local["Local matrices<br/>[BigMatrix.cpp]"]
  node_shared_counter["Shared lifetime<br/>[SharedCounter.cpp]"]
  node_shared_memory[("Shared memory<br/>[BigMatrix.cpp]")]
  node_mapped_files[("Mapped files<br/>[BigMatrix.cpp]")]
end

subgraph group_framework["C++ framework"]
  node_matrix_object["BigMatrix types<br/>[BigMatrix.h]"]
  node_accessors["Typed accessors<br/>[MatrixAccessor.hpp]"]
end

node_user(("R user"))
node_advanced["Extension packages"]

node_user -->|"uses"| node_r_api
node_r_api -->|"invokes"| node_bindings
node_bindings -->|"dispatches"| node_native_bindings
node_native_bindings -->|"calls"| node_matrix_ops
node_native_bindings -->|"calls"| node_copy
node_matrix_ops -->|"operates on"| node_matrix_object
node_copy -->|"copies between"| node_matrix_object
node_matrix_ops -->|"accesses data"| node_accessors
node_copy -->|"accesses data"| node_accessors
node_matrix_object -->|"allocates locally"| node_local
node_matrix_object -->|"uses shared storage"| node_shared_memory
node_matrix_object -->|"uses mapped storage"| node_mapped_files
node_shared_memory -->|"tracks usage"| node_shared_counter
node_r_api -.->|"supports extensions"| node_advanced

click node_r_api "https://github.com/kaneplusplus/bigmemory/blob/master/R/bigmemory.R"
click node_bindings "https://github.com/kaneplusplus/bigmemory/blob/master/R/RcppExports.R"
click node_native_bindings "https://github.com/kaneplusplus/bigmemory/blob/master/src/RcppExports.cpp"
click node_matrix_ops "https://github.com/kaneplusplus/bigmemory/blob/master/src/bigmemory.cpp"
click node_copy "https://github.com/kaneplusplus/bigmemory/blob/master/src/deepcopy.cpp"
click node_local "https://github.com/kaneplusplus/bigmemory/blob/master/src/BigMatrix.cpp"
click node_shared_counter "https://github.com/kaneplusplus/bigmemory/blob/master/src/SharedCounter.cpp"
click node_matrix_object "https://github.com/kaneplusplus/bigmemory/blob/master/inst/include/bigmemory/BigMatrix.h"
click node_accessors "https://github.com/kaneplusplus/bigmemory/blob/master/inst/include/bigmemory/MatrixAccessor.hpp"
click node_shared_memory "https://github.com/kaneplusplus/bigmemory/blob/master/src/BigMatrix.cpp"
click node_mapped_files "https://github.com/kaneplusplus/bigmemory/blob/master/src/BigMatrix.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_r_api,node_bindings,node_user toneBlue
class node_native_bindings,node_matrix_ops,node_copy toneAmber
class node_local,node_shared_counter,node_shared_memory,node_mapped_files toneMint
class node_matrix_object,node_accessors toneRose
class node_advanced toneIndigo
```

## Components

### R interface

- [Matrix API](https://github.com/kaneplusplus/bigmemory/blob/master/R/bigmemory.R): `R/bigmemory.R`
- [Native bindings](https://github.com/kaneplusplus/bigmemory/blob/master/R/RcppExports.R): `R/RcppExports.R`

### Native operations

- [Rcpp entry points](https://github.com/kaneplusplus/bigmemory/blob/master/src/RcppExports.cpp): `src/RcppExports.cpp`
- [Matrix operations](https://github.com/kaneplusplus/bigmemory/blob/master/src/bigmemory.cpp): `src/bigmemory.cpp`
- [Deep copy](https://github.com/kaneplusplus/bigmemory/blob/master/src/deepcopy.cpp): `src/deepcopy.cpp`

### Matrix storage

- [Local matrices](https://github.com/kaneplusplus/bigmemory/blob/master/src/BigMatrix.cpp): `src/BigMatrix.cpp`
- [Shared lifetime](https://github.com/kaneplusplus/bigmemory/blob/master/src/SharedCounter.cpp): `src/SharedCounter.cpp`
- [Shared memory](https://github.com/kaneplusplus/bigmemory/blob/master/src/BigMatrix.cpp): `src/BigMatrix.cpp`
- [Mapped files](https://github.com/kaneplusplus/bigmemory/blob/master/src/BigMatrix.cpp): `src/BigMatrix.cpp`

### C++ framework

- [BigMatrix types](https://github.com/kaneplusplus/bigmemory/blob/master/inst/include/bigmemory/BigMatrix.h): `inst/include/bigmemory/BigMatrix.h`
- [Typed accessors](https://github.com/kaneplusplus/bigmemory/blob/master/inst/include/bigmemory/MatrixAccessor.hpp): `inst/include/bigmemory/MatrixAccessor.hpp`

### Other components

- **R user**
- **Extension packages**

## Connections

- R user → Matrix API: uses
- Matrix API → Native bindings: invokes
- Native bindings → Rcpp entry points: dispatches
- Rcpp entry points → Matrix operations: calls
- Rcpp entry points → Deep copy: calls
- Matrix operations → BigMatrix types: operates on
- Deep copy → BigMatrix types: copies between
- Matrix operations → Typed accessors: accesses data
- Deep copy → Typed accessors: accesses data
- BigMatrix types → Local matrices: allocates locally
- BigMatrix types → Shared memory: uses shared storage
- BigMatrix types → Mapped files: uses mapped storage
- Shared memory → Shared lifetime: tracks usage
- Matrix API → Extension packages: supports extensions
