![]() |
VCTR
|
A container for complex values that stores the real and imaginary parts in two separate, equally sized buffers instead of interleaved like std::complex does. More...
Public Types | |
| using | ContainerType = std::remove_const_t< ContainerTypeParam > |
| The type of the containers storing the real and imaginary parts. | |
| using | value_type = std::remove_const_t< typename ContainerType::value_type > |
| The real floating point type of the real and imaginary parts, e.g. | |
| using | ComplexType = std::complex< value_type > |
| The std::complex type matching value_type, returned by the element access functions. | |
| using | element_type = std::remove_reference_t< decltype(*std::declval< ContainerType & >().data())> |
| The element type of the underlying containers, which is const qualified for a SplitComplexSpan<const T>. | |
Public Member Functions | |
| constexpr | SplitComplexBase ()=default |
| Creates a default constructed SplitComplexBase. | |
| SplitComplexBase (size_t size) | |
| Creates a SplitComplexBase with the given size and all values initialised to zero. | |
| template<class Real , class Imag > requires std::constructible_from<ContainerType, Real&&> && std::constructible_from<ContainerType, Imag&&> | |
| constexpr | SplitComplexBase (Real &&realPart, Imag &&imagPart) |
| Creates a SplitComplexBase from a real and an imaginary part container of the same size. | |
| template<class Other > requires (! std::same_as<Other, ContainerTypeParam>) && std::constructible_from<ContainerType, Span<value_type>> | |
| constexpr | SplitComplexBase (SplitComplexBase< Other > &other) |
| Creates a SplitComplexBase by converting from another one, e.g. | |
| template<class Other > requires (! std::same_as<Other, ContainerTypeParam>) && std::constructible_from<ContainerType, Span<const value_type>> | |
| constexpr | SplitComplexBase (const SplitComplexBase< Other > &other) |
| Creates a SplitComplexBase by converting from another one, e.g. | |
| template<is::anyVctrWithComplexFloatValueType Interleaved> requires (! is::view<ContainerType>) | |
| SplitComplexBase (const Interleaved &interleaved) | |
| Creates a SplitComplexBase by deinterleaving a container of std::complex values. | |
| template<is::expression RealExpression, is::expression ImagExpression> | |
| constexpr | SplitComplexBase (SplitComplexExpression< RealExpression, ImagExpression > &&expressions) |
| Creates a split-complex container from a split-complex expression. | |
| constexpr | SplitComplexBase (const SplitComplexBase &)=default |
| Copy constructor. | |
| constexpr | SplitComplexBase (SplitComplexBase &&)=default |
| Move constructor. | |
| constexpr SplitComplexBase & | operator= (const SplitComplexBase &)=default |
| Copy and move assignment of owning containers, e.g. | |
| constexpr SplitComplexBase & | operator= (SplitComplexBase &&)=default |
| Copy and move assignment of owning containers, e.g. | |
| constexpr SplitComplexBase & | operator= (const SplitComplexBase &other) |
| Copies the elements viewed by another span of the same type into the elements viewed by this span. | |
| constexpr SplitComplexBase & | operator= (SplitComplexBase &&other) |
| Copy and move assignment of owning containers, e.g. | |
| template<is::expression RealExpression, is::expression ImagExpression> requires isMutable | |
| constexpr void | operator= (const SplitComplexExpression< RealExpression, ImagExpression > &expressions) |
| Assigns the result of a split-complex expression to this container. | |
| template<class Other > requires isMutable | |
| &&std::convertible_to< typename SplitComplexBase< Other >::value_type, value_type > constexpr void | operator= (const SplitComplexBase< Other > &other) |
| Copies the elements of another SplitComplexBase of identical size. | |
| template<is::anyVctrWithComplexFloatValueType Interleaved> requires isMutable | |
| constexpr void | operator= (const Interleaved &interleaved) |
| Deinterleaves a container of std::complex values of identical size into this container. | |
| constexpr auto | real () const |
| Returns a view of the real parts. | |
| constexpr auto | imag () const |
| Returns a view of the imaginary parts. | |
| constexpr auto | real () |
| Returns a view of the real parts. | |
| constexpr auto | imag () |
| Returns a view of the imaginary parts. | |
| constexpr ComplexType | get (size_t i) const |
| Returns a copy of the complex value at index i. | |
| constexpr void | set (size_t i, value_type realValue, value_type imagValue) |
| Sets the real and imaginary part at index i. | |
| constexpr void | set (size_t i, ComplexType value) |
| Sets the complex value at index i. | |
| template<size_t startIdx> | |
| constexpr auto | subSpan () |
| Returns a SplitComplexSpan that views the elements from startIdx to the end. | |
| template<size_t startIdx> | |
| constexpr auto | subSpan () const |
| Returns a SplitComplexSpan that views the elements from startIdx to the end. | |
| constexpr auto | subSpan (size_t startIdx) |
| Returns a SplitComplexSpan that views the elements from startIdx to the end. | |
| constexpr auto | subSpan (size_t startIdx) const |
| Returns a SplitComplexSpan that views the elements from startIdx to the end. | |
| template<size_t startIdx, size_t numElements> | |
| constexpr auto | subSpan () |
| Returns a SplitComplexSpan that views numElements elements, starting at startIdx. | |
| template<size_t startIdx, size_t numElements> | |
| constexpr auto | subSpan () const |
| Returns a SplitComplexSpan that views numElements elements, starting at startIdx. | |
| constexpr auto | subSpan (size_t startIdx, size_t numElements) |
| Returns a SplitComplexSpan that views numElements elements, starting at startIdx. | |
| constexpr auto | subSpan (size_t startIdx, size_t numElements) const |
| Returns a SplitComplexSpan that views numElements elements, starting at startIdx. | |
| constexpr size_t | size () const |
| Returns the number of complex values. | |
| constexpr bool | empty () const |
| Returns true if the container holds no values. | |
| constexpr void | resize (size_t newSize) |
| Resizes both parts. | |
| constexpr void | fill (ComplexType value) |
| Sets all elements to the given complex value. | |
| constexpr void | clear () |
| Removes all elements, like std::vector::clear. | |
| template<is::anySplitComplexVectorOrExpression V> requires isMutable | |
| constexpr void | operator*= (const V &v) |
| Multiplies this by a split-complex vector or expression in place. | |
| constexpr void | operator*= (value_type c) |
| Multiplies this by a real constant in place. | |
| constexpr void | operator*= (ComplexType c) |
| Multiplies this by a complex constant in place. | |
| template<is::anySplitComplexVectorOrExpression V> requires isMutable | |
| constexpr void | operator/= (const V &v) |
| Divides this by a split-complex vector or expression in place. | |
| constexpr void | operator/= (value_type c) |
| Divides this by a real constant in place. | |
| constexpr void | operator/= (ComplexType c) |
| Divides this by a complex constant in place. | |
| template<is::anySplitComplexVectorOrExpression V> requires isMutable | |
| constexpr void | operator+= (const V &v) |
| Adds a split-complex vector or expression to this in place. | |
| constexpr void | operator+= (value_type c) |
| Adds a real constant to the real parts in place. | |
| constexpr void | operator+= (ComplexType c) |
| Adds a complex constant to this in place. | |
| template<is::anySplitComplexVectorOrExpression V> requires isMutable | |
| constexpr void | operator-= (const V &v) |
| Subtracts a split-complex vector or expression from this in place. | |
| constexpr void | operator-= (value_type c) |
| Subtracts a real constant from the real parts in place. | |
| constexpr void | operator-= (ComplexType c) |
| Subtracts a complex constant from this in place. | |
Static Public Attributes | |
| static constexpr bool | isMutable = ! std::is_const_v<element_type> |
| True if the elements can be modified through this container, false for a SplitComplexSpan<const T>. | |
A container for complex values that stores the real and imaginary parts in two separate, equally sized buffers instead of interleaved like std::complex does.
This layout allows element-wise complex math to be evaluated without any dependencies between neighbouring elements, which is ideal for SIMD vectorisation. The math operations are available as allocation free free functions, see SplitComplexMath.h.
The ContainerTypeParam decides about ownership and size: Use SplitComplexVector for an owning, resizable container, SplitComplexArray for an owning container with a compile time size and SplitComplexSpan for a non-owning view. Use SplitComplexSpan<const T> for a read-only view.
Interleaved std::complex containers convert to split-complex containers through the constructor and assignment operator. To convert a split-complex container or expression back into interleaved values, use vctr::realImagToComplex.
| ContainerTypeParam | Any VCTR container holding a real floating point value_type, e.g. Vector<float>, Array<float, n>, Span<float> or Span<float, n>. A const qualifier on the container type is ignored, use a const value type to make the elements read-only. |
| using vctr::SplitComplexBase< ContainerTypeParam >::ComplexType = std::complex<value_type> |
The std::complex type matching value_type, returned by the element access functions.
| using vctr::SplitComplexBase< ContainerTypeParam >::ContainerType = std::remove_const_t<ContainerTypeParam> |
The type of the containers storing the real and imaginary parts.
This is ContainerTypeParam without a const qualifier, so the members stay assignable and movable even if a const container type is passed.
| using vctr::SplitComplexBase< ContainerTypeParam >::element_type = std::remove_reference_t<decltype (*std::declval<ContainerType&>().data())> |
The element type of the underlying containers, which is const qualified for a SplitComplexSpan<const T>.
Note that ContainerType::value_type can't be used for this, as VctrBase strips the const qualifier from it.
| using vctr::SplitComplexBase< ContainerTypeParam >::value_type = std::remove_const_t<typename ContainerType::value_type> |
The real floating point type of the real and imaginary parts, e.g.
float or double.
|
constexprdefault |
Creates a default constructed SplitComplexBase.
Only available for owning containers.
For a SplitComplexVector this creates an empty container, for a SplitComplexArray the elements are uninitialised, just like for a default constructed vctr::Array.
|
inlineexplicit |
Creates a SplitComplexBase with the given size and all values initialised to zero.
Only available for a SplitComplexVector.
|
inlineconstexpr |
Creates a SplitComplexBase from a real and an imaginary part container of the same size.
Owning containers copy the data, views refer to the passed containers.
|
inlineconstexpr |
Creates a SplitComplexBase by converting from another one, e.g.
a SplitComplexSpan viewing a SplitComplexVector, or a SplitComplexVector holding a copy of a SplitComplexSpan.
|
inlineconstexpr |
Creates a SplitComplexBase by converting from another one, e.g.
a SplitComplexSpan viewing a SplitComplexVector, or a SplitComplexVector holding a copy of a SplitComplexSpan.
|
inline |
Creates a SplitComplexBase by deinterleaving a container of std::complex values.
Only available for owning containers.
Allows implicit conversion from an interleaved container. For containers with a compile time size, the size of the interleaved container has to match.
|
inlineconstexpr |
Creates a split-complex container from a split-complex expression.
The real and imaginary component expressions are assigned to the corresponding parts of this container.
|
constexprdefault |
Copy constructor.
Owning containers copy the data, views refer to the same data as the other view.
|
constexprdefault |
Move constructor.
A SplitComplexVector takes over the buffers of the other container.
|
inlineconstexpr |
Removes all elements, like std::vector::clear.
Only available for a SplitComplexVector.
To set all elements to zero while keeping the size, use fill ({}).
|
inlineconstexpr |
Returns true if the container holds no values.
|
inlineconstexpr |
Sets all elements to the given complex value.
|
inlineconstexpr |
Returns a copy of the complex value at index i.
Use set to modify it.
|
inlineconstexpr |
Returns a view of the imaginary parts.
It is mutable unless this is a SplitComplexSpan<const T>.
|
inlineconstexpr |
Returns a view of the imaginary parts.
See real() const for the constness of the returned view.
|
inlineconstexpr |
Multiplies this by a complex constant in place.
|
inlineconstexpr |
Multiplies this by a split-complex vector or expression in place.
|
inlineconstexpr |
Multiplies this by a real constant in place.
|
inlineconstexpr |
Adds a complex constant to this in place.
|
inlineconstexpr |
Adds a split-complex vector or expression to this in place.
|
inlineconstexpr |
Adds a real constant to the real parts in place.
|
inlineconstexpr |
Subtracts a complex constant from this in place.
|
inlineconstexpr |
Subtracts a split-complex vector or expression from this in place.
|
inlineconstexpr |
Subtracts a real constant from the real parts in place.
|
inlineconstexpr |
Divides this by a complex constant in place.
|
inlineconstexpr |
Divides this by a split-complex vector or expression in place.
|
inlineconstexpr |
Divides this by a real constant in place.
|
inlineconstexpr |
Deinterleaves a container of std::complex values of identical size into this container.
|
constexprdefault |
Copy and move assignment of owning containers, e.g.
a SplitComplexVector or SplitComplexArray.
|
inlineconstexpr |
Copies the elements viewed by another span of the same type into the elements viewed by this span.
Like vctr::Span, a SplitComplexSpan never rebinds on assignment. This makes assigning a span of the same type behave like assigning any other split complex container. Both spans need to have the same size. A read-only SplitComplexSpan<const T> can't be assigned to.
|
inlineconstexpr |
Copies the elements of another SplitComplexBase of identical size.
|
inlineconstexpr |
Assigns the result of a split-complex expression to this container.
The underlying containers may resize if their size differs from the expression size.
|
constexprdefault |
Copy and move assignment of owning containers, e.g.
a SplitComplexVector or SplitComplexArray.
|
inlineconstexpr |
Copy and move assignment of owning containers, e.g.
a SplitComplexVector or SplitComplexArray.
|
inlineconstexpr |
Returns a view of the real parts.
It is mutable unless this is a SplitComplexSpan<const T>.
|
inlineconstexpr |
Returns a view of the real parts.
The constness of the elements is deduced from the underlying container: It is read-only for a const owning container or a SplitComplexSpan<const T>. Like vctr::Span, a const SplitComplexSpan<T> still returns a mutable view.
|
inlineconstexpr |
Resizes both parts.
Only available for a SplitComplexVector. New elements are zero.
|
inlineconstexpr |
Sets the complex value at index i.
|
inlineconstexpr |
Sets the real and imaginary part at index i.
|
inlineconstexpr |
Returns the number of complex values.
|
inlineconstexpr |
Returns a SplitComplexSpan that views the elements from startIdx to the end.
This overload with a compile time start index returns a SplitComplexSpan with a static extent in case this container also has a static extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views numElements elements, starting at startIdx.
This overload with a compile time length always returns a SplitComplexSpan with a static extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views the elements from startIdx to the end.
This overload with a compile time start index returns a SplitComplexSpan with a static extent in case this container also has a static extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views numElements elements, starting at startIdx.
This overload with a compile time length always returns a SplitComplexSpan with a static extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views the elements from startIdx to the end.
This overload with a runtime start index always returns a SplitComplexSpan with a dynamic extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views the elements from startIdx to the end.
This overload with a runtime start index always returns a SplitComplexSpan with a dynamic extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views numElements elements, starting at startIdx.
This overload with a runtime length always returns a SplitComplexSpan with a dynamic extent.
|
inlineconstexpr |
Returns a SplitComplexSpan that views numElements elements, starting at startIdx.
This overload with a runtime length always returns a SplitComplexSpan with a dynamic extent.
|
staticconstexpr |
True if the elements can be modified through this container, false for a SplitComplexSpan<const T>.