rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
rexlib Namespace Reference

Arrays, the operations on them and the devices that run those operations. More...

Namespaces

namespace  cpu
 The backend that runs operations on the CPU of the host.
 
namespace  em
 Operations for CryoEM and CryoET image processing.
 
namespace  ops
 The declarations of the operations: their operands, parameters and rules.
 

Classes

class  access_hazard_tracker
 Tracks the commands that access a piece of memory. More...
 
class  ambiguous_backend_error
 Exception indicating that could not disambiguate among multiple backend candidates. More...
 
struct  any_extent_domain
 Domain admitting every extent. More...
 
struct  any_type_domain
 Named domain holding every representable type. More...
 
class  array
 Container for multidimensional numeric data. More...
 
class  array_descriptor
 Description of the memory representation of a multidimensional array. More...
 
class  array_ref
 Non-owning reference to an array. More...
 
struct  axis_run
 Leading core axes as many as the operation instance names. More...
 
class  bad_dynamic_subscript_access
 
class  bad_scalar_value_access
 Exception thrown when accessing a scalar_value with an incorrect type. More...
 
class  basic_operation
 CRTP base supplying the static description of an operation. More...
 
class  broadcast_error
 
class  buffer
 Represents an untyped memory allocation at a given memory resource. More...
 
struct  category_type_domain
 Named domain holding every type of a given category. More...
 
class  command
 Specification of work to be executed on a command_queue. More...
 
class  command_queue
 Abstract command queue belonging to a device. More...
 
class  command_timeline
 Tells the host which commands of a queue have finished. More...
 
class  command_token
 Identifies a command submitted to a command_queue. More...
 
struct  complex_type_transform
 Transform mapping a pivot type onto its complex counterpart. More...
 
class  const_array
 Read-only view into an array. More...
 
class  const_array_ref
 Non-owning read-only reference to an array. More...
 
struct  core_dimensions
 The core axes of one operand. More...
 
class  core_dimensions_descriptor
 Type erased form of a core_dimensions. More...
 
struct  core_dimensions_descriptor_table
 Lower the core axes of every operand of one kind into a table. More...
 
struct  core_dimensions_descriptor_table< type_list< Cores... > >
 
struct  core_dimensions_descriptor_table< type_list<> >
 
class  device
 Abstract representation of a hardware compute device. More...
 
class  device_backend
 Abstract class that represents a hardware backend. More...
 
class  device_context
 Scoped, configurable view over a device_session. More...
 
class  device_index
 Location of a device as a (backend, id) tuple. More...
 
class  device_manager
 Centralize multiple device_backend sessions and route device queries to the appropriate one. More...
 
class  device_properties
 Description of the static characteristics of a physical device visible from the host. More...
 
class  device_session
 Immutable aggregate of a device handle and its associated objects. More...
 
class  dispatcher
 Abstract interface that executes operations on a set of operands. More...
 
struct  domain_difference
 Named domain holding what one domain has and another lacks. More...
 
struct  domain_intersection
 Named domain holding the intersection of other named domains. More...
 
struct  domain_union
 Named domain holding the union of other named domains. More...
 
class  dynamic_library
 RAII style class to load, query and unload dynamic libraries. More...
 
class  dynamic_subscript
 Class describing a runtime defined subscript. More...
 
struct  ellipsis_tag
 Tag to express the consumption of an arbitrary amount of axes until no slack is left on the right-hand dimensions. More...
 
class  execution_context
 Pairs the hardware resources and the dispatch strategy used to run operations. More...
 
class  extent_domain
 Set of extents an axis may take. More...
 
struct  extent_pivot
 Declaration of one extent variable of a shape rule. More...
 
class  extent_pivot_descriptor
 Type erased form of an extent_pivot. More...
 
struct  extent_pivot_descriptor_table
 Lower the extent variables of a shape rule into a table. More...
 
struct  extent_pivot_descriptor_table< type_list< Extents... > >
 
struct  extent_pivot_descriptor_table< type_list<> >
 
struct  extent_slot
 Binding of one core axis to an extent variable through a transform. More...
 
class  extent_slot_descriptor
 Type erased form of an extent_slot. More...
 
struct  extent_slot_descriptor_table
 Lower the slots of one core into a table of descriptors. More...
 
struct  extent_slot_descriptor_table< type_list< Slots... > >
 
struct  extent_slot_descriptor_table< type_list<> >
 
class  extent_transform
 Type erased form of an extent transform. More...
 
struct  fixed_extent
 Accessor yielding a fixed extent, whatever the parameters. More...
 
struct  fixed_type_transform
 Transform ignoring the pivot and yielding a fixed type. More...
 
class  flagset
 Stores a set of bits in the form of flags Similar to std::bitset but instead of a index based interface it provides a enum based interface. More...
 
class  float16_t
 16 bit floating point number representation. More...
 
struct  inexact_type_transform
 Transform mapping a pivot type onto its inexact counterpart. More...
 
class  invalid_operation_error
 Exception indicating that the function call is not available due to a misconfiguration of the class. More...
 
struct  is_floating_point
 Determine if a type is a floating point type. More...
 
class  joint_cursor
 Traversal state (indices and per-operand offsets) of a joint_layout. More...
 
class  joint_layout
 Provides joint access semantics for multiple operands. More...
 
class  joint_layout_builder
 Factory class to obtain instances of array_access_layout. More...
 
class  memory_allocator
 Abstract allocator of buffer objects on a memory_resource. More...
 
class  memory_resource
 Abstract description of a physical memory region. More...
 
struct  named_core
 Placement of the core axes where the operation instance names them. More...
 
struct  named_domain
 Base giving a named domain both of its halves. More...
 
struct  native_type_of
 Convert numerical_type-s to static types. More...
 
struct  native_type_of< numerical_type::boolean >
 
struct  native_type_of< numerical_type::char8 >
 
struct  native_type_of< numerical_type::complex_float16 >
 
struct  native_type_of< numerical_type::complex_float32 >
 
struct  native_type_of< numerical_type::complex_float64 >
 
struct  native_type_of< numerical_type::float16 >
 
struct  native_type_of< numerical_type::float32 >
 
struct  native_type_of< numerical_type::float64 >
 
struct  native_type_of< numerical_type::int16 >
 
struct  native_type_of< numerical_type::int32 >
 
struct  native_type_of< numerical_type::int64 >
 
struct  native_type_of< numerical_type::int8 >
 
struct  native_type_of< numerical_type::uint16 >
 
struct  native_type_of< numerical_type::uint32 >
 
struct  native_type_of< numerical_type::uint64 >
 
struct  native_type_of< numerical_type::uint8 >
 
struct  new_axis_tag
 Tag to express the creation a new axis of size one. More...
 
class  no_parameters
 Parameters of an operation that takes none. More...
 
class  numerical_type_domain
 Set of numerical_type-s. More...
 
struct  numerical_type_of
 Convert static types to numerical_type. More...
 
struct  numerical_type_of< bool >
 
struct  numerical_type_of< char >
 
struct  numerical_type_of< float16_t >
 
struct  numerical_type_of< float32_t >
 
struct  numerical_type_of< float64_t >
 
struct  numerical_type_of< std::complex< float16_t > >
 
struct  numerical_type_of< std::complex< float32_t > >
 
struct  numerical_type_of< std::complex< float64_t > >
 
struct  numerical_type_of< std::int16_t >
 
struct  numerical_type_of< std::int32_t >
 
struct  numerical_type_of< std::int64_t >
 
struct  numerical_type_of< std::int8_t >
 
struct  numerical_type_of< std::uint16_t >
 
struct  numerical_type_of< std::uint32_t >
 
struct  numerical_type_of< std::uint64_t >
 
struct  numerical_type_of< std::uint8_t >
 
class  operand_descriptor
 Logical representation of an operand's properties. More...
 
struct  operand_names
 Compile time list of operand names. More...
 
struct  operand_names_count
 Get the operand count of an operand name list. More...
 
struct  operand_shape_rule
 Declarative shape rule for the operands of an operation. More...
 
class  operand_specification
 Shape and data type of an operand. More...
 
struct  operand_type_rule
 Declarative typing rule for the operands of an operation. More...
 
class  operation
 Abstract class that describes an operation. More...
 
class  operation_arity
 Describes the operand count of an operation. More...
 
class  operation_descriptor
 Immutable static description of an operation type. More...
 
class  operation_id
 Unique identification for an operation type. More...
 
class  operation_signature
 Interface deciding the shape and data type of the operands of an operation. More...
 
class  parametric_operation
 CRTP base for operations whose signature depends on parameters. More...
 
class  plugin
 Abstract class representing a plugin interface. More...
 
class  plugin_load_error
 Exception indicating that an error occurred when loading a plugin. More...
 
class  plugin_manager
 Class managing a set of plugins. More...
 
struct  positive_extent_domain
 Domain admitting every extent but zero. More...
 
class  program
 Abstract representation of an executable program. More...
 
class  program_builder
 Abstract representation of a factory class for operation programs. More...
 
class  program_builder_registration
 Appends a factory for Builder to a registry upon construction. More...
 
class  program_builder_registry
 Collects program_builder factories for bulk registration into a program_manager. More...
 
class  program_cache
 Bounded associative store for backend-private resources reused across operation program builds. More...
 
class  program_cache_key
 Abstract base for keys stored in an program_cache. More...
 
class  program_manager
 Centralizes all known instances of operation program builders. More...
 
class  program_scratch_requirement
 Describes a scratch buffer requirement for program execution. More...
 
struct  real_type_transform
 Transform mapping a pivot type onto its real counterpart. More...
 
struct  repeated_type_list
 Utility class to obtain a type_list with a type repeated a fixed number of times. More...
 
struct  repeated_type_list< T, 0 >
 
class  rule_signature
 Operation signature made of a shape rule and a typing rule. More...
 
struct  same_extent_transform
 Transform mapping an extent onto itself. More...
 
struct  same_type_transform
 Transform mapping a pivot type onto itself. More...
 
class  scalar_value
 Owns a copy of a dynamically typed scalar value. More...
 
class  service_catalog
 Stores a single instance of each type service_manager. More...
 
class  service_manager
 Abstract class defining the interface of a service manager. More...
 
struct  shape_rule_accessors
 Read the values a shape rule depends on from the parameters of an operation instance. More...
 
class  shape_rule_descriptor
 Type erased form of an operand_shape_rule. More...
 
struct  shape_rule_descriptor_of
 Lower a shape rule into its descriptor. More...
 
class  shape_rule_interpreter
 Interpreter of a shape rule lowered to tables. More...
 
struct  shared_rule_signature
 The signature of every operation that takes no parameters and follows a given pair of rules. More...
 
struct  single_type_domain
 Named domain holding a single type. More...
 
class  slice
 Class representing an slice of an array. More...
 
class  span
 Represents a non-owning area of contiguous memory. More...
 
class  strided_layout
 
struct  trailing_core
 Placement of the core axes at the end of every operand. More...
 
class  trivial_operation
 CRTP base for operations that are trivially declared. More...
 
struct  type_list
 Helper class to pass a heterogeneous sequence of types to a function. More...
 
struct  type_list_cat
 Utility class to concatenate an arbitrary number of type_list-s. More...
 
struct  type_list_cat< type_list< As... >, type_list< Bs... >, Rest... >
 
struct  type_list_cat< type_list< Ts... > >
 
struct  type_list_element
 Utility class to index a type on a type_list. More...
 
struct  type_list_element< 0, type_list< Head, Tail... > >
 
struct  type_list_element< I, type_list< Head, Tail... > >
 
struct  type_list_prepend
 Utility class to prepend a type to the front of a type_list. More...
 
struct  type_list_prepend< T, type_list< Ts... > >
 
struct  type_list_size
 Utility class to obtain the size of a type_list. More...
 
struct  type_list_size< type_list< Ts... > >
 
struct  type_pivot
 Declaration of one free variable of a typing rule. More...
 
class  type_pivot_descriptor
 Type erased form of a type_pivot. More...
 
struct  type_pivot_descriptor_table
 Lower a rule's pivot list into a table of descriptors. More...
 
struct  type_pivot_descriptor_table< type_list< Pivots... > >
 
struct  type_pivot_descriptor_table< type_list<> >
 
struct  type_rule_accessors
 Read the data types a typing rule depends on from the parameters of an operation instance. More...
 
class  type_rule_descriptor
 Type erased form of an operand_type_rule. More...
 
struct  type_rule_descriptor_of
 Lower a type rule into a descriptor. More...
 
class  type_rule_interpreter
 Interpreter of a typing rule lowered to a descriptor. More...
 
struct  type_rule_operand_types
 Apply the transform of every slot to the type of its pivot. More...
 
struct  type_rule_operand_types< type_list< Slots... >, type_list< Pivots... > >
 
struct  type_rule_pivots_in_domain
 Check that each pivot type lies in the domain its pivot declares. More...
 
struct  type_rule_pivots_in_domain< type_list< Pivot, Pivots... >, type_list< Type, Types... > >
 
struct  type_rule_pivots_in_domain< type_list<>, type_list<> >
 
class  type_rule_resolution
 Resolved pivot values of a typing rule, or the reason it failed. More...
 
struct  type_slot
 Binding of one operand to a pivot through a transform. More...
 
class  type_slot_descriptor
 Type erased form of a type_slot. More...
 
struct  type_slot_descriptor_table
 Lower a rule's slot list into a table of descriptors. More...
 
struct  type_slot_descriptor_table< type_list< Slots... > >
 
struct  type_slot_descriptor_table< type_list<> >
 
class  type_tag
 Helper class to pass type information to a function. More...
 
class  type_transform
 Type erased form of a type transform. More...
 
class  typed_program_cache_key
 Default key wrapper for value types that model std::hash and equality comparison. More...
 
class  unsupported_capability_error
 Exception indicating that an object lacks a capability a call requires. More...
 
class  unsupported_operation_error
 Exception indicating that nothing available can carry out a requested operation. More...
 
class  version
 

Typedefs

using program_builder_factory = std::unique_ptr< program_builder >(*)()
 Factory function that creates a fresh program_builder instance.
 
using joint_layout_build_flags = flagset< joint_layout_build_flag_bits >
 Set of joint_layout_build_flag_bits used to control the joint_layout build behavior.
 
template<typename... Lists>
using type_list_cat_t = typename type_list_cat< Lists... >::type
 Convenience alias for type_list_cat<Lists...>::type.
 
using float32_t = float
 32 bit floating point number representation.
 
using float64_t = double
 64 bit floating point number representation.
 
using boolean_type_domain = category_type_domain< numerical_type_category::boolean >
 
using character_type_domain = category_type_domain< numerical_type_category::character >
 
using signed_integer_type_domain = category_type_domain< numerical_type_category::signed_integer >
 
using unsigned_integer_type_domain = category_type_domain< numerical_type_category::unsigned_integer >
 
using floating_point_type_domain = category_type_domain< numerical_type_category::floating_point >
 
using complex_type_domain = category_type_domain< numerical_type_category::complex >
 
using integral_type_domain = domain_union< signed_integer_type_domain, unsigned_integer_type_domain >
 Signed and unsigned integers.
 
using inexact_type_domain = domain_union< floating_point_type_domain, complex_type_domain >
 Floating point and complex types, i.e. those with a fractional part.
 
using real_arithmetic_type_domain = domain_union< integral_type_domain, floating_point_type_domain >
 Integers and floating point types, i.e. arithmetic types on the real line.
 
using arithmetic_type_domain = domain_union< integral_type_domain, inexact_type_domain >
 Every type arithmetic operations are defined on.
 
using signed_arithmetic_type_domain = domain_union< signed_integer_type_domain, inexact_type_domain >
 Arithmetic types that can represent a negative value.
 
template<typename Domain = any_extent_domain>
using extent_from_inputs = extent_pivot< extent_pivot_source::inputs, void, Domain >
 Extent variable bound by the input axes that name it.
 
template<typename Accessor , typename Domain = any_extent_domain>
using extent_from_operation = extent_pivot< extent_pivot_source::operation, Accessor, Domain >
 Extent variable supplied by the operation instance.
 
template<std::size_t N>
using extent_fixed = extent_pivot< extent_pivot_source::fixed, fixed_extent< N >, any_extent_domain >
 Extent variable fixed by the declaration of the operation.
 
template<std::size_t E>
using axis_same_as = extent_slot< E, same_extent_transform >
 Axis of the extent of an extent variable.
 
template<std::size_t I, typename Domain = any_type_domain>
using pivot_from_input = type_pivot< type_pivot_source::input, I, Domain >
 Pivot fixed by the data type of an input operand.
 
template<std::size_t I, typename Domain = any_type_domain, std::ptrdiff_t DefaultPivot = -1>
using pivot_from_output = type_pivot< type_pivot_source::output, I, Domain, DefaultPivot >
 Free pivot, adopted from a user supplied output operand.
 
