Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
mdspan_matrix_view_example.cc File Reference

Aleph::mdspan as a zero-copy 2D "matrix" view over a flat buffer. More...

#include <iostream>
#include <vector>
#include <ah-mdspan.H>
#include <print_rule.H>
Include dependency graph for mdspan_matrix_view_example.cc:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Aleph::mdspan as a zero-copy 2D "matrix" view over a flat buffer.

Overview

Aleph::mdspan never owns memory: it is a pointer plus a shape. This example walks through the case that motivates it most directly — numerical code that already works with a flat, contiguous buffer (Array<T>, std::vector<T>, a T* from a C library, ...) and wants readable m(row, col) indexing without transposing or copying anything.

  • [1] Row-major (the default): wrap a flat buffer and index it like a matrix, matching the C/row-major convention Aleph itself uses.
  • [2] Column-major interop: view the same buffer as column-major (Aleph::layout_left) without moving a single byte — useful when interfacing with Fortran/BLAS-style routines that expect that layout.
  • [3] Read-only views: mdspan<const T, ...> exposes a buffer for reading without allowing the view to mutate it.

Definition in file mdspan_matrix_view_example.cc.

Function Documentation

◆ main()

int main ( void  )