Typed Linear Algebra 0.1.0
Typed Linear Algebra
Loading...
Searching...
No Matches
Typed Linear Algebra

This library provides a C++ statically type-safe linear algebra facade to the Eigen linear algebra library.

Installation

Example of installation commands in Shell:

git clone --depth 1 "https://github.com/FrancoisCarouge/TypedLinearAlgebra"
cmake -S "TypedLinearAlgebra" -B "build"
cmake --build "build" --parallel
sudo cmake --install "build"

Another variation for your CMake infrastructure via fetch content:

include(FetchContent)
FetchContent_Declare(
fcarouge-typed-linear-algebra
GIT_REPOSITORY "https://github.com/FrancoisCarouge/TypedLinearAlgebra"
FIND_PACKAGE_ARGS NAMES fcarouge-typed-linear-algebra)
FetchContent_MakeAvailable(fcarouge-typed-linear-algebra)
target_link_libraries(your_target PRIVATE fcarouge-typed-linear-algebra::linalg)

For more, see installation instructions.

Reference

Class Typed Matrix

Strongly typed matrix. Compose a linear algebra backend matrix into a typed matrix. Row and column indexes provide each element's index type.

Also documented in the fcarouge/typed_linear_algebra.hpp header.

Declaration

template <typename Matrix, typename RowIndexes, typename ColumnIndexes>
class typed_matrix

Template Parameters

Template Parameter Definition
Matrix The underlying linear algebra matrix.
RowIndexes The tuple type of the row indexes.
ColumnIndexes The tuple type of the row indexes.

Member Types

Member Type Definition
underlying The type of the element's underlying storage.
row_indexes The tuple with the row components of the indexes.
column_indexes The tuple with the column components of the indexes.
element<i, j> The type of the element at the given matrix indexes position.

Member Functions

Member Function Definition
(default constructor) Construct a default typed matrix.
(default copy constructor) Copy construct the typed matrix.
(default copy assignment operator) Copy assign a typed matrix.
(default move constructor) Move construct a typed matrix.
(default move assignment operator) Move construct a typed matrix.
(conversion copy constructor) Copy construct the typed matrix from another typed matrix with a compatible underlying matrix or from a compatible underlying matrix.
(conversion copy constructor) Copy construct the typed column-vector from a parameter pack or C-style array.
(conversion copy constructor) Copy construct the typed row-vector from a parameter pack or C-style array.
(conversion copy constructor) Copy construct the typed singletin matrix from the sole element.
operator[i, j] Access the specified element.
operator(i, j) Access the specified element.
at<i, j>() Access the specified element.
(conversion operator) Access the singleton element.
(destructor) Destruct a default typed matrix.

Structure Element Caster

Typed matrix element conversions customization point. Specialize this template to allow conversion of element's type and underlying type.

template <typename To, typename From> struct element_caster

Aliases

template <typename Matrix, typename... ColumnIndexes>
typed_row_vector;
template <typename Matrix, typename... RowIndexes>
typed_column_vector;

Format

A specialization of the standard formatter is provided for the typed matrix. Use std::format to store a formatted representation of the matrix. Standard format parameters to be supported.

Considerations

Lessons Learned

Type safety cannot be guaranteed at compilation time without index safety. The indexes can either be non-type template parameters or strong types overloadings. Converting a runtime index to a dependent template type is not possible in C++. A proxy reference could be used to allow traditional assignment syntax but the runtime check and extra indirection are not interesting tradeoffs. A template call operator can be used for getting a type safe value but impractical syntax for setting. Without index safety, the accepted tradeoff is a templated index at<i, j>() method.

Performance

Projects

The library is used in projects:

  • Kalman: A Kalman filter library.

Your project link here!

Resources

Third Party Acknowledgement

The library is designed, developed, and tested with the help of third-party tools and services acknowledged and thanked here:

  • actions-gh-pages to upload the documentation to GitHub pages.
  • Clang for compilation and code sanitizers.
  • CMake for build automation.
  • cmakelang for pretty CMake list files.
  • cppcheck for static analysis.
  • Doxygen for documentation generation.
  • Doxygen Awesome for pretty documentation.
  • Eigen for linear algebra.
  • GCC for compilation and code sanitizers.
  • lcov to process coverage information.
  • mp-units the quantities and units library for C++.
  • MSVC for compilation and code sanitizers.
  • Valgrind to check for correct memory management.

Sponsors

Become a sponsor today! Support this project with coffee and infrastructure!

Sponsor

Corporations & Institutions

Your group logo and link here!

Individuals

Your name and link here!

Thanks everyone!

Continuous Integration & Deployment Actions

Code Repository

Pipeline

Sanitizer
Format
ClangTidy
CppCheck
Doxygen
Valgrind

Public Domain
License Scan
OpenSSF Best Practices

Deploy Unit Test Code Coverage
Deploy Doxygen

Sponsor

License

TypedLinearAlgebra is public domain:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to https://unlicense.org