template<typename Accessor , typename Domain = any_type_domain>
using pivot_from_operation = type_pivot< type_pivot_source::operation, 0, Domain, -1, Accessor >
 Pivot supplied by the operation instance.
 
template<typename Slots , typename Pivots >
using type_rule_operand_types_t = typename type_rule_operand_types< Slots, Pivots >::type
 Convenience alias for type_rule_operand_types<Slots, Pivots>::type.
 
template<std::size_t I = 0>
using slot_same_as = type_slot< I, same_type_transform >
 Slot whose operand has the pivot type itself.
 
template<std::size_t I = 0>
using slot_real_of = type_slot< I, real_type_transform >
 Slot whose operand has the real counterpart of the pivot type.
 
template<std::size_t I = 0>
using slot_complex_of = type_slot< I, complex_type_transform >
 Slot whose operand has the complex counterpart of the pivot type.
 
template<std::size_t I = 0>
using slot_inexact_of = type_slot< I, inexact_type_transform >
 Slot whose operand has the inexact counterpart of the pivot type.
 
template<numerical_type Type, std::size_t I = 0>
using slot_fixed = type_slot< I, fixed_type_transform< Type > >
 Slot whose operand has a fixed type, whatever the pivot is.
 
using access_flags = flagset< access_flag_bits >
 

Enumerations

enum class  backend_priority { unsupported = std::numeric_limits<int>::min() , fallback = -1024 , normal = 0 , optimal = 1024 }
 Enumeration defining the preference over the selection of a particular backend. More...
 
enum class  device_type { unknown = -1 , cpu , gpu , integrated_gpu }
 Broad classification of compute devices. More...
 
enum class  memory_resource_affinity { host , device , count }
 Enumeration to query memory_resource according to its intended usage. More...
 
enum class  memory_resource_kind {
  unified , managed , device_local , device_mapped ,
  host_staging , host
}
 Describes the nature of a memory resource. More...
 
enum class  joint_layout_build_flag_bits { enable_reordering = bit(0) , enable_coalescing = bit(1) }
 Flags to control the behavior of the joint_layout build behavior. More...
 
enum class  byte : uint8_t
 A byte of memory. More...
 
enum class  numerical_type {
  unknown = -1 , boolean , char8 , int8 ,
  uint8 , int16 , uint16 , int32 ,
  uint32 , int64 , uint64 , float16 ,
  float32 , float64 , complex_float16 , complex_float32 ,
  complex_float64 , count
}
 Representation of all considered numerical types for computations.
 
enum class  numerical_type_category {
  unknown = -1 , boolean , character , signed_integer ,
  unsigned_integer , floating_point , complex , count
}
 Broad categorical classification of numerical_type. More...
 
enum class  core_placement { trailing , named }
 Where the core axes of the operands lie. More...
 
enum class  extent_pivot_source { inputs , operation , fixed }
 Origin of the value of a shape rule extent variable. More...
 
enum class  output_batch { exact , broadcast_target , accumulated }
 Which batch axes an output supplied in advance may have. More...
 
enum class  type_pivot_source { input , output , operation }
 Origin of the value of a typing rule pivot. More...
 
enum class  type_rule_status {
  ok , invalid_type , domain_violation , undefined_transform ,
  slot_mismatch , unresolved_pivot , operand_count_mismatch
}
 Outcome of resolving a typing rule against concrete operand types. More...
 
enum class  access_flag_bits { read = bit(0) , write = bit(1) }
 

Functions

REXLIB_CONSTEXPR bool operator< (backend_priority lhs, backend_priority rhs) noexcept
 
REXLIB_CONSTEXPR bool operator<= (backend_priority lhs, backend_priority rhs) noexcept
 
REXLIB_CONSTEXPR bool operator> (backend_priority lhs, backend_priority rhs) noexcept
 
REXLIB_CONSTEXPR bool operator>= (backend_priority lhs, backend_priority rhs) noexcept
 
REXLIB_CONSTEXPR const char * to_string (backend_priority priority) noexcept
 
template<typename T >
std::basic_ostream< T > & operator<< (std::basic_ostream< T > &os, backend_priority priority)
 
REXLIB_NODISCARD REXLIB_CONSTEXPR std::size_t bit (std::size_t i) noexcept
 Returns a std::size_t type with a single bit set at the provided index.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type bit_range_mask (std::size_t start, std::size_t end) noexcept
 
template<typename T >
REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T & >::type set_lowest_zero_inplace (T &x) noexcept
 Sets the lowest '0' bit to '1' in place.
 
template<typename T >
REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T & >::type clear_lowest_one_inplace (T &x) noexcept
 Sets the lowest '1' bit to '0' in place.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type mask_trailing_zeros (T x) noexcept
 Returns a mask for all the consecutive trailing '0'-s of the input word.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type mask_trailing_ones (T x) noexcept
 Returns a mask for all the consecutive trailing '1'-s of the input word.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rotate_left (T x, int s) noexcept
 Returns the input word with a bitwise rotation towards the left.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rotate_right (T x, int s) noexcept
 Returns the input word with a bitwise rotation towards the right.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, bool >::type has_single_bit (T x) noexcept
 Checks if the input word has one and only one bit set to '1'.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type bit_floor (T x) noexcept
 Returns the largest power of 2 not greater than the input word.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type bit_ceil (T x) noexcept
 Returns the smallest power of 2 not less than the input word.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type bit_width (T x) noexcept
 Returns the number of bits required to represent the input number.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type count_leading_zeros (T x) noexcept
 Counts the number of consecutive '0's from the MSB.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type count_leading_ones (T x) noexcept
 Counts the number of consecutive '1's from the MSB.
 
template<typename T >
REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type count_trailing_zeros (T x) noexcept
 Counts the number of consecutive '0's from the LSB.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type count_trailing_ones (T x) noexcept
 Counts the number of consecutive '1's from the LSB.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type popcount (T x) noexcept
 Counts the number '1's in the input word.
 
template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, bool >::type parity (T x) noexcept
 Computes the parity of the input word.
 
std::shared_ptr< dispatcher > make_eager_dispatcher (std::shared_ptr< const program_manager > program_manager)
 Create a dispatcher that submits operations eagerly.
 
void execute (const operation &operation, span< array > output_operands, span< const const_array_ref > input_operands, const execution_context &context)
 Execute a operation.
 
array execute (const operation &operation, span< const const_array_ref > input_operands, const execution_context &context, array *out=nullptr)
 Execute a operation.
 
array execute_unary (const operation &operation, const const_array_ref &input, const execution_context &context, array *out=nullptr)
 Execute an unary operation.
 
void execute_unary (const operation &operation, span< array > output_operands, const_array_ref input, const execution_context &context)
 Execute an unary operation producing several outputs.
 
array execute_binary (const operation &operation, const_array_ref first_input, const_array_ref second_input, const execution_context &context, array *out=nullptr)
 Execute an unary operation.
 
void execute_binary (const operation &operation, span< array > output_operands, const_array_ref first_input, const_array_ref second_input, const execution_context &context)
 Execute a binary operation producing several outputs.
 
array execute_ternary (const operation &operation, const_array_ref first_input, const_array_ref second_input, const_array_ref third_input, const execution_context &context, array *out=nullptr)
 Execute an unary operation.
 
bool parse_device_index (const std::string &text, device_index &result)
 Parse the device ID from a string.
 
const char * to_string (device_type type) noexcept
 
const memory_resource & get_host_memory_resource () noexcept
 Get the resource representing host memory.
 
int score_host_affinity (memory_resource_kind kind) noexcept
 Assign a numeric affinity score for host use to a memory kind.
 
int score_device_affinity (memory_resource_kind kind) noexcept
 Assign a numeric affinity score for device use to a memory kind.
 
bool is_host_accessible (memory_resource_kind kind) noexcept
 Check if the memory kind can be directly accessed from the host.
 
bool is_device_accessible (memory_resource_kind kind) noexcept
 Check if the memory kind can be directly accessed from the device.
 
void broadcast_extents (std::vector< std::size_t > &extents1, std::vector< std::size_t > &extents2)
 Perform a broadcast operation between two sets of extents.
 
void broadcast_extents_accumulate (std::vector< std::size_t > &result, span< const std::size_t > other)
 Perform an cumulative extent broadcast step.
 
bool is_broadcast_compatible (span< const std::size_t > extents1, span< const std::size_t > extents2) noexcept
 Check if two extents can be broadcasted together.
 
bool is_broadcastable_to (span< const std::size_t > from_extents, span< const std::size_t > to_extents) noexcept
 Check if a set of extents can be broadcasted into another.
 
template<typename F >
REXLIB_CONSTEXPR auto visit (F &&func, const dynamic_subscript &subscript)
 Invoke the provided function with the value held by the dynamic subscript.
 
std::size_t sanitize_index (std::ptrdiff_t index, std::size_t extent)
 Ensure that the index is within bounds for a given extent.
 
REXLIB_CONSTEXPR const char * to_string (joint_layout_build_flag_bits x) noexcept
 
template<typename T >
std::basic_ostream< T > & operator<< (std::basic_ostream< T > &os, joint_layout_build_flag_bits x)
 
REXLIB_CONSTEXPR std::size_t end () noexcept
 Get the value representing the end of an array to be used as count.
 
REXLIB_CONSTEXPR slice all () noexcept
 Construct an slice containing all positions in the axis.
 
REXLIB_CONSTEXPR slice even () noexcept
 Construct an slice containing even positions in the axis.
 
REXLIB_CONSTEXPR slice odd () noexcept
 Construct an slice containing odd positions in the axis.
 
REXLIB_CONSTEXPR slice make_slice (std::size_t count) noexcept
 Create an slice using its count value.
 
REXLIB_CONSTEXPR slice make_slice (std::ptrdiff_t start, std::size_t count) noexcept
 Create an slice using its start and count values.
 
REXLIB_CONSTEXPR slice make_slice (std::ptrdiff_t start, std::size_t count, std::ptrdiff_t step) noexcept
 Create an slice using its start and count values.
 
slice sanitize_slice (const slice &slice, std::size_t extent)
 Sanitize a slice to ensure it is valid and within bounds for a given extent.
 
REXLIB_CONSTEXPR ellipsis_tag ellipsis () noexcept
 Construct an ellipsis_tag.
 
REXLIB_CONSTEXPR new_axis_tag new_axis () noexcept
 Construct a new_axis_tag.
 
version get_library_version () noexcept
 Get the version of the rexlib installation.
 
template<typename T >
REXLIB_NODISCARD std::size_t get_alignment (T *address) noexcept
 Get the alignment of a pointer.
 
REXLIB_NODISCARD REXLIB_CONSTEXPR std::size_t get_alignment (std::uintptr_t address) noexcept
 Get the alignment of an address.
 
template<typename T >
REXLIB_NODISCARD bool is_aligned (T *address, std::size_t alignment) noexcept
 Check if a pointer is aligned to the provided boundary.
 
REXLIB_NODISCARD REXLIB_CONSTEXPR bool is_aligned (std::uintptr_t address, std::size_t alignment) noexcept
 Check if an address is aligned to the provided boundary.
 
template<typename T >
REXLIB_NODISCARD T * align_floor (T *address, std::size_t alignment) noexcept
 Align a pointer to a lower or equal address that satisfies the provided alignment.
 
REXLIB_NODISCARD REXLIB_CONSTEXPR std::uintptr_t align_floor (std::uintptr_t address, std::size_t alignment) noexcept
 Align an address to a lower or equal address that satisfies the provided alignment.
 
REXLIB_CONSTEXPR std::uintptr_t & align_floor_inplace (std::uintptr_t &address, std::size_t alignment) noexcept
 Align an address to a lower or equal address that satisfies the provided alignment.
 
template<typename T >
REXLIB_NODISCARD T * align_ceil (T *address, std::size_t alignment) noexcept
 Align a pointer to a higher or equal address that satisfies the provided alignment.
 
REXLIB_NODISCARD REXLIB_CONSTEXPR std::uintptr_t align_ceil (std::uintptr_t address, std::size_t alignment) noexcept
 Align an address to a higher or equal address that satisfies the provided alignment.
 
REXLIB_CONSTEXPR std::uintptr_t & align_ceil_inplace (std::uintptr_t &address, std::size_t alignment) noexcept
 Align an address to a higher or equal address that satisfies the provided alignment.
 
template<typename T >
REXLIB_NODISCARD T * offset_bytes (T *address, std::ptrdiff_t count)
 Offset an address by a given amount of bytes.
 
void * aligned_alloc (std::size_t size, std::size_t alignment) noexcept
 Allocate memory with an alignment specification.
 
void aligned_free (void *ptr) noexcept
 Release a memory block previously allocated with aligned_alloc.
 
REXLIB_CONSTEXPR uint8_t as_uint8 (byte b) noexcept
 
REXLIB_CONSTEXPR byte as_byte (uint8_t b) noexcept
 
template<typename T >
byte * as_bytes (T *ptr) noexcept
 View an object as the bytes it is stored in.
 
template<typename T >
const byte * as_bytes (const T *ptr) noexcept
 View an object as the bytes it is stored in.
 
template<class IntegerType >
REXLIB_CONSTEXPR byte operator<< (byte b, IntegerType shift) noexcept
 
template<class IntegerType >
REXLIB_CONSTEXPR byte operator>> (byte b, IntegerType shift) noexcept
 
template<class IntegerType >
REXLIB_CONSTEXPR byte & operator<<= (byte &b, IntegerType shift) noexcept
 
template<class IntegerType >
REXLIB_CONSTEXPR byte & operator>>= (byte &b, IntegerType shift) noexcept
 
REXLIB_CONSTEXPR byte operator~ (byte b) noexcept
 
REXLIB_CONSTEXPR byte operator| (byte lhs, byte rhs) noexcept
 
REXLIB_CONSTEXPR byte operator& (byte lhs, byte rhs) noexcept
 
REXLIB_CONSTEXPR byte operator^ (byte lhs, byte rhs) noexcept
 
REXLIB_CONSTEXPR byte & operator|= (byte &lhs, byte rhs) noexcept
 
REXLIB_CONSTEXPR byte & operator&= (byte &lhs, byte rhs) noexcept
 
REXLIB_CONSTEXPR byte & operator^= (byte &lhs, byte rhs) noexcept
 
REXLIB_CONSTEXPR std::size_t get_byte_bits () noexcept
 
template<typename C >
REXLIB_CONSTEXPR void to_hex (byte b, C &high, C &low) noexcept
 
template<typename T >
std::basic_ostream< T > & operator<< (std::basic_ostream< T > &os, const byte &b)
 
array_descriptor make_contiguous_array_descriptor (span< const std::size_t > extents, numerical_type data_type)
 Create an array descriptor with a contiguous layout.
 
bool is_initialized (const array_descriptor &descriptor) noexcept
 Check if the array descriptor is initialized.
 
std::size_t compute_storage_requirement (const array_descriptor &descriptor)
 Compute the number of bytes required to store the given descriptor.
 
void * get_host_data (array_ref array)
 Get where an array holds its values, on the host, to write them.
 
const void * get_host_data (const_array_ref array)
 Get where an array holds its values, on the host, to read them.
 
template<typename T , typename Q >
REXLIB_NODISCARD T numerical_cast (const Q &src) noexcept
 Explicitly cast a numerical value from one type to another.
 
std::size_t get_size (numerical_type type) noexcept
 Get the size of a numerical type.
 
numerical_type make_complex (numerical_type type) noexcept
 Create a complex version, if exists.
 
numerical_type make_real (numerical_type type) noexcept
 Get the real equivalent of a numerical type.
 
numerical_type make_inexact (numerical_type type) noexcept
 Get the inexact equivalent of a numerical type.
 
numerical_type promote_types (numerical_type type1, numerical_type type2) noexcept
 Get the common type of two numerical types.
 
REXLIB_CONSTEXPR numerical_type_category get_category (numerical_type type) noexcept
 Get the category of the provided numerical type.
 
const char * to_string (numerical_type type) noexcept
 
const char * to_string (numerical_type_category category) noexcept
 
std::ostream & operator<< (std::ostream &os, numerical_type type)
 
std::ostream & operator<< (std::ostream &os, numerical_type_category category)
 
template<typename F , typename... Types>
REXLIB_CONSTEXPR auto dispatch_numerical_types (F &&visitor, Types &&...types)
 Dispatch a function with the numerical types.
 
REXLIB_CONSTEXPR bool is_domain_representable (numerical_type type) noexcept
 Check whether a type has a bit representation within a domain.
 
REXLIB_CONSTEXPR numerical_type_domain operator~ (const numerical_type_domain &domain) noexcept
 Compute the complement of a domain.
 
