Loading...
Searching...
No Matches
libcamera::Vector< T, Rows > Class Template Reference

Vector class. More...

## Public Member Functions

constexpr | Vector ()=default
| Construct an uninitialized vector.
constexpr | Vector (T scalar)
| Construct a vector filled with a scalar value.
constexpr | Vector (const std::array< T, Rows > &data)
| Construct vector from supplied data.
constexpr | Vector (const Span< const T, Rows > data)
| Construct vector from supplied data.
const T & | operator[] (size_t i) const
| Index to an element in the vector.
T & | operator[] (size_t i)
| Index to an element in the vector.
constexpr Vector< T, Rows > | operator- () const
| Negate a Vector by negating both all of its coordinates.
constexpr Vector | operator+ (const Vector &other) const
| Calculate the sum of this vector and other element-wise.
constexpr Vector | operator+ (T scalar) const
| Calculate the sum of this vector and scalar element-wise.
constexpr Vector | operator- (const Vector &other) const
| Calculate the difference of this vector and other element-wise.
constexpr Vector | operator- (T scalar) const
| Calculate the difference of this vector and scalar element-wise.
constexpr Vector | operator* (const Vector &other) const
| Calculate the product of this vector and other element-wise.
constexpr Vector | operator* (T scalar) const
| Calculate the product of this vector and scalar element-wise.
constexpr Vector | operator/ (const Vector &other) const
| Calculate the quotient of this vector and other element-wise.
constexpr Vector | operator/ (T scalar) const
| Calculate the quotient of this vector and scalar element-wise.
Vector & | operator+= (const Vector &other)
| Add other element-wise to this vector.
Vector & | operator+= (T scalar)
| Add scalar element-wise to this vector.
Vector & | operator-= (const Vector &other)
| Subtract other element-wise from this vector.
Vector & | operator-= (T scalar)
| Subtract scalar element-wise from this vector.
Vector & | operator*= (const Vector &other)
| Multiply this vector by other element-wise.
Vector & | operator*= (T scalar)
| Multiply this vector by scalar element-wise.
Vector & | operator/= (const Vector &other)
| Divide this vector by other element-wise.
Vector & | operator/= (T scalar)
| Divide this vector by scalar element-wise.
constexpr Vector | min (const Vector &other) const
| Calculate the minimum of this vector and other element-wise.
constexpr Vector | min (T scalar) const
| Calculate the minimum of this vector and scalar element-wise.
constexpr Vector | max (const Vector &other) const
| Calculate the maximum of this vector and other element-wise.
constexpr Vector | max (T scalar) const
| Calculate the maximum of this vector and scalar element-wise.
constexpr T | dot (const Vector< T, Rows > &other) const
| Compute the dot product.
constexpr const T & | x () const
| Convenience function to access the first element of the vector.
constexpr const T & | y () const
| Convenience function to access the second element of the vector.
constexpr const T & | z () const
| Convenience function to access the third element of the vector.
constexpr T & | x ()
| Convenience function to access the first element of the vector.
constexpr T & | y ()
| Convenience function to access the second element of the vector.
constexpr T & | z ()
| Convenience function to access the third element of the vector.
constexpr const T & | r () const
| Convenience function to access the first element of the vector.
constexpr const T & | g () const
| Convenience function to access the second element of the vector.
constexpr const T & | b () const
| Convenience function to access the third element of the vector.
constexpr T & | r ()
| Convenience function to access the first element of the vector.
constexpr T & | g ()
| Convenience function to access the second element of the vector.
constexpr T & | b ()
| Convenience function to access the third element of the vector.
constexpr double | length2 () const
| Get the squared length of the vector.
constexpr double | length () const
| Get the length of the vector.
template<typename R = T>
constexpr R | sum () const
| Calculate the sum of all the vector elements.

## Detailed Description

template<typename T, unsigned int Rows>
class libcamera::Vector< T, Rows >

Vector class.

Template Parameters

  T | Type of numerical values to be stored in the vector
  Rows | Number of dimension of the vector (= number of elements)

## Constructor & Destructor Documentation

## Vector() [1/3]

template<typename T, unsigned int Rows>

