31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.10 Double-Valued Vectors ( vector )<br />

1. Definition<br />

An instance of data type vector is a vector of variables of type double.<br />

#include < <strong>LEDA</strong>/numbers/vector.h ><br />

2. Creation<br />

vector v; creates an instance v of type vector; v is initialized to the zerodimensional<br />

vector.<br />

vector v(int d); creates an instance v of type vector; v is initialized to the zero<br />

vector of dimension d.<br />

vector<br />

vector<br />

vector<br />

v(double a, double b);<br />

creates an instance v of type vector; v is initialized to the twodimensional<br />

vector (a, b).<br />

v(double a, double b, double c);<br />

creates an instance v of type vector; v is initialized to the threedimensional<br />

vector (a, b, c).<br />

v(const vector& w, int prec);<br />

creates an instance v of type vector; v is initialized to a copy of w.<br />

<strong>The</strong> second argument is for compatibility with rat vector.<br />

3. Operations<br />

int v.dim( ) returns the dimension of v.<br />

double& v[int i] returns i-th component of v.<br />

Precondition: 0 ≤ i ≤ v.dim()−1.<br />

double v.hcoord(int i) for compatibility with rat vector.<br />

double v.coord(int i) for compatibility with rat vector.<br />

double v.sqr length( ) returns the square of the Euclidean length of v.<br />

double v.length( ) returns the Euclidean length of v.<br />

vector v.norm( ) returns v normalized.<br />

double v.angle(const vector& w) returns the angle between v and w.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!