REXLIB_CONSTEXPR_CPP14 numerical_type_domain make_numerical_type_domain (numerical_type_category category) noexcept
 Create the domain holding every type of a given category.
 
template<typename Func >
auto visit (Func &&func, const scalar_value &value)
 Access the value held by a scalar_value with its concrete type.
 
template<typename T >
T scalar_value_cast (const scalar_value &value)
 Convert the value held by a scalar_value into a concrete type.
 
template<typename... Names>
REXLIB_CONSTEXPR operand_names< sizeof...(Names)> make_operand_names (Names... names) noexcept
 Build an operand name list.
 
REXLIB_NORETURN void throw_unexpected_operation (const operation &got, const operation_descriptor &expected)
 Report an operation that is not of the expected type.
 
REXLIB_NORETURN void throw_unexpected_operation (const operation &got, const char *expected)
 Report an operation that is not of the expected type, which has no static description.
 
template<typename Op >
const Op & operation_cast (const operation &op)
 Downcast an operation after checking its identity.
 
std::string describe_operand (const operation_descriptor &descriptor, std::size_t index, bool output_operand)
 Describe an operand for a diagnostic.
 
template<std::size_t OutputCount, std::size_t InputCount>
operation_descriptor make_operation_descriptor (const char *component, const char *name, const operand_names< OutputCount > &outputs, const operand_names< InputCount > &inputs) noexcept
 Build a descriptor from compile time operand name lists.
 
template<typename Domain >
extent_domain make_extent_domain () noexcept
 Build the domain an extent domain tag names.
 
template<typename Transform >
extent_transform make_extent_transform () noexcept
 Erase an extent transform tag.
 
template<typename Op >
type_rule_accessors< typenameOp::type_rule_type >::operation_data_type_array_type get_operation_data_types (const Op &operation) noexcept
 Get the data types an operation instance supplies to its typing rule.
 
const char * to_string (type_rule_status status) noexcept
 Get a human readable representation of a rule status.
 
template<typename Transform >
type_transform make_type_transform () noexcept
 Erase a type transform tag.
 
std::string get_default_plugin_directory ()
 Get the default plugin directory.
 
std::vector< std::string > get_plugin_search_path ()
 Get the directories where plugins are searched for.
 
void discover_plugins (const std::string &directory, plugin_manager &manager)
 Discover and load all plugins in a directory.
 
void discover_plugins (plugin_manager &manager)
 Discover and load all plugins in the search path.
 
std::size_t register_all_plugins_at (const plugin_manager &manager, service_catalog &catalog)
 Register all plugins from a plugin manager into an interface catalog.
 
template<typename T >
REXLIB_CONSTEXPR span< byte > as_bytes (const span< T > &other) noexcept
 
template<typename T >
REXLIB_CONSTEXPR span< const byte > as_bytes (const span< const T > &other) noexcept
 
template<typename T , std::size_t N>
REXLIB_CONSTEXPR span< byte, N *sizeof(T)> as_bytes (const span< T, N > &other) noexcept
 
template<typename T , std::size_t N>
REXLIB_CONSTEXPR span< const byte, N *sizeof(T)> as_bytes (const span< const T, N > &other) noexcept
 
template<typename T >
REXLIB_CONSTEXPR span< T > make_span (T *ptr, std::size_t count) noexcept
 
template<typename T >
REXLIB_CONSTEXPR span< const T > make_span (const T *ptr, std::size_t count) noexcept
 
template<typename T , std::size_t N>
REXLIB_CONSTEXPR span< T, N > make_span (std::array< T, N > &array) noexcept
 
template<typename T , std::size_t N>
REXLIB_CONSTEXPR span< const T, N > make_span (const std::array< T, N > &array) noexcept
 
template<typename T >
REXLIB_CONSTEXPR span< T > make_span (std::vector< T > &array) noexcept
 
template<typename T >
REXLIB_CONSTEXPR span< const T > make_span (const std::vector< T > &array) noexcept
 
REXLIB_INLINE_CONST_CONSTEXPR access_flags read_only (access_flag_bits::read)
 
REXLIB_INLINE_CONST_CONSTEXPR access_flags write_only (access_flag_bits::write)
 
REXLIB_INLINE_CONST_CONSTEXPR access_flags read_write ({access_flag_bits::read, access_flag_bits::write})
 
REXLIB_CONSTEXPR const char * to_string (access_flag_bits v) noexcept
 
template<typename T >
std::basic_ostream< T > & operator<< (std::basic_ostream< T > &os, access_flag_bits v)
 
void swap (dynamic_library &lhs, dynamic_library &rhs) noexcept
 Exchange two dynamic_library objects.
 
std::string get_hostname ()
 Get the hostname of the machine.
 
std::size_t get_total_system_memory ()
 Get the total memory available in the system.
 
std::size_t get_available_system_memory ()
 Get the memory available in the system.
 
std::size_t get_page_size ()
 Get the page size of the memory management subsystem.
 