libcamera::Vector< T, Rows >::Vector | ( | T | scalar | ) |

inline explicit constexpr

Construct a vector filled with a scalar value.

Parameters

  [in] | scalar | The scalar value

## Vector() [2/3]

template<typename T, unsigned int Rows>

libcamera::Vector< T, Rows >::Vector | ( | const std::array< T, Rows > & | data | ) |

inline constexpr

Construct vector from supplied data.

Parameters

  data | Data from which to construct a vector

The size of data must be equal to the dimension size Rows of the vector.

## Vector() [3/3]

template<typename T, unsigned int Rows>

libcamera::Vector< T, Rows >::Vector | ( | const Span< const T, Rows > | data | ) |

inline constexpr

Construct vector from supplied data.

Parameters

  data | Data from which to construct a vector

The size of data must be equal to the dimension size Rows of the vector.

## Member Function Documentation

## b() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::b | ( |  | ) |

inline constexpr

Convenience function to access the third element of the vector.

Returns
  The third element of the vector

## b() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::b | ( |  | ) | const

inline constexpr

Convenience function to access the third element of the vector.

Returns
  The third element of the vector

## dot()

template<typename T, unsigned int Rows>

T libcamera::Vector< T, Rows >::dot | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Compute the dot product.

Parameters

  [in] | other | The other vector

Returns
  The dot product of the two vectors

## g() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::g | ( |  | ) |

inline constexpr

Convenience function to access the second element of the vector.

Returns
  The second element of the vector

## g() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::g | ( |  | ) | const

inline constexpr

Convenience function to access the second element of the vector.

Returns
  The second element of the vector

## length()

template<typename T, unsigned int Rows>

double libcamera::Vector< T, Rows >::length | ( |  | ) | const

inline constexpr

Get the length of the vector.

Returns
  The length of the vector

## length2()

template<typename T, unsigned int Rows>

double libcamera::Vector< T, Rows >::length2 | ( |  | ) | const

inline constexpr

Get the squared length of the vector.

Returns
  The squared length of the vector

## max() [1/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::max | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Calculate the maximum of this vector and other element-wise.

Parameters

  [in] | other | The other vector

Returns
  The element-wise maximum of this vector and other

## max() [2/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::max | ( | T | scalar | ) | const

inline constexpr

Calculate the maximum of this vector and scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  The element-wise maximum of this vector and scalar

## min() [1/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::min | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Calculate the minimum of this vector and other element-wise.

Parameters

  [in] | other | The other vector

Returns
  The element-wise minimum of this vector and other

## min() [2/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::min | ( | T | scalar | ) | const

inline constexpr

Calculate the minimum of this vector and scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  The element-wise minimum of this vector and scalar

## operator*() [1/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator* | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Calculate the product of this vector and other element-wise.

Parameters

  [in] | other | The other vector

Returns
  The element-wise product of this vector and other

## operator*() [2/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator* | ( | T | scalar | ) | const

inline constexpr

Calculate the product of this vector and scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  The element-wise product of this vector and scalar

## operator*=() [1/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator*= | ( | const Vector< T, Rows > & | other | ) |

inline

Multiply this vector by other element-wise.

Parameters

  [in] | other | The other vector

Returns
  This vector

## operator*=() [2/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator*= | ( | T | scalar | ) |

inline

Multiply this vector by scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  This vector

## operator+() [1/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator+ | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Calculate the sum of this vector and other element-wise.

Parameters

  [in] | other | The other vector

Returns
  The element-wise sum of this vector and other

## operator+() [2/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator+ | ( | T | scalar | ) | const

inline constexpr

Calculate the sum of this vector and scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  The element-wise sum of this vector and other

## operator+=() [1/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator+= | ( | const Vector< T, Rows > & | other | ) |

inline

Add other element-wise to this vector.

Parameters

  [in] | other | The other vector

Returns
  This vector

## operator+=() [2/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator+= | ( | T | scalar | ) |

inline

Add scalar element-wise to this vector.

Parameters

  [in] | scalar | The scalar

Returns
  This vector

## operator-() [1/3]

