Go::Array< T, Dim > Class Template Reference
['utils' - a collection of useful math and programming tools]

Compile-time sized array. More...

#include <Array.h>

List of all members.

Public Member Functions

 Array ()
 Default constructor, does not initialize elements.
 Array (T x, T y)
 Constructor taking 2 arguments, only compiles if Array dimension argument is 2.
 Array (T x, T y, T z)
 Constructor taking 3 arguments, only compiles if Array dimension argument is 3.
 Array (T x, T y, T z, T w)
 Constructor taking 4 arguments, only compiles if Array dimension argument is 4.
 Array (const Array &v)
 Copy constructor.
template<typename RandomAccessIterator>
 Array (RandomAccessIterator start)
 Constructor taking a pointer or other random access iterator and copying all elements into the Array.
template<typename RandomAccessIterator>
void setValue (RandomAccessIterator from)
 Takes a pointer or other random access iterator and copies all elements into the Array.
template<typename U>
 Array (const Array< U, Dim > &v)
 Constructor that takes an Array of a compatible type.
template<typename RandomAccessIterator>
void setValueConvert (RandomAccessIterator from)
 Takes a pointer or other random access iterator with compatible value type and copies all elements into the Array.
Arrayoperator= (const Array &v)
 Assignment operator.
void read (std::istream &is)
 Reads an Array elementwise from a standard istream.
void write (std::ostream &os) const
 Writes an Array elementwise to a standard ostream.
const T & x () const
 Access to first element.
T & x ()
 Access to first element.
const T & y () const
 Access to first element.
T & y ()
 Access to first element.
const T & z () const
 Access to first element.
T & z ()
 Access to first element.
const T & operator[] (int i) const
 Read-only index access.
T & operator[] (int i)
 Index access.
const T * begin () const
 Get a read-only start iterator.
T * begin ()
 Get a start iterator.
const T * end () const
 Get a read-only end iterator.
T * end ()
 Get a end iterator.
int size () const
 Get the dimension of the Array.
length2 () const
 Get the square of the euclidian length of the vector.
length () const
 Get the euclidian length of the vector.
lengthInf () const
 Get the infinity-norm (or max-norm) length of the vector.
dist2 (const Array &v) const
 Get the square of the euclidian length of the difference between this vector and another vector.
dist (const Array &v) const
 Get the euclidian length of the difference between this vector and another vector.
distInf (const Array &v) const
 Get the infinity-norm (or max-norm) length of the difference between this vector and another vector.
void normalize ()
 Normalize this vector, i.e.
Array operator+ (const Array &v) const
 The sum of two vectors.
bool operator== (const Array &v) const
 Add a vector to this vector.
Arrayoperator+= (const Array &v)
 Add a vector to this vector.
Array operator- (const Array &v) const
 The difference between two vectors.
Arrayoperator-= (const Array &v)
 Subtract a vector from this vector.
Array operator * (T d) const
 The product of a vector and a scalar.
Arrayoperator *= (T d)
 Multiply this vector by a scalar.
Array operator/ (double d) const
 A vector divided by a scalar.
Arrayoperator/= (double d)
 Divide this vector with a scalar.
Array operator- () const
 The negation of a vector.
operator * (const Array &v) const
 The scalar product (or inner product, or dot product) of two vectors.
Array operator% (const Array &v) const
 The cross product of two vectors.
Array cross (const Array &v) const
 The cross product of two vectors.
cosAngle (const Array &v) const
 The cosine of the angle between this and another vector.
angle (const Array &v) const
 The angle between this and another vector.
void zero ()
 Sets the vector to the zero vector.


Detailed Description

template<typename T, int Dim>
class Go::Array< T, Dim >

Compile-time sized array.

Encapsulates an array with full value semantics, i.e. copying and assignment works as expected. The class also has some vector algebra functionality, such as scalar product, multiplication by scalars etc. In such contexts the objects are talked about as 'vectors' and not 'Arrays'.

Definition at line 58 of file Array.h.


Member Function Documentation

template<typename T, int Dim>
void Go::Array< T, Dim >::write ( std::ostream &  os  )  const [inline]

Writes an Array elementwise to a standard ostream.

Precision is set to 16 by this function.

Definition at line 152 of file Array.h.

template<typename T, int Dim>
const T& Go::Array< T, Dim >::x (  )  const [inline]

Access to first element.

(Deprecated, kept for backward compatibility)

Definition at line 162 of file Array.h.

template<typename T, int Dim>
T& Go::Array< T, Dim >::x (  )  [inline]

Access to first element.

(Deprecated, kept for backward compatibility)

Definition at line 165 of file Array.h.

template<typename T, int Dim>
const T& Go::Array< T, Dim >::y (  )  const [inline]

Access to first element.

(Deprecated, kept for backward compatibility)

Definition at line 168 of file Array.h.

template<typename T, int Dim>
T& Go::Array< T, Dim >::y (  )  [inline]

Access to first element.

(Deprecated, kept for backward compatibility)

Definition at line 171 of file Array.h.

template<typename T, int Dim>
const T& Go::Array< T, Dim >::z (  )  const [inline]

Access to first element.

(Deprecated, kept for backward compatibility)

Definition at line 174 of file Array.h.

template<typename T, int Dim>
T& Go::Array< T, Dim >::z (  )  [inline]

Access to first element.

(Deprecated, kept for backward compatibility)

Definition at line 177 of file Array.h.

template<typename T, int Dim>
void Go::Array< T, Dim >::normalize (  )  [inline]

Normalize this vector, i.e.

divide every element by length().

Definition at line 257 of file Array.h.

Referenced by Go::BaryCoordSystemTriangle3D::BaryCoordSystemTriangle3D(), and Go::MatrixXD< double, 3 >::setToRotation().

template<typename T, int Dim>
Array Go::Array< T, Dim >::operator% ( const Array< T, Dim > &  v  )  const [inline]

The cross product of two vectors.

Only compiles if dimension is 3.

Definition at line 355 of file Array.h.

Referenced by Go::Array< double, Dim >::cross().

template<typename T, int Dim>
Array Go::Array< T, Dim >::cross ( const Array< T, Dim > &  v  )  const [inline]

The cross product of two vectors.

Only compiles if dimension is 3.

Definition at line 365 of file Array.h.

Referenced by Go::area(), and Go::signed_area().


The documentation for this class was generated from the following file:
Generated on Mon Jun 11 14:48:18 2007 for GoTools Core Library by  doxygen 1.5.1