Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8607959
Remove old build status flag
kylekrol Apr 20, 2020
5bf1a86
Add updated status icon to README
kylekrol Apr 20, 2020
9d65edb
Merge pull request #1 from kkrol27/master
kylekrol Apr 22, 2020
f0aa199
Merge pull request #2 from kkrol27/master
kylekrol Apr 28, 2020
a125238
Added Default Template size for RowVector. (#3)
nhz2 Apr 30, 2020
fa44ecf
Merge branch 'master' of https://github.com/kkrol27/lin into kkrol27-…
kylekrol May 7, 2020
2e12088
Merge branch 'kkrol27-master'
kylekrol May 7, 2020
e4b11d2
autodeploy github pages
kylekrol May 7, 2020
6da39ca
Merge pull request #5 from kkrol27/master
kylekrol May 7, 2020
14cbed7
Merge pull request #6 from kkrol27/master
kylekrol May 10, 2020
a6a6649
Add docs link to README (#8)
kylekrol May 16, 2020
f8fafaa
Merge pull request #7 from kkrol27/master
kylekrol May 18, 2020
234da26
Create WORKSPACE
tanishqaggarwal Jul 14, 2020
f449083
Create BUILD
tanishqaggarwal Jul 14, 2020
6b3da39
Merge upstream updates
kylekrol Jul 14, 2020
cc59a42
Testing
tanishqaggarwal Jul 14, 2020
bfd7df9
Merge branch 'master' into bazel
tanishqaggarwal Jul 14, 2020
61271e7
Merge pull request #10 from pathfinder-for-autonomous-navigation/upst…
kylekrol Jul 15, 2020
08afacf
Merge branch 'master' into bazel
tanishqaggarwal Jul 15, 2020
c9b2b4c
Merge pull request #11 from pathfinder-for-autonomous-navigation/bazel
tanishqaggarwal Jul 15, 2020
8744f68
Merge upstream updates
kylekrol Jul 18, 2020
64cde77
Merge upstream updates
kylekrol Jul 19, 2020
1adce4f
Merge pull request #12 from pathfinder-for-autonomous-navigation/upst…
kylekrol Jul 19, 2020
fb7ff06
Remove case sensitive FS naming issue with pip install. (#13)
kylekrol Sep 25, 2020
5dd5d10
Update setup.py to fix build issues on OSX (#15)
kylekrol Oct 20, 2020
34529a9
Update library.json to prevent PIO from trying to compiler a library …
kylekrol Oct 21, 2020
85f5338
Gaussian (Standard Normal) Number Generators (#16)
shihaocao Nov 26, 2020
e77b835
Fix reorder warning (#17)
kylekrol Nov 27, 2020
6ef5235
Update pybind11 for Python 3.9.0 (#18)
kylekrol Dec 3, 2020
c8ab410
Square Brackets Operator (#19)
kylekrol Jan 2, 2021
dc85049
Add Const Views to the Views Module (#20)
kylekrol Jan 5, 2021
f0b5824
Update CI to Include GH Pages Deployment (#21)
kylekrol Jan 5, 2021
b1b53aa
Refactor References Module (#22)
kylekrol Jan 27, 2021
915d9af
Update formatting of the views module (#24)
kylekrol Feb 1, 2021
45fbd83
Added diag function to generators and references (#23)
kylekrol Feb 1, 2021
adf71e9
Mapping transpose operation
kylekrol Feb 10, 2021
faaef35
Updated class comments
kylekrol Feb 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build --cxxopt=-std=c++14
build --cxxopt=-std=c++14
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
.DS_Store
.vscode
build
tmp
docs/*
!docs/Doxyfile
!docs/DoxygenLayout.xml
!docs/index.html
build/
bazel-*/
venv
.venv
__pycache__
.eggs
.pytest_cache
lin.cpp
bazel-*
bazel-*
compile_commands.json
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ matrix:
- pip install -vvv .
script:
- pytest -v test_lin.py
- sudo: false
branches:
only:
- master
addons:
apt:
packages:
- doxygen
script:
- cd docs && doxygen && cd ..
deploy:
provider: pages
skip_cleanup: true
local_dir: docs/html
github_token: $GH_REPO_TOKEN
on:
branch: master
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2020 kkrol27
Copyright (c) 2020 kylekrol
Copyright (c) 2020 Pathfinder for Autonomous Navigation (PAN)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# lin

[![Build Status](https://travis-ci.com/kkrol27/lin.svg?branch=master)](https://travis-ci.com/kkrol27/lin)
[![Build Status](https://travis-ci.com/pathfinder-for-autonomous-navigation/lin.svg?branch=master)](https://travis-ci.com/pathfinder-for-autonomous-navigation/lin)

Linear algebra library solely using static memory alocation. It's been developed primarily for the [PAN](https://github.com/pathfinder-for-autonomous-navigation) mission.

Expand Down Expand Up @@ -32,6 +32,8 @@ Documentation can be built with doxygen by running:

and then opening `docs/html/index.html`. Starting at the modules page will be most helpful.

The documentation is also hosted online at https://pathfinder-for-autonomous-navigation.github.io/lin/modules.html

## Python Bindings

There is a small python module wrapping a few basic types from `lin` that have `double` elements. All of the core module is implemented with a handful of helpful additions. The source code for the it is generated at install time by the `setup.py` file.
Expand All @@ -47,3 +49,4 @@ For running tests locally using a virtual environment may be useful:
pip install -r requirements.txt
pip install . -vvv
pytest -v test_lin.py

File renamed without changes.
12 changes: 12 additions & 0 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,18 @@ INPUT = \
../include/lin/views/tensor_view.hpp \
../include/lin/views/matrix_view.hpp \
../include/lin/views/vector_view.hpp \
../include/lin/views/const_tensor_view.hpp \
../include/lin/views/const_matrix_view.hpp \
../include/lin/views/const_vector_view.hpp \
../include/lin/references.hpp \
../include/lin/references/tensor_mapping_reference.hpp \
../include/lin/references/matrix_mapping_reference.hpp \
../include/lin/references/vector_mapping_reference.hpp \
../include/lin/references/diagonal_mapping_reference.hpp \
../include/lin/references/tensor_stream_reference.hpp \
../include/lin/references/matrix_stream_reference.hpp \
../include/lin/references/vector_stream_reference.hpp \
../include/lin/references/diagonal_stream_reference.hpp \
../include

# This tag can be used to specify the character encoding of the source files
Expand Down
107 changes: 107 additions & 0 deletions include/lin/core/operations/mapping_transpose.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// vim: set tabstop=2:softtabstop=2:shiftwidth=2:expandtab

/** @file lin/core/operations/mapping_transpose.hpp
* @author Kyle Krol
*/

#ifndef LIN_CORE_OPERATIONS_MAPPING_TRANSPOSE_HPP_
#define LIN_CORE_OPERATIONS_MAPPING_TRANSPOSE_HPP_

namespace lin {
namespace internal {

/** @brief Proxy to a lazily evalutated transpose operation.
*
* @tparam Cs %Tensor type.
*
* Details to come...
*
* @ingroup COREOPERATIONS
*/
template <class C>
class MappingTranspose : public Mapping<MappingTranspose<C>> {
private:
/** @brief Mapping reference.
*/
Mapping<C> &c;

public:
/** @brief Traits information for this type.
*
* @sa internal::traits
*/
typedef traits<MappingTranspose<C>> Traits;

protected:
using Mapping<MappingTranspose<C>>::derived;

public:
using Mapping<MappingTranspose<C>>::size;
using Mapping<MappingTranspose<C>>::eval;
using Mapping<MappingTranspose<C>>::operator();
using Mapping<MappingTranspose<C>>::operator=;

constexpr MappingTranspose() = delete;
constexpr MappingTranspose(MappingTranspose<C> const &) = default;
constexpr MappingTranspose(MappingTranspose<C> &&) = default;
constexpr MappingTranspose<C> &operator=(MappingTranspose<C> const &) = default;
constexpr MappingTranspose<C> &operator=(MappingTranspose<C> &&) = default;

/** @brief Constructs a proxy to a tensor transpose operation.
*
* @param c %Tensor mapping.
*/
constexpr MappingTranspose(Mapping<C> &c)
: c(c) { }

/** @return Number of rows in the tensor.
*/
constexpr size_t rows() const {
return c.cols();
}

/** @return Number of columns in the tensor.
*/
constexpr size_t cols() const {
return c.rows();
}

/** @brief Read write access to the requested tensor element.
*
* @param i Row index.
* @param j Column index.
*
* @return Reference to the tensor element.
*/
constexpr typename Traits::elem_t &operator()(size_t i, size_t j) {
return c(j, i);
}

/** @brief Read write access to the requested tensor element.
*
* @param i Index.
*
* @return Reference to the tensor element.
*
* Element access proceeds as if all the elements of the tensor stream were
* flattened into an array in row major order.
*/
constexpr typename Traits::elem_t &operator()(size_t i) {
return (*this)(i / cols(), i % cols());
}
};

template <class C>
struct _elem<MappingTranspose<C>> : _elem<C> { };

template <class C>
struct _dims<MappingTranspose<C>> {
static constexpr size_t rows = _dims<C>::cols;
static constexpr size_t cols = _dims<C>::rows;
static constexpr size_t max_rows = _dims<C>::max_cols;
static constexpr size_t max_cols = _dims<C>::max_rows;
};
} // namespace internal
} // namespace lin

#endif
7 changes: 7 additions & 0 deletions include/lin/core/operations/tensor_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../traits.hpp"
#include "../types.hpp"
#include "functors.hpp"
#include "mapping_transpose.hpp"
#include "stream_element_wise_operator.hpp"
#include "stream_transpose.hpp"

Expand Down Expand Up @@ -316,6 +317,12 @@ constexpr auto sum(internal::Stream<C> const &c) {
return x;
}

template <class C, std::enable_if_t<
internal::matches_tensor<C>::value, size_t> = 0>
constexpr auto transpose(internal::Mapping<C> &c) {
return internal::MappingTranspose<C>(c);
}

template <class C, std::enable_if_t<
internal::matches_tensor<C>::value, size_t> = 0>
constexpr auto transpose(internal::Stream<C> const &c) {
Expand Down
1 change: 1 addition & 0 deletions include/lin/core/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define LIN_CORE_TYPES_HPP_

#include "types/base.hpp"
#include "types/const_base.hpp"
#include "types/dimensions.hpp"
#include "types/mapping.hpp"
#include "types/matrix.hpp"
Expand Down
10 changes: 5 additions & 5 deletions include/lin/core/types/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace lin {
namespace internal {

/** @brief %Value backed tensor interface with resizing support.
/** @brief Value backed tensor interface with resizing support.
*
* @tparam D Derived type.
*
Expand All @@ -26,8 +26,8 @@ namespace internal {
* added. A getter to retrive a pointer to the element backing array is also
* included.
*
* The main purpose is to provide an interface that supports value backed types -
* i.e. those directly storing tensor elements in a member array or and a
* The main purpose is to provide an interface that supports value backed types
* - i.e. those directly storing tensor elements in a member array or and a
* pointer.
*
* @sa internal::Stream
Expand Down Expand Up @@ -72,7 +72,7 @@ class Base : public Mapping<D>, public Dimensions<D> {
* @returns Pointer to the backing array.
*
* The elements of the tensor are layed out in row major order in the backing
* array. They are stored continguously in memory.
* array. They are stored contiguously in memory.
*/
inline constexpr typename Traits::elem_t *data() {
return derived().data();
Expand All @@ -83,7 +83,7 @@ class Base : public Mapping<D>, public Dimensions<D> {
* @returns Constant pointer to the backing array.
*
* The elements of the tensor are layed out in row major order in the backing
* array. They are stored continguously in memory.
* array. They are stored contiguously in memory.
*/
inline constexpr typename Traits::elem_t const *data() const {
return const_cast<D &>(derived()).data();
Expand Down
118 changes: 118 additions & 0 deletions include/lin/core/types/const_base.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// vim: set tabstop=2:softtabstop=2:shiftwidth=2:expandtab

/** @file lin/core/types/const_base.hpp
* @author Kyle Krol
*/

#ifndef LIN_CORE_TYPES_CONST_BASE_HPP_
#define LIN_CORE_TYPES_CONST_BASE_HPP_

#include "../config.hpp"
#include "../traits.hpp"
#include "dimensions.hpp"
#include "stream.hpp"

namespace lin {
namespace internal {

/** @brief Value backed, read only tensor interface.
*
* @tparam D Derived type.
*
* This is the third of the three main entry points on the lin inheritance tree
* after internal::Mapping.
*
* Here, direct tracking of runtime dimensions and the ability to resize is
* added. A getter to retrive a pointer to the element backing array is also
* included.
*
* The main purpose is to provide an interface that supports value backed types -
* i.e. those directly storing tensor elements in a member array or and a
* pointer.
*
* @sa internal::Stream
* @sa internal::Mapping
* @sa internal::Tensor
*
* @ingroup CORETYPES
*/
template <class D>
class ConstBase : public Stream<D>, public Dimensions<D> {
static_assert(has_valid_traits<D>::value,
"Derived types to ConstBase<...> must have valid traits");

public:
/** @brief Traits information for this type.
*
* @sa internal::traits
*/
typedef traits<D> Traits;

protected:
using Stream<D>::derived;

public:
using Stream<D>::size;
using Stream<D>::eval;
using Stream<D>::operator();

using Dimensions<D>::rows;
using Dimensions<D>::cols;
using Dimensions<D>::resize;

constexpr ConstBase() = default;
constexpr ConstBase(ConstBase<D> const &) = default;
constexpr ConstBase(ConstBase<D> &&) = default;
constexpr ConstBase<D> &operator=(ConstBase<D> const &) = default;
constexpr ConstBase<D> &operator=(ConstBase<D> &&) = default;

/** @brief Retrives a constant pointer to the element backing array.
*
* @returns Constant pointer to the backing array.
*
* The elements of the tensor are layed out in row major order in the backing
* array. They are stored contiguously in memory.
*/
inline constexpr typename Traits::elem_t const *data() const {
return derived().data();
}

/** @brief Provides read only access to tensor elements.
*
* @param i Row index.
* @param j Column index.
*
* @return Value of the tensor element.
*
* If the indices are out of bounds as defined by the tensor's current
* dimensions, lin assertion errors will be triggered.
*/
constexpr typename Traits::elem_t const &operator()(size_t i, size_t j) const {
LIN_ASSERT(0 <= i && i < rows());
LIN_ASSERT(0 <= j && j < cols());

return data()[i * cols() + j];
}

/** @brief Provides read only access to tensor elements.
*
* @param i Index
*
* @return Value of the tensor element.
*
* Element access proceeds as if all the elements of the tensor stream were
* flattened into an array in row major order.
*
* If the index is out of bounds as defined by the tensor's current size, lin
* lin assertion errors will be triggered.
*/
constexpr typename Traits::elem_t const &operator()(size_t i) {
LIN_ASSERT(0 <= i && i < size());

return data()[i];
}
};
} // namespace internal
} // namespace lin

#endif
Loading