Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::math::Vector3< T > Class Template Reference

A lightweight, constexpr, stack-based 3D vector. More...

#include <LinearAlgebra.hpp>

Inheritance diagram for correlation::math::Vector3< T >:

Public Types

using value_type = T
 Scalar type.

Public Member Functions

constexpr Vector3 () noexcept
 Default constructor. Initializes all components to zero.
constexpr Vector3 (T x_val, T y_val, T z_val) noexcept
 Parameterized constructor.
template<typename U>
constexpr Vector3 (U x_val, U y_val, U z_val) noexcept
template<typename U>
constexpr Vector3 (const Vector3< U > &other) noexcept
constexpr Vector3 (const std::array< T, 3 > &arr) noexcept
 Array-based constructor.
constexpr T operator[] (std::size_t idx) const noexcept
 Access component by index (0, 1, or 2).
constexpr T & operator[] (std::size_t idx) noexcept
 Access mutable component by index (0, 1, or 2).
constexpr T x () const noexcept
constexpr T & x () noexcept
constexpr T y () const noexcept
constexpr T & y () noexcept
constexpr T z () const noexcept
constexpr T & z () noexcept
constexpr T & operator() (std::size_t idx) noexcept
 Access component by index (alternative syntax).
constexpr T operator() (std::size_t idx) const noexcept
 Access component by index (alternative syntax).
constexpr bool empty () const noexcept
 Checks if the vector is a zero vector.
constexpr const T * begin () const noexcept
constexpr const T * end () const noexcept
constexpr T * begin () noexcept
constexpr T * end () noexcept
constexpr Vector3 operator+ (const Vector3 &rhs) const noexcept
 Vector addition.
constexpr Vector3 operator- (const Vector3 &rhs) const noexcept
 Vector subtraction.
constexpr Vector3 operator- () const noexcept
 Unary negation.
constexpr Vector3 operator* (T scalar) const noexcept
 Scalar multiplication.
constexpr Vector3 operator/ (T scalar) const noexcept
 Scalar division.
constexpr Vector3 & operator+= (const Vector3 &rhs) noexcept
 In-place addition.
constexpr Vector3 & operator-= (const Vector3 &rhs) noexcept
 In-place subtraction.
constexpr Vector3 & operator*= (T scalar) noexcept
 In-place scalar multiplication.
constexpr Vector3 & operator/= (T scalar) noexcept
 In-place scalar division.
constexpr T operator* (const Vector3 &rhs) const noexcept
 Vector-vector multiplication (dot product shorthand).
constexpr std::array< T, 3 > array () const noexcept
 Converts the vector to a std::array.
constexpr bool operator== (const Vector3 &rhs) const noexcept
 Equality comparison.
constexpr bool operator!= (const Vector3 &rhs) const noexcept
 Inequality comparison.

Private Attributes

std::array< T, 3 > data_
 Underlying vector components.

Detailed Description

template<typename T>
class correlation::math::Vector3< T >

A lightweight, constexpr, stack-based 3D vector.

Provides basic linear algebra operations for 3D geometric calculations. Supports SIMD optimization for specific types (e.g., double).

Template Parameters
TThe scalar type stored by the vector (e.g., float, double, int).

Member Typedef Documentation

◆ value_type

template<typename T>
using correlation::math::Vector3< T >::value_type = T

Scalar type.

Constructor & Destructor Documentation

◆ Vector3() [1/5]

template<typename T>
correlation::math::Vector3< T >::Vector3 ( )
inlineconstexprnoexcept

Default constructor. Initializes all components to zero.

◆ Vector3() [2/5]

template<typename T>
correlation::math::Vector3< T >::Vector3 ( T x_val,
T y_val,
T z_val )
inlineconstexprnoexcept

Parameterized constructor.

Parameters
x_valX-component value.
y_valY-component value.
z_valZ-component value.

◆ Vector3() [3/5]

template<typename T>
template<typename U>
correlation::math::Vector3< T >::Vector3 ( U x_val,
U y_val,
U z_val )
inlineconstexprnoexcept

◆ Vector3() [4/5]

template<typename T>
template<typename U>
correlation::math::Vector3< T >::Vector3 ( const Vector3< U > & other)
inlineconstexprnoexcept

◆ Vector3() [5/5]

template<typename T>
correlation::math::Vector3< T >::Vector3 ( const std::array< T, 3 > & arr)
inlineexplicitconstexprnoexcept

Array-based constructor.

Parameters
arrStandard array containing {x, y, z}.

Member Function Documentation

◆ array()

template<typename T>
std::array< T, 3 > correlation::math::Vector3< T >::array ( ) const
inlinenodiscardconstexprnoexcept

Converts the vector to a std::array.

Returns
Array containing {x, y, z}.

◆ begin() [1/2]

template<typename T>
const T * correlation::math::Vector3< T >::begin ( ) const
inlineconstexprnoexcept
Returns
Pointer to the beginning of the underlying data.

◆ begin() [2/2]

template<typename T>
T * correlation::math::Vector3< T >::begin ( )
inlineconstexprnoexcept
Returns
Mutable pointer to the beginning of the underlying data.

◆ empty()

template<typename T>
bool correlation::math::Vector3< T >::empty ( ) const
inlinenodiscardconstexprnoexcept

Checks if the vector is a zero vector.

Returns
True if every component is exactly zero.

◆ end() [1/2]

template<typename T>
const T * correlation::math::Vector3< T >::end ( ) const
inlineconstexprnoexcept
Returns
Pointer to the end of the underlying data.

