Vectors/Points 2D. More...
Public Member Functions | |
v2 () | |
empty constructor | |
v2 (const double &x, const double &y) | |
direct constructor | |
const double & | x () const |
get x coordinate | |
double & | x () |
get x coordinate | |
const double & | y () const |
get y coordinate | |
double & | y () |
get y coordinate | |
const double & | operator[] (const size_t &k) const |
Access to the k_th entry (k in [0,1]) | |
double & | operator[] (const size_t &k) |
Access to the k_th entry (k in [0,1]) | |
const double & | operator() (const size_t &k) const |
Access to the k_th entry (k in [0,1]) | |
double & | operator() (const size_t &k) |
Access to the k_th entry (k in [0,1]) | |
void | set_zero () |
set every entry to 0 | |
double | dot (const v2 &p) const |
perform dot product between two v2 | |
double | norm () const |
get the norm of the vector | |
double | norm2 () const |
get the square norm of the vector | |
v2 | normalized () const |
normalize the vector to unit length | |
v2 | operator+ (const v2 &p2) const |
| |
v2 | operator+ (const double &s) const |
| |
v2 | operator- (const v2 &p2) const |
| |
v2 | operator- (const double &s) const |
| |
v2 | operator* (const double &s) const |
multiply by a scalar operator | |
v2 | operator/ (const double &s) const |
divide by a scalar operator | |
v2 & | operator+= (const v2 &p) |
internal + | |
v2 & | operator+= (const double &s) |
internal + | |
v2 & | operator-= (const v2 &p) |
internal - | |
v2 & | operator-= (const double &s) |
internal - | |
v2 & | operator*= (const double &s) |
internal * | |
v2 & | operator/= (const double &s) |
internal / | |
v2 | operator- () const |
unary negation | |
v2 | product_compontentwise (const v2 &p) const |
does componentwise mutliplication | |
v2 & | product_compontentwise_internal (const v2 &p) |
does componentwise mutliplication | |
void | scale (const double &sx, const double &sy) |
internal scaling (similar to componentwise) | |
std::string | to_string () const |
export the value as string cout<<v2(2,3,6) => 2 3 6 | |
Private Member Functions | |
void | assert_size (const size_t &k) const |
assert that a size_t belongs to [[0,1]] | |
Private Attributes | |
double | internal_x |
x coordinate | |
double | internal_y |
y coordinate | |
Vectors/Points 2D.
cpe::v2::v2 | ( | ) |
empty constructor
Referenced by operator*(), operator+(), operator-(), operator/(), and product_compontentwise().
cpe::v2::v2 | ( | const double & | x, |
const double & | y | ||
) |
direct constructor
|
private |
assert that a size_t belongs to [[0,1]]
Referenced by operator[]().
double cpe::v2::dot | ( | const v2 & | p | ) | const |
perform dot product between two v2
References internal_x, internal_y, x(), and y().
double cpe::v2::norm | ( | ) | const |
get the norm of the vector
References norm2().
Referenced by normalized().
double cpe::v2::norm2 | ( | ) | const |
get the square norm of the vector
References internal_x, and internal_y.
Referenced by norm().
v2 cpe::v2::normalized | ( | ) | const |
const double & cpe::v2::operator() | ( | const size_t & | k | ) | const |
Access to the k_th entry (k in [0,1])
double & cpe::v2::operator() | ( | const size_t & | k | ) |
Access to the k_th entry (k in [0,1])
v2 cpe::v2::operator* | ( | const double & | s | ) | const |
v2 & cpe::v2::operator*= | ( | const double & | s | ) |
internal *
References internal_x, and internal_y.
v2 cpe::v2::operator+ | ( | const double & | s | ) | const |
internal +
References internal_x, internal_y, x(), and y().
v2 & cpe::v2::operator+= | ( | const double & | s | ) |
internal +
References internal_x, and internal_y.
v2 cpe::v2::operator- | ( | const double & | s | ) | const |
v2 cpe::v2::operator- | ( | ) | const |
unary negation
References internal_x, internal_y, and v2().
internal -
References internal_x, internal_y, x(), and y().
v2 & cpe::v2::operator-= | ( | const double & | s | ) |
internal -
References internal_x, and internal_y.
v2 cpe::v2::operator/ | ( | const double & | s | ) | const |
v2 & cpe::v2::operator/= | ( | const double & | s | ) |
internal /
References internal_x, and internal_y.
const double & cpe::v2::operator[] | ( | const size_t & | k | ) | const |
Access to the k_th entry (k in [0,1])
References assert_size(), internal_x, and internal_y.
double & cpe::v2::operator[] | ( | const size_t & | k | ) |
Access to the k_th entry (k in [0,1])
References assert_size(), internal_x, and internal_y.
does componentwise mutliplication
References internal_x, internal_y, v2(), x(), and y().
does componentwise mutliplication
perform p=(p.x()*p2.x(),p.y()*p2.x())
References internal_x, internal_y, x(), and y().
void cpe::v2::scale | ( | const double & | sx, |
const double & | sy | ||
) |
internal scaling (similar to componentwise)
References internal_x, and internal_y.
void cpe::v2::set_zero | ( | ) |
set every entry to 0
References internal_x, and internal_y.
std::string cpe::v2::to_string | ( | ) | const |
export the value as string cout<<v2(2,3,6) => 2 3 6
References internal_x, and internal_y.
Referenced by cpe::operator<<().
const double & cpe::v2::x | ( | ) | const |
get x coordinate
References internal_x.
Referenced by dot(), cpe::matrix2::operator*(), operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), and product_compontentwise_internal().
double & cpe::v2::x | ( | ) |
get x coordinate
References internal_x.
const double & cpe::v2::y | ( | ) | const |
get y coordinate
References internal_y.
Referenced by dot(), cpe::matrix2::operator*(), operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), and product_compontentwise_internal().
double & cpe::v2::y | ( | ) |
get y coordinate
References internal_y.
|
private |
x coordinate
Referenced by dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), and x().
|
private |
y coordinate
Referenced by dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), and y().