Skip to content

Commit

Permalink
Merge branch 'ankith26-gsoc' of https://github.com/ankith26/PyElastica
Browse files Browse the repository at this point in the history
…into ankith26-gsoc
  • Loading branch information
skim0119 committed Jul 13, 2024
2 parents d92a09c + 63b1c27 commit 96f67a3
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 6 deletions.
12 changes: 12 additions & 0 deletions backend/buildscripts/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,16 @@ if [ ! -d sleef ]; then
cd ..
fi

# brigand
if [ ! -d brigand ]; then
git clone --depth 1 https://github.com/edouarda/brigand.git && cd brigand

mkdir build
cmake -B build $ELASTICA_BASE_CMAKE_FLAGS \
-S .
cmake --build build --parallel $(nproc)
cmake --install build
cd ..
fi

cd $OLD_CWD
9 changes: 8 additions & 1 deletion backend/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pybind11_dep = declare_dependency(
).stdout().strip(),
)

# python and pybind deps are used together
py_deps = [py_dep, pybind11_dep]

fs = import('fs')

message('Running buildscripts/build-all.sh (might take a while)')
Expand Down Expand Up @@ -93,7 +96,11 @@ endif
# blaze and deps commonly used together
blaze_deps = [blaze_dep, blaze_tensor_dep, sleef_dep]

brigand_dep = dependency('brigand', fallback : 'brigand')
brigand_dep = dependency('brigand', required: false)
if not brigand_dep.found()
brigand_dep = declare_dependency(include_directories: deps_inc_dirs)
endif

cxxopts_dep = dependency('cxxopts', fallback : 'cxxopts')

# meson-python: error: Could not map installation path to an equivalent wheel directory:
Expand Down
42 changes: 42 additions & 0 deletions backend/src/Utilities/AsTaggedTuple.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

//******************************************************************************
// Includes
//******************************************************************************
#include "Utilities/TMPL.hpp"
#include "Utilities/TaggedTuple.hpp"

namespace brigand {

//****************************************************************************
/*!\brief Transform any typelist into a tuples::TaggedTuple
* \ingroup type_traits
*
* \details
* Transform any typelist (such as a `tmpl::list`, `std::tuple` or even a
* tuples::TaggedTuple) into a tuples::TaggedTuple
*
* \usage
* For any typelist called `L`
* \code
* using result = tmpl::as_tagged_tuple<L>;
* \endcode
* \metareturns
* tuples::TaggedTuple
*
* \semantics
* If the type `L` is a typelist with types `Types...`
* \code
* result = tuples::TaggedTuple<Types...>;
* \endcode
*
* \example
* \snippet Test_AsTaggedTuple.cpp as_tagged_tuple_eg
*
* \tparam L type list to be converted to a tagged tuple
*/
template <typename L>
using as_tagged_tuple = wrap<L, tuples::tagged_tuple_wrapper>;
//****************************************************************************

} // namespace brigand
70 changes: 70 additions & 0 deletions backend/src/Utilities/StaticConst.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//==============================================================================
/*!
// \file
// \brief Create a static constant that avoids ODR violations
//
// Copyright (C) 2020-2020 Tejaswin Parthasarathy - All Rights Reserved
// Copyright (C) 2020-2020 MattiaLab - All Rights Reserved
//
// Distributed under the MIT License.
// See LICENSE.txt for details.
//
// This was taken from the Range v3 library with the following copyrights
** Copyright Eric Niebler 2013-present
**
** Use, modification and distribution is subject to the
** Boost Software License, Version 1.0. (See accompanying
** file LICENSE_1_0.txt or copy at
** http://www.boost.org/LICENSE_1_0.txt)
**
** Project home: https://github.com/ericniebler/range-v3
**
*/
//==============================================================================

#pragma once

namespace elastica {

//============================================================================
//
// CLASS DEFINITION
//
//============================================================================

//****************************************************************************
/*!\brief Holds a static compile-time constant
// \ingroup utils
//
// static_const is a helper to create and hold a static compile-time constant
//
// \usage
\code
// create a default initialized integer
constexpr auto zero = elastica::static_const<int>::value;
\endcode
//
// \example
// \snippet Test_StaticConst.cpp static_const_example
//
// \tparam T Type of static constant to create
*/
template <typename T>
struct static_const {
static constexpr T value{};
};
//****************************************************************************

//****************************************************************************
/*!\brief Variable template storage for a static compile-time constant
// \ingroup utils
//
// \tparam T Type of static constant to create
//
// \see static_const
*/
template <typename T>
constexpr T static_const<T>::value;
//****************************************************************************

} // namespace elastica
10 changes: 5 additions & 5 deletions backend/src/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
example_1 = py.extension_module(
'example_1',
sources: ['example_1.cpp'],
dependencies: [py_dep, pybind11_dep],
dependencies: py_deps,
link_language: 'cpp',
install: true,
subdir: package,
Expand All @@ -10,7 +10,7 @@ example_1 = py.extension_module(
_linalg = py.extension_module(
'_linalg',
sources: ['_linalg.cpp'],
dependencies: [py_dep, pybind11_dep] + blaze_deps,
dependencies: py_deps + blaze_deps,
link_language: 'cpp',
install: true,
subdir: package,
Expand All @@ -19,7 +19,7 @@ _linalg = py.extension_module(
_linalg_numpy = py.extension_module(
'_linalg_numpy',
sources: ['_linalg_numpy.cpp'],
dependencies: [py_dep, pybind11_dep] + blaze_deps,
dependencies: py_deps + blaze_deps,
link_language: 'cpp',
install: true,
subdir: package,
Expand All @@ -33,7 +33,7 @@ _PyArrays = py.extension_module(
'Utilities/Math/Python/BlazeMatrix.cpp',
'Utilities/Math/Python/BlazeTensor.cpp',
],
dependencies: [py_dep, pybind11_dep] + blaze_deps,
dependencies: py_deps + blaze_deps,
link_language: 'cpp',
install: true,
subdir: package,
Expand All @@ -45,7 +45,7 @@ _PyTags = py.extension_module(
'Systems/Python/Bindings.cpp',
'Systems/Python/BindTags.cpp',
],
dependencies: [py_dep, pybind11_dep] + blaze_deps,
dependencies: py_deps + blaze_deps + brigand_dep,
link_language: 'cpp',
install: true,
subdir: package,
Expand Down

0 comments on commit 96f67a3

Please sign in to comment.