Skip to content

Latest commit

 

History

History
53 lines (48 loc) · 2.71 KB

vector_general.md

File metadata and controls

53 lines (48 loc) · 2.71 KB

MathLbr::vector Introduction

template<
  Concepts::underlying_vector_type T, 
  std::size_t Size = dynamic_extent
> class vector;

vector is a header-only class that represents a mathematical vector, and its elements are stored continuously. This class implements general vectorial operations and predicates. Internally, elements are held inside a std::array<T, Size> if the Size template argument is provided by the user, otherwise they are held inside std::vector<T>. Most member functions of this class are constexpr (see specific references).

#include "vector.h"
int main() {
  MathLbr::vector<double> a{{2,3,4}}; // OK, internal container is std::vector since no template size was passed
  MathLbr::vector<int, 3> b{{2,4,3}}; // OK, internal container is std::array since a template size was passed
}

Template parameters

T: The type of the elements. Currently, T must be only of the following:

Support for user defined arithmetic type might be added in the future.

Size: Represents how many elements there are inside the vector.
Passing a size through a template argument means that MathLbr::vector will internally use std::array<T, Size> to store its elements.
Omitting this argument means that MathLbr::vector will internally use std::vector<T> to store its elements.
Note: Some constructors might need different parameters, depending on what container is used to store the elements internally. (see specific references)

Aliases

The vector class contains the usual, standard aliases:

		using size_type = std::size_t;
		using value_type = T;
		using pointer_type = T*;
		using reference_type = T&;
		using const_pointer_type = const T*;
		using const_reference_type = const T&;

Additional aliases are:

using underlying_container = std::conditional_t<Concepts::dynamic_extent_enabled<Size, dynamic_extent>, std::vector<T>, std::array<T, Size>>;
template<typename _T>
using complex_internal_value_type = typename Concepts::is_complex<_T>::value_type;

with

  • underlying_container: alias of the currently used underlying container (either std::array or std::vector),
  • complex_internal_value_type: useful for the library itself, contains the underlying type of a passed std::complex. For all the other details, see the member function page.