Skip to content

dakku::VectorBase

vector base More...

#include <vector_base.h>

Inherited by dakku::Point< int, 2 >, dakku::Point< float, 3 >, dakku::Vector< float, 3 >

Public Functions

Name
VectorBase()
Construct a new Vector Base object all components initialized to zero.
template <ArithmeticType Arg>
VectorBase(Arg value)
Construct a new Vector Base object all components initalized to value
VectorBase(const sol::table & table)
Construct a new Vector Base object all components initalized to table.
template <ArithmeticType Other,typename OtherDerived >
VectorBase(const VectorBase< Other, S, OtherDerived > & other)
Construct a new Vector Base object with given values.
VectorBase(const VectorBase & other)
VectorBase(VectorBase && other)
VectorBase & operator=(const VectorBase & other)
VectorBase & operator=(VectorBase && other)
const D & derived() const
convert to derived type
D & derived()
convert to derived type
template <ArithmeticType Arg>
void
set(Arg value)
set all components to value
template <ArithmeticType Arg>
void
set_by_index(size_t index, Arg value)
set data[index] to value
template <ArithmeticType... Args,size_t... Is>
void
set(std::index_sequence< Is... > , Args &&... args)
set data to args
template <ArithmeticType... Args>
void
set(Args &&... args)
set data to args
template <ArithmeticType Other,typename OtherDerived >
void
set(const VectorBase< Other, S, OtherDerived > & rhs)
set data by rhs's data
const T & get(size_t i) const
get i'th component
size_t size() const
size of the vector
std::string to_string() const
convert vector to string
bool has_nans() const
check whether there are nan components
D clone() const
get a copy
const T & operator[](size_t i) const
get i'th value
T & operator[](size_t i)
get i'th value
D & operator+=(const D & rhs)
addition
template <ArithmeticType V>
D &
operator+=(V rhs)
addition
D operator+(const D & rhs) const
addition
template <ArithmeticType V>
D
operator+(V rhs) const
addition
D & operator-=(const D & rhs)
subtraction
template <ArithmeticType V>
D &
operator-=(V rhs)
subtraction
D & operator*=(const D & rhs)
multiplication
template <ArithmeticType V>
D &
operator*=(V rhs)
multiplication
D operator*(const D & rhs) const
multiplication
template <ArithmeticType V>
D
operator*(V rhs) const
multiplication
D & operator/=(const D & rhs)
division
template <ArithmeticType V>
D &
operator/=(V rhs)
division
D operator/(const D & rhs) const
division
template <ArithmeticType U>
D
operator/(U rhs) const
division
bool operator==(const VectorBase & rhs) const
bool operator!=(const VectorBase & rhs) const
decltype(auto) x() const
get the first element
decltype(auto) x()
get the first element
decltype(auto) y() const
get the second element
decltype(auto) y()
get the second element
decltype(auto) z() const
get the third element
decltype(auto) z()
get the fourth element
decltype(auto) w() const
get the fourth element
decltype(auto) w()
get the third element
size_t max_element_index() const
get the index of the max element
decltype(auto) max_element() const
get the max element in the vector
D max(const D & rhs) const
element wise max
D min(const D & rhs) const
element wise min
template <typename OtherDerived >
decltype(auto)
dot(const VectorBase< T, S, OtherDerived > & rhs) const
dot product between two vectors
decltype(auto) squared_norm() const
squared norm
decltype(auto) norm() const
norm
decltype(auto) length() const
length
decltype(auto) distance(const D & rhs) const
the distance
D abs() const
abs
D cross(const D & rhs) const
cross product
bool is_zero() const
check whether all components are zero
D sqrt() const
element-wise sqrt
template <ArithmeticType E>
D
pow(E e) const
element-wise power
D exp() const
element-wise exp
D floor() const
element-wise floor
D ceil() const
element-wise ceil
D lerp(const D & b, T t) const
element-wise linear interpolation
operator std::span< T, S >()
operator std::span< const T, S >() const

Friends

Name
D operator+(U a, const D & b)
addition
D operator-(U a, const D & b)
subtraction
D operator*(U a, const D & b)
multiplication
D operator/(U a, const D & b)
division
std::ostream & operator<<(std::ostream & os, const VectorBase & vec)
output the vector
D max(const D & v1, const D & v2)
element wise max
D min(const D & v1, const D & v2)
element wise min
decltype(auto) distance(const D & a, const D & b)
the distance
D abs(const D & v)
abs
D sqrt(const D & v)
element-wise sqrt
D pow(const D & v, E e)
element-wise power
D exp(const D & v)
element-wise exp
D floor(const D & v)
element-wise floor
D ceil(const D & v)
element-wise ceil
D lerp(const D & a, const D & b, T t)
element-wise linear interpolation

