Template Numerical Library version\ main:94209208
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions | Variables
TNL Namespace Reference

The main TNL namespace. More...

Namespaces

namespace  Algorithms
 Namespace for fundamental TNL algorithms.
 
namespace  Allocators
 Namespace for TNL allocators.
 
namespace  Assert
 Internal namespace for helper classes used in the TNL_ASSERT_* macros.
 
namespace  Backend
 Internal namespace for CUDA/HIP backend support.
 
namespace  base64
 Namespace for base64 encoding and decoding functions.
 
namespace  CFD
 Namespace for Computational Fluid Dynamics utilities in TNL.
 
namespace  Containers
 Namespace for TNL containers.
 
namespace  Devices
 Namespace for TNL execution models.
 
namespace  Exceptions
 Namespace for TNL exceptions.
 
namespace  Images
 Namespace for image processing.
 
namespace  Matrices
 Namespace for matrix formats.
 
namespace  Meshes
 Namespace for numerical meshes and related objects.
 
namespace  Pointers
 Namespace for TNL pointers.
 
namespace  Solvers
 Namespace for solvers.
 

Classes

struct  allocates_host_accessible_data
 A trait-class that determines if an allocator allocates data that are directly accessible from the host code without the need for explicit copy operations. More...
 
struct  allocates_host_accessible_data< Allocators::Cuda< T > >
 
struct  allocates_host_accessible_data< Allocators::Hip< T > >
 
struct  AnyWithArg
 Function object implementing argany(x, y, i, j) for use with TNL::Algorithms::reduceWithArgument. More...
 
class  Atomic
 
class  Atomic< T, Devices::Cuda >
 
class  Atomic< T, Devices::Host >
 
class  Atomic< T, Devices::Sequential >
 
struct  BitAnd
 Extension of std::bit_and<void> for use with TNL::Algorithms::reduce. More...
 
struct  BitOr
 Extension of std::bit_or<void> for use with TNL::Algorithms::reduce. More...
 
struct  BitXor
 Extension of std::bit_xor<void> for use with TNL::Algorithms::reduce. More...
 
struct  Cast
 
struct  copy_const
 Copy const qualifier from Source type to Target type. More...
 
struct  CPUCacheSizes
 CPU cache sizes. More...
 
struct  CPUInfo
 CPU information. More...
 
struct  enable_if_type
 
class  File
 This class serves for binary IO. It allows to do IO even for data allocated on GPU together with on-the-fly data type conversion. More...
 
class  FileName
 Helper class for the construction of file names based on name, index and extension. More...
 
class  HasAddAssignmentOperator
 Type trait for checking if T has operator+= taking one argument of type T. More...
 
struct  HasConstexprGetSizeMethod
 Type trait for checking if T has a constexpr getSize method. More...
 
class  HasCountMember
 Type trait for checking if T has count member. More...
 
class  HasGetArrayDataMethod
 Type trait for checking if T has getArrayData method. More...
 
class  HasGetCommunicatorMethod
 Type trait for checking if T has getCommunicator method. More...
 
class  HasGetSizeMethod
 Type trait for checking if T has getSize method. More...
 
class  HasIsMatrixMethod
 Type trait for checking if T has getCommunicator method. More...
 
class  HasSetSizeMethod
 Type trait for checking if T has setSize method. More...
 
class  HasSubscriptOperator
 Type trait for checking if T has operator[] taking one index argument. More...
 
struct  Hypre
 A simple RAII wrapper for Hypre's initialization and finalization. More...
 
struct  is_complex
 
struct  is_complex< Arithmetics::Complex< T > >
 
struct  is_complex< const T >
 
struct  is_complex< std::complex< T > >
 
struct  is_complex< volatile const T >
 
struct  is_complex< volatile T >
 
struct  IsArrayType
 Type trait for checking if T is an array type, e.g. Containers::Array or Containers::Vector. More...
 
struct  IsScalarType
 Type trait for checking if T is a scalar type (in the mathemtatical sense). Not to be confused with std::is_scalar. More...
 
struct  IsStaticArrayType
 Type trait for checking if T is a static array type. More...
 
struct  IsVectorType
 Type trait for checking if T is a vector type, e.g. Containers::Vector or Containers::VectorView. More...
 