template<typename T, unsigned int Rows>

Vector< T, Rows > libcamera::Vector< T, Rows >::operator- | ( |  | ) | const

inline constexpr

Negate a Vector by negating both all of its coordinates.

Returns
  The negated vector

## operator-() [2/3]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator- | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Calculate the difference of this vector and other element-wise.

Parameters

  [in] | other | The other vector

Returns
  The element-wise subtraction of other from this vector

## operator-() [3/3]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator- | ( | T | scalar | ) | const

inline constexpr

Calculate the difference of this vector and scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  The element-wise subtraction of scalar from this vector

## operator-=() [1/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator-= | ( | const Vector< T, Rows > & | other | ) |

inline

Subtract other element-wise from this vector.

Parameters

  [in] | other | The other vector

Returns
  This vector

## operator-=() [2/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator-= | ( | T | scalar | ) |

inline

Subtract scalar element-wise from this vector.

Parameters

  [in] | scalar | The scalar

Returns
  This vector

## operator/() [1/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator/ | ( | const Vector< T, Rows > & | other | ) | const

inline constexpr

Calculate the quotient of this vector and other element-wise.

Parameters

  [in] | other | The other vector

Returns
  The element-wise division of this vector by other

## operator/() [2/2]

template<typename T, unsigned int Rows>

Vector libcamera::Vector< T, Rows >::operator/ | ( | T | scalar | ) | const

inline constexpr

Calculate the quotient of this vector and scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  The element-wise division of this vector by scalar

## operator/=() [1/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator/= | ( | const Vector< T, Rows > & | other | ) |

inline

Divide this vector by other element-wise.

Parameters

  [in] | other | The other vector

Returns
  This vector

## operator/=() [2/2]

template<typename T, unsigned int Rows>

Vector & libcamera::Vector< T, Rows >::operator/= | ( | T | scalar | ) |

inline

Divide this vector by scalar element-wise.

Parameters

  [in] | scalar | The scalar

Returns
  This vector

## operator[]() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::operator[] | ( | size_t | i | ) |

inline

Index to an element in the vector.

Parameters

  i | Index of element to retrieve

Returns
  Element at index i from the vector

## operator[]() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::operator[] | ( | size_t | i | ) | const

inline

Index to an element in the vector.

Parameters

  i | Index of element to retrieve

Returns
  Element at index i from the vector

## r() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::r | ( |  | ) |

inline constexpr

Convenience function to access the first element of the vector.

Returns
  The first element of the vector

## r() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::r | ( |  | ) | const

inline constexpr

Convenience function to access the first element of the vector.

Returns
  The first element of the vector

## sum()

template<typename T, unsigned int Rows>
template<typename R = T>

R libcamera::Vector< T, Rows >::sum | ( |  | ) | const

inline constexpr

Calculate the sum of all the vector elements.

Template Parameters

  R | The type of the sum

The type R of the sum defaults to the type T of the elements, but can be set explicitly to use a different type in case the type T would risk overflowing.

Returns
  The sum of all the vector elements

## x() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::x | ( |  | ) |

inline constexpr

Convenience function to access the first element of the vector.

Returns
  The first element of the vector

## x() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::x | ( |  | ) | const

inline constexpr

Convenience function to access the first element of the vector.

Returns
  The first element of the vector

## y() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::y | ( |  | ) |

inline constexpr

Convenience function to access the second element of the vector.

Returns
  The second element of the vector

## y() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::y | ( |  | ) | const

inline constexpr

Convenience function to access the second element of the vector.

Returns
  The second element of the vector

## z() [1/2]

template<typename T, unsigned int Rows>

T & libcamera::Vector< T, Rows >::z | ( |  | ) |

inline constexpr

Convenience function to access the third element of the vector.

Returns
  The third element of the vector

## z() [2/2]

template<typename T, unsigned int Rows>

const T & libcamera::Vector< T, Rows >::z | ( |  | ) | const

inline constexpr

Convenience function to access the third element of the vector.

Returns
  The third element of the vector

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

- include/libcamera/internal/vector.h
- src/libcamera/vector.cpp