Detailed Description

template <ArithmeticType T,
size_t S,
typename D >
class dakku::VectorBase;

vector base

Template Parameters:

  • T type
  • S size
  • D derived

Public Functions Documentation

function VectorBase

inline VectorBase()

Construct a new Vector Base object all components initialized to zero.

function VectorBase

template <ArithmeticType Arg>
inline VectorBase(
    Arg value
)

Construct a new Vector Base object all components initalized to value

Parameters:

  • value init value

Template Parameters:

  • Arg value type

function VectorBase

inline VectorBase(
    const sol::table & table
)

Construct a new Vector Base object all components initalized to table.

function VectorBase

template <ArithmeticType Other,
typename OtherDerived >
inline explicit VectorBase(
    const VectorBase< Other, S, OtherDerived > & other
)

Construct a new Vector Base object with given values.

Parameters:

  • args init values
  • expr the given expression

Template Parameters:

  • Args value types
  • Other
  • OtherDerived
  • Expr

Construct a new Vector Base object with a vector expression

function VectorBase

inline VectorBase(
    const VectorBase & other
)

function VectorBase

inline VectorBase(
    VectorBase && other
)

function operator=

inline VectorBase & operator=(
    const VectorBase & other
)

function operator=

inline VectorBase & operator=(
    VectorBase && other
)

function derived

inline const D & derived() const

convert to derived type

function derived

inline D & derived()

convert to derived type

function set

template <ArithmeticType Arg>
inline void set(
    Arg value
)

set all components to value

Parameters:

  • value the given value

Template Parameters:

  • Arg value type

function set_by_index

template <ArithmeticType Arg>
inline void set_by_index(
    size_t index,
    Arg value
)

set data[index] to value

Parameters:

  • index the index of the component
  • value the given value

Template Parameters:

  • Arg value type

function set

template <ArithmeticType... Args,
size_t... Is>
inline void set(
    std::index_sequence< Is... > ,
    Args &&... args
)

set data to args

Parameters:

  • args values

Template Parameters:

  • Args value types
  • Is indices (generated by std::index_sequence_for)

function set

template <ArithmeticType... Args>
inline void set(
    Args &&... args
)

set data to args

Parameters:

  • args values

Template Parameters:

  • Args value types

function set

template <ArithmeticType Other,
typename OtherDerived >
inline void set(
    const VectorBase< Other, S, OtherDerived > & rhs
)

set data by rhs's data

Parameters:

  • rhs the given vector

Template Parameters:

  • Other rhs type
  • OtherDerived rhs derived type

function get

inline const T & get(
    size_t i
) const

get i'th component

Parameters:

  • i the index

Return: the value

function size

inline size_t size() const

size of the vector

Return: size

function to_string

inline std::string to_string() const

convert vector to string

Return: the converted string

function has_nans

inline bool has_nans() const

check whether there are nan components

Return:

  • true vector contains nan
  • false vector does not contain nans

function clone

inline D clone() const

get a copy

function operator[]

inline const T & operator[](
    size_t i
) const

get i'th value

Parameters:

  • i index

Return: value

function operator[]

inline T & operator[](
    size_t i
)

get i'th value

Parameters:

  • i index

Return: value

function operator+=

inline D & operator+=(
    const D & rhs
)

addition

Parameters:

  • rhs another vector

Return: this

function operator+=

template <ArithmeticType V>
inline D & operator+=(
    V rhs
)

addition

Parameters:

  • rhs scalar

Return: this

function operator+

inline D operator+(
    const D & rhs
) const

addition

Parameters:

  • rhs another vector

Return: result

function operator+

template <ArithmeticType V>
inline D operator+(
    V rhs
) const

addition

Parameters:

  • rhs another vector

Return: result

function operator-=

inline D & operator-=(
    const D & rhs
)

subtraction

Parameters:

  • rhs another vector

Return: this

function operator-=

template <ArithmeticType V>
inline D & operator-=(
    V rhs
)

subtraction

Parameters:

  • rhs scalar

Return: this

function operator*=

inline D & operator*=(
    const D & rhs
)

multiplication

Parameters:

  • rhs another vector

Return: this

function operator*=

template <ArithmeticType V>
inline D & operator*=(
    V rhs
)

multiplication

Parameters:

  • rhs scalar

Return: this

function operator*

inline D operator*(
    const D & rhs
) const

multiplication

Parameters:

  • rhs another vector

Return: result

function operator*