struct  IsViewType
 Type trait for checking if T is a view type. More...
 
class  Logger
 Creates calculations log in the form of a table. More...
 
struct  LogicalAnd
 Function object implementing x && y. More...
 
struct  LogicalOr
 Function object implementing x || y. More...
 
struct  Max
 Function object implementing max(x, y). More...
 
struct  MaxWithArg
 Function object implementing argmax(x, y, i, j) for use with TNL::Algorithms::reduceWithArgument. More...
 
struct  Min
 Function object implementing min(x, y). More...
 
struct  MinWithArg
 Function object implementing argmin(x, y, i, j) for use with TNL::Algorithms::reduceWithArgument. More...
 
struct  Multiplies
 Function object implementing x * y. More...
 
class  Object
 Basic class for majority of TNL objects like matrices, meshes, grids, solvers, etc.. More...
 
struct  PerformanceCounters
 Performance counter for measuring CPU cycles. More...
 
struct  Plus
 Function object implementing x + y. More...
 
class  Real
 
class  String
 Class for managing strings. More...
 
class  Timer
 Class for real time, CPU time and CPU cycles measuring. More...
 
class  tnlFlopsCounter
 
struct  UnaryPlus
 Function object implementing +x. More...
 

Typedefs

using BitNot = std::bit_not< void >
 Function object implementing ~x.
 
using Divides = std::divides< void >
 Function object implementing x / y.
 
using EqualTo = std::equal_to< void >
 Function object implementing x == y.
 
using Greater = std::greater< void >
 Function object implementing x > y.
 
using GreaterEqual = std::greater_equal< void >
 Function object implementing x >= y.
 
using HYPRE_Device = Devices::Host
 The device compatible with Hypre's data structures.
 
using Less = std::less< void >
 Function object implementing x < y.
 
using LessEqual = std::less_equal< void >
 Function object implementing x <= y.
 
using LogicalNot = std::logical_not< void >
 Function object implementing !x.
 
using Minus = std::minus< void >
 Function object implementing x - y.
 
using Modulus = std::modulus< void >
 Function object implementing x % y.
 
using NotEqualTo = std::not_equal_to< void >
 Function object implementing x != y.
 
typedef Real< double > tnlDouble
 
typedef Real< float > tnlFloat
 
using UnaryMinus = std::negate< void >
 Function object implementing -x.
 

Functions

template<class T , std::enable_if_t< std::is_arithmetic_v< T > &&! std::is_unsigned_v< T >, bool > = true>
__cuda_callable__abs (const T &n)
 This function returns absolute value of given number n.
 
