GithubHelp home page GithubHelp logo

alifahrri / nmtools Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 6.85 MB

A generic, composable multi-dimensional array library.

CMake 1.02% C++ 98.65% Shell 0.18% Dockerfile 0.14% Python 0.01%
generic-programming cpp17 header-only numpy ndarray tensor multidimensional-arrays platformio

nmtools's Introduction

nmtools's People

Contributors

alifahrri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nmtools's Issues

add blas module

  • cleanup matvec, refactor to blas
  • saxpy, gaxpy, dot, outer, in addition to mul and add
  • constexpr support

cleanup interpolation module

  • use linalg::tridiagonal for solving spline
  • provide options to return callable instead of directly compute the results
  • clean-up meta functions
  • add linear splne

compiler error notes: Clang constexpr variable lifetime

clang error: note: read of variable whose lifetime has ended

branch: https://github.com/alifahrri/nmtools/tree/clang-compile-error-constexpr-variable-lifetime

CI log (clang-14)

2022-10-01T13:26:22.6894603Z In file included from /work/tests/meta/array/view/moveaxis.cpp:5:
2022-10-01T13:26:22.6895063Z In file included from /work/include/nmtools/array/view/moveaxis.hpp:4:
2022-10-01T13:26:22.6895649Z In file included from /work/include/nmtools/array/index/argsort.hpp:5:
2022-10-01T13:26:22.6919427Z /work/include/nmtools/array/shape.hpp:242:47: error: non-type template argument is not a constant expression
2022-10-01T13:26:22.6939473Z                     }, nmtools_tuple<meta::ct<(size_t)at(fixed_shape,0)>>{});
2022-10-01T13:26:22.6943928Z                                               ^~~~~~~~~~~~~~~~~~~~~~~~~
2022-10-01T13:26:22.6951885Z /work/include/nmtools/array/view/transpose.hpp:42:50: note: in instantiation of function template specialization 'nmtools::shape<true, nmtools::array::ndarray_t<std::array<float, 12>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 2>, nmtools::meta::integral_constant<unsigned long, 6>>>>' requested here
2022-10-01T13:26:22.6956189Z         using src_shape_type = decltype(nmtools::shape</*force_constant_index*/true>(meta::declval<array_t>()));
2022-10-01T13:26:22.6959811Z                                                  ^
2022-10-01T13:26:22.6966252Z /work/include/nmtools/array/view/decorator.hpp:129:26: note: in instantiation of template class 'nmtools::view::transpose_t<nmtools::array::ndarray_t<std::array<float, 12>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 2>, nmtools::meta::integral_constant<unsigned long, 6>>>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 0>, nmtools::meta::integral_constant<unsigned long, 2>>>' requested here
2022-10-01T13:26:22.6971507Z     struct decorator_t : view_t<Ts...>
2022-10-01T13:26:22.6971763Z                          ^
2022-10-01T13:26:22.6983224Z /work/include/nmtools/array/view/transpose.hpp:100:16: note: in instantiation of template class 'nmtools::view::decorator_t<nmtools::view::transpose_t, nmtools::array::ndarray_t<std::array<float, 12>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 2>, nmtools::meta::integral_constant<unsigned long, 6>>>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 0>, nmtools::meta::integral_constant<unsigned long, 2>>>' requested here
2022-10-01T13:26:22.6984659Z         return decorator_t<transpose_t,array_t,axes_t>{{array,axes}};
2022-10-01T13:26:22.6984952Z                ^
2022-10-01T13:26:22.6992103Z /work/include/nmtools/array/view/moveaxis.hpp:37:56: note: in instantiation of function template specialization 'nmtools::view::transpose<nmtools::array::ndarray_t<std::array<float, 12>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 2>, nmtools::meta::integral_constant<unsigned long, 6>>>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 0>, nmtools::meta::integral_constant<unsigned long, 2>>>' requested here
2022-10-01T13:26:22.6994480Z         using result_t = meta::remove_cvref_t<decltype(transpose(array,*order))>;
2022-10-01T13:26:22.6995209Z                                                        ^
2022-10-01T13:26:22.7005677Z /work/tests/meta/array/view/moveaxis.cpp:54:44: note: in instantiation of function template specialization 'nmtools::view::moveaxis<nmtools::array::ndarray_t<std::array<float, 12>, std::tuple<nmtools::meta::integral_constant<unsigned long, 1>, nmtools::meta::integral_constant<unsigned long, 2>, nmtools::meta::integral_constant<unsigned long, 6>>>, nmtools::meta::integral_constant<unsigned long, 0>, nmtools::meta::integral_constant<unsigned long, 1>>' requested here
2022-10-01T13:26:22.7006825Z         using view_type   = decltype(view::moveaxis(meta::declval<array_type>(),meta::declval<src_type>(),meta::declval<dst_type>()));
2022-10-01T13:26:22.7008561Z                                            ^
2022-10-01T13:26:22.7013855Z /work/include/nmtools/array/shape.hpp:242:55: note: read of variable whose lifetime has ended
2022-10-01T13:26:22.7015592Z                     }, nmtools_tuple<meta::ct<(size_t)at(fixed_shape,0)>>{});
2022-10-01T13:26:22.7017908Z                                                       ^

works fine on gcc

related code: https://github.com/alifahrri/nmtools/blob/clang-compile-error-constexpr-variable-lifetime/include/nmtools/array/shape.hpp#L236

                constexpr auto fixed_shape = meta::fixed_shape_v<array_t>;
                if constexpr (!meta::is_fail_v<decltype(fixed_shape)>) {
                    return meta::template_reduce<len(fixed_shape)-1>([&](auto init, auto index){
                        using init_type = decltype(init);
                        using type = meta::append_type_t<init_type,meta::ct<(size_t)at(fixed_shape,index+1)>>;
                        return type{};
                    }, nmtools_tuple<meta::ct<(size_t)at(fixed_shape,0)>>{});
                } else {
                    return impl::shape<array_t>(array);
                }

clean-up cmake

  • make installable
  • easily find package
  • reduce duplication using macro/function

cleanup curvefit

  • make sinusoid to return value instead of taking reference
  • add docs
  • constexpr support

add inverse

add functional inverse frontend with eigen and armadillo backend

add gauss elimination

  • forward elimination
  • backward substitution
  • naive gauss elimination
  • gauss elimination with pivot & scales

make finite difference to return value instead of taking reference

from

template <size_t order, Formulas formula = Formulas::Centered, typename F, typename Scalar>
        void finite_difference(F &f, Scalar x, Scalar step, Scalar &d)
        {
            detail::finite_difference(detail::Order<order>{}, detail::ComputeType<formula>{}, f, x, step, d);
        }

to

template <size_t order, Formulas formula = Formulas::Centered, typename F, typename Scalar>
        auto finite_difference(F &f, Scalar x, Scalar step)
        {
            return detail::finite_difference(detail::Order<order>{}, detail::ComputeType<formula>{}, f, x, step);
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.