version 0.4
Ikarus::utils Namespace Reference

Classes

struct  CheckFlags
 Struct to hold flags for function checks. More...
 
struct  LoadDefault
 Empty struct representing a default load operation. More...
 
struct  SolverDefault
 Default functor for solving operations. More...
 
struct  UpdateDefault
 Default functor for updating operations. More...
 

Functions

void makeUniqueAndSort (std::ranges::random_access_range auto &r)
 Sorts and removes duplicate elements from a random access range.*. More...
 
template<typename Value >
auto appendUnique (std::ranges::random_access_range auto &r, Value &&v)
 Appends a value to the range if it is not already present. More...
 
template<class Container >
void printContent (Container &&c, std::ostream &os=std::cout)
 Prints the contents of a container to the specified output stream. More...
 
template<class Container >
auto transformValueRangeToPointerRange (Container &cont)
 Transforms a value range to a pointer range. More...
 
template<class Container >
auto transformPointerRangeToReferenceRange (Container &cont)
 Transforms a pointer range to a reference range. More...
 
template<typename Tuple , typename Predicate >
constexpr size_t find_if (Tuple &&tuple, Predicate pred)
 Finds the index of the first element in the tuple satisfying a predicate. More...
 
template<typename Tuple , typename Predicate >
bool none_of (Tuple &&tuple, Predicate pred)
 Checks if none of the elements in the tuple satisfy a given predicate. More...
 
template<typename Tuple , typename Predicate >
bool any_of (Tuple &&tuple, Predicate pred)
 Checks if any of the elements in the tuple satisfy a given predicate. More...
 
template<typename Tuple , typename Predicate >
auto filter (Tuple &&tuple, Predicate pred)
 Filters the elements of a tuple based on a given predicate. More...
 
template<typename... Types>
constexpr auto unique (std::tuple< Types... > &&tuple)
 Creates a tuple with unique types from the given tuple. More...
 
template<typename Tuple , typename Predicate >
constexpr size_t count_if (Tuple &&tuple, Predicate pred)
 Counts the number of elements in the tuple satisfying the given predicate. More...
 
template<template< auto... > class Type, typename Tuple >
constexpr int findTypeSpecialization ()
 Finds the index of the first element in the tuple that is a specialization of the given template type. More...
 
template<template< auto... > class Type, typename Tuple >
auto getSpecialization (Tuple &&tuple)
 Gets the specialization of the given template type from the tuple. More...
 
template<template< auto... > class Type, typename Tuple >
constexpr bool hasTypeSpecialization ()
 Checks if a tuple has a specialization of a template type. More...
 
template<template< auto... > class Type, typename Tuple >
constexpr bool countTypeSpecialization ()
 Counts the occurrences of a specialization of a template type in a tuple. More...
 
template<int N, class Tuple >
constexpr auto makeTupleSubset (Tuple &&t)
 Creates a subset tuple with the first N elements from the given tuple. More...
 
template<class Tuple , std::size_t... I>
constexpr auto makeTupleFromTupleIndices (Tuple &&t)
 Creates a new tuple using indices from the original tuple. More...
 
template<typename... Types>
auto makeNestedTupleFlat (std::tuple< Types... >)
 Creates a flattened nested tuple. More...
 
template<typename Tuple >
auto makeNestedTupleFlatAndStoreReferences (Tuple &&tup)
 Creates a flattened nested tuple and stores references. More...
 
template<typename T >
requires traits::Pointer<T>
auto & returnReferenceOrNulloptIfObjectIsNullPtr (T v)
 Returns a reference or std::nullopt if the object is a nullptr. More...
 
template<typename Fun , typename... Vars, typename... Args, typename U , typename G , typename H >
void hessianN (const Fun &f, const autodiff::Wrt< Vars... > &wrt, const autodiff::At< Args... > &at, U &u, std::array< G, U::RowsAtCompileTime > &g, std::array< H, U::RowsAtCompileTime > &h)
 Computes the Hessian matrix for each parameter of a given function.The Hessian matrix represents the second-order partial derivatives of the function with respect to the specified variables. More...
 
std::tuple< Dune::Functions::Polynomial< double >, decltype(Eigen::seq(0, 0))> findLineSegment (const Eigen::VectorXd &x, const Eigen::VectorXd &y, int segmentSize)
 Find a linear segment in a set of data points. More...
 
template<int size, typename LocalView >
void obtainLagrangeNodePositions (const LocalView &localView, std::vector< Dune::FieldVector< double, size > > &lagrangeNodeCoords)
 A function to obtain the global positions of the nodes of an element with Lagrangian basis, see Dune book page 314. More...
 
template<typename NonlinearOperator , typename UpdateType = typename NonlinearOperator::template ParameterValue<0>>
bool checkGradient (NonlinearOperator &nonLinOp, CheckFlags checkFlags=CheckFlags(), std::function< void(typename NonlinearOperator::template ParameterValue< 0 > &, const UpdateType &)> p_updateFunction=[](typename NonlinearOperator::template ParameterValue< 0 > &a, const UpdateType &b) { a+=b;})
 Checks the gradient of a nonlinear operator. More...
 
template<typename NonlinearOperator , typename UpdateType = typename NonlinearOperator::template ParameterValue<0>>
bool checkJacobian (NonlinearOperator &nonLinOp, CheckFlags checkFlags=CheckFlags(), std::function< void(typename NonlinearOperator::template ParameterValue< 0 > &, const UpdateType &)> p_updateFunction=[](typename NonlinearOperator::template ParameterValue< 0 > &a, const UpdateType &b) { a+=b;})
 Checks the Jacobian of a nonlinear operator. More...
 
template<typename NonlinearOperator , typename UpdateType = typename NonlinearOperator::template ParameterValue<0>>
bool checkHessian (NonlinearOperator &nonLinOp, CheckFlags checkFlags=CheckFlags(), std::function< void(typename NonlinearOperator::template ParameterValue< 0 > &, const UpdateType &)> p_updateFunction=[](typename NonlinearOperator::template ParameterValue< 0 > &a, const UpdateType &b) { a+=b;})
 Checks the Hessian of a nonlinear operator. More...
 
std::tuple< Dune::Functions::Polynomial< double >, double > polyfit (const Eigen::Ref< const Eigen::VectorXd > &x, const Eigen::Ref< const Eigen::VectorXd > &y, int deg)
 Fits a polynomial of a given degree to the given data points. More...
 

Variables

template<template< auto... > class Type, typename Tuple >
static constexpr bool countTypeSpecialization_v = countTypeSpecialization<Type, Tuple>()
 Variable template for counting the occurrences of a specialization of a template type in a tuple. More...
 

Function Documentation

◆ makeNestedTupleFlat()

template<typename... Types>
auto Ikarus::utils::makeNestedTupleFlat ( std::tuple< Types... >  )
Template Parameters
TypesTypes contained in the original tuple.
Returns
A new flattened nested tuple.

◆ makeNestedTupleFlatAndStoreReferences()

template<typename Tuple >
auto Ikarus::utils::makeNestedTupleFlatAndStoreReferences ( Tuple &&  tup)
Template Parameters
TupleType of the original tuple.
Parameters
tupThe original tuple.
Returns
A new tuple with stored references.

This function creates a flattened nested tuple and stores references.

◆ returnReferenceOrNulloptIfObjectIsNullPtr()

template<typename T >
requires traits::Pointer<T>
auto & Ikarus::utils::returnReferenceOrNulloptIfObjectIsNullPtr ( v)
Template Parameters
TType of the pointer.
Parameters
vPointer value.
Returns
Reference or std::nullopt.