Skip to content

Commit 8e04306

Browse files
committed
Simplify view conversions, view ops
* ra/arrays.hh (ViewBig, ViewSmall): Replace const/unconst conversions with conversions from Slice. (reconst, unconst): Unused, remove. (reshape, colapse, stencil): Take Slice arguments.
1 parent 3238743 commit 8e04306

File tree

7 files changed

+146
-186
lines changed

7 files changed

+146
-186
lines changed

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
**ra-ra** implements [expression templates](https://en.wikipedia.org/wiki/Expression_templates). This is a C++ technique (pioneered by [Blitz++](http://blitz.sourceforge.net)) to delay the execution of expressions involving array operands, and in this way avoid the unnecessary creation of large temporary array objects.
99

10-
**ra-ra** is compact (≈4k loc), easy to extend, and generic. There are no arbitrary type restrictions or limits on rank or argument count.
10+
**ra-ra** is compact, generic, and easy to extend.
1111

12-
In this example ([examples/read-me.cc](examples/read-me.cc)), we create some arrays, do operations on them, and print the result.
12+
In this example ([examples/read-me.cc](examples/read-me.cc)), we create some arrays, operate on them, and print the result.
1313

1414
```c++
1515
#include "ra/ra.hh"
@@ -38,7 +38,7 @@ B:
3838
{215.00, 218.00, -221.00, -224.00}}
3939
```
4040
41-
Please check the manual online at [lloda.github.io/ra-ra](https://lloda.github.io/ra-ra), or have a look at the [examples/](examples/) folder.
41+
Check the manual at [lloda.github.io/ra-ra](https://lloda.github.io/ra-ra), or have a look at the [examples/](examples/).
4242
4343
**ra-ra** offers:
4444
@@ -50,48 +50,45 @@ Please check the manual online at [lloda.github.io/ra-ra](https://lloda.github.i
5050
* iterators over subarrays (cells) of any rank
5151
* rank conjunction as in J (compile time rank only), outer product operation
5252
* short-circuiting logical operators
53-
* operators to select from argument list using either bool or integer (`where`, `pick`)
53+
* operators to select from argument list (`where`, `pick`)
5454
* view operations: reshape, transpose, reverse, collapse/explode, stencils
5555
* arbitrary types as array elements, or as scalar operands
56-
* many predefined array operations, adding yours is trivial
56+
* many predefined array operations; adding yours is trivial
5757
* configurable error handling
5858
* as much `constexpr` as possible.
5959
60-
Performance is competitive with hand written scalar (element by element) loops, but probably not with cache-tuned code such as your platform BLAS, or with code using SIMD. Please have a look at the benchmarks in [bench/](bench/).
60+
Performance is competitive with hand written scalar (element by element) loops, but probably not with cache-tuned code such as your platform BLAS, or with code using SIMD. Have a look at the benchmarks in [bench/](bench/).
6161
6262
#### Building the tests and the benchmarks
6363
64-
**ra-ra** is header-only and has no dependencies other than a C++23 compiler and the standard library. At the moment I test with gcc 14.2. If you can test with Clang, please let me know.
64+
**ra-ra** is header-only and only depends on the standard library. A C++23 compiler is required. At the moment I test with gcc 14. If you can test with Clang, please let me know.
6565
66-
The test suite in [test/](test/) runs under either SCons (`CXXFLAGS=-O3 scons`) or CMake (`CXXFLAGS=-O3 cmake . && make && make test`). Running the test suite will also build and run the [examples](examples/) and the [benchmarks](bench/). Please check the manual for options.
66+
The test suite in [test/](test/) runs under either SCons (`CXXFLAGS=-O3 scons`) or CMake (`CXXFLAGS=-O3 cmake . && make && make test`). Running the test suite will also build and run the [examples](examples/) and the [benchmarks](bench/). Check the manual for options.
6767
6868
#### Notes
6969
7070
* Both index and size types are signed. Index base is 0.
71-
* The default array order is C or row-major (last dimension changes fastest). You can make array views with other orders, but newly created arrays use C order.
71+
* The default array order is C or row-major (last dimension changes fastest). You can make array views with other orders.
7272
* The subscripting operator is `()` or `[]`, indistinctly.
73-
* Indices are checked by default. This can be disabled with a compilation flag.
73+
* Indices are checked by default. Checks can be disabled with a compilation flag.
7474
7575
#### Bugs & defects
7676
7777
* Operations that require allocation, such as concatenation or search, are mostly absent.
7878
* No good abstraction for reductions. You can write reductions abusing rank extension, but it's awkward.
79-
* Traversal of arrays is basic, just unrolling of inner dimensions.
79+
* Basic array traversal, just unrolling of inner dimensions.
8080
* Handling of nested / ragged arrays is inconsistent.
81-
* No support for parallel operations or GPU.
82-
* No SIMD to speak of.
83-
84-
Please see the TODO file for a concrete list of known issues.
81+
* No parallel operations, GPU, or SIMD (but should be thread safe).
8582
8683
#### Motivation
8784
88-
I do numerical work in C++, and I need support for array operations. The built-in array types that C++ inherits from C are very insufficient, so at the time of C++11 when I started writing **ra-ra**, a number of libraries were already available. However, most of these libraries seemed to support only vectors and matrices, or small objects for vector algebra.
85+
I do numerical work in C++, and I need support for array operations. The built-in array types that C++ inherits from C are insufficient, so at the time of C++11 when I started writing **ra-ra**, a number of libraries were already available. However, most of these libraries seemed to support only vectors and matrices, or small objects for vector algebra.
8986
9087
Blitz++ was a major inspiration as an early *generic* library. But it was a heroic feat to write such a library in C++ in the late 90s. Variadic templates, lambdas, perfect forwarding, etc. make things much easier, for the library writer as well as for the user.
9188
92-
From APL and J I've taken the rank extension mechanism, and perhaps an inclination for carrying each feature to its logical end.
89+
From APL and J I've taken the rank extension mechanism, as well as an inclination for carrying each feature to its logical end.
9390
94-
**ra-ra** wants to remain simple. I try not to second-guess the compiler and I don't stress performance as much as Blitz++ did. However, I'm wary of adding features that could become an obstacle if I ever tried to make things fast(er). I believe that implementating new traversal methods, or perhaps optimizing specific expression patterns, should be possible without having to turn the library inside out.
91+
I want **ra-ra** to remain simple. I try not to second-guess the compiler and I don't fret over performance as much as Blitz++ did. However, I'll avoid features that could become an obstacle if I ever tried to make things fast(er). It should be possible to implement new traversal methods, or perhaps optimize specific expression patterns, without having to turn the library inside out.
9592
9693
#### Other C++ array libraries
9794

0 commit comments

Comments
 (0)