Template Numerical Library version main:1655e92
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  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 different matrix types.
 
namespace  Meshes
 Namespace for numerical meshes and related objects.
 
namespace  Pointers
 Namespace for TNL pointers.
 
namespace  Solvers
 Namespace for solvers.
 

Classes

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  CacheSizes
 
struct  Cast
 
struct  copy_const
 Copy const qualifier from Source type to Target type. 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  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  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  Plus
 Function object implementing x + y. More...
 
class  Real
 
class  String
 Class for managing strings. More...
 
class  SystemInfo
 
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 HYPRE_Device = Devices::Host
 The device compatible with Hypre's data structures. More...
 
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.
 
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< T >::value &&! std::is_unsigned< T >::value, bool > = true>
__cuda_callable__abs (const T &n)
 This function returns absolute value of given number n. More...
 
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 = typename std::common_type< T1, T2 >::type>
__cuda_callable__ ResultType argAbsMax (const T1 &a, const T2 &b)
 
template<typename T1 , typename T2 , typename ResultType = typename std::common_type< T1, T2 >::type>
__cuda_callable__ ResultType argAbsMin (const T1 &a, const T2 &b)
 
template<typename T1 , typename T2 , typename ResultType = typename std::common_type< T1, T2 >::type>
__cuda_callable__ ResultType argMax (const T1 &a, const T2 &b)
 
template<typename T1 , typename T2 , typename ResultType = typename std::common_type< T1, T2 >::type>
__cuda_callable__ 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 atanh (const T &value) -> decltype(std::atanh(value))
 This function returns the inverse hyperbolic tangent of the given value.
 
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<>
String convertToString (const bool &value)
 Specialization of function convertToString for boolean. More...
 
template<typename T >
String convertToString (const T &value)
 Converts value of type T to a String. More...
 
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. More...
 
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. More...
 
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 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)
 
bool fileExists (const String &fileName)
 Returns true if the file exists and false otherwise. More...
 
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.
 
String getFileExtension (const String &fileName)
 Returns extension of given file name, i.e. part after the last dot. More...
 
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. More...
 
String getObjectType (File &file)
 Extracts object type from a binary file. More...
 
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. More...
 
std::string getSerializationType (Algorithms::Segments::ElementsOrganization Organization)
 
template<typename T >
std::string getType ()
 Returns a human-readable string representation of given type. More...
 
template<typename T >
std::string getType (T &&obj)
 Returns a human-readable string representation of given object's type. More...
 
bool isLittleEndian ()
 Function returns true iff the system executing the program is little endian.
 
__cuda_callable__ bool isPow2 (int x)
 This function checks if x is an integral power of two. More...
 
__cuda_callable__ bool isPow2 (long int x)
 This function checks if x is an integral power of two. More...
 
template<typename Real >
__cuda_callable__ bool isSmall (const Real &v, const Real &tolerance=1.0e-5)
 This function tests whether the given real number is small. More...
 
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 = typename std::common_type< T1, T2 >::type, std::enable_if_t< std::is_arithmetic< T1 >::value &&std::is_arithmetic< T2 >::value, bool > = true>
constexpr ResultType max (const T1 &a, const T2 &b)
 This function returns maximum of two numbers. More...
 
template<typename T1 , typename T2 , typename T3 , typename... Ts>
__cuda_callable__ 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. More...
 
template<typename T1 , typename T2 , typename ResultType = typename std::common_type< T1, T2 >::type, std::enable_if_t< std::is_arithmetic< T1 >::value &&std::is_arithmetic< T2 >::value, bool > = true>
constexpr ResultType min (const T1 &a, const T2 &b)
 This function returns minimum of two numbers. More...
 
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. More...
 
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. More...
 
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 = typename std::common_type< T1, T2 >::type, std::enable_if_t< std::is_arithmetic< T1 >::value &&std::is_arithmetic< T2 >::value, bool > = true>
__cuda_callable__ ResultType pow (const T1 &base, const T2 &exp)
 This function returns the result of base to the power of exp.
 
String removeFileNameExtension (String fileName)
 Cuts off the file extension. More...
 
__cuda_callable__ int roundToMultiple (int number, int multiple)
 This function rounds up number to the nearest multiple of number multiple. More...
 
__cuda_callable__ int roundUpDivision (const int num, const int div)
 This function divides num by div and rounds up the result. More...
 
void saveObjectType (File &file, const String &type)
 Saves object type into a binary file. More...
 
template<class T , std::enable_if_t< ! HasSubscriptOperator< T >::value, bool > = true>
__cuda_callable__sign (const T &a)
 This function represents the signum function. More...
 
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<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__ void swap (Type &a, Type &b)
 This function swaps values of two parameters. More...
 
template<typename T >
swapEndianness (T u)
 Function takes a value and swaps its endianness. More...
 
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. More...
 

Variables

tnlFlopsCounter tnl_flops_counter
 

Detailed Description

The main TNL namespace.

Function Documentation

◆ abs()

template<class T , std::enable_if_t< std::is_arithmetic< T >::value &&! std::is_unsigned< T >::value, 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.

◆ 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.

◆ fileExists()

bool TNL::fileExists ( const String fileName)
inline

Returns true if the file exists and false otherwise.

Finds out if the file fileName exists.

Parameters
fileNameName of the file to check.
Returns
returns true if the file exists and false othervise

◆ 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.

◆ isPow2() [1/2]

__cuda_callable__ bool TNL::isPow2 ( int  x)
inline

This function 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]

__cuda_callable__ bool TNL::isPow2 ( long int  x)
inline

This function 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 >
__cuda_callable__ bool TNL::isSmall ( const Real v,
const Real tolerance = 1.0e-5 
)

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() [1/2]

template<typename T1 , typename T2 , typename ResultType = typename std::common_type< T1, T2 >::type, std::enable_if_t< std::is_arithmetic< T1 >::value &&std::is_arithmetic< T2 >::value, bool > = true>
constexpr ResultType TNL::max ( const T1 &  a,
const T2 &  b 
)
constexpr

This function returns maximum of two numbers.

GPU device code uses the functions defined in the CUDA's math_functions.h, host uses the STL functions.

◆ max() [2/2]

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

This function returns minimum of a variadic number of inputs.

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

◆ min() [1/2]

template<typename T1 , typename T2 , typename ResultType = typename std::common_type< T1, T2 >::type, std::enable_if_t< std::is_arithmetic< T1 >::value &&std::is_arithmetic< T2 >::value, bool > = true>
constexpr ResultType TNL::min ( const T1 &  a,
const T2 &  b 
)
constexpr

This function returns minimum of two numbers.

GPU device code uses the functions defined in the CUDA's math_functions.h, host uses the STL functions.

◆ min() [2/2]

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 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:33
T endl(T... args)
The main TNL namespace.
Definition: AtomicOperations.h:13
std::vector< String > parseObjectType(const String &objectType)
Parses the object type.
Definition: Object.hpp:86
Output
MyObject
Value
Device
Index

◆ 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()

__cuda_callable__ int TNL::roundToMultiple ( int  number,
int  multiple 
)
inline

This function rounds up number to the nearest multiple of number multiple.

Parameters
numberInteger we want to round.
multipleInteger.

◆ roundUpDivision()

__cuda_callable__ int TNL::roundUpDivision ( const int  num,
const int  div 
)
inline

This function 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>
__cuda_callable__ T TNL::sign ( const T &  a)

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__ void TNL::swap ( Type &  a,
Type &  b 
)

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 ( 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