external_vec<T, int NN = 0, SizeType=unsigned int> [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:containers Component type:type
Description
This is similar to dense1D, except that the memory is provided by the user. This allows for interoperability with other array packages and even with Fortran. This function does not allocation memory. Better hope enough memory is already there!
Example
In dot_prod.cc:
  const int N = 3;
  double dx[] = { 1, 2, 3};
  double dy[] = { 3, 0, -1};
  typedef external_vec<double> Vec;
  Vec x(dx,N), y(dy,N);

  print_vector(x);
  print_vector(y);

  double dotprd = dot(x, y);

  if (dotprd == 0)
    cout << "Vectors x and y are orthogonal." << endl;
  else
    cout << "dot(x,y) = " << dotprd << endl;

More examples can be found in apply_givens.cc, euclid_norm.cc, max_index.cc

Definition
linalg_vec.h
Template Parameters

ParameterDescriptionDefault
TThe element type. 
NNThe static size of the Vector, 0 if dynamic size 
SizeTThe size type to use size_t
DiffTptrdiff_t 
Model of
Vector
Members
Member Where defined Description
enum { N = NN }    
IndexArray    
sparsity   The vector is dense
scaled_type   Scaled type for the vector
size_type    
difference_type    
value_type   The element type
reference   The reference to the value type
pointer   The pointer ot the value type
const_reference   The const reference type
iterator   The iterator type
const_iterator   The const iterator type
const_iterator   The const iterator type
reverse_iterator   The reverse iterator type
const_reverse_iterator   The const reverse iterator type
IndexArrayRef Vector  
subrange_type Vector The type for the subrange vector
range    
dimension   This is a 1D container
external_vec ()   Default Constructor
external_vec (T* data)   External Data Contructor
external_vec (T* data, size_type n, size_type start = 0)   Preallocated Memory Constructor with optional non-zero starting index
external_vec (const self& x)   Copy Constructor
self& operator= (const self& x)   Assignment
~external_vec ()   Destructor
iterator begin () Container Return an iterator pointing to the beginning of the vector
iterator end () Container Return an iterator pointing past the end of the vector
const_iterator begin () const Container Return a const iterator pointing to the begining of the vector
const_iterator end () const Container Return a const iterator pointing past the end of the vector
reverse_iterator rbegin () Reversible Container Return a reverse iterator pointing to the last element of the vector
reverse_iterator rend () Reversible Container Return a reverse iterator pointing past the end of the vector
const_reverse_iterator rbegin () const Reversible Container Return a const reverse iterator pointing to the last element of the vector
const_reverse_iterator rend () const Reversible Container Return a const reverse iterator pointing past the end of the vector
reference operator[] (size_type i) Vector Return a reference to the element with the ith index
const_reference operator[] (size_type i) const Vector Return a const reference to the element with the ith index
subrange_type operator() (size_type s, size_type f) const Vector Return a subrange vector with start at s and finish at f
subrange_type operator() (range r)    
size_type size () const Container The size of the vector
size_type nnz () const Vector The number of non-zeroes in the vector
void clear ()   Resize the vector to size n
value_type* data () const   Raw Memory Access
self& adjust_index (size_type i)    
void push_back (const T& x)   Push x onto the end of the vector, increasing the size
New members
Notes
See also

[MTL Home] Copyright © 1998,1999 University of Notre Dame. All Rights Reserved.