template <ArithmeticType V>
inline D operator*(
    V rhs
) const

multiplication

Parameters:

  • rhs scalar

Return: result

function operator/=

inline D & operator/=(
    const D & rhs
)

division

Parameters:

  • rhs another vector

Return: this

function operator/=

template <ArithmeticType V>
inline D & operator/=(
    V rhs
)

division

Parameters:

  • rhs scalar

Return: this

function operator/

inline D operator/(
    const D & rhs
) const

division

Parameters:

  • rhs another vector

Return: result

function operator/

template <ArithmeticType U>
inline D operator/(
    U rhs
) const

division

Parameters:

  • rhs scalar

Return: result

function operator==

inline bool operator==(
    const VectorBase & rhs
) const

function operator!=

inline bool operator!=(
    const VectorBase & rhs
) const

function x

inline decltype(auto) x() const

get the first element

function x

inline decltype(auto) x()

get the first element

function y

inline decltype(auto) y() const

get the second element

function y

inline decltype(auto) y()

get the second element

function z

inline decltype(auto) z() const

get the third element

function z

inline decltype(auto) z()

get the fourth element

function w

inline decltype(auto) w() const

get the fourth element

function w

inline decltype(auto) w()

get the third element

function max_element_index

inline size_t max_element_index() const

get the index of the max element

Return: the index

function max_element

inline decltype(auto) max_element() const

get the max element in the vector

Return: the max value

function max

inline D max(
    const D & rhs
) const

element wise max

function min

inline D min(
    const D & rhs
) const

element wise min

function dot

template <typename OtherDerived >
inline decltype(auto) dot(
    const VectorBase< T, S, OtherDerived > & rhs
) const

dot product between two vectors

Return: \(\vec a \cdot \vec b\)

function squared_norm

inline decltype(auto) squared_norm() const

squared norm

Return: \(||v|| ^ 2\)

function norm

inline decltype(auto) norm() const

norm

Return: \(||v||\)

function length

inline decltype(auto) length() const

length

Return: \(||v||\)

function distance

inline decltype(auto) distance(
    const D & rhs
) const

the distance

function abs

inline D abs() const

abs

function cross

inline D cross(
    const D & rhs
) const

cross product

function is_zero

inline bool is_zero() const

check whether all components are zero

function sqrt

inline D sqrt() const

element-wise sqrt

function pow

template <ArithmeticType E>
inline D pow(
    E e
) const

element-wise power

function exp

inline D exp() const

element-wise exp

function floor

inline D floor() const

element-wise floor

function ceil

inline D ceil() const

element-wise ceil

function lerp

inline D lerp(
    const D & b,
    T t
) const

element-wise linear interpolation

function operator std::span< T, S >

inline operator std::span< T, S >()

function operator std::span< const T, S >

inline operator std::span< const T, S >() const

Friends

friend operator+

friend D operator+(
    U a,

    const D & b
);

addition

Parameters:

  • a\(aa\)
  • b \(\vec b\)

Return: elementwise add a

friend operator-

friend D operator-(
    U a,

    const D & b
);

subtraction

Parameters:

  • a\(aa\)
  • b \(\vec b\)

Return: elementwise sub

friend operator*

friend D operator*(
    U a,

    const D & b
);

multiplication

Parameters:

  • a\(aa\)
  • b \(\vec b\)

Return: elementwise mul

friend operator/

friend D operator/(
    U a,

    const D & b
);

division

Parameters:

  • a\(aa\)
  • b \(\vec b\)

Return: elementwise div (broad cast \(a\))

friend operator<<

friend std::ostream & operator<<(
    std::ostream & os,

    const VectorBase & vec
);

output the vector

Parameters:

  • os ostream
  • vec the vector to output

Return: ostream

friend max

friend D max(
    const D & v1,

    const D & v2
);

element wise max

friend min

friend D min(
    const D & v1,

    const D & v2
);

element wise min

friend distance

friend decltype(auto) distance(
    const D & a,

    const D & b
);

the distance

friend abs

friend D abs(
    const D & v
);

abs

friend sqrt

friend D sqrt(
    const D & v
);

element-wise sqrt

friend pow

friend D pow(
    const D & v,

    E e
);

element-wise power

friend exp

friend D exp(
    const D & v
);

element-wise exp

friend floor

friend D floor(
    const D & v
);

element-wise floor

friend ceil

friend D ceil(
    const D & v
);

element-wise ceil

friend lerp

friend D lerp(
    const D & a,

    const D & b,

    T t
);

element-wise linear interpolation


Updated on 2022-04-30 at 15:46:11 +0000