array add (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise sum of two arrays.
 
array subtract (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise difference of two arrays.
 
array negate (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise negation of an array.
 
array abs (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise absolute value of an array.
 
array multiply (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise product of two arrays.
 
array divide (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise quotient of two arrays.
 
array modulo (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise modulo of two arrays.
 
array floor_divide (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise floor division of two arrays.
 
array sign (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise sign of an array.
 
std::pair< array, array > divmod (const_array_ref x, const_array_ref y, const execution_context &context, array *quotient=nullptr, array *remainder=nullptr)
 Compute the element-wise quotient and remainder of two arrays.
 
array bitwise_and (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise bitwise conjunction of two arrays.
 
array bitwise_or (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise bitwise disjunction of two arrays.
 
array bitwise_xor (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise bitwise exclusive disjunction of two arrays.
 
array bitwise_not (const_array_ref x, const execution_context &context, array *out=nullptr)
 Invert the bits of every element of an array.
 
array left_shift (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Shift the bits of an array leftwards.
 
array right_shift (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Shift the bits of an array rightwards.
 
array cast (array &input, numerical_type target_type, const execution_context &context)
 Cast an array to a given numerical type.
 
array cast_copy (const_array_ref input, numerical_type target_type, const execution_context &context, array *out=nullptr)
 Cast an array to a given numerical type into a new array.
 
array equal (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Test element-wise whether one array is equal to another.
 
array not_equal (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Test element-wise whether one array is different from another.
 
array less (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Test element-wise whether one array is less than another.
 
array less_equal (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Test element-wise whether one array is less than or equal to another.
 
array greater (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Test element-wise whether one array is greater than another.
 
array greater_equal (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Test element-wise whether one array is greater than or equal to another.
 
array real (array &x)
 Obtain a view of the real part of an array.
 
array imag (array &x)
 Obtain a view of the imaginary part of an array.
 
array conjugate (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise conjugate of an array.
 
array angle (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise argument of an array.
 
array empty (array_descriptor descriptor, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create an array without initializing its elements.
 
array zeros (array_descriptor descriptor, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create an array with all its elements set to zero.
 
array ones (array_descriptor descriptor, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create an array with all its elements set to one.
 
array full (array_descriptor descriptor, memory_resource_affinity affinity, const scalar_value &fill_value, const execution_context &context, array *out=nullptr)
 Create an array with all its elements set to a given value.
 
array arange (const scalar_value &start, const scalar_value &stop, const scalar_value &step, numerical_type data_type, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create a one dimensional array holding an arithmetic progression.
 
array arange (const scalar_value &start, const scalar_value &stop, numerical_type data_type, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create a one dimensional array counting from start to stop by one.
 
array arange (const scalar_value &stop, numerical_type data_type, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create a one dimensional array counting from zero to stop by one.
 
array linspace (const scalar_value &start, const scalar_value &stop, std::size_t count, numerical_type data_type, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create a one dimensional array of evenly spaced samples.
 
array linspace (const scalar_value &start, const scalar_value &stop, std::size_t count, bool endpoint, numerical_type data_type, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Create a one dimensional array of evenly spaced samples.
 
array copy (const_array_ref source, const execution_context &context, array *out=nullptr)
 Create an array as a copy of an existing one.
 
void fill (array &out, const scalar_value &fill_value, const execution_context &context)
 Set all the elements of an array to a given value.
 
array fft (const_array_ref x, span< const std::ptrdiff_t > axes, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft (const_array_ref x, span< const std::ptrdiff_t > axes, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft2 (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft2 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft3 (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array fft3 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform an array to the frequency domain.
 
array ifft (const_array_ref x, span< const std::ptrdiff_t > axes, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft (const_array_ref x, span< const std::ptrdiff_t > axes, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft2 (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft2 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft3 (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array ifft3 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform an array back from the frequency domain.
 
array rfft (const_array_ref x, span< const std::ptrdiff_t > axes, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft (const_array_ref x, span< const std::ptrdiff_t > axes, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft2 (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft2 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft3 (const_array_ref x, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array rfft3 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Transform a real array to the frequency domain.
 
array irfft (const_array_ref x, span< const std::ptrdiff_t > axes, std::size_t extent, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft (const_array_ref x, span< const std::ptrdiff_t > axes, std::size_t extent, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft (const_array_ref x, std::size_t extent, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft (const_array_ref x, std::size_t extent, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft2 (const_array_ref x, std::size_t extent, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft2 (const_array_ref x, std::size_t extent, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft3 (const_array_ref x, std::size_t extent, ops::fourier_normalization normalization, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array irfft3 (const_array_ref x, std::size_t extent, const execution_context &context, array *out=nullptr)
 Transform a half spectrum back into a real array.
 
array fftshift (const_array_ref x, span< const std::ptrdiff_t > axes, const execution_context &context, array *out=nullptr)
 Move the zero frequency of a spectrum to its centre.
 
array fftshift (const_array_ref x, const execution_context &context, array *out=nullptr)
 Move the zero frequency of a spectrum to its centre.
 
array ifftshift (const_array_ref x, span< const std::ptrdiff_t > axes, const execution_context &context, array *out=nullptr)
 Move the zero frequency of a spectrum back to its origin.
 
array ifftshift (const_array_ref x, const execution_context &context, array *out=nullptr)
 Move the zero frequency of a spectrum back to its origin.
 
array matmul (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Multiply two arrays as stacks of matrices.
 
array matvec (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Multiply a stack of matrices by a stack of vectors.
 
array vecmat (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Multiply a stack of vectors by a stack of matrices.
 
array vecdot (const_array_ref x, const_array_ref y, std::ptrdiff_t axis, const execution_context &context, array *out=nullptr)
 Contract two arrays along one axis, broadcasting the rest.
 
array vecdot (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Contract two arrays along their last axis.
 
array cross (const_array_ref x, const_array_ref y, std::ptrdiff_t axis, const execution_context &context, array *out=nullptr)
 Take the cross product of two arrays along one axis.
 
array cross (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Take the cross product of two arrays along their last axis.
 
array logical_and (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise conjunction of two arrays.
 
array logical_or (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise disjunction of two arrays.
 
array logical_xor (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise exclusive disjunction of two arrays.
 
array logical_not (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise negation of an array.
 
array is_nan (const_array_ref x, const execution_context &context, array *out=nullptr)
 Test element-wise whether an array holds values that are not numbers.
 
array is_inf (const_array_ref x, const execution_context &context, array *out=nullptr)
 Test element-wise whether an array holds infinite values.
 
array is_finite (const_array_ref x, const execution_context &context, array *out=nullptr)
 Test element-wise whether an array holds finite values.
 
array sign_bit (const_array_ref x, const execution_context &context, array *out=nullptr)
 Test element-wise whether the sign bit of an array is set.
 
array copysign (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compose an array from the magnitude of one and the sign of another.
 
array power (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Raise the elements of an array to the power of another.
 
array square (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise square of an array.
 
array reciprocal (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise reciprocal of an array.
 
array sqrt (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise square root of an array.
 
array cbrt (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise cube root of an array.
 
array exp (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise exponential of an array.
 
array exp2 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise base two exponential of an array.
 
array expm1 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise exponential of an array, minus one.
 
array log (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise natural logarithm of an array.
 
array log2 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise base two logarithm of an array.
 
array log10 (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise base ten logarithm of an array.
 
array log1p (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise natural logarithm of one plus an array.
 
array make_key (std::uint64_t seed, const execution_context &context, array *out=nullptr)
 Create a key from a seed.
 
std::uint64_t entropy_seed ()
 Draw a seed from the entropy source of the system.
 
array fold_in_key (const_array_ref key, const_array_ref data, const execution_context &context, array *out=nullptr)
 Derive keys from keys and values.
 
array split_key (const_array_ref key, std::size_t count, const execution_context &context, array *out=nullptr)
 Derive a sequence of keys from every key.
 
array sum (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Sum the elements of an array along the given axes.
 
array sum (const_array_ref x, const execution_context &context, array *out=nullptr)
 Sum the elements of an array over every axis.
 
array product (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Multiply the elements of an array along the given axes.
 
array product (const_array_ref x, const execution_context &context, array *out=nullptr)
 Multiply the elements of an array over every axis.
 
array amin (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Take the smallest elements of an array along the given axes.
 
array amin (const_array_ref x, const execution_context &context, array *out=nullptr)
 Take the smallest elements of an array over every axis.
 
array amax (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Take the largest elements of an array along the given axes.
 
array amax (const_array_ref x, const execution_context &context, array *out=nullptr)
 Take the largest elements of an array over every axis.
 
array all (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Test whether every element along the given axes is true.
 
array all (const_array_ref x, const execution_context &context, array *out=nullptr)
 Test whether every element over every axis is true.
 
array any (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Test whether any element along the given axes is true.
 
array any (const_array_ref x, const execution_context &context, array *out=nullptr)
 Test whether any element over every axis is true.
 
array argmin (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Locate the smallest elements of an array along the given axes.
 
array argmin (const_array_ref x, const execution_context &context, array *out=nullptr)
 Locate the smallest elements of an array over every axis.
 
array argmax (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Locate the largest elements of an array along the given axes.
 
array argmax (const_array_ref x, const execution_context &context, array *out=nullptr)
 Locate the largest elements of an array over every axis.
 
array count_nonzero (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Count the non zero elements along the given axes.
 
array count_nonzero (const_array_ref x, const execution_context &context, array *out=nullptr)
 Count the non zero elements over every axis.
 
array mean (const_array_ref x, span< const std::ptrdiff_t > axes, bool keep_dimensions, const execution_context &context, array *out=nullptr)
 Average the elements of an array along the given axes.
 
array mean (const_array_ref x, const execution_context &context, array *out=nullptr)
 Average the elements of an array over every axis.
 
array floor (const_array_ref x, const execution_context &context, array *out=nullptr)
 Round the elements of an array downwards.
 
array ceil (const_array_ref x, const execution_context &context, array *out=nullptr)
 Round the elements of an array upwards.
 
array trunc (const_array_ref x, const execution_context &context, array *out=nullptr)
 Round the elements of an array towards zero.
 
array round (const_array_ref x, const execution_context &context, array *out=nullptr)
 Round the elements of an array to the nearest integer.
 
array where (const_array_ref condition, const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Select element-wise between two arrays according to a condition.
 
array clip (const_array_ref x, const_array_ref lower, const_array_ref upper, const execution_context &context, array *out=nullptr)
 Confine the elements of an array to an interval.
 
array maximum (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Take the element-wise maximum of two arrays.
 
array minimum (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Take the element-wise minimum of two arrays.
 
array transfer (array &input, memory_resource_affinity affinity, const execution_context &context)
 Transfer an array to memory with the requested affinity.
 
array transfer_copy (const_array_ref input, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
 Transfer an array to memory with the requested affinity enforcing a copy.
 
array to_device (array &input, const execution_context &context)
 Transfer an array from host to device memory.
 
array to_device_copy (const_array_ref input, const execution_context &context, array *out=nullptr)
 Transfer an array to device memory enforcing a copy.
 
array to_host (array &input, const execution_context &context)
 Transfer an array to host accessible memory.
 
array to_host_copy (const_array_ref input, const execution_context &context, array *out=nullptr)
 Transfer an array to host accessible memory enforcing a copy.
 
array sin (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise sine of an array.
 
array cos (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise cosine of an array.
 
array tan (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise tangent of an array.
 
array asin (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise arc sine of an array.
 
array acos (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise arc cosine of an array.
 
array atan (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise arc tangent of an array.
 
array sinh (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise hyperbolic sine of an array.
 
array cosh (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise hyperbolic cosine of an array.
 
array tanh (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise hyperbolic tangent of an array.
 
array asinh (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise inverse hyperbolic sine of an array.
 
array acosh (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise inverse hyperbolic cosine of an array.
 
array atanh (const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise inverse hyperbolic tangent of an array.
 
array atan2 (const_array_ref y, const_array_ref x, const execution_context &context, array *out=nullptr)
 Compute the element-wise arc tangent of two arrays, by quadrant.
 
array hypot (const_array_ref x, const_array_ref y, const execution_context &context, array *out=nullptr)
 Compute the element-wise hypotenuse of two arrays.
 
array degrees (const_array_ref x, const execution_context &context, array *out=nullptr)
 Convert an array from radians to degrees.
 
array radians (const_array_ref x, const execution_context &context, array *out=nullptr)
 Convert an array from degrees to radians.
 
std::pair< array, array > sincos (const_array_ref x, const execution_context &context, array *sine=nullptr, array *cosine=nullptr)
 Compute the element-wise sine and cosine of an array at once.
 
array subarray (array &input, span< const dynamic_subscript > subscripts)
 Obtain a view of a rectangular part of an array.
 
const_array subarray (const_array_ref input, span< const dynamic_subscript > subscripts)
 Obtain a read-only view of a rectangular part of an array.
 

Variables

REXLIB_INLINE_CONST_CONSTEXPR std::size_t max_extent_pivot_count = 8
 Maximum number of extent variables a shape rule may declare.
 
REXLIB_INLINE_CONST_CONSTEXPR std::size_t max_type_pivot_count = 8
 Maximum number of free variables a typing rule may declare.
 
REXLIB_CONSTEXPR auto dynamic_extent = std::numeric_limits<std::size_t>::max()
 Constant representing dynamic size of an array.
 

Detailed Description

Arrays, the operations on them and the devices that run those operations.

Typedef Documentation

◆ axis_same_as

Axis of the extent of an extent variable.

Template Parameters
EIndex of the extent variable.

◆ extent_fixed

Extent variable fixed by the declaration of the operation.

Models core axes of a fixed length, such as the three components of a cross product. The value reaches the interpreter with the extents the operation instance supplies, so a rule reading only fixed extents needs no parameters.

Template Parameters
NThe extent.

◆ extent_from_inputs

Extent variable bound by the input axes that name it.

Template Parameters
DomainTag naming the admissible extents.

◆ extent_from_operation

Extent variable supplied by the operation instance.

Models operations that fix an extent by themselves, such as the length of a sequence.

Template Parameters
AccessorType reading the extent from the parameters of the operation instance.
DomainTag naming the admissible extents.

◆ pivot_from_input

Pivot fixed by the data type of an input operand.

Template Parameters
IIndex of the input operand.
DomainTag naming the admissible types.

◆ pivot_from_operation

Pivot supplied by the operation instance.

Models operations that carry a type as a parameter, such as a cast to a requested data type. The values the operation supplies are taken in the order the pivots that read them are declared.

Template Parameters
AccessorType reading the value from the parameters of the operation instance.
DomainTag naming the admissible types.

◆ pivot_from_output

template<std::size_t I, typename Domain = any_type_domain, std::ptrdiff_t DefaultPivot = -1>
using rexlib::pivot_from_output = typedef type_pivot<type_pivot_source::output, I, Domain, DefaultPivot>

Free pivot, adopted from a user supplied output operand.

Template Parameters
IIndex of the output operand.
DomainTag naming the admissible types.
DefaultPivotIndex of the pivot whose value is adopted when the user did not pre-allocate the output, or -1 to leave it unknown.

◆ slot_complex_of

Slot whose operand has the complex counterpart of the pivot type.

Template Parameters
IIndex of the pivot.

◆ slot_fixed

Slot whose operand has a fixed type, whatever the pivot is.

Template Parameters
TypeThe type of the operand.
IIndex of the pivot. Unused, but kept so that every slot names a pivot.

◆ slot_inexact_of

Slot whose operand has the inexact counterpart of the pivot type.

Template Parameters
IIndex of the pivot.

◆ slot_real_of

Slot whose operand has the real counterpart of the pivot type.

Template Parameters
IIndex of the pivot.

◆ slot_same_as

Slot whose operand has the pivot type itself.

Template Parameters
IIndex of the pivot.

◆ type_list_cat_t

template<typename... Lists>
using rexlib::type_list_cat_t = typedef typename type_list_cat<Lists...>::type

Convenience alias for type_list_cat<Lists...>::type.

Template Parameters
ListsSequence of type_list specializations to be concatenated.

◆ type_rule_operand_types_t

Convenience alias for type_rule_operand_types<Slots, Pivots>::type.

Template Parameters
Slotstype_list of type_slot, one per operand.
Pivotstype_list of the resolved pivot element types.

Enumeration Type Documentation

◆ backend_priority

Enumeration defining the preference over the selection of a particular backend.

Enumerator
unsupported 

Backend isn't supported.

fallback 

Used for dummy implementations.

normal 

Normal priority. Use by default.

optimal 

Backend specially optimized for the use case.

◆ byte

A byte of memory.

An object of any type can be read and written through a pointer to byte, as it can through a pointer to a character type. as_bytes gives such a pointer.

◆ core_placement

Where the core axes of the operands lie.

Enumerator
trailing 

The last axes of every operand.

named 

The axes the operation instance names.

◆ device_type

Broad classification of compute devices.

Enumerator
unknown 

Catch-all for devices that do not fit any of the following categories.

cpu 

CPU of the host node.

gpu 

A discrete Graphics Processing Unit (GPU), with its own dedicated memory.

integrated_gpu 

An integrated Graphics Processing Unit (iGPU), typically sharing memory with the host CPU.

◆ extent_pivot_source

Origin of the value of a shape rule extent variable.

Enumerator
inputs 

Bound by the input axes that name the variable.

operation 

Supplied by the operation instance.

fixed 

Fixed by the declaration of the operation.

◆ joint_layout_build_flag_bits

Flags to control the behavior of the joint_layout build behavior.

Enumerator
enable_reordering 

Reorder axes by memory locality.

enable_coalescing 

Coalesce contiguous axes.

◆ memory_resource_affinity

Enumeration to query memory_resource according to its intended usage.

Enumerator
host 

The memory resource can be optimally accessed by the host.

device 

The memory resource can be optimally accessed by the device.

◆ memory_resource_kind

Describes the nature of a memory resource.

Enumerator
unified 

The device and host share the same physical memory, such that both can access it efficiently.

managed 

The device and host have their own physical memory, although transfers are managed by the driver. Therefore, buffers can be treated as if they were residing in unified memory.

device_local 

Memory resource lives locally on the device and can not be accessed from the host.

device_mapped 

Memory resource resides in the host although it can be accessed from the device at a certain performance penalty.

host_staging 

Memory resource resides in the host and can not be accessed from the device. However, contents can be transferred from and to the device.

host 

Memory resource resides in the host and can not be accessed nor transferred to a device.

◆ numerical_type_category

Broad categorical classification of numerical_type.

See also
numerical_type

◆ output_batch

Which batch axes an output supplied in advance may have.

Enumerator
exact 

Exactly those the inputs broadcast to.

broadcast_target 

Any the inputs broadcast to, shared by every output.

accumulated 

Those of the input at the same position, its accumulator.

Each output has the shape of its accumulator. The batch axes of all inputs broadcast together, and the broadcast batch axes an accumulator lacks, or holds with an extent of one, are reduced into it.

◆ type_pivot_source

Origin of the value of a typing rule pivot.

Enumerator
input 

Fixed by the data type of an input operand.

output 

Free. Adopted from the user supplied output operand, if any.

operation 

Supplied by the operation instance at runtime.

◆ type_rule_status

Outcome of resolving a typing rule against concrete operand types.

Enumerator
ok 

The rule resolved successfully.

invalid_type 

A pivot took a value that is not a concrete numerical type.

domain_violation 

A pivot took a value outside the domain the rule declares.

undefined_transform 

A transform is not defined on the value its pivot took.

slot_mismatch 

An operand type disagrees with the slot binding it.

unresolved_pivot 

A free pivot could not be determined from the operands.

operand_count_mismatch 

An operand kind has more or fewer operands than slots.

The failure is attributed to the first operand without a slot, or to the first slot without an operand.

Function Documentation

◆ abs()

array rexlib::abs ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise absolute value of an array.

For complex types, the output is the real equivalent of the input type (e.g. complex_float32 -> float32).

Parameters
xThe array from which the absolute value is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise absolute value.

◆ acos()

array rexlib::acos ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise arc cosine of an array.

Parameters
xThe array whose arc cosine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise arc cosine.

◆ acosh()

array rexlib::acosh ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise inverse hyperbolic cosine of an array.

Parameters
xThe array whose inverse hyperbolic cosine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise inverse hyperbolic cosine.

◆ add()

array rexlib::add ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise sum of two arrays.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe first array to be added.
yThe second array to be added.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise sum.

◆ align_ceil() [1/2]

REXLIB_NODISCARD REXLIB_CONSTEXPR std::uintptr_t rexlib::align_ceil ( std::uintptr_t  address,
std::size_t  alignment 
)
noexcept

Align an address to a higher or equal address that satisfies the provided alignment.

Parameters
addressThe address to be aligned
alignmentThe minimum alignment
Returns
std::uintptr_t Aligned address

◆ align_ceil() [2/2]

template<typename T >
REXLIB_NODISCARD T * rexlib::align_ceil ( T *  address,
std::size_t  alignment 
)
noexcept

Align a pointer to a higher or equal address that satisfies the provided alignment.

Template Parameters
TPointed value type
Parameters
addressThe address to be aligned
alignmentThe minimum alignment
Returns
T* Aligned pointer

◆ align_ceil_inplace()

REXLIB_CONSTEXPR std::uintptr_t & rexlib::align_ceil_inplace ( std::uintptr_t &  address,
std::size_t  alignment 
)
noexcept

Align an address to a higher or equal address that satisfies the provided alignment.

Parameters
addressThe address to be aligned
alignmentThe minimum alignment
Returns
std::uintptr_t Aligned address
Note
The result is written in place and a reference is returned

◆ align_floor() [1/2]

REXLIB_NODISCARD REXLIB_CONSTEXPR std::uintptr_t rexlib::align_floor ( std::uintptr_t  address,
std::size_t  alignment 
)
noexcept

Align an address to a lower or equal address that satisfies the provided alignment.

Parameters
addressThe address to be aligned
alignmentThe minimum alignment
Returns
std::uintptr_t Aligned address

◆ align_floor() [2/2]

template<typename T >
REXLIB_NODISCARD T * rexlib::align_floor ( T *  address,
std::size_t  alignment 
)
noexcept

Align a pointer to a lower or equal address that satisfies the provided alignment.

Template Parameters
TPointed value type
Parameters
addressThe address to be aligned
alignmentThe minimum alignment
Returns
T* Aligned pointer

◆ align_floor_inplace()

REXLIB_CONSTEXPR std::uintptr_t & rexlib::align_floor_inplace ( std::uintptr_t &  address,
std::size_t  alignment 
)
noexcept

Align an address to a lower or equal address that satisfies the provided alignment.

Parameters
addressThe address to be aligned
alignmentThe minimum alignment
Returns
std::uintptr_t Aligned address
Note
The result is written in place and a reference is returned

◆ aligned_alloc()

void * rexlib::aligned_alloc ( std::size_t  size,
std::size_t  alignment 
)
noexcept

Allocate memory with an alignment specification.

Parameters
sizeNumber of bytes to allocate. It must be multiple of the alignment.
alignmentThe alignment of the data. Must be power of two.
Returns
void* The allocated memory area. nullptr on failure.
See also
aligned_free

◆ aligned_free()

void rexlib::aligned_free ( void *  ptr)
noexcept

Release a memory block previously allocated with aligned_alloc.

Parameters
ptrPointer to the data to be freed.
See also
aligned_alloc

◆ all() [1/3]

REXLIB_CONSTEXPR slice rexlib::all ( )
noexcept

Construct an slice containing all positions in the axis.

Returns
An slice representing all positions in the axis.

◆ all() [2/3]

array rexlib::all ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Test whether every element over every axis is true.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the tests.

◆ all() [3/3]

array rexlib::all ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Test whether every element along the given axes is true.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the tests.
Note
An element counts as true when it is non zero, so any type is accepted and the result is boolean regardless.

◆ amax() [1/2]

array rexlib::amax ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Take the largest elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the maxima.

◆ amax() [2/2]

array rexlib::amax ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Take the largest elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the maxima.
Note
Named apart from the element-wise maximum, which is a different operation. Complex arrays are not accepted, there being no ordering.

◆ amin() [1/2]

array rexlib::amin ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Take the smallest elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the minima.

◆ amin() [2/2]

array rexlib::amin ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Take the smallest elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the minima.
Note
Named apart from the element-wise minimum, which is a different operation. Complex arrays are not accepted, there being no ordering.

◆ angle()

array rexlib::angle ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise argument of an array.

Parameters
xThe array whose argument is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise argument, in radians.
Note
The result has the real counterpart of the input type, an angle having no imaginary part. Integer arrays are not accepted: the argument of an integer is a degenerate choice between zero and pi.

◆ any() [1/2]

array rexlib::any ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Test whether any element over every axis is true.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the tests.

◆ any() [2/2]

array rexlib::any ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Test whether any element along the given axes is true.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the tests.
Note
An element counts as true when it is non zero, so any type is accepted and the result is boolean regardless.

◆ arange() [1/3]

array rexlib::arange ( const scalar_value &  start,
const scalar_value &  stop,
const scalar_value &  step,
numerical_type  data_type,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create a one dimensional array holding an arithmetic progression.

The elements are start, start + step, start + 2 * step and so on, stopping before stop is reached or passed, so that the range is half open exactly as a loop over it would be. The length follows from the three of them and is ceil((stop - start) / step), or zero when the step points away from the stop.

The length is worked out in whole numbers when all three bounds are integers, and in double precision otherwise. This mirrors what a loop over the range would count, and is what keeps a purely integral range exact regardless of how large its bounds are.

Parameters
startValue of the first element.
stopValue the progression stops before.
stepDifference between one element and the next.
data_typeElement type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.
Exceptions
std::invalid_argumentIf the step is zero, or if the length the bounds describe is not a finite number.

◆ arange() [2/3]

array rexlib::arange ( const scalar_value &  start,
const scalar_value &  stop,
numerical_type  data_type,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create a one dimensional array counting from start to stop by one.

Parameters
startValue of the first element.
stopValue the progression stops before.
data_typeElement type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ arange() [3/3]

array rexlib::arange ( const scalar_value &  stop,
numerical_type  data_type,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create a one dimensional array counting from zero to stop by one.

Parameters
stopValue the progression stops before.
data_typeElement type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ argmax() [1/2]

array rexlib::argmax ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Locate the largest elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the indices of the maxima.

◆ argmax() [2/2]

array rexlib::argmax ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Locate the largest elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the indices of the maxima.
Note
The result holds indices, and so is int64 whatever the input type was.

◆ argmin() [1/2]

array rexlib::argmin ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Locate the smallest elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the indices of the minima.

◆ argmin() [2/2]

array rexlib::argmin ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Locate the smallest elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the indices of the minima.
Note
The result holds indices, and so is int64 whatever the input type was.

◆ as_bytes() [1/2]

template<typename T >
const byte * rexlib::as_bytes ( const T *  ptr)
noexcept

View an object as the bytes it is stored in.

Parameters
ptrPointer to the object.
Returns
const byte* Pointer to its first byte.

◆ as_bytes() [2/2]

template<typename T >
byte * rexlib::as_bytes ( T *  ptr)
noexcept

View an object as the bytes it is stored in.

Parameters
ptrPointer to the object.
Returns
byte* Pointer to its first byte.

◆ asin()

array rexlib::asin ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise arc sine of an array.

Parameters
xThe array whose arc sine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise arc sine.

◆ asinh()

array rexlib::asinh ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise inverse hyperbolic sine of an array.

Parameters
xThe array whose inverse hyperbolic sine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise inverse hyperbolic sine.

◆ atan()

array rexlib::atan ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise arc tangent of an array.

Parameters
xThe array whose arc tangent is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise arc tangent.

◆ atan2()

array rexlib::atan2 ( const_array_ref  y,
const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise arc tangent of two arrays, by quadrant.

Parameters
yThe ordinate array.
xThe abscissa array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise arc tangent of y / x.
Note
The ordinate comes first and the abscissa second, matching std::atan2 rather than reading left to right.

◆ atanh()

array rexlib::atanh ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise inverse hyperbolic tangent of an array.

Parameters
xThe array whose inverse hyperbolic tangent is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise inverse hyperbolic tangent.

◆ bit()

REXLIB_NODISCARD REXLIB_CONSTEXPR std::size_t rexlib::bit ( std::size_t  i)
noexcept

Returns a std::size_t type with a single bit set at the provided index.

If the provided index is larger than the width of std::size_t, the result will be zero.

Parameters
iIndex of the bit to be set. Zero based, starting from the LSB
Returns
std::size_t with one or zero bits set.

◆ bit_ceil()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::bit_ceil ( T  x)
noexcept

Returns the smallest power of 2 not less than the input word.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The result

◆ bit_floor()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::bit_floor ( T  x)
noexcept

Returns the largest power of 2 not greater than the input word.

If the input word is zero, it returns zero

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The result

◆ bit_range_mask()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::bit_range_mask ( std::size_t  start,
std::size_t  end 
)
noexcept
Template Parameters
TUnsigned integer type
Parameters
startFirst bit in the range (0 is LSB)
endPast-the-end bit in the range (0 is LSB)
Returns
T The mask

◆ bit_width()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type rexlib::bit_width ( T  x)
noexcept

Returns the number of bits required to represent the input number.

Template Parameters
Tunsigned type
Parameters
xThe input number
Returns
The number of bits required to represent the input

◆ bitwise_and()

array rexlib::bitwise_and ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise bitwise conjunction of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise bitwise conjunction.
Note
Every type with a defined bit pattern is accepted, which excludes only the floating point and complex ones.

◆ bitwise_not()

array rexlib::bitwise_not ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Invert the bits of every element of an array.

Parameters
xThe array whose bits are inverted.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise bitwise inversion.
Note
Every type with a defined bit pattern is accepted, which excludes only the floating point and complex ones.

◆ bitwise_or()

array rexlib::bitwise_or ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise bitwise disjunction of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise bitwise disjunction.
Note
Every type with a defined bit pattern is accepted, which excludes only the floating point and complex ones.

◆ bitwise_xor()

array rexlib::bitwise_xor ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise bitwise exclusive disjunction of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise bitwise exclusive disjunction.
Note
Every type with a defined bit pattern is accepted, which excludes only the floating point and complex ones.

◆ broadcast_extents()

void rexlib::broadcast_extents ( std::vector< std::size_t > &  extents1,
std::vector< std::size_t > &  extents2 
)

Perform a broadcast operation between two sets of extents.

This operation pads the smallest set of extents with ones at the beginning. Then, both sets are iterated jointly. If both elements are equal, none of them is modified. If unequal but one of them is 1, it is replaced by the other. Otherwise an exception is thrown.

Parameters
extents1The first set of extents.
extents2The second set of extents.
Exceptions
std::broadcast_errorwhen one of of the extents cannot be broadcasted.

◆ broadcast_extents_accumulate()

void rexlib::broadcast_extents_accumulate ( std::vector< std::size_t > &  result,
span< const std::size_t >  other 
)

Perform an cumulative extent broadcast step.

Parameters
resultThe extent vector to be updated. After a successful call, the broadcast result between the previous value of result and other is stored.
otherThe other set of extents.
Exceptions
std::broadcast_errorwhen one of of the extents cannot be broadcasted.

◆ cast()

array rexlib::cast ( array &  input,
numerical_type  target_type,
const execution_context &  context 
)

Cast an array to a given numerical type.

When the array already has the requested type, an alias of the input is returned without copying its data. Otherwise, a new array holding the cast elements is allocated and returned.

Parameters
inputThe array to be cast.
target_typeThe numerical type to cast the array to.
contextThe execution context used for dispatching.
Returns
array The array cast to the target type.

◆ cast_copy()

array rexlib::cast_copy ( const_array_ref  input,
numerical_type  target_type,
const execution_context &  context,
array *  out = nullptr 
)

Cast an array to a given numerical type into a new array.

Unlike cast, this function always allocates a new array holding the cast elements, even when the input already has the requested type.

Parameters
inputThe array to be cast.
target_typeThe numerical type to cast the array to.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array cast to the target type.

◆ cbrt()

array rexlib::cbrt ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise cube root of an array.

Parameters
xThe array whose cube root is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise cube root.
Note
Unlike sqrt this is defined for negative arrays, and accepts only real floating point ones.

◆ ceil()

array rexlib::ceil ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Round the elements of an array upwards.

Parameters
xThe array to be rounded.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise ceiling.

◆ clear_lowest_one_inplace()

template<typename T >
REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T & >::type rexlib::clear_lowest_one_inplace ( T &  x)
noexcept

Sets the lowest '1' bit to '0' in place.

When there are no bits to be cleared (because all are '0'-s) it does not have any effect

Template Parameters
Tunsigned type
Parameters
xThe input/output word
Returns
A reference to x

◆ clip()

array rexlib::clip ( const_array_ref  x,
const_array_ref  lower,
const_array_ref  upper,
const execution_context &  context,
array *  out = nullptr 
)

Confine the elements of an array to an interval.

Parameters
xThe array to be confined.
lowerThe lower bound.
upperThe upper bound.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise confined values.
Note
The bounds are arrays rather than scalars, so they broadcast against the value and may vary across it. Complex arrays are not accepted, there being no ordering to clamp against.

◆ compute_storage_requirement()

std::size_t rexlib::compute_storage_requirement ( const array_descriptor &  descriptor)

Compute the number of bytes required to store the given descriptor.

Parameters
descriptorThe descriptor from which the storage requirement is computed.
Returns
std::size_t Minimum number of bytes required to store the descriptor.

◆ conjugate()

array rexlib::conjugate ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise conjugate of an array.

Parameters
xThe array to be conjugated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise conjugate.
Note
Real arrays are accepted and left unchanged, so that code generic over the element type needs no special case.

◆ copy()

array rexlib::copy ( const_array_ref  source,
const execution_context &  context,
array *  out = nullptr 
)

Create an array as a copy of an existing one.

Parameters
sourceThe array to be copied.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ copysign()

array rexlib::copysign ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compose an array from the magnitude of one and the sign of another.

Parameters
xThe array supplying the magnitude.
yThe array supplying the sign.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise composition.

◆ cos()

array rexlib::cos ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise cosine of an array.

Parameters
xThe array whose cosine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise cosine.

◆ cosh()

array rexlib::cosh ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise hyperbolic cosine of an array.

Parameters
xThe array whose hyperbolic cosine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise hyperbolic cosine.

◆ count_leading_ones()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type rexlib::count_leading_ones ( T  x)
noexcept

Counts the number of consecutive '1's from the MSB.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The number of consecutive '1's in the input

◆ count_leading_zeros()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type rexlib::count_leading_zeros ( T  x)
noexcept

Counts the number of consecutive '0's from the MSB.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The number of consecutive '0's in the input

◆ count_nonzero() [1/2]

array rexlib::count_nonzero ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Count the non zero elements over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the counts.

◆ count_nonzero() [2/2]

array rexlib::count_nonzero ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Count the non zero elements along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the counts.
Note
The result holds counts, and so is int64 whatever the input type was.

◆ count_trailing_ones()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type rexlib::count_trailing_ones ( T  x)
noexcept

Counts the number of consecutive '1's from the LSB.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The number of consecutive '1's in the input

◆ count_trailing_zeros()

template<typename T >
REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type rexlib::count_trailing_zeros ( T  x)
noexcept

Counts the number of consecutive '0's from the LSB.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The number of consecutive '0's in the input

◆ cross() [1/2]

array rexlib::cross ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Take the cross product of two arrays along their last axis.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the cross products.

◆ cross() [2/2]

array rexlib::cross ( const_array_ref  x,
const_array_ref  y,
std::ptrdiff_t  axis,
const execution_context &  context,
array *  out = nullptr 
)

Take the cross product of two arrays along one axis.

Parameters
xThe first array.
yThe second array.
axisThe axis to take the product along. Negative values refer to axes from the end. It must have three components.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the cross products.
Note
The inputs are broadcast together, so a stack of vectors crosses with a single one without either being written out.

◆ degrees()

array rexlib::degrees ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Convert an array from radians to degrees.

Parameters
xThe array to be converted, in radians.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the converted angles, in degrees.

◆ describe_operand()

std::string rexlib::describe_operand ( const operation_descriptor &  descriptor,
std::size_t  index,
bool  output_operand 
)

Describe an operand for a diagnostic.

Yields the operand's quoted name when it has one and its index otherwise, so that building a message never depends on a name being present.

Parameters
descriptorThe operation description.
indexIndex of the operand.
output_operandWhether the operand is an output.
Returns
std::string The description.

◆ discover_plugins() [1/2]

void rexlib::discover_plugins ( const std::string &  directory,
plugin_manager &  manager 
)

Discover and load all plugins in a directory.

Parameters
directoryDirectory where plugins are searched.
managerPlugin manager where plugins are loaded.

◆ discover_plugins() [2/2]

void rexlib::discover_plugins ( plugin_manager &  manager)

Discover and load all plugins in the search path.

Parameters
managerPlugin manager where plugins are loaded.
See also
get_plugin_search_path

◆ dispatch_numerical_types()

template<typename F , typename... Types>
REXLIB_CONSTEXPR auto rexlib::dispatch_numerical_types ( F &&  visitor,
Types &&...  types 
)

Dispatch a function with the numerical types.

This function dispatches a set of numerical_type-s and calls the provided visitor with the dispatched types wrapped around a type_tag. In case a type fails conversion to a C++ type, type_tag<void> is passed.

Template Parameters
FFunctor to be dispatched.
Typesany amount of numeric_type-s
Parameters
visitorFunction to be called with the dispatched types.
typesTypes to be dispatched.
Returns
auto The result of calling visitor(types...)
See also
numerical_type
type_tag

◆ divide()

array rexlib::divide ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise quotient of two arrays.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe dividend array.
yThe divisor array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise quotient x / y.

◆ divmod()

std::pair< array, array > rexlib::divmod ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  quotient = nullptr,
array *  remainder = nullptr 
)

Compute the element-wise quotient and remainder of two arrays.

Computing both at once is cheaper than calling floor_divide and modulo in turn, the division being the expensive half of each, and the two results agree by construction.

Parameters
xThe dividend array.
yThe divisor array.
contextThe execution context used for dispatching.
quotientOptional output parameter to be re-used.
remainderOptional output parameter to be re-used.
Returns
std::pair<array, array> The element-wise quotient and remainder.
Note
As with floor_divide the quotient is rounded towards negative infinity, so that it pairs with the remainder. Complex arrays are not accepted.
See also
floor_divide
modulo

◆ ellipsis()

REXLIB_CONSTEXPR ellipsis_tag rexlib::ellipsis ( )
noexcept

Construct an ellipsis_tag.

Returns
ellipsis_tag Newly constructed tag.

◆ empty()

array rexlib::empty ( array_descriptor  descriptor,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create an array without initializing its elements.

Parameters
descriptorDescribes the shape and data type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ end()

REXLIB_CONSTEXPR std::size_t rexlib::end ( )
noexcept

Get the value representing the end of an array to be used as count.

Returns
std::size_t end value

◆ entropy_seed()

std::uint64_t rexlib::entropy_seed ( )

Draw a seed from the entropy source of the system.

The seed joins two draws of std::random_device, so all of its 64 bits are random. Each call gives a different seed, and the result can be recorded to repeat a computation.

Returns
std::uint64_t The seed.
Exceptions
std::exceptionWhen std::random_device cannot reach an entropy source.

◆ equal()

array rexlib::equal ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether one array is equal to another.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise comparison.

◆ even()

REXLIB_CONSTEXPR slice rexlib::even ( )
noexcept

Construct an slice containing even positions in the axis.

Returns
An slice representing even positions in the axis.

◆ execute() [1/2]

void rexlib::execute ( const operation &  operation,
span< array >  output_operands,
span< const const_array_ref >  input_operands,
const execution_context &  context 
)

Execute a operation.

Parameters
operationThe operation to be executed.
output_operandsThe output operands.
input_operandsThe input operands.
contextThe execution context used for dispatching.

◆ execute() [2/2]

array rexlib::execute ( const operation &  operation,
span< const const_array_ref >  input_operands,
const execution_context &  context,
array *  out = nullptr 
)

Execute a operation.

Parameters
operationThe operation to be executed.
input_operandsThe input operands.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.

◆ execute_binary() [1/2]

array rexlib::execute_binary ( const operation &  operation,
const_array_ref  first_input,
const_array_ref  second_input,
const execution_context &  context,
array *  out = nullptr 
)

Execute an unary operation.

Parameters
operationThe operation to be executed.
first_inputThe first input operand.
second_inputThe second input operand.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.

◆ execute_binary() [2/2]

void rexlib::execute_binary ( const operation &  operation,
span< array >  output_operands,
const_array_ref  first_input,
const_array_ref  second_input,
const execution_context &  context 
)

Execute a binary operation producing several outputs.

Parameters
operationThe operation to be executed.
output_operandsThe output operands, in signature order.
first_inputThe first input operand.
second_inputThe second input operand.
contextThe execution context used for dispatching.
See also
execute_unary

◆ execute_ternary()

array rexlib::execute_ternary ( const operation &  operation,
const_array_ref  first_input,
const_array_ref  second_input,
const_array_ref  third_input,
const execution_context &  context,
array *  out = nullptr 
)

Execute an unary operation.

Parameters
operationThe operation to be executed.
first_inputThe first input operand.
second_inputThe second input operand.
third_inputThe third input operand.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.

◆ execute_unary() [1/2]

array rexlib::execute_unary ( const operation &  operation,
const const_array_ref &  input,
const execution_context &  context,
array *  out = nullptr 
)

Execute an unary operation.

Parameters
operationThe operation to be executed.
inputThe input operand.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.

◆ execute_unary() [2/2]

void rexlib::execute_unary ( const operation &  operation,
span< array >  output_operands,
const_array_ref  input,
const execution_context &  context 
)

Execute an unary operation producing several outputs.

Unlike the single output form there is nothing to return: an output that already holds storage is reused and one that does not is allocated and written back in place, so the results are delivered through output_operands.

Parameters
operationThe operation to be executed.
output_operandsThe output operands, in signature order.
inputThe input operand.
contextThe execution context used for dispatching.

◆ exp()

array rexlib::exp ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise exponential of an array.

Parameters
xThe array whose exponential is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise exponential.

◆ exp2()

array rexlib::exp2 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise base two exponential of an array.

Parameters
xThe array whose exponential is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise base two exponential.

◆ expm1()

array rexlib::expm1 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise exponential of an array, minus one.

Parameters
xThe array whose exponential is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise exponential minus one.
Note
Accurate for arrays close to zero, where computing the exponential and subtracting one loses the significant digits.

◆ fft() [1/4]

array rexlib::fft ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Transforms along the last axis and treats the rest as batch dimensions, which is how one dimensional data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ fft() [2/4]

array rexlib::fft ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Transforms along the last axis and treats the rest as batch dimensions, which is how one dimensional data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.

◆ fft() [3/4]

array rexlib::fft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Parameters
xThe array to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.
Note
Real arrays are accepted and produce the complex spectrum of the same precision. The full spectrum is stored; use rfft to store only what a real signal needs.
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ fft() [4/4]

array rexlib::fft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Parameters
xThe array to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.
Note
Real arrays are accepted and produce the complex spectrum of the same precision. The full spectrum is stored; use rfft to store only what a real signal needs.

◆ fft2() [1/2]

array rexlib::fft2 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Transforms along the last two axes and treats the rest as batch dimensions, which is how image data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ fft2() [2/2]

array rexlib::fft2 ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Transforms along the last two axes and treats the rest as batch dimensions, which is how image data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.

◆ fft3() [1/2]

array rexlib::fft3 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Transforms along the last three axes and treats the rest as batch dimensions, which is how volume data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ fft3() [2/2]

array rexlib::fft3 ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array to the frequency domain.

Transforms along the last three axes and treats the rest as batch dimensions, which is how volume data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex spectrum.

◆ fftshift() [1/2]

array rexlib::fftshift ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Move the zero frequency of a spectrum to its centre.

Shifts along every axis.

Parameters
xThe array to be shifted.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the shifted array.

◆ fftshift() [2/2]

array rexlib::fftshift ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
const execution_context &  context,
array *  out = nullptr 
)

Move the zero frequency of a spectrum to its centre.

Parameters
xThe array to be shifted.
axesThe axes to shift along. Negative values refer to axes from the end.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the shifted array.

◆ fill()

void rexlib::fill ( array &  out,
const scalar_value &  fill_value,
const execution_context &  context 
)

Set all the elements of an array to a given value.

Parameters
outThe array whose elements are set.
fill_valueValue to which all the elements are set.
contextThe execution context used for dispatching.

◆ floor()

array rexlib::floor ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Round the elements of an array downwards.

Parameters
xThe array to be rounded.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise floor.
Note
Integer arrays are not accepted, rounding one being a copy.

◆ floor_divide()

array rexlib::floor_divide ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise floor division of two arrays.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe dividend array.
yThe divisor array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise quotient, rounded down.
Note
The quotient is rounded towards negative infinity rather than towards zero, so that it pairs with the remainder computed by modulo. Complex arrays are not accepted.
See also
modulo

◆ fold_in_key()

array rexlib::fold_in_key ( const_array_ref  key,
const_array_ref  data,
const execution_context &  context,
array *  out = nullptr 
)

Derive keys from keys and values.

Parameters
keyThe uint64 keys.
dataThe uint64 values folded into the keys. It broadcasts against key.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The derived keys.
See also
ops::fold_in_key_operation

◆ full()

array rexlib::full ( array_descriptor  descriptor,
memory_resource_affinity  affinity,
const scalar_value &  fill_value,
const execution_context &  context,
array *  out = nullptr 
)

Create an array with all its elements set to a given value.

Parameters
descriptorDescribes the shape and data type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
fill_valueValue to which all the elements are set.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ get_alignment() [1/2]

REXLIB_NODISCARD REXLIB_CONSTEXPR std::size_t rexlib::get_alignment ( std::uintptr_t  address)
noexcept

Get the alignment of an address.

Finds the largest power of two that is a divisor of the address

Parameters
addressThe address of which the alignment is determined
Returns
std::size_t The alignment (a power of two)

◆ get_alignment() [2/2]

template<typename T >
REXLIB_NODISCARD std::size_t rexlib::get_alignment ( T *  address)
noexcept

Get the alignment of a pointer.

Finds the largest power of two that is a divisor of the address

Template Parameters
TPointed value type
Parameters
addressThe address of which the alignment is determined
Returns
std::size_t The alignment (a power of two)

◆ get_available_system_memory()

std::size_t rexlib::get_available_system_memory ( )

Get the memory available in the system.

Returns
std::size_t Total memory in bytes.

◆ get_category()

REXLIB_CONSTEXPR numerical_type_category rexlib::get_category ( numerical_type  type)
noexcept

Get the category of the provided numerical type.

Parameters
typeThe type from which the category is inferred.
Returns
numerical_type_category The category of the input type or numerical_type_category::unknown if error.
Note
Usable in a constant expression, so that the same definition serves both a runtime classification and a compile time one. Anything classifying types on both sides of the dispatch boundary, such as a numerical_type_domain, depends on there being only one.

◆ get_default_plugin_directory()

std::string rexlib::get_default_plugin_directory ( )

Get the default plugin directory.

Returns the path to a sub-directory named as "plugins" located in the same directory as the shared library of the core.

Returns
std::string Default plugin directory.

◆ get_host_data() [1/2]

void * rexlib::get_host_data ( array_ref  array)

Get where an array holds its values, on the host, to write them.

Blocks the calling thread until the commands that read or write the memory of the array have finished.

Parameters
arrayThe array to reach.
Returns
void* Its first byte of storage, never null.
Exceptions
std::invalid_argumentIf array is not initialized.
unsupported_capability_errorIf its storage is not host accessible.
See also
access_hazard_tracker

◆ get_host_data() [2/2]

const void * rexlib::get_host_data ( const_array_ref  array)

Get where an array holds its values, on the host, to read them.

Blocks the calling thread until the commands that write the memory of the array have finished.

Parameters
arrayThe array to reach.
Returns
const void* Its first byte of storage, never null.
Exceptions
std::invalid_argumentIf array is not initialized.
unsupported_capability_errorIf its storage is not host accessible.
See also
access_hazard_tracker

◆ get_host_memory_resource()

const memory_resource & rexlib::get_host_memory_resource ( )
noexcept

Get the resource representing host memory.

The returned resource has kind memory_resource_kind::host. It represents plain host-addressable memory.

Returns
Reference to the host memory resource singleton. The reference is valid for the entire lifetime of the process.

◆ get_hostname()

std::string rexlib::get_hostname ( )

Get the hostname of the machine.

Returns
std::string The hostname.

◆ get_library_version()

version rexlib::get_library_version ( )
noexcept

Get the version of the rexlib installation.

This function returns the version of the loaded rexlib .so file

Returns
version Version of the installation

◆ get_operation_data_types()

template<typename Op >
type_rule_accessors< typenameOp::type_rule_type >::operation_data_type_array_type rexlib::get_operation_data_types ( const Op &  operation)
noexcept

Get the data types an operation instance supplies to its typing rule.

Evaluates the accessors of the rule's operation supplied pivots on the parameters of the operation. An operation whose rule has none supplies none, whether it has parameters or not.

Template Parameters
OpThe concrete operation type.
Parameters
operationThe operation instance.
Returns
The data types, in the order their pivots are declared.

◆ get_page_size()

std::size_t rexlib::get_page_size ( )

Get the page size of the memory management subsystem.

Returns
std::size_t The page size.

◆ get_plugin_search_path()

std::vector< std::string > rexlib::get_plugin_search_path ( )

Get the directories where plugins are searched for.

The entries of the REXLIB_PLUGINS_PATH environment variable come first, in the order they are written, separated by the platform's path separator. The default plugin directory is always searched last, so that setting the variable adds locations rather than hiding the installed plugins. Duplicates are removed.

Returns
std::vector<std::string> The plugin search path.
See also
get_default_plugin_directory

◆ get_size()

std::size_t rexlib::get_size ( numerical_type  type)
noexcept

Get the size of a numerical type.

Parameters
typeThe type for which the size should be obtained.
Returns
std::size_t The size.

◆ get_total_system_memory()

std::size_t rexlib::get_total_system_memory ( )

Get the total memory available in the system.

Returns
std::size_t Total memory in bytes.

◆ greater()

array rexlib::greater ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether one array is greater than another.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise comparison.
Note
Complex arrays are not accepted, the complex plane having no ordering.

◆ greater_equal()

array rexlib::greater_equal ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether one array is greater than or equal to another.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise comparison.
Note
Complex arrays are not accepted, the complex plane having no ordering.

◆ has_single_bit()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, bool >::type rexlib::has_single_bit ( T  x)
noexcept

Checks if the input word has one and only one bit set to '1'.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
true when x has a single bit set, otherwise false

◆ hypot()

array rexlib::hypot ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise hypotenuse of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise hypotenuse.
Note
Computed without the intermediate overflow that squaring the inputs would cause.

◆ ifft() [1/4]

array rexlib::ifft ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Transforms along the last axis and treats the rest as batch dimensions, which is how one dimensional data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ ifft() [2/4]

array rexlib::ifft ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Transforms along the last axis and treats the rest as batch dimensions, which is how one dimensional data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.

◆ ifft() [3/4]

array rexlib::ifft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Parameters
xThe array to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.
Note
The result stays complex. Use irfft for a spectrum known to come from a real signal.
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ ifft() [4/4]

array rexlib::ifft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Parameters
xThe array to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.
Note
The result stays complex. Use irfft for a spectrum known to come from a real signal.

◆ ifft2() [1/2]

array rexlib::ifft2 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Transforms along the last two axes and treats the rest as batch dimensions, which is how image data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ ifft2() [2/2]

array rexlib::ifft2 ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Transforms along the last two axes and treats the rest as batch dimensions, which is how image data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.

◆ ifft3() [1/2]

array rexlib::ifft3 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Transforms along the last three axes and treats the rest as batch dimensions, which is how volume data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ ifft3() [2/2]

array rexlib::ifft3 ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform an array back from the frequency domain.

Transforms along the last three axes and treats the rest as batch dimensions, which is how volume data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the complex signal.

◆ ifftshift() [1/2]

array rexlib::ifftshift ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Move the zero frequency of a spectrum back to its origin.

Shifts along every axis.

Parameters
xThe array to be shifted.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the shifted array.

◆ ifftshift() [2/2]

array rexlib::ifftshift ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
const execution_context &  context,
array *  out = nullptr 
)

Move the zero frequency of a spectrum back to its origin.

Parameters
xThe array to be shifted.
axesThe axes to shift along. Negative values refer to axes from the end.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the shifted array.

◆ imag()

array rexlib::imag ( array &  x)

Obtain a view of the imaginary part of an array.

As with real, nothing is computed and the result aliases x.

Unlike real this is not defined for every array: the imaginary part of a real array is zero everywhere, and no view can produce a value the storage does not hold. Build it with zeros instead.

Parameters
xThe array whose imaginary part is viewed. Must be complex.
Returns
array A view of the imaginary part of x.
Exceptions
std::invalid_argumentIf x is not complex.
See also
real

◆ irfft() [1/4]

array rexlib::irfft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
std::size_t  extent,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Parameters
xThe half spectrum to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.
Note
The extent of the restored axis cannot be deduced: an axis of m stored coefficients comes from either 2*(m - 1) or 2*m - 1 samples.
See also
rfft
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ irfft() [2/4]

array rexlib::irfft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
std::size_t  extent,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Parameters
xThe half spectrum to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.
Note
The extent of the restored axis cannot be deduced: an axis of m stored coefficients comes from either 2*(m - 1) or 2*m - 1 samples.
See also
rfft

◆ irfft() [3/4]

array rexlib::irfft ( const_array_ref  x,
std::size_t  extent,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Transforms along the last axis and treats the rest as batch dimensions.

Parameters
xThe half spectrum to be transformed.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ irfft() [4/4]

array rexlib::irfft ( const_array_ref  x,
std::size_t  extent,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Transforms along the last axis and treats the rest as batch dimensions.

Parameters
xThe half spectrum to be transformed.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.

◆ irfft2() [1/2]

array rexlib::irfft2 ( const_array_ref  x,
std::size_t  extent,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Transforms along the last two axes and treats the rest as batch dimensions.

Parameters
xThe half spectrum to be transformed.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ irfft2() [2/2]

array rexlib::irfft2 ( const_array_ref  x,
std::size_t  extent,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Transforms along the last two axes and treats the rest as batch dimensions.

Parameters
xThe half spectrum to be transformed.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.

◆ irfft3() [1/2]

array rexlib::irfft3 ( const_array_ref  x,
std::size_t  extent,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Transforms along the last three axes and treats the rest as batch dimensions.

Parameters
xThe half spectrum to be transformed.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ irfft3() [2/2]

array rexlib::irfft3 ( const_array_ref  x,
std::size_t  extent,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a half spectrum back into a real array.

Transforms along the last three axes and treats the rest as batch dimensions.

Parameters
xThe half spectrum to be transformed.
extentThe number of samples along the last transformed axis. That axis must hold extent / 2 + 1 coefficients.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the real signal.

◆ is_aligned() [1/2]

REXLIB_NODISCARD REXLIB_CONSTEXPR bool rexlib::is_aligned ( std::uintptr_t  address,
std::size_t  alignment 
)
noexcept

Check if an address is aligned to the provided boundary.

Parameters
addressThe address to be checked.
alignmentThe alignment requirement to be checked.
Returns
std::size_t The alignment (a power of two)

◆ is_aligned() [2/2]

template<typename T >
REXLIB_NODISCARD bool rexlib::is_aligned ( T *  address,
std::size_t  alignment 
)
noexcept

Check if a pointer is aligned to the provided boundary.

Template Parameters
TPointed value type
Parameters
addressThe address to be checked.
alignmentThe alignment requirement to be checked.
Returns
true If the pointer is aligned.
false If the pointer is not aligned.

◆ is_broadcast_compatible()

bool rexlib::is_broadcast_compatible ( span< const std::size_t >  extents1,
span< const std::size_t >  extents2 
)
noexcept

Check if two extents can be broadcasted together.

Parameters
extents1The first set of extents.
extents2The second set of extents.
Returns
true If both shapes are compatible.
false If both shapes are not compatible.

◆ is_broadcastable_to()

bool rexlib::is_broadcastable_to ( span< const std::size_t >  from_extents,
span< const std::size_t >  to_extents 
)
noexcept

Check if a set of extents can be broadcasted into another.

Parameters
from_extentsThe extents to be broadcasted.
to_extentsThe target set of extents.
Returns
true If both shapes are compatible.
false If both shapes are not compatible.

◆ is_device_accessible()

bool rexlib::is_device_accessible ( memory_resource_kind  kind)
noexcept

Check if the memory kind can be directly accessed from the device.

Parameters
kindMemory resource kind to be checked.
Returns
true If the memory resource can be accessed from the device.
false If the memory resource can not be accessed from the device. or an invalid kind was given.

◆ is_domain_representable()

REXLIB_CONSTEXPR bool rexlib::is_domain_representable ( numerical_type  type)
noexcept

Check whether a type has a bit representation within a domain.

Only the enumerators in [numerical_type::boolean, numerical_type::count) are representable. In particular numerical_type::unknown is not.

Parameters
typeThe type to be tested.
Returns
true The type is representable.
false The type is not representable.

◆ is_finite()

array rexlib::is_finite ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether an array holds finite values.

Parameters
xThe array to be tested.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise test.
Note
Only floating point and complex arrays are accepted, no other type being able to hold a non finite value.

◆ is_host_accessible()

bool rexlib::is_host_accessible ( memory_resource_kind  kind)
noexcept

Check if the memory kind can be directly accessed from the host.

Parameters
kindMemory resource kind to be checked.
Returns
true If the memory resource can be accessed from the host.
false If the memory resource can not be accessed from the host. or an invalid kind was given.

◆ is_inf()

array rexlib::is_inf ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether an array holds infinite values.

Parameters
xThe array to be tested.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise test.
Note
Only floating point and complex arrays are accepted, no other type being able to hold an infinity.

◆ is_initialized()

bool rexlib::is_initialized ( const array_descriptor &  descriptor)
noexcept

Check if the array descriptor is initialized.

Parameters
descriptorThe descriptor to check.
Returns
true If the descriptor is initialized.
false If the descriptor is not initialized.

◆ is_nan()

array rexlib::is_nan ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether an array holds values that are not numbers.

Parameters
xThe array to be tested.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise test.
Note
Only floating point and complex arrays are accepted, no other type being able to hold such a value.

◆ left_shift()

array rexlib::left_shift ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Shift the bits of an array leftwards.

Parameters
xThe array whose bits are shifted.
yThe number of positions to shift by.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise shifted values.
Note
Only integer arrays are accepted: the count shares the type of the value being shifted, and a boolean or character count is not a meaningful quantity.

◆ less()

array rexlib::less ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether one array is less than another.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise comparison.
Note
Complex arrays are not accepted, the complex plane having no ordering.

◆ less_equal()

array rexlib::less_equal ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether one array is less than or equal to another.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise comparison.
Note
Complex arrays are not accepted, the complex plane having no ordering.

◆ linspace() [1/2]

array rexlib::linspace ( const scalar_value &  start,
const scalar_value &  stop,
std::size_t  count,
bool  endpoint,
numerical_type  data_type,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create a one dimensional array of evenly spaced samples.

Parameters
startValue of the first element.
stopEnd of the sampled segment.
countNumber of samples.
endpointWhether stop is itself a sample. When it is not, the samples are those of the half open segment, so that consecutive blocks of them tile the line without repeating a value.
data_typeElement type of the array. It must be a floating point or complex type.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ linspace() [2/2]

array rexlib::linspace ( const scalar_value &  start,
const scalar_value &  stop,
std::size_t  count,
numerical_type  data_type,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create a one dimensional array of evenly spaced samples.

Takes count samples of the segment going from start to stop, both ends included. Unlike arange the length is what the caller states and the spacing is what follows from it, which is why the last element is exactly stop however the spacing rounds.

Parameters
startValue of the first element.
stopValue of the last element.
countNumber of samples.
data_typeElement type of the array. It must be a floating point or complex type: evenly spaced samples generally have a fractional part, and arange is the one that enumerates whole numbers.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ log()

array rexlib::log ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise natural logarithm of an array.

Parameters
xThe array whose logarithm is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise natural logarithm.

◆ log10()

array rexlib::log10 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise base ten logarithm of an array.

Parameters
xThe array whose logarithm is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise base ten logarithm.

◆ log1p()

array rexlib::log1p ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise natural logarithm of one plus an array.

Parameters
xThe array to which one is added.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise logarithm of one plus x.
Note
Accurate for arrays close to zero, where adding one first loses the significant digits.

◆ log2()

array rexlib::log2 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise base two logarithm of an array.

Parameters
xThe array whose logarithm is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise base two logarithm.

◆ logical_and()

array rexlib::logical_and ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise conjunction of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise conjunction.
Note
Arrays of any type are accepted, an element counting as true when it is non zero, and the result is boolean regardless.

◆ logical_not()

array rexlib::logical_not ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise negation of an array.

Parameters
xThe array to be negated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise negation.
Note
Arrays of any type are accepted, an element counting as true when it is non zero, and the result is boolean regardless.

◆ logical_or()

array rexlib::logical_or ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise disjunction of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise disjunction.
Note
Arrays of any type are accepted, an element counting as true when it is non zero, and the result is boolean regardless.

◆ logical_xor()

array rexlib::logical_xor ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise exclusive disjunction of two arrays.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise exclusive disjunction.
Note
Arrays of any type are accepted, an element counting as true when it is non zero, and the result is boolean regardless.

◆ make_complex()

numerical_type rexlib::make_complex ( numerical_type  type)
noexcept

Create a complex version, if exists.

Create the complex version of a numerical type, if this exists. Otherwise unknown is returned. This includes an already complex type.

Parameters
type
Returns
numerical_type.

◆ make_contiguous_array_descriptor()

array_descriptor rexlib::make_contiguous_array_descriptor ( span< const std::size_t >  extents,
numerical_type  data_type 
)

Create an array descriptor with a contiguous layout.

The resulting descriptor holds a contiguous layout built from the given extents paired with the provided numerical type.

Parameters
extentsThe extents of each dimension.
data_typeThe numerical type.
Returns
array_descriptor The resulting descriptor.
See also
strided_layout::make_contiguous_layout

◆ make_eager_dispatcher()

std::shared_ptr< dispatcher > rexlib::make_eager_dispatcher ( std::shared_ptr< const program_manager >  program_manager)

Create a dispatcher that submits operations eagerly.

The returned dispatcher builds and submits the executable program for each operation as soon as it is dispatched, caching backend-private resources (compiled kernels, FFT plans, ...) so they are reused across builds with matching launch configurations.

Parameters
program_managerThe manager queried to build the program for each operation. Must not be null.
Returns
A newly created eager dispatcher.
Exceptions
std::invalid_argumentif program_manager is null.

◆ make_extent_domain()

template<typename Domain >
extent_domain rexlib::make_extent_domain ( )
noexcept

Build the domain an extent domain tag names.

Template Parameters
DomainThe tag. It must provide static bool contains(std::size_t) and static const char* get_description().
Returns
extent_domain The domain.

◆ make_extent_transform()

template<typename Transform >
extent_transform rexlib::make_extent_transform ( )
noexcept

Erase an extent transform tag.

Template Parameters
TransformAn extent transform, such as same_extent_transform.
Returns
extent_transform The erased transform.

◆ make_inexact()

numerical_type rexlib::make_inexact ( numerical_type  type)
noexcept

Get the inexact equivalent of a numerical type.

Types that can only represent whole values, which is to say booleans and integers, map onto float64, the widest type able to hold their result. Floating point and complex types already have a fractional part and are returned unchanged.

Models the result type of operations whose value is not representable in the operand's own type, such as a mean. Characters are not admitted: they are not a numeric quantity to average.

Parameters
typeThe type to be made inexact.
Returns
numerical_type The equivalent inexact type. numerical_type::unknown if error.

◆ make_key()

array rexlib::make_key ( std::uint64_t  seed,
const execution_context &  context,
array *  out = nullptr 
)

Create a key from a seed.

A key is a uint64 element. The key of a seed holds the seed unchanged.

Parameters
seedThe seed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array A uint64 array without axes, in device memory, holding the key.

◆ make_numerical_type_domain()

REXLIB_CONSTEXPR_CPP14 numerical_type_domain rexlib::make_numerical_type_domain ( numerical_type_category  category)
noexcept

Create the domain holding every type of a given category.

Parameters
categoryThe category of the types belonging to the domain.
Returns
numerical_type_domain The domain.
See also
numerical_type_category

◆ make_operand_names()

template<typename... Names>
REXLIB_CONSTEXPR operand_names< sizeof...(Names)> rexlib::make_operand_names ( Names...  names)
noexcept

Build an operand name list.

Parameters
namesThe operand names, in signature order.
Returns
operand_names<sizeof...(Names)> The name list.

◆ make_operation_descriptor()

template<std::size_t OutputCount, std::size_t InputCount>
operation_descriptor rexlib::make_operation_descriptor ( const char *  component,
const char *  name,
const operand_names< OutputCount > &  outputs,
const operand_names< InputCount > &  inputs 
)
noexcept

Build a descriptor from compile time operand name lists.

Template Parameters
OutputCountNumber of output operands.
InputCountNumber of input operands.
Parameters
componentName of the component owning the operation.
nameName of the operation.
outputsNames of the output operands.
inputsNames of the input operands.
Returns
operation_descriptor The descriptor.

◆ make_real()

numerical_type rexlib::make_real ( numerical_type  type)
noexcept

Get the real equivalent of a numerical type.

For complex types, returns the corresponding floating-point type (e.g. complex_float32 -> float32). For other valid types it returns the type itself.

Parameters
typeA potentially complex numerical type.
Returns
numerical_type The equivalent real type. numerical_type::unknown if error.

◆ make_slice() [1/3]

REXLIB_CONSTEXPR slice rexlib::make_slice ( std::ptrdiff_t  start,
std::size_t  count 
)
noexcept

Create an slice using its start and count values.

The step is defaulted to be 1.

Parameters
startIndex of the first element
countNumber of elements.
Returns
slice An slice representing the first count positions starting from start.

◆ make_slice() [2/3]

REXLIB_CONSTEXPR slice rexlib::make_slice ( std::ptrdiff_t  start,
std::size_t  count,
std::ptrdiff_t  step 
)
noexcept

Create an slice using its start and count values.

The step is defaulted to be 1.

Parameters
startIndex of the first element
countNumber of elements.
stepJump between consecutive elements.
Returns
slice An slice representing the first count positions starting from start from step to step.

◆ make_slice() [3/3]

REXLIB_CONSTEXPR slice rexlib::make_slice ( std::size_t  count)
noexcept

Create an slice using its count value.

The start is defaulter to be 0. The step is defaulted to be 1.

Parameters
countNumber of elements.
Returns
slice An slice representing the first count positions in the axis.

◆ make_type_transform()

template<typename Transform >
type_transform rexlib::make_type_transform ( )
noexcept

Erase a type transform tag.

Template Parameters
TransformA type transform, such as same_type_transform.
Returns
type_transform The erased transform.

◆ mask_trailing_ones()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::mask_trailing_ones ( T  x)
noexcept

Returns a mask for all the consecutive trailing '1'-s of the input word.

Examples: 0b00000111 -> 0b00000111
0b00000110 -> 0b00000000
0b00000101 -> 0b00000001

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The mask

◆ mask_trailing_zeros()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::mask_trailing_zeros ( T  x)
noexcept

Returns a mask for all the consecutive trailing '0'-s of the input word.

Examples: 0b00000111 -> 0b00000000
0b00000110 -> 0b00000001
0b00000100 -> 0b00000011
0b00000000 -> 0b11111111

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The mask

◆ matmul()

array rexlib::matmul ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Multiply two arrays as stacks of matrices.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the product.
Note
The last two axes of each input are the matrix and the rest are a stack of them, broadcast between the inputs. Both inputs must have at least two axes: a vector is not promoted to a matrix.

◆ matvec()

array rexlib::matvec ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Multiply a stack of matrices by a stack of vectors.

Parameters
xThe stack of matrices.
yThe stack of vectors.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the products.
Note
The matrix's last axis is contracted with the vector's last axis, and everything before is a stack broadcast between the operands, as with matmul. Unlike matmul, neither operand is promoted: x must already have rank two or more and y rank one or more.
See also
vecmat
matmul

◆ maximum()

array rexlib::maximum ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Take the element-wise maximum of two arrays.

Selects, element by element, whichever of the two operands is greater, which is the lower half of a clip taken on its own.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise maximum.
Note
Complex arrays are not accepted, the complex plane having no ordering.

◆ mean() [1/2]

array rexlib::mean ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Average the elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the averages.

◆ mean() [2/2]

array rexlib::mean ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Average the elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the averages.
Note
The result has the inexact counterpart of the input type: an integer array averages to float64, while a float32 one stays float32.

◆ minimum()

array rexlib::minimum ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Take the element-wise minimum of two arrays.

Selects, element by element, whichever of the two operands is smaller, which is the upper half of a clip taken on its own.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise minimum.
Note
Complex arrays are not accepted, the complex plane having no ordering.

◆ modulo()

array rexlib::modulo ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise modulo of two arrays.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe dividend array.
yThe divisor array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise modulo x % y.
Note
The modulo behaves as Python's modulo and not like C's modulo. This is, output has the same sign as the divisor.

◆ multiply()

array rexlib::multiply ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise product of two arrays.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe first array to be multiplied.
yThe second array to be multiplied.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise product.

◆ negate()

array rexlib::negate ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise negation of an array.

Parameters
xThe array to be negated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise negation -x.

◆ new_axis()

REXLIB_CONSTEXPR new_axis_tag rexlib::new_axis ( )
noexcept

Construct a new_axis_tag.

Returns
new_axis_tag Newly constructed tag.

◆ not_equal()

array rexlib::not_equal ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether one array is different from another.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise comparison.

◆ numerical_cast()

template<typename T , typename Q >
REXLIB_NODISCARD T rexlib::numerical_cast ( const Q &  src)
noexcept

Explicitly cast a numerical value from one type to another.

Behaves like static_cast<T> for ordinary arithmetic types, but avoids the implicit intermediate conversions that static_cast performs when float16_t is involved. As float16_t interoperates with the rest of the world exclusively through float, a plain static_cast<T> to or from float16_t hides a second, implicit conversion (e.g. double -> float -> float16_t).

The conversion is applied element-wise for std::complex operands, so that complex values holding float16_t components are handled as well.

Template Parameters
TDestination type.
QSource type (deduced).
Parameters
srcValue to convert.
Returns
T The converted value.

◆ odd()

REXLIB_CONSTEXPR slice rexlib::odd ( )
noexcept

Construct an slice containing odd positions in the axis.

Returns
An slice representing odd positions in the axis.

◆ offset_bytes()

template<typename T >
REXLIB_NODISCARD T * rexlib::offset_bytes ( T *  address,
std::ptrdiff_t  count 
)

Offset an address by a given amount of bytes.

Template Parameters
TPointed type.
Parameters
addressPointer to be modified.
countNumber of bytes to add.
Returns
T* Pointer with offset.
Warning
This may break alignment requirements. Of the underlying type. Use it under your own risk

◆ ones()

array rexlib::ones ( array_descriptor  descriptor,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create an array with all its elements set to one.

Parameters
descriptorDescribes the shape and data type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

◆ operation_cast()

template<typename Op >
const Op & rexlib::operation_cast ( const operation &  op)

Downcast an operation after checking its identity.

Program builders reach an operation's parameters by downcasting it. Doing so through the operation id rather than through RTTI matches how the builder was selected in the first place, and accepts a subclass that reports its base's identity, which is exactly the substitutability the identity is supposed to express.

Template Parameters
OpThe concrete operation type.
Parameters
opThe operation to be downcast.
Returns
const Op& The operation.
Exceptions
std::invalid_argumentWhen op is not an Op.

◆ operator~()

REXLIB_CONSTEXPR numerical_type_domain rexlib::operator~ ( const numerical_type_domain &  domain)
noexcept

Compute the complement of a domain.

The complement is taken with respect to the set of all representable types, so no unrepresentable bit is ever set.

◆ parity()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, bool >::type rexlib::parity ( T  x)
noexcept

Computes the parity of the input word.

When the number of '1's in the input word is odd it returns true. Otherwise it returns false.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The number of '1's in the input

◆ parse_device_index()

bool rexlib::parse_device_index ( const std::string &  text,
device_index &  result 
)

Parse the device ID from a string.

A device ID string representation is expected to be:

Parameters
textAppropriately formatted string with the device ID
resultOutput device_index object.
Returns
true The string was parsed successfully and the result was written.
false The string was not parsed and the result was not written.

◆ popcount()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, int >::type rexlib::popcount ( T  x)
noexcept

Counts the number '1's in the input word.

Template Parameters
Tunsigned type
Parameters
xThe input word
Returns
The number of '1's in the input

◆ power()

array rexlib::power ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Raise the elements of an array to the power of another.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe base array.
yThe exponent array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise power x ** y.
Note
A negative exponent has no representable result for integer arrays, and is reported by the backend rather than rejected up front.

◆ product() [1/2]

array rexlib::product ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Multiply the elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the products.

◆ product() [2/2]

array rexlib::product ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Multiply the elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the products.

◆ promote_types()

numerical_type rexlib::promote_types ( numerical_type  type1,
numerical_type  type2 
)
noexcept

Get the common type of two numerical types.

The type promotion mechanism is heavily influenced by JAX's approach: https://docs.jax.dev/en/latest/jep/9407-type-promotion.html

However, unlike JAX, it allows type promotion from uint64 to int64.

Parameters
type1First numerical type.
type2Second numerical type.
Returns
numerical_type The common type.

◆ radians()

array rexlib::radians ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Convert an array from degrees to radians.

Parameters
xThe array to be converted, in degrees.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the converted angles, in radians.

◆ real()

array rexlib::real ( array &  x)

Obtain a view of the real part of an array.

Nothing is computed and nothing is allocated. A complex array is an array of twice as many real values, std::complex being layout compatible with an array of two of its value type, so the real parts are reachable by doubling the strides. The result therefore aliases x, and writing through it writes into x.

A real array is already its own real part and is returned as a plain alias.

Being a view rather than an operation, this needs no execution context and reaches no backend. Call array::share_const on the result for a read-only alias.

Parameters
xThe array whose real part is viewed.
Returns
array A view of the real part of x.
See also
imag

◆ reciprocal()

array rexlib::reciprocal ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise reciprocal of an array.

Parameters
xThe array whose reciprocal is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise reciprocal 1 / x.
Note
Integer arrays are not accepted: the reciprocal of every integer of magnitude above one is zero.

◆ register_all_plugins_at()

std::size_t rexlib::register_all_plugins_at ( const plugin_manager &  manager,
service_catalog &  catalog 
)

Register all plugins from a plugin manager into an interface catalog.

Parameters
managerThe plugin_manager that contains the plugins to be registered.
catalogInterface catalog where plugins will be registered.
Returns
std::size_t Number of plugins registered.

◆ rfft() [1/4]

array rexlib::rfft ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Transforms along the last axis and treats the rest as batch dimensions, which is how one dimensional data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ rfft() [2/4]

array rexlib::rfft ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Transforms along the last axis and treats the rest as batch dimensions, which is how one dimensional data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.

◆ rfft() [3/4]

array rexlib::rfft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Parameters
xThe array to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.
Note
Only the half that is not redundant is stored: the last axis named holds n / 2 + 1 coefficients. Complex arrays are not accepted.
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ rfft() [4/4]

array rexlib::rfft ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Parameters
xThe array to be transformed.
axesThe axes to transform along. Negative values refer to axes from the end. The remaining axes are batch dimensions.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.
Note
Only the half that is not redundant is stored: the last axis named holds n / 2 + 1 coefficients. Complex arrays are not accepted.

◆ rfft2() [1/2]

array rexlib::rfft2 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Transforms along the last two axes and treats the rest as batch dimensions, which is how image data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ rfft2() [2/2]

array rexlib::rfft2 ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Transforms along the last two axes and treats the rest as batch dimensions, which is how image data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.

◆ rfft3() [1/2]

array rexlib::rfft3 ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Transforms along the last three axes and treats the rest as batch dimensions, which is how volume data is usually laid out.

Parameters
xThe array to be transformed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.
Note
Scales as ops::fourier_normalization::backward does. Name another convention through the overload that takes one.

◆ rfft3() [2/2]

array rexlib::rfft3 ( const_array_ref  x,
ops::fourier_normalization  normalization,
const execution_context &  context,
array *  out = nullptr 
)

Transform a real array to the frequency domain.

Transforms along the last three axes and treats the rest as batch dimensions, which is how volume data is usually laid out.

Parameters
xThe array to be transformed.
normalizationWhich of the transform pair carries the scaling. A transform and its inverse undo one another whenever they are given the same one.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the half spectrum.

◆ right_shift()

array rexlib::right_shift ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Shift the bits of an array rightwards.

Parameters
xThe array whose bits are shifted.
yThe number of positions to shift by.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise shifted values.
Note
Only integer arrays are accepted: the count shares the type of the value being shifted, and a boolean or character count is not a meaningful quantity.

◆ rotate_left()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::rotate_left ( T  x,
int  s 
)
noexcept

Returns the input word with a bitwise rotation towards the left.

If the bit count is negative, it is equivalent to calling rotate_right(x, -s).

If the bit count is larger than the size of the word, it repeats cyclically.

Template Parameters
Tunsigned type
Parameters
xThe input word
sNumber of bits to be shifted
Returns
Input word rotated left

◆ rotate_right()

template<typename T >
REXLIB_NODISCARD REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T >::type rexlib::rotate_right ( T  x,
int  s 
)
noexcept

Returns the input word with a bitwise rotation towards the right.

If the bit count is negative, it is equivalent to calling rotate_left(x, -s)

If the bit count is larger than the size of the word, it repeats cyclically.

Template Parameters
Tunsigned type
Parameters
xThe input word
sNumber of bits to be shifted
Returns
Input word rotated right

◆ round()

array rexlib::round ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Round the elements of an array to the nearest integer.

Parameters
xThe array to be rounded.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise rounding.
Note
Ties are resolved towards the even neighbour, as IEEE 754 requires, rather than away from zero.

◆ sanitize_index()

std::size_t rexlib::sanitize_index ( std::ptrdiff_t  index,
std::size_t  extent 
)

Ensure that the index is within bounds for a given extent.

This function ensures that the input index is within bounds for the provided axis extent. In addition, it replaces negative values with indices referred from the end of the array.

Parameters
indexIndex to be checked.
extentExtent of the indexed axis.
Returns
std::size_t Sanitize value. Guaranteed to be in [0, extent)
Exceptions
std::out_of_rangeif the provided index is out of [-extent, extent)

◆ sanitize_slice()

slice rexlib::sanitize_slice ( const slice &  slice,
std::size_t  extent 
)

Sanitize a slice to ensure it is valid and within bounds for a given extent.

When end() is provided as count, it computes and replaces it by the actual element count.

Parameters
sliceSlice to be sanitized.
extentExtent of the axis to which the slice applies.
Returns
slice Sanitized slice.
Exceptions
std::out_of_rangeIf the slice is invalid or out of bounds.
std::invalid_argumentIf the slice step is zero.

◆ scalar_value_cast()

template<typename T >
T rexlib::scalar_value_cast ( const scalar_value &  value)

Convert the value held by a scalar_value into a concrete type.

Unlike get<T>(), which requires the requested type to match the stored one exactly, this dispatches on the stored numerical type and returns the value converted to T following numerical_cast's conversion rules.

Template Parameters
TDestination type. Must be one of the numerical_type native types.
Parameters
valueThe scalar value to convert.
Returns
T The stored value converted to T.
Exceptions
std::bad_castif the stored value's type can not be converted into T (e.g. a complex value into a real type).

◆ score_device_affinity()

int rexlib::score_device_affinity ( memory_resource_kind  kind)
noexcept

Assign a numeric affinity score for device use to a memory kind.

Higher values indicate memory that is more suitable for device access. Kinds that are fully device-local (e.g. device_local) receive the highest scores, while kinds that reside on the host and cannot be accessed from the device (e.g. host) receive the lowest ones.

Parameters
kindMemory resource kind to be scored.
Returns
int Affinity score. Higher means more device-friendly. Returns 0 if the memory kind is not device-accessible or kind is invalid.

◆ score_host_affinity()

int rexlib::score_host_affinity ( memory_resource_kind  kind)
noexcept

Assign a numeric affinity score for host use to a memory kind.

Higher values indicate memory that is more suitable for host access. Kinds that are fully host-local (e.g. host) receive the highest scores, while kinds that reside on the device and cannot be accessed from the host (e.g. device_local) receive the lowest ones.

Parameters
kindMemory resource kind to be scored.
Returns
int Affinity score. Higher means more host-friendly. Returns 0 if the memory kind is not host-accessible or kind is invalid.

◆ set_lowest_zero_inplace()

template<typename T >
REXLIB_CONSTEXPR std::enable_if< std::is_unsigned< T >::value, T & >::type rexlib::set_lowest_zero_inplace ( T &  x)
noexcept

Sets the lowest '0' bit to '1' in place.

When there are no bits to be set (because all are '1'-s) it does not have any effect

Template Parameters
Tunsigned type
Parameters
xThe input/output word
Returns
A reference to x

◆ sign()

array rexlib::sign ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise sign of an array.

Parameters
xThe array whose sign is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise sign.
Note
For complex types the result is the unit value with the same argument, x / |x|, rather than the sign of the real part.

◆ sign_bit()

array rexlib::sign_bit ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Test element-wise whether the sign bit of an array is set.

Parameters
xThe array to be tested.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise test.
Note
Only floating point arrays are accepted. This distinguishes negative zero from positive zero; for integers, comparing against zero says the same thing more plainly.

◆ sin()

array rexlib::sin ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise sine of an array.

Parameters
xThe array whose sine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise sine.

◆ sincos()

std::pair< array, array > rexlib::sincos ( const_array_ref  x,
const execution_context &  context,
array *  sine = nullptr,
array *  cosine = nullptr 
)

Compute the element-wise sine and cosine of an array at once.

Cheaper than calling sin and cos in turn, the two sharing the argument reduction that dominates their cost. Rotations and projections need both.

Parameters
xThe array whose sine and cosine are computed.
contextThe execution context used for dispatching.
sineOptional output parameter to be re-used.
cosineOptional output parameter to be re-used.
Returns
std::pair<array, array> The element-wise sine and cosine.
See also
sin
cos

◆ sinh()

array rexlib::sinh ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise hyperbolic sine of an array.

Parameters
xThe array whose hyperbolic sine is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise hyperbolic sine.

◆ split_key()

array rexlib::split_key ( const_array_ref  key,
std::size_t  count,
const execution_context &  context,
array *  out = nullptr 
)

Derive a sequence of keys from every key.

Parameters
keyThe uint64 keys.
countThe number of keys derived from every key.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The derived keys: the shape of key followed by one axis of count elements.
See also
ops::split_key_operation

◆ sqrt()

array rexlib::sqrt ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise square root of an array.

Parameters
xThe array whose square root is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise square root.
Note
The square root of a negative real is not representable in the operand type and yields NaN. Cast the input to a complex type first to obtain the complex branch.

◆ square()

array rexlib::square ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise square of an array.

Parameters
xThe array whose square is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise square.

◆ subarray() [1/2]

array rexlib::subarray ( array &  input,
span< const dynamic_subscript >  subscripts 
)

Obtain a view of a rectangular part of an array.

The result shares the storage of input and describes it through the layout that subscripts selects, so writing through the result writes through input. Nothing is allocated and no element is touched: this is a reinterpretation of the extents, the strides and the offset, which is why it needs neither an execution context nor an output parameter.

The subscripts are the same ones strided_layout::apply_subscripts accepts, so an axis may be indexed away, sliced with a step, kept whole with ellipsis_tag or introduced with new_axis_tag. Axes left unaddressed are kept whole, so fewer subscripts than the array has axes views the remaining ones in full.

Parameters
inputThe array to view into. Its storage outlives the result, which shares ownership of it.
subscriptsThe subscripts selecting the part of interest.
Returns
array A view of the selected part of input.
Exceptions
std::invalid_argumentIf input is not initialized or if there are more subscripts than the array has axes.
std::out_of_rangeIf a subscript falls outside its axis.
See also
strided_layout::apply_subscripts

◆ subarray() [2/2]

const_array rexlib::subarray ( const_array_ref  input,
span< const dynamic_subscript >  subscripts 
)

Obtain a read-only view of a rectangular part of an array.

Behaves as the non-const overload, except that the result only allows reading. It accepts anything a const_array_ref accepts, so it is also the overload chosen for a const array.

Parameters
inputThe array to view into. Its storage outlives the result, which shares ownership of it.
subscriptsThe subscripts selecting the part of interest.
Returns
const_array A read-only view of the selected part of input.
Exceptions
std::invalid_argumentIf input is not initialized or if there are more subscripts than the array has axes.
std::out_of_rangeIf a subscript falls outside its axis.
See also
strided_layout::apply_subscripts

◆ subtract()

array rexlib::subtract ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise difference of two arrays.

The inputs must be broadcast-compatible and share the same numerical type. When out is null, the shape and type of the result are deduced from the (broadcast) inputs.

Parameters
xThe array to be subtracted from.
yThe array to subtract.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise difference x - y.

◆ sum() [1/2]

array rexlib::sum ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Sum the elements of an array over every axis.

Parameters
xThe array to be reduced.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the sums.

◆ sum() [2/2]

array rexlib::sum ( const_array_ref  x,
span< const std::ptrdiff_t >  axes,
bool  keep_dimensions,
const execution_context &  context,
array *  out = nullptr 
)

Sum the elements of an array along the given axes.

Parameters
xThe array to be reduced.
axesThe axes to reduce over. Negative values refer to axes from the end. An empty list reduces over no axis; call the overload without it to reduce over every one.
keep_dimensionsWhether the reduced axes are kept with an extent of one instead of being dropped.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the sums.
Note
Every type add accepts is admitted, including boolean, whose sum is a disjunction. Overflow is a question about values, not about types.

◆ tan()

array rexlib::tan ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise tangent of an array.

Parameters
xThe array whose tangent is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise tangent.

◆ tanh()

array rexlib::tanh ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Compute the element-wise hyperbolic tangent of an array.

Parameters
xThe array whose hyperbolic tangent is computed.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise hyperbolic tangent.

◆ throw_unexpected_operation() [1/2]

REXLIB_NORETURN void rexlib::throw_unexpected_operation ( const operation &  got,
const char *  expected 
)

Report an operation that is not of the expected type, which has no static description.

Parameters
gotThe operation that was passed.
expectedName of the type that was expected.
Exceptions
std::invalid_argumentAlways.

◆ throw_unexpected_operation() [2/2]

REXLIB_NORETURN void rexlib::throw_unexpected_operation ( const operation &  got,
const operation_descriptor &  expected 
)

Report an operation that is not of the expected type.

Parameters
gotThe operation that was passed.
expectedDescription of the operation that was expected.
Exceptions
std::invalid_argumentAlways.

◆ to_device()

array rexlib::to_device ( array &  input,
const execution_context &  context 
)

Transfer an array from host to device memory.

If the array is already device-accessible, this operation returns an alias of the input array. Otherwise it behaves like to_device_copy

Parameters
inputArray to be transferred.
contextThe execution environment.
Returns
array The transferred array.
Warning
The returned array may alias the input array. Thus modifications to it may have side-effects on the input array and vice-versa. Prefer to_device_copy if this is a concern.

◆ to_device_copy()

array rexlib::to_device_copy ( const_array_ref  input,
const execution_context &  context,
array *  out = nullptr 
)

Transfer an array to device memory enforcing a copy.

Parameters
inputArray to be transferred.
contextThe execution environment.
outOptional array to reuse. If provided, its resources may be re-used and it will be overwritten with the newly created array.
Returns
array The transferred array.

◆ to_host()

array rexlib::to_host ( array &  input,
const execution_context &  context 
)

Transfer an array to host accessible memory.

If the array is already host-accessible, this operation returns an alias of the input array. Otherwise it behaves like to_host_copy

Parameters
inputArray to be transferred.
contextThe execution environment.
Returns
array The transferred array.
Warning
The returned array may alias the input array. Thus modifications to it may have side-effects on the input array and vice-versa. Prefer to_host_copy if this is a concern.

◆ to_host_copy()

array rexlib::to_host_copy ( const_array_ref  input,
const execution_context &  context,
array *  out = nullptr 
)

Transfer an array to host accessible memory enforcing a copy.

Parameters
inputArray to be transferred.
contextThe execution environment.
outOptional array to reuse. If provided, its resources may be re-used and it will be overwritten with the newly created array.
Returns
array The transferred array.

◆ to_string()

const char * rexlib::to_string ( type_rule_status  status)
noexcept

Get a human readable representation of a rule status.

Parameters
statusThe status.
Returns
const char* The representation.

◆ transfer()

array rexlib::transfer ( array &  input,
memory_resource_affinity  affinity,
const execution_context &  context 
)

Transfer an array to memory with the requested affinity.

If the array is already accessible from a memory resource with the requested affinity, this operation returns an alias of the input array. Otherwise it behaves like transfer_copy.

Parameters
inputArray to be transferred.
affinityAffinity of the memory resource to transfer the array to.
contextThe execution environment.
Returns
array The transferred array.
Warning
The returned array may alias the input array. Thus modifications to it may have side-effects on the input array and vice-versa. Prefer transfer_copy if this is a concern.

◆ transfer_copy()

array rexlib::transfer_copy ( const_array_ref  input,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Transfer an array to memory with the requested affinity enforcing a copy.

Unlike transfer, this operation always allocates fresh storage and copies the input into it, so the result never aliases the input.

Parameters
inputArray to be transferred.
affinityAffinity of the memory resource to transfer the array to.
contextThe execution environment.
outOptional array to reuse. If provided, its resources may be re-used and it will be overwritten with the newly created array.
Returns
array The transferred array.

◆ trunc()

array rexlib::trunc ( const_array_ref  x,
const execution_context &  context,
array *  out = nullptr 
)

Round the elements of an array towards zero.

Parameters
xThe array to be rounded.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise truncation.

◆ vecdot() [1/2]

array rexlib::vecdot ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Contract two arrays along their last axis.

Parameters
xThe first array.
yThe second array.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the contracted products.

◆ vecdot() [2/2]

array rexlib::vecdot ( const_array_ref  x,
const_array_ref  y,
std::ptrdiff_t  axis,
const execution_context &  context,
array *  out = nullptr 
)

Contract two arrays along one axis, broadcasting the rest.

Parameters
xThe first array.
yThe second array.
axisThe axis to contract along. Negative values refer to axes from the end.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the contracted products.
Note
The inputs are broadcast together and the contracted axis is lost. This differs from matmul, which takes the last two axes as a matrix.
See also
matmul

◆ vecmat()

array rexlib::vecmat ( const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Multiply a stack of vectors by a stack of matrices.

Parameters
xThe stack of vectors.
yThe stack of matrices.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the products.
Note
The vector's last axis is contracted with the matrix's second to last axis, and everything before is a stack broadcast between the operands. It is the mirror image of matvec. Neither operand is promoted, so x must already have rank one or more and y rank two or more.
See also
matvec
matmul

◆ visit() [1/2]

template<typename F >
REXLIB_CONSTEXPR auto rexlib::visit ( F &&  func,
const dynamic_subscript &  subscript 
)

Invoke the provided function with the value held by the dynamic subscript.

Template Parameters
FFunction type.
Parameters
funcThe function to be invoked. Must be callable with the following argument types:
subscriptThe subscript to be evaluated.
Returns
auto result of calling func with the evaluated argument.

◆ visit() [2/2]

template<typename Func >
auto rexlib::visit ( Func &&  func,
const scalar_value &  value 
)

Access the value held by a scalar_value with its concrete type.

Dispatches on the stored numerical type and calls the provided functor with a const reference to the value, statically typed as the corresponding C++ type. This allows accessing the value in a type-safe manner without knowing its type in advance.

The argument order mirrors std::visit: the visitor comes first.

Template Parameters
FuncFunctor type, callable with any of the native scalar types.
Parameters
funcFunctor to be called with the stored value.
valueThe scalar value to be visited.
Returns
The result of calling func with the stored value.

◆ where()

array rexlib::where ( const_array_ref  condition,
const_array_ref  x,
const_array_ref  y,
const execution_context &  context,
array *  out = nullptr 
)

Select element-wise between two arrays according to a condition.

Parameters
conditionThe boolean array selecting between the other two.
xThe array selected where the condition holds.
yThe array selected where it does not.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The array holding the element-wise selection.
Note
The condition must be a boolean array. All three inputs must be broadcast-compatible.

◆ zeros()

array rexlib::zeros ( array_descriptor  descriptor,
memory_resource_affinity  affinity,
const execution_context &  context,
array *  out = nullptr 
)

Create an array with all its elements set to zero.

Parameters
descriptorDescribes the shape and data type of the array.
affinityAffinity used to select the memory resource where the array is allocated.
contextThe execution context used for dispatching.
outOptional output parameter to be re-used.
Returns
array The newly created array.

Variable Documentation

◆ max_extent_pivot_count

REXLIB_INLINE_CONST_CONSTEXPR std::size_t rexlib::max_extent_pivot_count = 8

Maximum number of extent variables a shape rule may declare.

Bounded so that a resolved rule stays an allocation free value on the dispatch path. Realistic rules use up to three.

◆ max_type_pivot_count

REXLIB_INLINE_CONST_CONSTEXPR std::size_t rexlib::max_type_pivot_count = 8

Maximum number of free variables a typing rule may declare.

Bounded so that a resolved rule stays a trivially copyable, allocation free value on the dispatch path. Realistic rules use one or two pivots.