template<class T >
const Real< T > acos (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto acos (const T &value) -> decltype(std::acos(value))
 This function returns the arc cosine of the given value.
 
template<typename T >
__cuda_callable__ auto acosh (const T &value) -> decltype(std::acosh(value))
 This function returns the inverse hyperbolic cosine of the given value.
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
Result addAndReduce (Vector &lhs, const Containers::Expressions::BinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
Result addAndReduce (Vector &lhs, const Containers::Expressions::DistributedBinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
Result addAndReduce (Vector &lhs, const Containers::Expressions::DistributedUnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
__cuda_callable__ Result addAndReduce (Vector &lhs, const Containers::Expressions::StaticBinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
__cuda_callable__ Result addAndReduce (Vector &lhs, const Containers::Expressions::StaticUnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
Result addAndReduce (Vector &lhs, const Containers::Expressions::UnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
Result addAndReduceAbs (Vector &lhs, const Containers::Expressions::BinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
Result addAndReduceAbs (Vector &lhs, const Containers::Expressions::DistributedBinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
Result addAndReduceAbs (Vector &lhs, const Containers::Expressions::DistributedUnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
__cuda_callable__ Result addAndReduceAbs (Vector &lhs, const Containers::Expressions::StaticBinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
__cuda_callable__ Result addAndReduceAbs (Vector &lhs, const Containers::Expressions::StaticUnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
Result addAndReduceAbs (Vector &lhs, const Containers::Expressions::UnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >>
__cuda_callable__ ResultType argAbsMax (const T1 &a, const T2 &b)
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >>
__cuda_callable__ ResultType argAbsMin (const T1 &a, const T2 &b)
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >>
constexpr ResultType argMax (const T1 &a, const T2 &b)
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >>
constexpr ResultType argMin (const T1 &a, const T2 &b)
 
template<class T >
const Real< T > asin (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto asin (const T &value) -> decltype(std::asin(value))
 This function returns the arc sine of the given value.
 
template<typename T >
__cuda_callable__ auto asinh (const T &value) -> decltype(std::asinh(value))
 This function returns the inverse hyperbolic sine of the given value.
 
template<class T >
const Real< T > atan (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto atan (const T &value) -> decltype(std::atan(value))
 This function returns the arc tangent of the given value.
 
template<class T >
const Real< T > atan2 (const Real< T > &x, const Real< T > &exp)
 
template<class T >
const Real< T > atan2 (const Real< T > &x, const T &exp)
 
template<typename T >
__cuda_callable__ auto atan2 (const T &y, const T &x) -> decltype(std::atan2(y, x))
 This function returns the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
 
template<typename T >
__cuda_callable__ auto atanh (const T &value) -> decltype(std::atanh(value))
 This function returns the inverse hyperbolic tangent of the given value.
 
template<typename T >
std::set< std::vector< T > > cartesianPower (std::vector< T > array, int N)
 Calculates the cartesian power of elements in an array: array^N.
 
template<typename T >
__cuda_callable__ auto cbrt (const T &value) -> decltype(std::cbrt(value))
 This function returns cubic root of the given value.
 
template<typename T >
__cuda_callable__ auto ceil (const T &value) -> decltype(std::ceil(value))
 This function returns the smallest integer value not less than the given value.
 
template<typename Index >
constexpr Index combinationsCount (Index k, Index n)
 Computes the number of k-combinations in set of n element.
 
template<>
String convertToString (const bool &value)
 Specialization of function convertToString for boolean.
 
template<typename T >
String convertToString (const T &value)
 Converts value of type T to a String.
 
template<class T >
const Real< T > cos (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto cos (const T &value) -> decltype(std::cos(value))
 This function returns cosine of the given value.
 
template<class T >
const Real< T > cosh (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto cosh (const T &value) -> decltype(std::cosh(value))
 This function returns the hyperbolic cosine of the given value.
 
template<typename HeaderType = std::uint64_t, typename T >
std::pair< HeaderType, std::unique_ptr< T[] > > decompress_block (const char *data)
 Decode and decompress data from a stream. The data must be in the format as produced by the write_compressed_block function.
 
template<typename HeaderType = std::uint64_t, typename T >
std::pair< HeaderType, std::unique_ptr< T[] > > decompress_block (std::istream &input_stream)
 Decode and decompress data from a stream. The data must be in the format as produced by the write_compressed_block function.
 
template<typename T >
std::unique_ptr< T[] > decompress_data (const std::uint8_t *decoded_data, const std::size_t decoded_data_length, const std::size_t data_size)
 Decompress data in given byte array and return an array of elements of type T and length data_size.
 
template<typename Index >
constexpr Index discreteLog2 (Index value)
 Computes an integral base-2 logarithm.
 
template<typename Index >
constexpr Index discretePow (Index value, Index power)
 Computes an integral power of an integer.
 
template<typename Index >
constexpr Index discreteProduct (Index first, Index last)
 Computes a product of integers first * (first+1) * ... * last.
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
Result evaluateAndReduce (Vector &lhs, const Containers::Expressions::BinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
Result evaluateAndReduce (Vector &lhs, const Containers::Expressions::DistributedBinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
Result evaluateAndReduce (Vector &lhs, const Containers::Expressions::DistributedUnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename T2 , typename Operation , typename Reduction , typename Result >
__cuda_callable__ Result evaluateAndReduce (Vector &lhs, const Containers::Expressions::StaticBinaryExpressionTemplate< T1, T2, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
__cuda_callable__ Result evaluateAndReduce (Vector &lhs, const Containers::Expressions::StaticUnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<typename Vector , typename T1 , typename Operation , typename Reduction , typename Result >
Result evaluateAndReduce (Vector &lhs, const Containers::Expressions::UnaryExpressionTemplate< T1, Operation > &expression, const Reduction &reduction, const Result &zero)
 
template<class T >
const Real< T > exp (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto exp (const T &value) -> decltype(std::exp(value))
 This function returns the base-e exponential of the given value.
 
template<class T >
const Real< T > fabs (const Real< T > &v)
 
template<typename Index >
constexpr Index firstKCombinationsSum (Index k, Index n)
 Computes the sum of all i-combinations in set of n elements for i from 0 up to k-1.
 
template<typename T >
__cuda_callable__ auto floor (const T &value) -> decltype(std::floor(value))
 This function returns largest integer value not greater than the given value.
 
template<typename T >
forceBigEndian (T value)
 Function takes a value and returns its big endian representation.
 
std::string getCompilerName ()
 Returns the name of the compiler.
 
CPUCacheSizes getCPUCacheSizes (int cpu_id=0)
 Returns the CPU cache sizes.
 
CPUInfo getCPUInfo ()
 Returns the CPU information.
 
int getCPUMaxFrequency (int cpu_id=0)
 Returns the CPU cache sizes.
 
std::string getCurrentTime (const char *format="%a %b %d %Y, %H:%M:%S")
 Returns the current time.
 
String getFileExtension (const String &fileName)
 Returns extension of given file name, i.e. part after the last dot.
 
std::size_t getFreeMemory ()
 Returns the free memory in bytes.
 
std::string getHostname ()
 Returns the hostname of the system.
 
constexpr HYPRE_MemoryLocation getHypreMemoryLocation ()
 Returns the memory location used by Hypre objects.
 
String getObjectType (const String &fileName)
 Does the same as getObjectType but with a fileName parameter instead of file.
 
String getObjectType (File &file)
 Extracts object type from a binary file.
 
std::string getOnlineCPUs ()
 Returns number of online CPUs.
 
template<typename T , std::enable_if_t< ! detail::HasStaticGetSerializationType< T >::value, bool > = true>
std::string getSerializationType ()
 Returns a string identifying a type for the purpose of serialization.
 
std::string getSerializationType (Algorithms::Segments::ElementsOrganization Organization)
 
std::string getSystemArchitecture ()
 Returns the name of the operating system.
 
std::string getSystemName ()
 Returns the name of the operating system.
 
std::string getSystemRelease ()
 Returns the release of the operating system.
 
template<typename T >
std::string getType ()
 Returns a human-readable string representation of given type.
 
template<typename T >
std::string getType (T &&obj)
 Returns a human-readable string representation of given object's type.
 
template<std::size_t N, typename Index >
std::set< std::array< Index, N > > integerFactorizationTuples (Index number)
 Finds all possible integer factorizations of a positive integer into a product of N factors.
 
template<typename Index , std::enable_if_t< std::is_integral_v< Index >, bool > = true>
bool integerMultiplyOverflow (Index a, Index b)
 Checks if two values of the same integral type can be multiplied without causing integer overflow or underflow.
 
bool isLittleEndian ()
 Function returns true iff the system executing the program is little endian.
 
constexpr bool isPow2 (int x)
 Checks if x is an integral power of two.
 
constexpr bool isPow2 (long int x)
 Checks if x is an integral power of two.
 
template<typename Real >
constexpr bool isSmall (const Real &v, const Real &tolerance=1.0e-5)
 This function tests whether the given real number is small.
 
template<typename T , typename I >
auto linspace (T a, T b, I n)
 
template<class T >
const Real< T > log (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto log (const T &value) -> decltype(std::log(value))
 This function returns the natural logarithm of the given value.
 
template<class T >
const Real< T > log10 (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto log10 (const T &value) -> decltype(std::log10(value))
 This function returns the common logarithm of the given value.
 
template<typename T >
__cuda_callable__ auto log2 (const T &value) -> decltype(std::log2(value))
 This function returns the binary logarithm of the given value.
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >>
constexpr ResultType max (const T1 &a, const T2 &b)
 This function returns maximum of two numbers.
 
template<typename T1 , typename T2 , typename T3 , typename... Ts>
constexpr std::common_type< T1, T2, T3, Ts... >::type max (T1 &&val1, T2 &&val2, T3 &&val3, Ts &&... vs)
 This function returns minimum of a variadic number of inputs.
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >>
constexpr ResultType min (const T1 &a, const T2 &b)
 This function returns minimum of two numbers.
 
template<typename T1 , typename T2 , typename T3 , typename... Ts>
constexpr std::common_type< T1, T2, T3, Ts... >::type min (T1 &&val1, T2 &&val2, T3 &&val3, Ts &&... vs)
 This function returns minimum of a variadic number of inputs.
 
template<class T >
bool operator!= (const T &v1, const Real< T > &v2)
 
template<class T , class S >
const Real< T > & operator* (const S &v1, const Real< T > &v2)
 
String operator+ (char string1, const String &string2)
 Returns concatenation of string1 and string2.
 
String operator+ (const char *string1, const String &string2)
 Returns concatenation of string1 and string2.
 
template<class T , class S >
const Real< T > & operator+ (const S &v1, const Real< T > &v2)
 
String operator+ (const std::string &string1, const String &string2)
 Returns concatenation of string1 and string2.
 
template<class T , class S >
const Real< T > & operator- (const S &v1, const Real< T > &v2)
 
template<class T , class S >
const Real< T > & operator/ (const S &v1, const Real< T > &v2)
 
template<class T >
bool operator< (const T &v1, const Real< T > &v2)
 
Fileoperator<< (File &file, const std::string &str)
 Serialization of strings.
 
template<class T >
std::ostreamoperator<< (std::ostream &str, const Real< T > &v)
 
template<class T >
bool operator<= (const T &v1, const Real< T > &v2)
 
template<class T >
bool operator== (const T &v1, const Real< T > &v2)
 
template<class T >
bool operator> (const T &v1, const Real< T > &v2)
 
template<class T >
bool operator>= (const T &v1, const Real< T > &v2)
 
Fileoperator>> (File &file, std::string &str)
 Deserialization of strings.
 
std::vector< StringparseObjectType (const String &objectType)
 Parses the object type.
 
template<class T >
const Real< T > pow (const Real< T > &x, const Real< T > &exp)
 
template<class T >
const Real< T > pow (const Real< T > &x, const T &exp)
 
template<typename T1 , typename T2 , typename ResultType = std::common_type_t< T1, T2 >, std::enable_if_t< std::is_arithmetic_v< T1 > &&std::is_arithmetic_v< T2 >, bool > = true>
__cuda_callable__ ResultType pow (const T1 &base, const T2 &exp)
 This function returns the result of base to the power of exp.
 
template<typename Index >
std::vector< Index > primeFactorization (Index number)
 Calculates the prime factorization of a positive integer.
 
String removeFileNameExtension (String fileName)
 Cuts off the file extension.
 
constexpr int roundToMultiple (int number, int multiple)
 Rounds up number to the nearest multiple of number multiple.
 
constexpr int roundUpDivision (const int num, const int div)
 Divides num by div and rounds up the result.
 
void saveObjectType (File &file, const String &type)
 Saves object type into a binary file.
 
template<class T , std::enable_if_t< ! HasSubscriptOperator< T >::value, bool > = true>
constexpr T sign (const T &a)
 This function represents the signum function.
 
template<class T >
const Real< T > sin (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto sin (const T &value) -> decltype(std::sin(value))
 This function returns sine of the given value.
 
template<class T >
const Real< T > sinh (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto sinh (const T &value) -> decltype(std::sinh(value))
 This function returns the hyperbolic sine of the given value.
 
template<typename T >
__cuda_callable__ std::enable_if_t< IsScalarType< T >::value, T > sqr (const T &value)
 This function returns the square the given value.
 
template<class T >
const Real< T > sqrt (const Real< T > &v)
 
template<typename T >
__cuda_callable__ auto sqrt (const T &value) -> decltype(std::sqrt(value))
 This function returns square root of the given value.
 
template<typename Type >
__cuda_callable__ constexpr void swap (Type &a, Type &b)
 This function swaps values of two parameters.
 
template<typename Index >
Index swapBits (Index n, std::uint8_t p1, std::uint8_t p2)
 This function swaps bits at positions p1 and p2 in an integer n.
 
template<typename T >
swapEndianness (T u)
 Function takes a value and swaps its endianness.
 
template<class T >
const Real< T > tan (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto tan (const T &value) -> decltype(std::tan(value))
 This function returns tangent of the given value.
 
template<class T >
const Real< T > tanh (const Real< T > &x)
 
template<typename T >
__cuda_callable__ auto tanh (const T &value) -> decltype(std::tanh(value))
 This function returns the hyperbolic tangent of the given value.
 
template<typename HeaderType = std::uint64_t, typename T >
void write_compressed_block (const T *data, const std::size_t data_size, std::ostream &output_stream, const int compression_level=Z_DEFAULT_COMPRESSION)
 Use zlib to compress the data, then encode it with base64 and write the result to the given stream.
 

Variables

template<typename Allocator >
constexpr bool allocates_host_accessible_data_v = allocates_host_accessible_data< Allocator >::value
 A helper variable template for allocates_host_accessible_data.
 
template<class T >
constexpr bool is_complex_v = is_complex< T >::value
 
tnlFlopsCounter tnl_flops_counter
 

Detailed Description

The main TNL namespace.

Function Documentation

◆ abs()

template<class T , std::enable_if_t< std::is_arithmetic_v< T > &&! std::is_unsigned_v< T >, bool > = true>
__cuda_callable__ T TNL::abs ( const T & n)

This function returns absolute value of given number n.

This function returns the absolute value of given unsigned number n, i.e. n.

◆ cartesianPower()

template<typename T >
std::set< std::vector< T > > TNL::cartesianPower ( std::vector< T > array,
int N )

Calculates the cartesian power of elements in an array: array^N.

For example, cartesianPower(std::vector<int>{0,1}, 2) returns the following set (written in pseudo-code): { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } }.

Template Parameters
Tis the type of elements in the array.
Parameters
arrayis the input array/vector of elements.
Nis the power of the cartesian product.
Returns
A set of vectors of elements, where each vector contains N elements from array.

◆ combinationsCount()

template<typename Index >
constexpr Index TNL::combinationsCount ( Index k,
Index n )
constexpr

Computes the number of k-combinations in set of n element.

See Wikipedia.

Template Parameters
Indexis an integral type used for the evaluation of the number of combinations.
Parameters
kdenotes the number of elements in one combination.
ndenotes the number of all elements in the set.
Returns
Number of all k-combinations in set of n elements.

◆ convertToString() [1/2]

template<>
String TNL::convertToString ( const bool & value)
inline

Specialization of function convertToString for boolean.

The boolean type is converted to 'true' or 'false'.

◆ convertToString() [2/2]

template<typename T >
String TNL::convertToString ( const T & value)

Converts value of type T to a String.

Template Parameters
Tcan be any type fir which operator << is defined.

◆ decompress_block() [1/2]

template<typename HeaderType = std::uint64_t, typename T >
std::pair< HeaderType, std::unique_ptr< T[] > > TNL::decompress_block ( const char * data)

Decode and decompress data from a stream. The data must be in the format as produced by the write_compressed_block function.

The function returns a pair of the resulting data size and a std::unique_ptr to the data.

◆ decompress_block() [2/2]

template<typename HeaderType = std::uint64_t, typename T >
std::pair< HeaderType, std::unique_ptr< T[] > > TNL::decompress_block ( std::istream & input_stream)

Decode and decompress data from a stream. The data must be in the format as produced by the write_compressed_block function.

The function returns a pair of the resulting data size and a std::unique_ptr to the data.

◆ discreteLog2()

template<typename Index >
constexpr Index TNL::discreteLog2 ( Index value)
constexpr

Computes an integral base-2 logarithm.

Parameters
valueis the argument of the log2 function.

◆ discretePow()

template<typename Index >
constexpr Index TNL::discretePow ( Index value,
Index power )
constexpr

Computes an integral power of an integer.

Parameters
valueis the argument of the power function.
poweris the exponent in the power function.

◆ discreteProduct()

template<typename Index >
constexpr Index TNL::discreteProduct ( Index first,
Index last )
constexpr

Computes a product of integers first * (first+1) * ... * last.

Template Parameters
Indexis an integral type used for evaluation of the product.
Parameters
firstis the first number of the product
lastis the last number of the product.

◆ firstKCombinationsSum()

template<typename Index >
constexpr Index TNL::firstKCombinationsSum ( Index k,
Index n )
constexpr

Computes the sum of all i-combinations in set of n elements for i from 0 up to k-1.

Template Parameters
Indexis an integral type used for the evaluation of the sum.
Parameters
kdenotes the number of terms in the sum.
ndenotes the number of elements in the set.
Returns
Sum of all i-combinations in set of n elements for i from 0 up to k-1.

◆ getFileExtension()

String TNL::getFileExtension ( const String & fileName)
inline

Returns extension of given file name, i.e. part after the last dot.

Parameters
fileNameInput file name.
Returns
Extension of the given file name.

◆ getObjectType() [1/2]

String TNL::getObjectType ( const String & fileName)
inline

Does the same as getObjectType but with a fileName parameter instead of file.

Throws Exceptions::FileDeserializationError if the object type cannot be detected.

Parameters
fileNamename of a file where the object is stored
Returns
string with the object type

◆ getObjectType() [2/2]

String TNL::getObjectType ( File & file)
inline

Extracts object type from a binary file.

Throws Exceptions::FileDeserializationError if the object type cannot be detected.

Parameters
fileis file where the object is stored
Returns
string with the object type

◆ getSerializationType()

template<typename T , std::enable_if_t< ! detail::HasStaticGetSerializationType< T >::value, bool > = true>
std::string TNL::getSerializationType ( )

Returns a string identifying a type for the purpose of serialization.

Specialization of getSerializationType for types which provide a static getSerializationType method to override the default behaviour.

By default, this function returns the same string as getType. However, if a user-defined class has a static getSerializationType method, it is called instead. This is useful for overriding the default typeid name, which may be necessary e.g. for class templates which should have the same serialization type for multiple devices.

◆ getType() [1/2]

template<typename T >
std::string TNL::getType ( )

Returns a human-readable string representation of given type.

Note that since we use the typeid operator internally, the top-level cv-qualifiers are always ignored. See https://stackoverflow.com/a/8889143 for details.

◆ getType() [2/2]

template<typename T >
std::string TNL::getType ( T && obj)

Returns a human-readable string representation of given object's type.

Note that since we use the typeid operator internally, the top-level cv-qualifiers are always ignored. See https://stackoverflow.com/a/8889143 for details.

◆ integerFactorizationTuples()

template<std::size_t N, typename Index >
std::set< std::array< Index, N > > TNL::integerFactorizationTuples ( Index number)

Finds all possible integer factorizations of a positive integer into a product of N factors.

Template Parameters
Nis the rank of the tuples (2 for pairs, 3 for triplets, etc.)
Indexis the integral type of the input number.
Parameters
numberis the integer to be factorized.
Returns
A set of N-tuples, where the product of all components in each tuple is equal to number.

◆ integerMultiplyOverflow()

template<typename Index , std::enable_if_t< std::is_integral_v< Index >, bool > = true>
bool TNL::integerMultiplyOverflow ( Index a,
Index b )

Checks if two values of the same integral type can be multiplied without causing integer overflow or underflow.

Template Parameters
Indexis the integral type of input values.
Parameters
ais the first operand in the expression a * b
bis the second operand in the expression a * b
Returns
true if the operation a * b results in an integer overflow or underflow, and false if the result fits into the Index type.

◆ isPow2() [1/2]

constexpr bool TNL::isPow2 ( int x)
constexpr

Checks if x is an integral power of two.

Returns true if x is a power of two. Otherwise returns false.

Parameters
xInteger.

◆ isPow2() [2/2]

constexpr bool TNL::isPow2 ( long int x)
constexpr

Checks if x is an integral power of two.

Returns true if x is a power of two. Otherwise returns false.

Parameters
xLong integer.

◆ isSmall()

template<typename Real >
constexpr bool TNL::isSmall ( const Real & v,
const Real & tolerance = 1.0e-5 )
constexpr

This function tests whether the given real number is small.

It tests whether the number v is in tolerance, in other words, whether v in absolute value is less then or equal to tolerance.

Parameters
vReal number.
toleranceCritical value which is set to 0.00001 by defalt.

◆ max()

template<typename T1 , typename T2 , typename T3 , typename... Ts>
constexpr std::common_type< T1, T2, T3, Ts... >::type TNL::max ( T1 && val1,
T2 && val2,
T3 && val3,
Ts &&... vs )
constexpr

This function returns minimum of a variadic number of inputs.

The inputs are folded with the binary max function from the left to the right.

◆ min()

template<typename T1 , typename T2 , typename T3 , typename... Ts>
constexpr std::common_type< T1, T2, T3, Ts... >::type TNL::min ( T1 && val1,
T2 && val2,
T3 && val3,
Ts &&... vs )
constexpr

This function returns minimum of a variadic number of inputs.

The inputs are folded with the binary min function from the left to the right.

◆ parseObjectType()

std::vector< String > TNL::parseObjectType ( const String & objectType)
inline

Parses the object type.

Parameters
objectTypeis a string with the object type to be parsed.
Returns
vector of strings where the first one is the object type and the next strings are the template parameters.
Example
#include <iostream>
#include <TNL/Object.h>
using namespace TNL;
int
main()
{
auto parsedObjectType = parseObjectType( String( "MyObject< Value, Device, Index >" ) );
for( auto& token : parsedObjectType )
std::cout << token << std::endl;
}
Class for managing strings.
Definition String.h:30
The main TNL namespace.
Definition AtomicOperations.h:9
std::vector< String > parseObjectType(const String &objectType)
Parses the object type.
Definition Object.hpp:83
STL namespace.
Output
MyObject
Value
Device
Index

◆ primeFactorization()

template<typename Index >
std::vector< Index > TNL::primeFactorization ( Index number)

Calculates the prime factorization of a positive integer.

The function uses the simple trial division algorithm, so it is not efficient for large numbers.

Template Parameters
Indexis the integral type of the input number.
Parameters
numberis the integer to be factorized.
Returns
A vector of the prime factors.

◆ removeFileNameExtension()

String TNL::removeFileNameExtension ( String fileName)
inline

Cuts off the file extension.

Parameters
fileNameInput file name.
Returns
String with the file name without extension.

◆ roundToMultiple()

constexpr int TNL::roundToMultiple ( int number,
int multiple )
constexpr

Rounds up number to the nearest multiple of number multiple.

Parameters
numberInteger we want to round.
multipleInteger.

◆ roundUpDivision()

constexpr int TNL::roundUpDivision ( const int num,
const int div )
constexpr

Divides num by div and rounds up the result.

Parameters
numAn integer considered as dividend.
divAn integer considered as divisor.

◆ saveObjectType()

void TNL::saveObjectType ( File & file,
const String & type )
inline

Saves object type into a binary file.

Throws Exceptions::FileDeserializationError if the object type cannot be detected.

Parameters
fileis the file where the object will be saved
typeis the object type to be saved

◆ sign()

template<class T , std::enable_if_t< ! HasSubscriptOperator< T >::value, bool > = true>
constexpr T TNL::sign ( const T & a)
constexpr

This function represents the signum function.

It extracts the sign of the number a. In other words, the signum function projects negative numbers to value -1, positive numbers to value 1 and zero to value 0.

◆ swap()

template<typename Type >
__cuda_callable__ constexpr void TNL::swap ( Type & a,
Type & b )
constexpr

This function swaps values of two parameters.

It assigns the value of a to the parameter b and vice versa.

◆ swapEndianness()

template<typename T >
T TNL::swapEndianness ( T u)

Function takes a value and swaps its endianness.

Reference: https://stackoverflow.com/a/4956493

◆ write_compressed_block()

template<typename HeaderType = std::uint64_t, typename T >
void TNL::write_compressed_block ( const T * data,
const std::size_t data_size,
std::ostream & output_stream,
const int compression_level = Z_DEFAULT_COMPRESSION )

Use zlib to compress the data, then encode it with base64 and write the result to the given stream.

Options for compression_level:

  • Z_NO_COMPRESSION
  • Z_BEST_SPEED
  • Z_BEST_COMPRESSION
  • Z_DEFAULT_COMPRESSION