◆ end() [2/2]

template<typename T>
T * correlation::math::Vector3< T >::end ( )
inlineconstexprnoexcept
Returns
Mutable pointer to the end of the underlying data.

◆ operator!=()

template<typename T>
bool correlation::math::Vector3< T >::operator!= ( const Vector3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Inequality comparison.

Parameters
rhsThe vector to compare with.
Returns
True if any component differs.

◆ operator()() [1/2]

template<typename T>
T correlation::math::Vector3< T >::operator() ( std::size_t idx) const
inlinenodiscardconstexprnoexcept

Access component by index (alternative syntax).

Parameters
idxIndex.
Returns
Component value.

◆ operator()() [2/2]

template<typename T>
T & correlation::math::Vector3< T >::operator() ( std::size_t idx)
inlineconstexprnoexcept

Access component by index (alternative syntax).

Parameters
idxIndex.
Returns
Reference to component.

◆ operator*() [1/2]

template<typename T>
T correlation::math::Vector3< T >::operator* ( const Vector3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Vector-vector multiplication (dot product shorthand).

See also
dot()
Parameters
rhsThe vector to multiply with.
Returns
The scalar result of the dot product.

◆ operator*() [2/2]

template<typename T>
Vector3 correlation::math::Vector3< T >::operator* ( T scalar) const
inlinenodiscardconstexprnoexcept

Scalar multiplication.

Parameters
scalarThe scalar factor.
Returns
A new vector scaled by s.

◆ operator*=()

template<typename T>
Vector3 & correlation::math::Vector3< T >::operator*= ( T scalar)
inlineconstexprnoexcept

In-place scalar multiplication.

Parameters
scalarThe scalar factor.
Returns
Reference to this vector.

◆ operator+()

template<typename T>
Vector3 correlation::math::Vector3< T >::operator+ ( const Vector3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Vector addition.

Parameters
rhsThe vector to add.
Returns
A new vector representing the sum.

◆ operator+=()

template<typename T>
Vector3 & correlation::math::Vector3< T >::operator+= ( const Vector3< T > & rhs)
inlineconstexprnoexcept

In-place addition.

Parameters
rhsThe vector to add.
Returns
Reference to this vector.

◆ operator-() [1/2]

template<typename T>
Vector3 correlation::math::Vector3< T >::operator- ( ) const
inlinenodiscardconstexprnoexcept

Unary negation.

Returns
A new vector with all components negated.

◆ operator-() [2/2]

template<typename T>
Vector3 correlation::math::Vector3< T >::operator- ( const Vector3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Vector subtraction.

Parameters
rhsThe vector to subtract.
Returns
A new vector representing the difference.

◆ operator-=()

template<typename T>
Vector3 & correlation::math::Vector3< T >::operator-= ( const Vector3< T > & rhs)
inlineconstexprnoexcept

In-place subtraction.

Parameters
rhsThe vector to subtract.
Returns
Reference to this vector.

◆ operator/()

template<typename T>
Vector3 correlation::math::Vector3< T >::operator/ ( T scalar) const
inlinenodiscardconstexprnoexcept

Scalar division.

Parameters
scalarThe scalar divisor.
Returns
A new vector scaled by 1/s.

◆ operator/=()

template<typename T>
Vector3 & correlation::math::Vector3< T >::operator/= ( T scalar)
inlineconstexprnoexcept

In-place scalar division.

Parameters
scalarThe scalar divisor.
Returns
Reference to this vector.

◆ operator==()

template<typename T>
bool correlation::math::Vector3< T >::operator== ( const Vector3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Equality comparison.

Parameters
rhsThe vector to compare with.
Returns
True if all components are exactly equal.

◆ operator[]() [1/2]

template<typename T>
T correlation::math::Vector3< T >::operator[] ( std::size_t idx) const
inlinenodiscardconstexprnoexcept

Access component by index (0, 1, or 2).

Parameters
idxIndex of the component.
Returns
The value at index i.

◆ operator[]() [2/2]

template<typename T>
T & correlation::math::Vector3< T >::operator[] ( std::size_t idx)
inlineconstexprnoexcept

Access mutable component by index (0, 1, or 2).

Parameters
idxIndex of the component.
Returns
Reference to the value at index i.

◆ x() [1/2]

template<typename T>
T correlation::math::Vector3< T >::x ( ) const
inlinenodiscardconstexprnoexcept
Returns
The X-component.
Here is the caller graph for this function:

◆ x() [2/2]

template<typename T>
T & correlation::math::Vector3< T >::x ( )
inlineconstexprnoexcept
Returns
Reference to the X-component.

◆ y() [1/2]

template<typename T>
T correlation::math::Vector3< T >::y ( ) const
inlinenodiscardconstexprnoexcept
Returns
The Y-component.
Here is the caller graph for this function:

◆ y() [2/2]

template<typename T>
T & correlation::math::Vector3< T >::y ( )
inlineconstexprnoexcept
Returns
Reference to the Y-component.

◆ z() [1/2]

template<typename T>
T correlation::math::Vector3< T >::z ( ) const
inlinenodiscardconstexprnoexcept
Returns
The Z-component.
Here is the caller graph for this function:

◆ z() [2/2]

template<typename T>
T & correlation::math::Vector3< T >::z ( )
inlineconstexprnoexcept
Returns
Reference to the Z-component.

Member Data Documentation

◆ data_

template<typename T>
std::array<T, 3> correlation::math::Vector3< T >::data_
private

Underlying vector components.


The documentation for this class was generated from the following files: