From 2239d64376bded338b02ca2c1d52386df6905e86 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Sat, 10 Jul 2004 08:40:37 +0000 Subject: [PATCH] From uBLAS project. Ready for regression testing for 1.32.0 [SVN r23424] --- Jamfile.v2 | 9 + doc/banded.htm | 334 ++---- doc/container.htm | 272 ++--- doc/expression.htm | 452 ++------ doc/functions.htm | 217 ++++ doc/hermitian.htm | 394 +++---- doc/index.htm | 284 ++--- doc/iterator.htm | 743 +++++------- doc/matrix.htm | 483 ++++---- doc/matrix_expression.htm | 1342 ++++++++-------------- doc/matrix_proxy.htm | 1010 ++++++----------- doc/matrix_sparse.htm | 560 ++++----- doc/overview.htm | 1576 +++++++------------------- doc/readme.txt | 8 - doc/samples/banded_adaptor.cpp | 2 +- doc/samples/banded_matrix.cpp | 2 +- doc/samples/matrix_binary.cpp | 4 +- doc/samples/matrix_matrix_binary.cpp | 4 +- doc/samples/matrix_matrix_solve.cpp | 2 +- doc/samples/matrix_vector_binary.cpp | 2 +- doc/samples/matrix_vector_solve.cpp | 2 +- doc/samples/vector_binary.cpp | 2 +- doc/samples/vector_binary_outer.cpp | 2 +- doc/samples/vector_binary_redux.cpp | 2 +- doc/storage.htm | 301 ++--- doc/storage_sparse.htm | 168 +-- doc/symmetric.htm | 378 +++--- doc/triangular.htm | 383 +++---- doc/types.htm | 561 +++++++++ doc/ublas.css | 14 + doc/vector.htm | 429 +++---- doc/vector_expression.htm | 811 +++++-------- doc/vector_proxy.htm | 369 ++---- doc/vector_sparse.htm | 484 +++----- index.html | 2 +- test4/test4.hpp | 4 +- 36 files changed, 4563 insertions(+), 7049 deletions(-) create mode 100644 doc/functions.htm create mode 100644 doc/types.htm create mode 100644 doc/ublas.css diff --git a/Jamfile.v2 b/Jamfile.v2 index 2a54743a..6f4fc0d9 100644 --- a/Jamfile.v2 +++ b/Jamfile.v2 @@ -20,6 +20,15 @@ project ublastest kylix:"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" ; +build-project test1 ; +build-project test2 ; +build-project test3 ; +build-project test4 ; +build-project test5 ; +build-project test6 ; +build-project test7 ; + + test-suite "uBLAS" : [ compile concepts.cpp ] [ run test1 ] diff --git a/doc/banded.htm b/doc/banded.htm index 80d55500..e8eaa1ff 100644 --- a/doc/banded.htm +++ b/doc/banded.htm @@ -1,20 +1,20 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Banded Matrix - -

c++boost.gif + +

c++boost.gif Banded Matrix

- -

Banded Matrix

- +

Banded +Matrix

Description

-

The templated class banded_matrix<T, F, A> is the base container adaptor for banded matrices. For a (m x n)-dimensional banded matrix with l lower and @@ -22,88 +22,69 @@ n)-dimensional banded matrix with l lower and <= j < n holds bi, j = 0, if i > j + l or i < j - u. The storage of banded matrices is packed.

-

Example

-
-#include <boost/numeric/ublas/banded.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- banded_matrix<double> m (3, 3, 1, 1);
- for (signed i = 0; i < signed (m.size1 ()); ++ i)
- for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (m.size2 ())); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << m << std::endl;
-}
+#include <boost/numeric/ublas/banded.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ banded_matrix<double> m (3, 3, 1, 1);
+ for (signed i = 0; i < signed (m.size1 ()); ++ i)
+ for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (m.size2 ())); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
+}
-

Definition

-

Defined in the header banded.hpp.

-

Template parameters

- - +
- - + - +"#banded_matrix_1">[1] - +"#banded_matrix_2">[2]
Parameter Description Default
T The type of object stored in the matrix. 
F Functor describing the storage organization. [1] row_major
A The type of the adapted array. [2] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<banded_matrix<T, F, A> >

-

Members

- - +
- - @@ -112,344 +93,285 @@ holds (lower + 1 + upper) diagonals around the main diagonal of a matrix with size1 rows of size2 elements. - - - - +lower = 0, size_type upper = 0, bool preserve = true) +existing elements of the banded_matrix are preseved +when specified. - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
banded_matrix () Allocates an uninitialized banded_matrix that holds zero rows of zero elements.
banded_matrix (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0)
banded_matrix (const banded_matrix &m) The copy constructor.
template<class AE>
- banded_matrix (const matrix_expression<AE> +
template<class AE>
+banded_matrix (const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type size2, size_type -lower = 0, size_type upper = 0) Reallocates a banded_matrix to hold (lower + 1 + upper) diagonals around the main diagonal of a matrix with size1 rows of size2 elements. The -content of the banded_matrix is not preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
size_type lower () const Returns the number of diagonals below the main diagonal.
size_type upper () const Returns the number of diagonals above the main diagonal.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
banded_matrix &operator = (const banded_matrix &m) The assignment operator.
banded_matrix &assign_temporary (banded_matrix &m) Assigns a temporary. May change the banded matrix m .
template<class AE>
- banded_matrix &operator = (const matrix_expression<AE> +
template<class AE>
+banded_matrix &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- banded_matrix &assign (const matrix_expression<AE> +
template<class AE>
+banded_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the banded matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- banded_matrix &operator += (const matrix_expression<AE> +
template<class AE>
+banded_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the banded matrix.
template<class AE>
- banded_matrix &plus_assign (const matrix_expression<AE> +
template<class AE>
+banded_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the banded matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- banded_matrix &operator -= (const matrix_expression<AE> +
template<class AE>
+banded_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the banded matrix.
template<class AE>
- banded_matrix &minus_assign (const matrix_expression<AE> +
template<class AE>
+banded_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the banded matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- banded_matrix &operator *= (const AT &at)
template<class AT>
+banded_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the banded matrix with a scalar.
template<class AT>
- banded_matrix &operator /= (const AT &at)
template<class AT>
+banded_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the banded matrix through a scalar.
void swap (banded_matrix &m) Swaps the contents of the banded matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th elemenst of the i-th row.
void clear () Clears the matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the banded_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the banded_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the banded_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the banded_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the banded_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the banded_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the banded_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the banded_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed banded_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed banded_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed banded_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed banded_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed banded_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed banded_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed banded_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed banded_matrix.
-

Notes

- -

[1] Supported parameters for the -storage organization are row_major and -column_major.

- -

[2] Supported parameters for the -adapted array are unbounded_array<T> , +

[1] Supported +parameters for the storage organization are row_major +and column_major.

+

[2] Supported +parameters for the adapted array are +unbounded_array<T> , bounded_array<T> and std::vector<T> .

- -

Banded Adaptor

- +

Banded +Adaptor

Description

-

The templated class banded_adaptor<M> is a banded matrix adaptor for other matrices.

-

Example

-
-#include <boost/numeric/ublas/banded.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- banded_adaptor<matrix<double> > ba (m, 1, 1);
- for (signed i = 0; i < signed (ba.size1 ()); ++ i)
- for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (ba.size2 ())); ++ j)
- ba (i, j) = 3 * i + j;
- std::cout << ba << std::endl;
-}
+#include <boost/numeric/ublas/banded.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ banded_adaptor<matrix<double> > ba (m, 1, 1);
+ for (signed i = 0; i < signed (ba.size1 ()); ++ i)
+ for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (ba.size2 ())); ++ j)
+ ba (i, j) = 3 * i + j;
+ std::cout << ba << std::endl;
+}
-

Definition

-

Defined in the header banded.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
M The type of the adapted matrix. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<banded_adaptor<M> >

-

Members

- - +
- - @@ -457,239 +379,201 @@ of zero elements.(lower + 1 + upper) diagonals around the main diagonal of a matrix. - - - - - - - - - - - - - - - - - - - - - - - + - - + - - + - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
banded_adaptor () Constructs a banded_adaptor that holds zero rows of zero elements.
banded_adaptor (matrix_type &data, size_type lower = 0, size_type upper = 0)
banded_adaptor (const banded_adaptor &m) The copy constructor.
template<class AE>
- banded_adaptor (const matrix_expression<AE> +
template<class AE>
+banded_adaptor (const matrix_expression<AE> &ae)
The extended copy constructor.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
size_type lower () const Returns the number of diagonals below the main diagonal.
size_type upper () const Returns the number of diagonals above the main diagonal.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
banded_adaptor &operator = (const banded_adaptor &m) The assignment operator.
banded_adaptor &assign_temporary (banded_adaptor &m) Assigns a temporary. May change the banded adaptor m .
template<class AE>
- banded_adaptor &operator = (const matrix_expression<AE> +
template<class AE>
+banded_adaptor &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- banded_adaptor &assign (const matrix_expression<AE> +
template<class AE>
+banded_adaptor &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the banded adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- banded_adaptor &operator += (const matrix_expression<AE> +
template<class AE>
+banded_adaptor &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the banded adaptor.
template<class AE>
- banded_adaptor &plus_assign (const matrix_expression<AE> +
template<class AE>
+banded_adaptor &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the banded adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- banded_adaptor &operator -= (const matrix_expression<AE> +
template<class AE>
+banded_adaptor &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the banded adaptor.
template<class AE>
- banded_adaptor &minus_assign (const -matrix_expression<AE> &ae)
template<class AE>
+banded_adaptor &minus_assign (const matrix_expression<AE> +&ae)
Subtracts a matrix expression from the banded adaptor. Left and right hand side of the assignment should be independent.
template<class AT>
- banded_adaptor &operator *= (const AT &at)
template<class AT>
+banded_adaptor &operator *= (const AT &at)
A computed assignment operator. Multiplies the banded adaptor with a scalar.
template<class AT>
- banded_adaptor &operator /= (const AT &at)
template<class AT>
+banded_adaptor &operator /= (const AT &at)
A computed assignment operator. Divides the banded adaptor through a scalar.
void swap (banded_adaptor &m) Swaps the contents of the banded adaptors.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the banded_adaptor.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the banded_adaptor.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the banded_adaptor.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the banded_adaptor.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the banded_adaptor.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the banded_adaptor.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the banded_adaptor.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the banded_adaptor.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed banded_adaptor.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed banded_adaptor.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed banded_adaptor.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed banded_adaptor.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed banded_adaptor.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed banded_adaptor.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed banded_adaptor.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed banded_adaptor.
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/container.htm b/doc/container.htm index 12186c77..5e68e3c0 100644 --- a/doc/container.htm +++ b/doc/container.htm @@ -1,89 +1,77 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Container Concepts - -

c++boost.gif + +

c++boost.gif Container Concepts

- -

Vector

- +

Vector

Description

-

A Vector describes common aspects of dense, packed and sparse vectors.

-

Refinement of

-

Vector Expression .

-

Associated types

- - +
- + - - + - - +
Value typevalue_type value_type The type of the vector.
Distance typedifference_type difference_type A signed integral type used to represent the distance between two of the vector's iterators.
Size typesize_type size_type An unsigned integral type that can represent any nonnegative value of the vector's distance type.
-

Notation

- - +
- + - - + - - + - - + + + + +
V V A type that is a model of Vector
vObjects of type V Objects of type V
n, iObjects of a type convertible to size_type Objects of a type convertible to size_type
tObject of a type convertible to value_type Object of a type convertible to value_type
pObject of a type convertible to bool
-

Definitions

-

Valid expressions

-

In addition to the expressions defined in Vector Expression the following expressions must be valid.

- - +
@@ -91,51 +79,44 @@ following expressions must be valid.

- - + - - + - - + - - + - + - - + - +
Name Type requirements Return type
Sizing constructorV v (n) V v (n)   V
Insertv.insert (i, t) v.insert (i, t) v is mutable. void
Erasev.erase (i) v.erase (i) v is mutable. void
Clearv.clear () v.clear () v is mutable.void void
Resizev.resize (n) v.resize (n)
+v.resize (n, p)
v is mutable.void void
-

Expression semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in Vector Expression .

- - +
@@ -144,150 +125,131 @@ from, or is not defined in Semantics - - - + + - - - + + - - - + + - - + - + - - + +elements.
+Erases or appends elements in order to bring the vector to the +prescribed size. Appended elements are value_type() +copies. When p == false then exisiting elements may no +be preserved and elements will not appended as normal. That is with +p == false the elements values after resize are +undefined.
NamePostcondition
Sizing constructorV v (n) n >= 0 V v (n)n >= 0 Creates a vector of n elements. v.size () == n.
Insertv.insert (i, t) 0 <= i < v.size () and
- v (i) is a copy of value_type ().
v.insert (i, t)0 <= i < v.size () and
+v (i) is a copy of value_type ().
A copy of t is inserted in v. v (i) is a copy of t.
Erasev.erase (i) 0 <= i < v.size () v.erase (i)0 <= i < v.size () Destroys the element v (i) and replaces it with value_type (). v (i) is a copy of value_type ().
Clearv.clear () v.clear ()  Equivalent to
- for (i = 0; i < v.size (); ++ i)
-   v.erase (i);
Equivalent to
+for (i = 0; i < v.size (); ++ i)
v.erase (i);
 
Resizev.resize (n) v.resize (n)   Modifies the vector so that it can hold n -elements.v.size () == n.
-

Complexity guarantees

-

The run-time complexity of the sizing constructor is linear in the vector's size.

-

The run-time complexity of insert and erase is specific for the vector.

- +

The run-time complexity of resize is linear in the vector's +size.

Invariants

-

Models

-
  • vector<T, A>
  • -
  • unit_vector<T>
  • -
  • zero_vector<T>
  • - +
  • scalar_vector<T, A>
  • sparse_vector<T, A>
- -

Matrix

- +

Matrix

Description

-

A Matrix describes common aspects of dense, packed and sparse matrices.

-

Refinement of

-

Matrix Expression .

-

Associated types

- - +
- + - - + - - +
Value typevalue_type value_type The type of the matrix.
Distance typedifference_type difference_type A signed integral type used to represent the distance between two of the matrix's iterators.
Size typesize_type size_type An unsigned integral type that can represent any nonnegative value of the matrix's distance type.
-

Notation

- - +
- + - - + - - + - - + + + + +
M M A type that is a model of Matrix
mObjects of type M Objects of type M
n1, n2, i, jObjects of a type convertible to size_type Objects of a type convertible to size_type
tObject of a type convertible to value_type Object of a type convertible to value_type
pObject of a type convertible to bool
-

Definitions

-

Valid expressions

-

In addition to the expressions defined in Matrix Expression the following expressions must be valid.

- - +
@@ -295,51 +257,44 @@ following expressions must be valid.

- - + - - + - - + - - + - + - - + - +
Name Type requirements Return type
Sizing constructorM m (n1, n2) M m (n1, n2)   M
Insertm.insert (i, j, t) m.insert (i, j, t) m is mutable. void
Erasem.erase (i, j) m.erase (i, j) m is mutable. void
Clearm.clear () m.clear () m is mutable.void void
Resizem.resize (n1, n2) m.resize (n1, n2)
+v.resize (n1, n2, p)
m is mutable.void void
-

Expression semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in Matrix Expression .

- - +
@@ -348,98 +303,87 @@ from, or is not defined in Semantics - - + - - - + + - - - + + - - + - + - - + - +
NamePostcondition
Sizing constructorM m (n1, n2) M m (n1, n2) n1 >= 0 and n2 >= 0 Creates a matrix of n1 rows and n2 columns. m.size1 () == n1 and m.size2 () == n2.
Insertm.insert (i, j, t) 0 <= i < m.size1 (),
- 0 <= j < m.size2 ()and
- m (i, j)
is a copy of value_type ().
m.insert (i, j, t)0 <= i < m.size1 (),
+0 <= j < m.size2 ()and
+m (i, j)
is a copy of value_type ().
A copy of t is inserted in m. m (i, j) is a copy of t.
Erasem.erase (i, j) 0 <= i < m.size1 ()and
- 0 <= j < m.size2
m.erase (i, j)0 <= i < m.size1 ()and
+0 <= j < m.size2
Destroys the element m (i, j) and replaces it with value_type (). m (i, j) is a copy of value_type ().
Clearm.clear () m.clear ()  Equivalent to
- for (i = 0; i < m.size1 (); ++ i)
-   for (j = 0; j < m.size2 (); ++ j)
-     m.erase (i, j);
Equivalent to
+for (i = 0; i < m.size1 (); ++ i)
for (j = 0; j < m.size2 (); ++ j)
+    m.erase (i, j);
 
Resizem.resize (n1, n2) m.resize (n1, n2)  Modifies the vector so that it can hold n1 rows -and n2 columns.Modifies the matrix so that it can hold n1 rows +and n2 columns.
+Erases or appends elements in order to bring the matrix to the +prescribed size. Appended elements are value_type() +copies. When p == false then exisiting elements may no +be preserved and elements will not appended as normal. That is with +p == false the elements values after resize are +undefined.
m.size1 () == n1 and m.size2 () == n2.
-

Complexity guarantees

-

The run-time complexity of the sizing constructor is quadratic in the matrix's size.

-

The run-time complexity of insert and erase is specific for the matrix.

- +

The run-time complexity of resize is quadratic in the matrix's +size.

Invariants

-

Models

-
  • matrix<T, F, A>
  • -
  • identity_matrix<T>
  • -
  • zero_matrix<T>
  • - +
  • scalar_matrix<T>
  • triangular_matrix<T, F1, F2, A>
  • -
  • symmetric_matrix<T, F1, F2, A>
  • -
  • banded_matrix<T, F, A>
  • -
  • sparse_matrix<T, F, A>
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

- -

Last revised: 1/15/2003

+

Last revised: 24/06/2004

- diff --git a/doc/expression.htm b/doc/expression.htm index 4d9860e9..e6fe9a9a 100644 --- a/doc/expression.htm +++ b/doc/expression.htm @@ -1,58 +1,48 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Expression Concepts - -

c++boost.gif + +

c++boost.gif Expression Concepts

- -

Scalar Expression

- +

Scalar +Expression

Description

-

A Scalar Expression is an expression convertible to a scalar type.

-

Refinement of

-

Default Constructible.

-

Associated types

- - +
- +
Value typevalue_type value_type The type of the scalar expression.
-

Notation

- - +
- +
S S A type that is a model of Scalar Expression
-

Definitions

-

Valid expressions

-

In addition to the expressions defined in Default Constructible the following expressions must be valid.

- - +
@@ -60,7 +50,6 @@ the following expressions must be valid.

- @@ -69,13 +58,10 @@ the following expressions must be valid.

Name Type requirements Return type
Evaluation operator value_type () const
-

Expression semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in Default Constructible.

- - +
@@ -84,7 +70,6 @@ from, or is not defined in Default Constructible.

- @@ -94,125 +79,98 @@ from, or is not defined in Default Constructible.

Name Semantics Postcondition
Evaluation operator value_type () const
-

Complexity guarantees

-

The run-time complexity of the evaluation is specific for the evaluated scalar expression.

-

Invariants

-

Models

-
  • vector_scalar_unary<E, F>
  • -
  • vector_scalar_binary<E1, E2, F>
- -

Vector Expression

- +

Vector +Expression

Description

-

A Vector Expression is an expression evaluatable to a vector. Vector Expression provides an Indexed Bidirectional Iterator or an Indexed Random Access Iterator .

-

Refinement of

-

Default Constructible.

-

Associated types

- - +
- + - - + - - + - - + - - + - - + - - +
Value typevalue_type value_type The type of the vector expression.
Const iterator typeconst_iterator const_iterator A type of iterator that may be used to examine a vector expression's elements.
Iterator typeiterator iterator A type of iterator that may be used to modify a vector expression's elements.
Distance typedifference_type difference_type A signed integral type used to represent the distance between two of the vector expression's iterators.
Size typesize_type size_type An unsigned integral type that can represent any nonnegative value of the vector expression's distance type.
Const reverse iterator typeconst_reverse_iterator const_reverse_iterator A Reverse Iterator adaptor whose base iterator type is the vector expression's const iterator type.
Reverse iterator typereverse_iterator reverse_iterator A Reverse Iterator adaptor whose base iterator type is the vector expression's iterator type.
-

Notation

- - +
- + - - + - - + -
V V A type that is a model of Vector Expression
v, v1, v2Object of type V Object of type V
iObject of a type convertible to size_type Object of a type convertible to size_type
t Object of a type convertible to value_type
-

Definitions

-

Valid expressions

-

In addition to the expressions defined in Default Constructible the following expressions must be valid.

- - +
@@ -220,80 +178,68 @@ the following expressions must be valid.

- - + - - - + - - + - - + - + - - + - - + - - + - - + - - + - - + - @@ -301,14 +247,12 @@ the following expressions must be valid.

to V. - - @@ -316,28 +260,24 @@ to V. to V. - - - -
Name Type requirements Return type
Beginning of rangev.begin () v.begin ()   const_iterator
v.begin () v is mutable. iterator
End of rangev.end () v.end ()   const_iterator
v.end () v.end () v is mutable. iterator
Sizev.size () v.size ()  size_type size_type
Swapv1.swap (v2) v1.swap (v2) v1 and v2 are mutable. void
Beginning of reverse rangev.rbegin () v.rbegin ()   const_reverse_iterator
v.rbegin () v.rbegin () v is mutable. reverse_iterator
End of reverse rangev.rend () v.rend ()   const_reverse_iterator
v.rend () v.rend () v is mutable. reverse_iterator
Element accessv (i) v (i) i is convertible to size_type. Convertible to value_type.
Assignment v2 = v1 V &
v2.assign (v1) v2 is mutable and v1 is convertible to V. V &
Computed assignment v2 += v1 V &
v2.plus_assign (v1) v2 is mutable and v1 is convertible to V. V &
v2 -= v1 v2 is mutable and v1 is convertible to V. V &
v2.minus_assign (v1) v2 is mutable and v1 is convertible to V. V &
v *= t v is mutable and t is convertible to @@ -346,13 +286,10 @@ to V.
-

Expression semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in Default Constructible.

- - +
@@ -361,10 +298,9 @@ from, or is not defined in Default Constructible.

- - + @@ -372,60 +308,53 @@ expression. past-the-end. It is past-the-end if and only if v.size () == 0. - - + - - + - + - - + - - + - - + - - - + + - @@ -435,7 +364,6 @@ expression. . - @@ -443,7 +371,6 @@ expression. element of v2. - @@ -453,7 +380,6 @@ element of v2.v2. - @@ -461,7 +387,6 @@ element of v2. element of v2. - @@ -470,7 +395,6 @@ element of v2. . - @@ -478,7 +402,6 @@ element of v2. corresponding element of v2. - @@ -488,53 +411,41 @@ corresponding element of v2.
Name Semantics Postcondition
Beginning of rangev.begin () v.begin ()   Returns an iterator pointing to the first element in the vector expression.
End of rangev.end () v.end ()   Returns an iterator pointing one past the last element in the vector expression. v.end () is past-the-end.
Sizev.size () v.size ()   Returns the size of the vector expression, that is, its number of elements.v.size () >= 0 v.size () >= 0
Swapv1.swap (v2) v1.swap (v2)   Equivalent to swap (v1, v2).  
Beginning of reverse rangev.rbegin () v.rbegin ()   Equivalent to reverse_iterator (v.end ()). v.rbegin () is either dereferenceable or past-the-end. It is past-the-end if and only if v.size () == 0.
End of reverse rangev.rend () v.rend ()   Equivalent to reverse_iterator (v.begin ()). v.rend () is past-the-end.
Element accessv (i) 0 <= i < v.size () v (i)0 <= i < v.size () Returns the i-th element of the vector expression.  
Assignment v2 = v1  
v2.assign (v1) v1.size () == v2.size ()  
Computed assignment v2 += v1  
v2.plus_assign (v1) v1.size () == v2.size ()  
v2 -= v1 v1.size () == v2.size ()  
v2.minus_assign (v1) v1.size () == v2.size ()  
v *= t  
-

Complexity guarantees

-

The run-time complexity of begin () and end () is specific for the evaluated vector expression, typically amortized constant time.

-

The run-time complexity of size () is constant time.

-

The run-time complexity of swap () is specific for the evaluated vector expression, typically constant time.

-

The run-time complexity of rbegin () and rend () is specific for the evaluated vector expression, typically amortized constant time.

-

The run-time complexity of the element access is specific for the evaluated vector expression, typically amortized constant time for the dense and logarithmic for the sparse case.

-

The run-time complexity of the arithmetic operations is specific for the evaluated vector expressions, typically linear in the size of the expressions.

-

Invariants

- - +
- - -
Valid range For any vector expression v, [v.begin (), v.end ()) is a valid range.
Completeness An algorithm that iterates through the range [v.begin (), v.end ()) will pass through every element of v .
Valid reverse range [v.rbegin (), v.rend ()) is a valid range.
Equivalence of ranges The distance from v.begin () to v.end @@ -543,166 +454,126 @@ to v.rend ().
-

Models

-
  • vector_range<V>
  • -
  • vector_slice<V>
  • -
  • matrix_row<M>
  • -
  • matrix_column<M>
  • -
  • matrix_vector_range<M>
  • -
  • matrix_vector_slice<M>
  • -
  • vector_unary<E, F>
  • -
  • vector_binary<E1, E2, F>
  • -
  • vector_binary_scalar1<E1, E2, F>
  • -
  • vector_binary_scalar2<E1, E2, F>
  • -
  • matrix_vector_unary1<E>
  • -
  • matrix_vector_unary2<E>
  • -
  • matrix_vector_binary1<E1, E2, F>
  • -
  • matrix_vector_binary2<E1, E2, F>
- -

Matrix Expression

- +

Matrix +Expression

Description

-

A Matrix Expression is an expression evaluatable to a matrix. Matrix Expression provides an Indexed Bidirectional Column/Row Iterator or an Indexed Random Access Column/Row Iterator .

-

Refinement of

-

Default Constructible.

-

Associated types

- - +
- + - - + - - - + - - - + - - + - - + - - + - - + - - +
Value typevalue_type value_type The type of the matrix expression.
Const iterator typesconst_iterator1 const_iterator1 A type of column iterator that may be used to examine a matrix expression's elements.
const_iterator2 A type of row iterator that may be used to examine a matrix expression's elements.
Iterator typesiterator1 iterator1 A type of column iterator that may be used to modify a matrix expression's elements.
iterator2 A type of row iterator that may be used to modify a matrix expression's elements.
Distance typedifference_type difference_type A signed integral type used to represent the distance between two of the matrix expression's iterators.
Size typesize_type size_type An unsigned integral type that can represent any nonnegative value of the matrix expression's distance type.
Const reverse iterator typesconst_reverse_iterator1 const_reverse_iterator1 A Reverse Iterator adaptor whose base iterator type is the matrix expression's const column iterator type.
const_reverse_iterator2 const_reverse_iterator2 A Reverse Iterator adaptor whose base iterator type is the matrix expression's const row iterator type.
Reverse iterator typesreverse_iterator1 reverse_iterator1 A Reverse Iterator adaptor whose base iterator type is the matrix expression's column iterator type.
reverse_iterator2 reverse_iterator2 A Reverse Iterator adaptor whose base iterator type is the matrix expression's row iterator type.
-

Notation

- - +
- + - - + - - + -
M M A type that is a model of Matrix Expression
m, m1, m2Object of type M Object of type M
i, jObjects of a type convertible to size_type Objects of a type convertible to size_type
t Object of a type convertible to value_type
-

Definitions

-

Valid expressions

-

In addition to the expressions defined in Default Constructible the following expressions must be valid.

- - +
@@ -710,135 +581,114 @@ the following expressions must be valid.

- - + - - + - - + - - + - - + - - + - - + - - + - - + - + - - + - + - - - + - - + - - + - - + - - + - - + - - + - - - + - @@ -846,14 +696,12 @@ the following expressions must be valid.

to M. - - @@ -861,28 +709,24 @@ to M. to M. - - - -
Name Type requirements Return type
Beginning of rangem.begin1 () m.begin1 ()   const_iterator1
m.begin2 () m.begin2 ()   const_iterator2
m.begin1 () m.begin1 () m is mutable.  iterator1
m.begin2 () m.begin2 () m is mutable. iterator2
End of rangem.end1 () m.end1 ()   const_iterator1
m.end2 () m.end2 ()   const_iterator2
m.end1 () m.end1 () m is mutable.  iterator1
m.end2 () m.end2 () m is mutable. iterator2
Sizem.size1 () m.size1 ()  size_type size_type
m.size2 () m.size2 ()  size_type size_type
Swap m1.swap (m2) m1 and m2 are mutable.  void
Beginning of reverse rangem.rbegin1 () m.rbegin1 ()   const_reverse_iterator1
m.rbegin2 () m.rbegin2 ()   const_reverse_iterator2
m.rbegin1 () m.rbegin1 () m is mutable.  reverse_iterator1
m.rbegin2 () m.rbegin2 () m is mutable. reverse_iterator2
End of reverse rangem.rend1 () m.rend1 ()   const_reverse_iterator1
m.rend2 () m.rend2 ()   const_reverse_iterator2
m.rend1 () m.rend1 () m is mutable. reverse_iterator1
m.rend2 () m is mutable. reverse_iterator2
Element accessm (i, j) m (i, j) i and j are convertible to size_type . Convertible to value_type.
Assignment m2 = m1 M &
m2.assign (m1) m2 is mutable and m1 is convertible to M. M &
Computed assignment m2 += m1 M &
m2.plus_assign (m1) m2 is mutable and m1 is convertible to M. M &
m2 -= m1 m2 is mutable and m1 is convertible to M. M &
m2.minus_assign (m1) m2 is mutable and m1 is convertible to M. M &
m *= t m is mutable and t is convertible to @@ -891,13 +735,10 @@ to M.
-

Expression semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in Default Constructible.

- - +
@@ -906,10 +747,9 @@ from, or is not defined in Default Constructible.

- - + @@ -917,9 +757,8 @@ column of a matrix expression. past-the-end. It is past-the-end if and only if m.size1 () == 0. - - + @@ -927,152 +766,135 @@ row of a matrix expression. past-the-end. It is past-the-end if and only if m.size2 () == 0. - - + - - + - - + - + - - + - + - - + - - + - - + - - + - - + - - + +m.size2 () - - + - - + - - + - - + - - + - - + - @@ -1082,34 +904,25 @@ corresponding element of m2.
Name Semantics Postcondition
Beginning of rangem.begin1 () m.begin1 ()   Returns an iterator pointing to the first element in the first column of a matrix expression.
m.begin2 () m.begin2 ()   Returns an iterator pointing to the first element in the first row of a matrix expression.
End of rangem.end1 () m.end1 ()   Returns an iterator pointing one past the last element in the matrix expression. m.end1 () is past-the-end.
m.end2 () m.end2 ()   Returns an iterator pointing one past the last element in the matrix expression. m.end2 () is past-the-end.
Sizem.size1 () m.size1 ()   Returns the number of rows of the matrix expression.m.size1 () >= 0 m.size1 () >= 0
m.size2 () m.size2 ()   Returns the number of columns of the matrix expression.m.size2 () >= 0 m.size2 () >= 0
Swapm1.swap (m2) m1.swap (m2)   Equivalent to swap (m1, m2).  
Beginning of reverse rangem.rbegin1 () m.rbegin1 ()   Equivalent to reverse_iterator1 (m.end1 ()). m.rbegin1 () is either dereferenceable or past-the-end. It is past-the-end if and only if m.size1 () == 0.
m.rbegin2 () m.rbegin2 ()   Equivalent to reverse_iterator2 (m.end2 ()). m.rbegin2 () is either dereferenceable or past-the-end. It is past-the-end if and only if m.size2 () == 0.
End of reverse rangem.rend1 () m.rend1 ()   Equivalent to reverse_iterator1 (m.begin1 ()). m.rend1 () is past-the-end.
m.rend2 () m.rend2 ()   Equivalent to reverse_iterator2 (m.begin2 ()). m.rend2 () is past-the-end.
Element accessm (i, j) m (i, j) 0 <= i < m.size1 () and 0 <= j < -m.size2 () Returns the j-th element of the i-th row of the matrix expression.  
Assignment m2 = m1m1.size1 () == m2.size1 () and
- m1.size2 () == m2.size2 ()
m1.size1 () == m2.size1 () and
+m1.size2 () == m2.size2 ()
Assigns every element of the evaluated matrix expression m1 to the corresponding element of m2 .  
m2.assign (m1)m1.size1 () == m2.size1 () and
- m1.size2 () == m2.size2 ()
m1.size1 () == m2.size1 () and
+m1.size2 () == m2.size2 ()
Assigns every element of m1 to the corresponding element of m2.  
Computed assignment m2 += m1m1.size1 () == m2.size1 () and
- m1.size2 () == m2.size2 ()
m1.size1 () == m2.size1 () and
+m1.size2 () == m2.size2 ()
Adds every element of the evaluated matrix expression m1 to the corresponding element of m2.  
m2.plus_assign (m1)m1.size1 () == m2.size1 () and
- m1.size2 () == m2.size2 ()
m1.size1 () == m2.size1 () and
+m1.size2 () == m2.size2 ()
Adds every element of m1 to the corresponding element of m2.  
m2 -= m1m1.size1 () == m2.size1 () and
- m1.size2 () == m2.size2 ()
m1.size1 () == m2.size1 () and
+m1.size2 () == m2.size2 ()
Subtracts every element of the evaluated matrix expression m1 from the corresponding element of m2 .  
m2.minus_assign (m1)m1.size1 () == m2.size1 () and
- m1.size2 () == m2.size2 ()
m1.size1 () == m2.size1 () and
+m1.size2 () == m2.size2 ()
Subtracts every element of m1 from the corresponding element of m2.  
m *= t  
-

Complexity guarantees

-

The run-time complexity of begin1 (), begin2 () , end1 () and end2 () is specific for the evaluated matrix expression.

-

The run-time complexity of size1 () and size2 () is constant time.

-

The run-time complexity of swap () is specific for the evaluated matrix expression, typically constant time.

-

The run-time complexity of rbegin1 (), rbegin2 () , rend1 () and rend2 () is specific for the evaluated matrix expression.

-

The run-time complexity of the element access is specific for the evaluated matrix expression, typically amortized constant time for the dense and logarithmic for the sparse case.

-

The run-time complexity of the arithmetic operations is specific for the evaluated matrix expressions, typically quadratic in the size of the proxies.

-

Invariants

- - +
@@ -1117,7 +930,6 @@ size of the proxies.

m.end1 ()) and [m.begin2 (), m.end2 ()) are valid ranges. - m.end2 ()) will pass through every column of m . - -
Valid range
Completeness An algorithm that iterates through the range [m.begin1 @@ -1126,13 +938,11 @@ valid ranges.
Valid reverse range [m.rbegin1 (), m.rend1 ()) and [m.rbegin2 (), m.rend2 ()) are valid ranges.
Equivalence of ranges The distance from m.begin1 () to m.end1 @@ -1144,44 +954,28 @@ the distance from m.rbegin2 () to m.rend2
-

Models

-
  • matrix_range<M>
  • -
  • matrix_slice<M>
  • -
  • triangular_adaptor<M, F>
  • -
  • symmetric_adaptor<M, F>
  • -
  • banded_adaptor<M>
  • -
  • vector_matrix_binary<E1, E2, F>
  • -
  • matrix_unary1<E, F>
  • -
  • matrix_unary2<E, F>
  • -
  • matrix_binary<E1, E2, F>
  • -
  • matrix_binary_scalar1<E1, E2, F>
  • -
  • matrix_binary_scalar2<E1, E2, F>
  • -
  • matrix_matrix_binary<E1, E2, F>
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/functions.htm b/doc/functions.htm new file mode 100644 index 00000000..f93baf19 --- /dev/null +++ b/doc/functions.htm @@ -0,0 +1,217 @@ + + + + + + + + +uBLAS functions overview + + +

c++boost.gif +Overview of Matrix and Vector Operations

+ +
+
Contents:
+
Basic Linear Algebra
+
Advanced Functions
+
Submatrices, Subvectors
+
Speed Improvements
+
+ +

Definitions:

+ + + + + + + + + + + + + + +
A, B, C are matrices
u, v, ware vectors
i, j, kare integer values
t, t1, t2are scalar values
r, r1, r2are ranges, e.g. range(0, 3)
s, s1, s2are slices, e.g. slice(0, 1, 3)
+ +

Note: A range r = range(start, count) +contains all indices i with start <= i < +start+count. A slice is something more general. The slice +s = slice(start, stride, count) contains the indices +start, start+stride, ..., start+(count-1)*stride. The +stride can be any integer including 0 and -1!

+ +

Basic Linear Algebra

+ +

standard operations: addition, subtraction, multiplication by a +scalar

+ +
+
+C = A + B; C = A - B; C = -A;
+w = u + v; w = u - v; w = -u;
+C = t * A; C = A * t; C = A / t;
+w = t * u; w = u * t; w = u / t;
+
+
+ +

computed assignements

+ +
+
+C += A; C -= A; 
+w += u; w -= u; 
+C *= t; C /= t; 
+w *= t; w /= t;
+
+
+ +

inner, outer and other products

+ +
+
+t = inner_prod(u, v);
+C = outer_prod(u, v);
+w = prod(A, u); w = prod(u, A); w = prec_prod(A, u); w = prec_prod(u, A);
+C = prod(A, B); C = prec_prod(A, B);
+w = element_prod(u, v); w = element_div(u, v);
+C = element_prod(A, B); C = element_div(A, B);
+
+
+ +

transformations

+ +
+
+w = conj(u); w = real(u); w = imag(u);
+C = trans(A); C = conj(A); C = herm(A); C = real(A); C = imag(A);
+
+
+ +

Advanced functions

+ +

norms

+ +
+
+t = norm_inf(v); i = index_norm_inf(v);
+t = norm_1(v);   t = norm_2(v); 
+t = norm_inf(A); i = index_norm_inf(A);
+t = norm_1(A);   t = norm_frobenius(A); 
+
+
+ +

products

+ +
+
+axpy_prod(A, u, w, true);  // w = A * u
+axpy_prod(A, u, w, false); // w += A * u
+axpy_prod(u, A, w, true);  // w = trans(A) * u
+axpy_prod(u, A, w, false); // w += trans(A) * u
+axpy_prod(A, B, C, true);  // C = A * B
+axpy_prod(A, B, C, false); // C += A * B
+
+
+

Note: The last argument (bool init) of +axpy_prod is optional. Currently it defaults to +true, but this may change in the future. Set the +init to true is equivalent to call +w.clear() before axpy_prod. Up to now +there are some specialisation for compressed matrices that give a +large speed up compared to prod.

+
+
+w = block_prod<matrix_type, 64> (A, u); // w = A * u
+w = block_prod<matrix_type, 64> (u, A); // w = trans(A) * u
+C = block_prod<matrix_type, 64> (A, B); // w = A * B
+
+
+

Note: The blocksize can be any integer. However, the +total speed depends very strong on the combination of blocksize, +CPU and compiler. The function block_prod is designed +for large dense matrices.

+

rank-k updates

+
+
+opb_prod(A, B, C, true);  // C = A * B
+opb_prod(A, B, C, false); // C += A * B
+
+
+

Note: The last argument (bool init) of +opb_prod is optional. Currently it defaults to +true, but this may change in the future. This function +may give a speedup if A has less columns than rows, +because the product is computed as a sum of outer products.

+ +

Submatrices, Subvectors

+ +
+
+w = project(u, r); w = project(u, s);
+C = project(A, r1, r2); C = project(A, s1, s2);
+w = row(A, i); w = column(A, j);
+
+
+

There are to more ways to access some matrix elements as a +vector:

+
+
+matrix_vector_range<matrix_type> (A, r1, r2);
+matrix_vector_slice<matrix_type> (A, s1, s2);
+
+
+

Note: These matrix proxies take a sequence of elements +of a matrix and allow you to access these as a vector. In +particular matrix_vector_slice can do this in a very +general way. matrix_vector_range is less useful as the +elements must lie along a diagonal.

+

Example: To access the first two elements of a sub +column of a matrix we access the row with a slice with stride 1 and +the column with a slice with stride 0 thus:
+matrix_vector_slice<matrix_type> (A, slice(0,1,2), +slice(0,0,2));

+ +

Speed improvements

+ +

If you know for sure that the left hand expression and the right +hand expression have no common storage, then you can tell ublas +that there is no aliasing:

+
+
+noalias(C) = prod(A, B);
+
+
+ +

Most often the right hand side of an assignement is constant. +So you can give your compiler a hint to use const member function +even if A is mutable. (MATRIX is the type of A.) +This cast drastically reduces the access time of sparse matrix elements, since no +temporary sparse element proxies are created. +

+
+
+C = static_cast<const MATRIX&> A;
+
+
+ +
+

Copyright (©) 2000-2004 Joerg Walter, Mathias Koch, Gunter +Winkler, Michael Stevens
+Permission to copy, use, modify, sell and distribute this document +is granted provided this copyright notice appears in all copies. +This document is provided ``as is'' without express or implied +warranty, and with no claim as to its suitability for any +purpose.

+

Last revised: 2004-07-05

+ + diff --git a/doc/hermitian.htm b/doc/hermitian.htm index fa53ccfc..00b4080f 100644 --- a/doc/hermitian.htm +++ b/doc/hermitian.htm @@ -1,20 +1,20 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Hermitian Matrix - -

c++boost.gif + +

c++boost.gif Hermitian Matrix

- -

Hermitian Matrix

- +

Hermitian +Matrix

Description

-

The templated class hermitian_matrix<T, F1, F2, A> is the base container adaptor for hermitian matrices. For a (n x n )-dimensional hermitian matrix and 0 @@ -22,690 +22,574 @@ For a (n x n )-dimensional hermitian matrix and 0 hi, j = hj, i-. The storage of hermitian matrices is packed.

-

Example

-
-#include <boost/numeric/ublas/hermitian.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- hermitian_matrix<std::complex<double>, lower> ml (3, 3);
- for (unsigned i = 0; i < ml.size1 (); ++ i) {
- for (unsigned j = 0; j < i; ++ j)
- ml (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- ml (i, i) = std::complex<double> (4 * i, 0);
- }
- std::cout << ml << std::endl;
- hermitian_matrix<std::complex<double>, upper> mu (3, 3);
- for (unsigned i = 0; i < mu.size1 (); ++ i) {
- mu (i, i) = std::complex<double> (4 * i, 0);
- for (unsigned j = i + 1; j < mu.size2 (); ++ j)
- mu (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- }
- std::cout << mu << std::endl;
-}
+#include <boost/numeric/ublas/hermitian.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ hermitian_matrix<std::complex<double>, lower> ml (3, 3);
+ for (unsigned i = 0; i < ml.size1 (); ++ i) {
+ for (unsigned j = 0; j < i; ++ j)
+ ml (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
+ ml (i, i) = std::complex<double> (4 * i, 0);
+ }
+ std::cout << ml << std::endl;
+ hermitian_matrix<std::complex<double>, upper> mu (3, 3);
+ for (unsigned i = 0; i < mu.size1 (); ++ i) {
+ mu (i, i) = std::complex<double> (4 * i, 0);
+ for (unsigned j = i + 1; j < mu.size2 (); ++ j)
+ mu (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
+ }
+ std::cout << mu << std::endl;
+}
-

Definition

-

Defined in the header hermitian.hpp.

-

Template parameters

- - +
- - + - + - +"#hermitian_matrix_1">[1] - +"#hermitian_matrix_2">[2] - +"#hermitian_matrix_3">[3]
Parameter Description Default
T T The type of object stored in the matrix. 
F1 Functor describing the type of the hermitian matrix. [1] lower
F2 Functor describing the storage organization. [2] row_major
A The type of the adapted array. [3] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<hermitian_matrix<T, F1, F2, A> >

-

Members

- - +
- - + - - - - - - + +size rows of size elements. The existing +elements of the hermitian_matrix are preseved when +specified. - - - - - - - - + - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
hermitian_matrix () hermitian_matrix () Allocates an uninitialized hermitian_matrix that holds zero rows of zero elements.
hermitian_matrix (size_type size) Allocates an uninitialized hermitian_matrix that holds size rows of size elements.
hermitian_matrix (const hermitian_matrix &m) The copy constructor.
template<class AE>
- hermitian_matrix (const matrix_expression<AE> +
template<class AE>
+hermitian_matrix (const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Reallocates a hermitian_matrix to hold -size rows of size elements. The content -of the hermitian_matrix is not preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
hermitian_matrix &operator = (const hermitian_matrix &m) The assignment operator.
hermitian_matrix &assign_temporary (hermitian_matrix &m) Assigns a temporary. May change the hermitian matrix m .
template<class AE>
- hermitian_matrix &operator = (const -matrix_expression<AE> &ae)
template<class AE>
+hermitian_matrix &operator = (const matrix_expression<AE> +&ae)
The extended assignment operator.
template<class AE>
- hermitian_matrix &assign (const matrix_expression<AE> +
template<class AE>
+hermitian_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the hermitian matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- hermitian_matrix &operator += (const +
template<class AE>
+hermitian_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the hermitian matrix.
template<class AE>
- hermitian_matrix &plus_assign (const +
template<class AE>
+hermitian_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the hermitian matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- hermitian_matrix &operator -= (const +
template<class AE>
+hermitian_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the hermitian matrix.
template<class AE>
- hermitian_matrix &minus_assign (const +
template<class AE>
+hermitian_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the hermitian matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- hermitian_matrix &operator *= (const AT &at)
template<class AT>
+hermitian_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the hermitian matrix with a scalar.
template<class AT>
- hermitian_matrix &operator /= (const AT &at)
template<class AT>
+hermitian_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the hermitian matrix through a scalar.
void swap (hermitian_matrix &m) Swaps the contents of the hermitian matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th elemenst of the i-th row.
void clear () Clears the matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the hermitian_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the hermitian_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the hermitian_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the hermitian_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the hermitian_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the hermitian_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the hermitian_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the hermitian_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed hermitian_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed hermitian_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed hermitian_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed hermitian_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed hermitian_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed hermitian_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed hermitian_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed hermitian_matrix.
-

Notes

- -

[1] Supported parameters for -the type of the hermitian matrix are lower and -upper.

- -

[2] Supported parameters for -the storage organization are row_major and -column_major.

- -

[3] Supported parameters for -the adapted array are unbounded_array<T> , +

[1] +Supported parameters for the type of the hermitian matrix are +lower and upper.

+

[2] +Supported parameters for the storage organization are +row_major and column_major.

+

[3] +Supported parameters for the adapted array are +unbounded_array<T> , bounded_array<T> and std::vector<T> .

- -

Hermitian Adaptor

- +

+Hermitian Adaptor

Description

-

The templated class hermitian_adaptor<M, F> is a hermitian matrix adaptor for other matrices.

-

Example

-
-#include <boost/numeric/ublas/hermitian.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<std::complex<double> > m (3, 3);
- hermitian_adaptor<matrix<std::complex<double> >, lower> hal (m);
- for (unsigned i = 0; i < hal.size1 (); ++ i) {
- for (unsigned j = 0; j < i; ++ j)
- hal (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- hal (i, i) = std::complex<double> (4 * i, 0);
- }
- std::cout << hal << std::endl;
- hermitian_adaptor<matrix<std::complex<double> >, upper> hau (m);
- for (unsigned i = 0; i < hau.size1 (); ++ i) {
- hau (i, i) = std::complex<double> (4 * i, 0);
- for (unsigned j = i + 1; j < hau.size2 (); ++ j)
- hau (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- }
- std::cout << hau << std::endl;
+#include <boost/numeric/ublas/hermitian.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<std::complex<double> > m (3, 3);
+ hermitian_adaptor<matrix<std::complex<double> >, lower> hal (m);
+ for (unsigned i = 0; i < hal.size1 (); ++ i) {
+ for (unsigned j = 0; j < i; ++ j)
+ hal (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
+ hal (i, i) = std::complex<double> (4 * i, 0);
+ }
+ std::cout << hal << std::endl;
+ hermitian_adaptor<matrix<std::complex<double> >, upper> hau (m);
+ for (unsigned i = 0; i < hau.size1 (); ++ i) {
+ hau (i, i) = std::complex<double> (4 * i, 0);
+ for (unsigned j = i + 1; j < hau.size2 (); ++ j)
+ hau (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
+ }
+ std::cout << hau << std::endl;
}
-

Definition

-

Defined in the header hermitian.hpp.

-

Template parameters

- - +
- - + - +"#hermitian_adaptor_1">[1]
Parameter Description Default
M The type of the adapted matrix. 
F Functor describing the type of the hermitian adaptor. [1] lower
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<hermitian_adaptor<M, F> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
hermitian_adaptor () hermitian_adaptor () Constructs a hermitian_adaptor that holds zero rows of zero elements.
hermitian_adaptor (matrix_type &data) Constructs a hermitian_adaptor of a matrix.
hermitian_adaptor (const hermitian_adaptor &m) The copy constructor.
template<class AE>
- hermitian_adaptor (const matrix_expression<AE> +
template<class AE>
+hermitian_adaptor (const matrix_expression<AE> &ae)
The extended copy constructor.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
hermitian_adaptor &operator = (const hermitian_adaptor &m) The assignment operator.
hermitian_adaptor &assign_temporary (hermitian_adaptor &m) Assigns a temporary. May change the hermitian adaptor m.
template<class AE>
- hermitian_adaptor &operator = (const +
template<class AE>
+hermitian_adaptor &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- hermitian_adaptor &assign (const matrix_expression<AE> +
template<class AE>
+hermitian_adaptor &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the hermitian adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- hermitian_adaptor &operator += (const +
template<class AE>
+hermitian_adaptor &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the hermitian adaptor.
template<class AE>
- hermitian_adaptor &plus_assign (const +
template<class AE>
+hermitian_adaptor &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the hermitian adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- hermitian_adaptor &operator -= (const +
template<class AE>
+hermitian_adaptor &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the hermitian adaptor.
template<class AE>
- hermitian_adaptor &minus_assign (const +
template<class AE>
+hermitian_adaptor &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the hermitian adaptor. Left and right hand side of the assignment should be independent.
template<class AT>
- hermitian_adaptor &operator *= (const AT &at)
template<class AT>
+hermitian_adaptor &operator *= (const AT &at)
A computed assignment operator. Multiplies the hermitian adaptor with a scalar.
template<class AT>
- hermitian_adaptor &operator /= (const AT &at)
template<class AT>
+hermitian_adaptor &operator /= (const AT &at)
A computed assignment operator. Divides the hermitian adaptor through a scalar.
void swap (hermitian_adaptor &m) Swaps the contents of the hermitian adaptors.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the hermitian_adaptor.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the hermitian_adaptor.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the hermitian_adaptor.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the hermitian_adaptor.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the hermitian_adaptor.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the hermitian_adaptor.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the hermitian_adaptor.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the hermitian_adaptor.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed hermitian_adaptor.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed hermitian_adaptor.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed hermitian_adaptor.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed hermitian_adaptor.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed hermitian_adaptor.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed hermitian_adaptor.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed hermitian_adaptor.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed hermitian_adaptor.
-

Notes

- -

[1] Supported parameters for -the type of the hermitian adaptor are lower and -upper.

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +

[1] +Supported parameters for the type of the hermitian adaptor are +lower and upper.

+
+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/index.htm b/doc/index.htm index 82e55320..b9963e0b 100644 --- a/doc/index.htm +++ b/doc/index.htm @@ -1,24 +1,23 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Boost Basic Linear Algebra - -

c++boost.gif + +

c++boost.gif Basic Linear Algebra

-

uBLAS is a C++ template class library that provides BLAS level 1, 2, 3 functionality for dense, packed and sparse matrices. The design and implementation unify mathematical notation via operator overloading and efficient code generation via expression templates.

-

Functionality

-

uBLAS provides templated C++ classes for dense, unit and sparse vectors, dense, identity, triangular, banded, symmetric, hermitian and sparse matrices. Views into vectors and matrices can be @@ -31,362 +30,263 @@ and triangular solver. The glue between containers, views and expression templated operations is a mostly STL conforming iterator interface.

-

Dense, packed and sparse matrix classes are being tested with the CLAPACK test suite.

-

Known limitations:

-
  • The implementation assumes a linear memory address model.
  • -
  • Tuning was focussed on dense matrices.
-

Documentation

- -

Supported Platforms

- -

As main development platform for uBLAS we used MSVC 6.0 with -Dinkumware STL. Other compilers known to accept the library are

- +

The original development platform for uBLAS we used MSVC 6.0 +with Dinkumware STL. Other compilers known to accept the library +are

  • MSVC 6.0 with STLPort-4.5.3, 7.0, 7.1
  • -
  • BCC 5.5
  • - -
  • GCC 2.95.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x
  • - -
  • ICC 5.0, 6.0, 7.0, 7.1
  • - +
  • GCC 2.95.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x
  • +
  • ICC 7.0, 7.1 8.0
  • Comeau 4.2.x
  • -
  • MWCW
-

For possible problems please consider to consult the Boost regression tests.

- -

Download

- -

You can download the latest release of the source code from here . -Prerequisite is the latest stable release of the Boost libraries Configuration, -MetaProgramming, TypeTraits, Timer and optionally SmartPointer.

- -

CVS Access

- -

You can also check out the latest version via anonymous CVS. -Here's how:

- -
- cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost login
- (password is empty)
- cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost checkout boost/boost/numeric/ublas
- cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost checkout boost/libs/numeric/ublas -
- -

If you have gzip installed on your system, you can speed up the -transfer using

- -
- cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost -z9 checkout boost/boost/numeric/ublas
- cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost -z9 checkout boost/libs/numeric/ublas -
- -

You can also Further Information +

Project Location and Download

+

The latest stable release of uBLAS is part of the Boost libraries.

+

Documentation and Discussion

+

Visit the +Effective uBLAS wiki for up to date information and +contributions.

+

There is also an active uBLAS development mailing list where +user and development questions are answered.

+

uBLAS and Boost Project

+

uBLAS development takes place via a two tier structure. Active +development takes place at the Sourceforge uBLAS project. This +where the latest uBLAS code is kept and bugs are tracked.

+

For wider testing purposes Boost project is occasionally updated +from the latest uBLAS project code. You can view the -CVS archive. You may find the library -here . Documentation and test programs reside . Documentation and test programs reside -here .

- -

Mailing lists

- -

uBLAS has a dedicated mailing list .

- +here.

Authors and Credits

-

uBLAS initially was written by Joerg Walter and Mathias Koch. We -would like to thank all, which supported and contributed to the development -of this library: David Abrahams, Ed Brey, Fernando Cacciola, Juan Jose -Gomez Cadenas, Beman Dawes, Matt Davies, Bob Fletcher, Kresimir Fresl, -Joachim Kessel, Patrick Kowalzick, Toon Knapen, Hendrik Kueck, John Maddock, -Jens Maurer, Alexei Novakov, Gary Powell, Joachim Pyras, -Peter Schmitteckert, Jeremy Siek, Markus Steffl, Michael Stevens, -Benedikt Weber, Martin Weiser, Gunter Winkler, Marc Zimmermann -and the members of Boost

- +would like to thank all, which supported and contributed to the +development of this library: David Abrahams, Ed Brey, Fernando +Cacciola, Juan Jose Gomez Cadenas, Beman Dawes, Matt Davies, Bob +Fletcher, Kresimir Fresl, Joachim Kessel, Patrick Kowalzick, Toon +Knapen, Hendrik Kueck, John Maddock, Jens Maurer, Alexei Novakov, +Gary Powell, Joachim Pyras, Peter Schmitteckert, Jeremy Siek, +Markus Steffl, Michael Stevens, Benedikt Weber, Martin Weiser, +Gunter Winkler, Marc Zimmermann and the members of Boost

Frequently Asked Questions

-

Q: I'm running the uBLAS dense vector and matrix benchmarks. Why do I see a significant performance difference between the native C -and library implementations?
- A: uBLAS distinguishes debug mode (size and type conformance -checks enabled, expression templates disabled) and release mode -(size and type conformance checks disabled, expression templates -enabled). Please check, if the preprocessor symbol -NDEBUG of cassert is defined. -NDEBUG enables release mode, which in turn uses -expression templates.

- +and library implementations?
+A: uBLAS distinguishes debug mode (size and type conformance checks +enabled, expression templates disabled) and release mode (size and +type conformance checks disabled, expression templates enabled). +Please check, if the preprocessor symbol NDEBUG of +cassert is defined. NDEBUG enables +release mode, which in turn uses expression templates.

Q: I've written some uBLAS tests, which try to incorrectly assign different matrix types or overrun vector and matrix dimensions. Why don't I get a compile time or runtime -diagnostic?
- A: uBLAS distinguishes debug mode (size and type conformance -checks enabled, expression templates disabled) and release mode -(size and type conformance checks disabled, expression templates -enabled). Please check, if the preprocessor symbol -NDEBUG of cassert is defined. -NDEBUG disables debug mode, which is needed to get -size and type conformance checks.

- +diagnostic?
+A: uBLAS distinguishes debug mode (size and type conformance checks +enabled, expression templates disabled) and release mode (size and +type conformance checks disabled, expression templates enabled). +Please check, if the preprocessor symbol NDEBUG of +cassert is defined. NDEBUG disables debug +mode, which is needed to get size and type conformance checks.

Q: I've written some uBLAS benchmarks to measure the performance of matrix chain multiplications like prod (A, prod (B, C)) and see a significant performance penalty due to the use of expression templates. How can I disable expression -templates?
- A: You do not need to disable expression templates. Please try +templates?
+A: You do not need to disable expression templates. Please try reintroducing temporaries using either prod (A, matrix_type (prod (B, C))) or prod (A, prod<matrix_type > (B, C)).

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

- -

Last revised: 1/15/2003

+

Last revised: 2004-07-05

- diff --git a/doc/iterator.htm b/doc/iterator.htm index 1001ae94..0d8fb7c9 100644 --- a/doc/iterator.htm +++ b/doc/iterator.htm @@ -1,42 +1,36 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Iterator Concepts - -

c++boost.gif + +

c++boost.gif Iterator Concepts

-

An Iterator is a restricted pointer-like object pointing into a vector or matrix container.

- -

Indexed -Bidirectional Iterator

- +

Indexed Bidirectional +Iterator

Description

-

An Indexed Bidirectional Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries index information.

-

Refinement of

-

Assignable, Equality Comparable, Default Constructible.

-

Associated types

- - +
-
Value type The type of the value obtained by dereferencing a Indexed Bidirectional Iterator
Container type The type of the container a Indexed Bidirectional Iterator @@ -44,74 +38,59 @@ points into.
-

Notation

- - +
- + - - - + + - - - - + + - - - + + -
I I A type that is a model of Indexed Bidirectional Iterator
T The value type of I TThe value type of I
C The container type of I
it, itt, it1, it2 Objects of type I it, itt, it1, it2Objects of type I
t Object of type T tObject of type T
c Object of type C
-

Definitions

-

A Indexed Bidirectional Iterator may be mutable, meaning that the values referred to by objects of that type may be modified, or constant , meaning that they may not. If an iterator type is mutable, this implies that its value type is a model of Assignable; the converse, though, is not necessarily true.

-

A Indexed Bidirectional Iterator may have a singular value, meaning that the results of most operations, including comparison for equality, are undefined. The only operation that is guaranteed to be supported is assigning a nonsingular iterator to a singular iterator.

-

A Indexed Bidirectional Iterator may have a dereferenceable value, meaning that dereferencing it yields a well-defined value. Dereferenceable iterators are always nonsingular, but the converse is not true.

-

An Indexed Bidirectional Iterator is past-the-end if it points beyond the last element of a container. Past-the-end values are nonsingular and nondereferenceable.

-

Valid expressions

-

In addition to the expressions defined for Assignable, Equality Comparable and Default Constructible, the following expressions must be valid.

- - +
@@ -119,71 +98,61 @@ must be valid.

- - + - - + - - + - - + - - + - + - - + - - - + - + - - @@ -192,14 +161,11 @@ defined.
Name Type requirements Return type
Default constructorI it I it    
Dereference*it *it   Convertible to T.
Dereference assignment*it = t *it = t I is mutable.  
Member accessit->m it->m T is a type for which t.m is defined.  
Preincrement++ it ++ it  I & I &
Postincrementit ++ it ++   I
Predecrement -- it   I &
Postdecrementit -- it --  I I
Function call it ()   Convertible to C &.
Index it.index ()
-

Expression Semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in, Assignable, Equality Comparable and Default Constructible.

- - +
@@ -208,23 +174,20 @@ Default Constructible.

- - + - - + - @@ -232,7 +195,6 @@ Default Constructible.

- @@ -240,58 +202,57 @@ Default Constructible.

- - + - + - - + - + - - - + - + - - + - + - @@ -300,48 +261,41 @@ element.it () = c. - - - - + +
Name Semantics Postcondition
Default constructorI it I it     it is singular.
Dereference*it *it it is dereferenceable.    
Dereference assignment *it = t   *it is a copy of t.
Member access it->m Equivalent to (*it).m  
Preincrement++ it ++ it it is dereferenceable. it is modified to point to the next element.it is dereferenceable or past-the-end.
- &it == &++ it
.
- If it1 == it2,
- then ++ it1 == ++ it2.
it is dereferenceable or past-the-end. +
+&it == &++ it
.
+If it1 == it2,
+then ++ it1 == ++ it2.
Postincrementit ++ it ++ Same as for ++ it.Equivalent to
- {
-  I itt = it;
-  ++ it;
-  return itt;
- }
Equivalent to
+{
+ I itt = it;
+ ++ it;
+ return itt;
+}
it is dereferenceable or past-the-end.
Predecrement-- it it is dereferenceable or past-the-end.
- There exists a dereferenceable iterator itt such that +
-- itit is dereferenceable or past-the-end.
+There exists a dereferenceable iterator itt such that it == ++ itt.
it is modified to point to the previous element.it is dereferenceable.
- &it = &-- it.
- If it1 == it2,
- then -- it1 == -- it2.
it is dereferenceable.
+&it = &-- it.
+If it1 == it2,
+then -- it1 == -- it2.
+If it2 is dereferenceable and it1 == +++it2,
+then --it1 == it2.
Postdecrementit -- it -- Same as for -- it.Equivalent to
- {
-  I itt = it;
-  -- it;
-  return itt;
- }
Equivalent to
+{
+ I itt = it;
+ -- it;
+ return itt;
+}
it is dereferenceable. 
Function call it ()  
Index it.index ()it is dereferenceable or past-the-end.it.index () >= 0
- and
- it.index () <= it ().size ()
If it1 == it2,
- then it1.index () == it2.index ().
- If it1 == it2,
- then it1.index () < (++ it2).index -().
- If it1 == it2,
- then it1.index () > (-- it2).index +
it is dereferenceable.it.index () >= 0
+and
+it.index () < it ().size ()
If it1 == it2,
+then it1.index () == it2.index ().
+If it1 == it2,
+then it1.index () < (++ it2).index +().
+If it1 == it2,
+then it1.index () > (-- it2).index ().
-

Complexity guarantees

-

The complexity of operations on indexed bidirectional iterators is guaranteed to be amortized constant time.

-

Invariants

- - +
- - @@ -350,38 +304,29 @@ operator
Identity it1 == it2 if and only if &*it1 == &*it2.
Symmetry of increment and decrement If it is dereferenceable, then ++ it; --it; is a null operation. Similarly, -- it; ++ it; is a null operation.
Relation between iterator index and container element operator
-

Models

-
  • sparse_vector<T>::iterator
- -

Indexed Random -Access Iterator

- +

Indexed Random Access +Iterator

Description

-

An Indexed Random Access Iterator is an iterator of a container that can be dereferenced, moved forward, moved backward and carries index information.

-

Refinement of

-

LessThanComparable, Indexed Bidirectional Iterator .

-

Associated types

- - +
-
Value type The type of the value obtained by dereferencing a Indexed Random Access Iterator
Container type The type of the container a Indexed Random Access Iterator @@ -389,58 +334,46 @@ points into.
-

Notation

- - +
- + - - - + + - - - - + + - - - + + -
I I A type that is a model of Indexed Random Access Iterator
T The value type of I TThe value type of I
C The container type of I
it, itt, it1, it2 Objects of type I it, itt, it1, it2Objects of type I
t Object of type T tObject of type T
n Object of type C::difference_type
-

Definitions

-

An Indexed Random Access Iterator it1 is reachable from an Indexed Random Access Iterator it2 if, after applying operator ++ to it2 a finite number of times, it1 == it2.

-

Valid expressions

-

In addition to the expressions defined for Indexed Bidirectional Iterator , the following expressions must be valid.

- - +
@@ -448,49 +381,42 @@ Iterator , the following expressions must be valid.

- - + - - + - - + - + - - + - - + - - @@ -499,15 +425,12 @@ Iterator , the following expressions must be valid.

Name Type requirements Return type
Forward motion it += n  I & I &
Iterator additionit + n it + n   I
Backward motioni -= n i -= n  I & I &
Iterator subtractionit - n it - n   I 
Difference it1 - it2  C::difference_type C::difference_type
Element operator it [n]   Convertible to T.
Element assignment it [n] = t
-

Expression Semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in, Indexed Bidirectional Iterator .

- - +
@@ -516,10 +439,9 @@ Iterator .

- - + - - + - @@ -553,55 +473,47 @@ negative. - - + - - + +n - - + - - +
Name Semantics Postcondition
Forward motionit += n it += n Including it itself, there must be n dereferenceable or past-the-end iterators following or preceding it, depending on whether n is positive or @@ -530,19 +452,17 @@ equivalent to executing -- it n times. If n == 0, this is a null operation. it is dereferenceable or past-the-end.
Iterator addition it + n Same as for i += n.Equivalent to
- {
-  I itt = it;
-  return itt += n;
- }
Equivalent to
+{
+ I itt = it;
+ return itt += n;
+}
Result is dereferenceable or past-the-end.
Backward motion it -= n Equivalent to it += (-n). it is dereferenceable or past-the-end.
Iterator subtraction it - n Same as for i -= n.Equivalent to
- {
-  I itt = it;
-  return itt -= n;
- }
Equivalent to
+{
+ I itt = it;
+ return itt -= n;
+}
Result is dereferenceable or past-the-end.
Differenceit1 - it2 it1 - it2 Either it1 is reachable from it2 or it2 is reachable from it1, or both. Returns a number n such that it1 == it2 + -n  
Element operatorit [n] it [n] it + n exists and is dereferenceable. Equivalent to *(it + n)  
Element assignmenti[n] = t i[n] = t Same as for it [n]. Equivalent to *(it + n) = t  
-

Complexity guarantees

-

The complexity of operations on indexed random access iterators is guaranteed to be amortized constant time.

-

Invariants

- - +
@@ -611,13 +523,11 @@ Similarly, if it - n is well-defined, then it -= n; it += n; and (it - n) + n are null operations. - -
Symmetry of addition and subtraction
Relation between distance and addition If it1 - it2 is well-defined, then it1 == it2 + (it1 - it2).
Reachability and distance If it1 is reachable from it2, then @@ -625,36 +535,27 @@ it2 + (it1 - it2).
-

Models

-
  • vector<T>::iterator
- -

Indexed -Bidirectional Column/Row Iterator

- +

Indexed Bidirectional +Column/Row Iterator

Description

-

An Indexed Bidirectional Column/Row Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries index information.

-

Refinement of

-

Assignable, Equality Comparable, Default Constructible.

-

Associated types

- - +
-
Value type The type of the value obtained by dereferencing a Indexed Bidirectional Column/Row Iterator
Container type The type of the container a Indexed Bidirectional Column/Row @@ -662,65 +563,52 @@ Iterator points into.
-

Notation

- - +
- + - - - - + + - - + - - - + + - - + - - - + + -
I1 I1 A type that is a model of Indexed Bidirectional Column/Row Iterator
I2 A type that is a model of Indexed Bidirectional Row/Column Iterator
T The value type of I1 and I2 TThe value type of I1 and I2
CThe container type of I1 and I2 The container type of I1 and I2
it1, it1t, it11, it12 -Objects of type I1 it1, it1t, it11, +it12Objects of type I1
it2, it2tObjects of type I2 Objects of type I2
t Object of type T tObject of type T
c Object of type C
-

Definitions

-

Valid expressions

-

In addition to the expressions defined for Assignable, Equality Comparable and Default Constructible, the following expressions must be valid.

- - +
@@ -728,122 +616,104 @@ must be valid.

- - + - - + - - + - - + - - + - + - - + - - - + - + - - - - - + - - + - - + - - +
Name Type requirements Return type
Default constructorI1 it1 I1 it1    
Dereference*it1 *it1   Convertible to T.
Dereference assignment*it1 = t *it1 = t I1 is mutable.  
Member accessit1->m it1->m T is a type for which t.m is defined.  
Preincrement++ it1 ++ it1  I1 & I1 &
Postincrementit1 ++ it1 ++   I1
Predecrement -- it1   I1 &
Postdecrementit1 -- it1 --  I1 I1
Function call it1 ()   Convertible to C &.
Row Index it1.index1 ()   C::size_type
Column Index it1.index2 ()   C::size_type
Row/Column Begin it1.begin ()  I2 I2
Row/Column End it1.end ()  I2 I2
Reverse Row/Column Begin it1.rbegin ()  reverse_iterator<I2> reverse_iterator<I2>
Reverse Row/Column End it1.rend ()  reverse_iterator<I2> reverse_iterator<I2>
-

Expression Semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in, Assignable, Equality Comparable and Default Constructible.

- - +
@@ -852,23 +722,20 @@ Default Constructible.

- - + - - + - @@ -876,7 +743,6 @@ Default Constructible.

- @@ -884,70 +750,65 @@ Default Constructible.

- - + - +the column/row, i.e. for column iterators holds
+it1.index1 () < (++ it1).index1 () and
+it1.index2 () == (++ it1).index2 (),
+for row iterators holds
+it1.index1 () == (++ it1).index1 () and
+it1.index2 () < (++ it1).index2 ().
+ - - + - + - - - + + - +element of the column/row, i.e. for column iterators holds
+it1.index1 () > (-- it1).index1 () and
+it1.index2 () == (-- it1).index2 (),
+for row iterators holds
+it1.index1 () == (-- it1).index1 () and
+it1.index2 () > (-- it1).index2 (). + - - + - + - @@ -956,81 +817,76 @@ element of the column/row, i.e. for column iterators holds
it1 () = c. - - - - + + - - - - + + - - - @@ -1039,7 +895,6 @@ Column Iterator
()). - @@ -1050,9 +905,7 @@ Column Iterator
Name Semantics Postcondition
Default constructorI1 it1 I1 it1     it1 is singular.
Dereference*it1 *it1 it1 is dereferenceable.    
Dereference assignment *it1 = t   *it1 is a copy of t.
Member access it1->m Equivalent to (*it1).m  
Preincrement++ it1 ++ it1 it1 is dereferenceable. it1 is modified to point to the next element of -the column/row, i.e. for column iterators holds
- it1.index1 () < (++ it1).index1 () and
- it1.index2 () == (++ it1).index2 (),
-for row iterators holds
- it1.index1 () == (++ it1).index1 () and
- it1.index2 () < (++ it1).index2 ().
-
it1 is dereferenceable or past-the-end.
- &it1 == &++ it1
.
- If it11 == it12,
- then ++ it11 == ++ it12.
it1 is dereferenceable or past-the-end. +
+&it1 == &++ it1
.
+If it11 == it12,
+then ++ it11 == ++ it12.
Postincrementit1 ++ it1 ++ Same as for ++ it1.Equivalent to
- {
-  I1 it1t = it1;
-  ++ it1;
-  return it1t;
- }
Equivalent to
+{
+ I1 it1t = it1;
+ ++ it1;
+ return it1t;
+}
it1 is dereferenceable or past-the-end.
Predecrement-- it1 it1 is dereferenceable or past-the-end.
- There exists a dereferenceable iterator it1t such -that it1 == ++ it1t.
-- it1it1 is dereferenceable or past-the-end.
+There exists a dereferenceable iterator it1t such that +it1 == ++ it1t.
it1 is modified to point to the previous  -element of the column/row, i.e. for column iterators holds
- it1.index1 () > (-- it1).index1 () and
- it1.index2 () == (-- it1).index2 (),
- for row iterators holds
- it1.index1 () == (-- it1).index1 () and
- it1.index2 () > (-- it1).index2 ().
it1 is dereferenceable.
- &it1 = &-- it1.
- If it11 == it12,
- then -- it11 == -- it12.
it1 is dereferenceable.
+&it1 = &-- it1.
+If it11 == it12,
+then -- it11 == -- it12.
Postdecrementit1 -- it1 -- Same as for -- it1.Equivalent to
- {
-  I1 it1t = it1;
-  -- it1;
-  return it1t;
- }
Equivalent to
+{
+ I1 it1t = it1;
+ -- it1;
+ return it1t;
+}
it1 is dereferenceable. 
Function call it1 ()  
Row Index it1.index1 ()it1 is dereferenceable or past-the-end.it1.index1 () >= 0 and
- it1.index1 () <= it () .size1 ()
If it11 == it12,
- then it11.index1 () == it12.index1 () -.
- If it11, it12 are Indexed Bidirectional -Row Iterators with it11 == it12,
- then it11.index1 () < (++ it12).index1 -().
- If it11, it12 are Indexed Bidirectional -Row Iterators with it11 == it12,
- then it11.index1 () > (-- it12).index1 +
it1 is dereferenceable.it1.index1 () >= 0 and
+it1.index1 () < it () .size1 ()
If it11 == it12,
+then it11.index1 () == it12.index1 () +.
+If it11, it12 are Indexed Bidirectional +Row Iterators with it11 == it12,
+then it11.index1 () < (++ it12).index1 +().
+If it11, it12 are Indexed Bidirectional +Row Iterators with it11 == it12,
+then it11.index1 () > (-- it12).index1 ().
Column Index it1.index2 ()it1 is dereferenceable or past-the-end.it1.index2 () >= 0 and
- it1.index2 () <= it () .size2 ()
If it11 == it12,
- then it11.index2 () == it12.index2 () -.
- If it11, it12 are Indexed Bidirectional -Column Iterators with it11 == it12,
- then it11.index2 () < (++ it12).index2 -().
- If it11, it12 are Indexed Bidirectional -Column Iterators with it11 == it12,
- then it11.index2 () > (-- it12).index2 +
it1 is dereferenceable.it1.index2 () >= 0 and
+it1.index2 () < it () .size2 ()
If it11 == it12,
+then it11.index2 () == it12.index2 () +.
+If it11, it12 are Indexed Bidirectional +Column Iterators with it11 == it12,
+then it11.index2 () < (++ it12).index2 +().
+If it11, it12 are Indexed Bidirectional +Column Iterators with it11 == it12,
+then it11.index2 () > (-- it12).index2 ().
Row/Column Begin it1.begin () it1 is dereferenceable. If it1 is a Indexed Bidirectional Column -Iterator,
- then it2 = it1.begin () is a Indexed Bidirectional -Row Iterator
- with it2.index1 () == it1.index1 (). - -

If it1 is a Indexed Bidirectional Row Iterator,
- then it2 = it1.begin () is a Indexed Bidirectional -Column Iterator
- with it2.index2 () == it1.index2 ().

+Iterator,
+then it2 = it1.begin () is a Indexed Bidirectional Row +Iterator
+with it2.index1 () == it1.index1 (). +

If it1 is a Indexed Bidirectional Row +Iterator,
+then it2 = it1.begin () is a Indexed Bidirectional +Column Iterator
+with it2.index2 () == it1.index2 ().

 
Row/Column End it1.end () it1 is dereferenceable. If it1 is a Indexed Bidirectional Column -Iterator,
- then it2 = it1.end () is a Indexed Bidirectional Row -Iterator
- with it2.index1 () == it1.index1 (). - -

If it1 is a Indexed Bidirectional Row Iterator,
- then it2 = it1.end () is a Indexed Bidirectional -Column Iterator
- with it2.index2 () == it1.index2 ().

+Iterator,
+then it2 = it1.end () is a Indexed Bidirectional Row +Iterator
+with it2.index1 () == it1.index1 (). +

If it1 is a Indexed Bidirectional Row +Iterator,
+then it2 = it1.end () is a Indexed Bidirectional +Column Iterator
+with it2.index2 () == it1.index2 ().

 
Reverse Row/Column Begin it1.rbegin ()  
Reverse Row/Column End it1.rend ()
-

Complexity guarantees

-

The complexity of operations on indexed bidirectional column/row iterators is guaranteed to be logarithmic depending on the size of the container. The complexity of one iterator (depending on the @@ -1060,31 +913,26 @@ storage layout) can be lifted to be amortized constant time. The complexity of the other iterator (depending on the storage layout and the container) can be lifted to be amortized constant time for the first row/first column respectively.

-

Invariants

- - +
- - - @@ -1092,8 +940,7 @@ index and it2 = it1.begin () then it2.index2 () < it2t.index2 () for all it2t with it2t () == it2 () and it2t ().index1 () == it2 ().index1 -(). - +().

If it1 is a Indexed Bidirectional Row Iterator and it2 = it1.begin () then it2.index1 () < it2t.index1 () for all it2t with it2t () @@ -1101,7 +948,6 @@ it2t.index1 () for all it2t with it2t () ().

- @@ -1109,8 +955,7 @@ index and it2 = it1.end () then it2.index2 () > it2t.index2 () for all it2t with it2t () == it2 () and it2t ().index1 () == it2 ().index1 -(). - +().

If it1 is a Indexed Bidirectional Row Iterator and it2 = it1.end () then it2.index1 () > it2t.index1 () for all it2t with it2t () @@ -1120,39 +965,29 @@ it2t.index1 () for all it2t with it2t ()

Identity it11 == it12 if and only if &*it11 == &*it12.
Symmetry of increment and decrement If it1 is dereferenceable, then ++ it1; --it1; is a null operation. Similarly, -- it1; ++ it1; is a null operation.
Relation between iterator index and container element operator If it1 is dereferenceable, *it1 == it1 () (it1.index1 (), it2.index2 ())
Relation between iterator column/row begin and iterator index
Relation between iterator column/row end and iterator index
-

Models

-
  • sparse_matrix<T>::iterator1
  • -
  • sparse_matrix<T>::iterator2
- -

Indexed Random -Access Column/Row Iterator

- +

Indexed Random Access +Column/Row Iterator

Description

-

An Indexed Random Access Column/Row Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries index information.

-

Refinement of

-

Indexed Bidirectional Column/Row Iterator .

-

Associated types

- - +
-
Value type The type of the value obtained by dereferencing a Indexed Random Access Column/Row Iterator
Container type The type of the container a Indexed Random Access Column/Row @@ -1160,54 +995,43 @@ Iterator points into.
-

Notation

- - +
- + - - + - - - - + + - - - + + -
I I A type that is a model of Indexed Random Access Column/Row Iterator
T T The value type of I
C The container type of I
it, itt, it1, it2 Objects of type I it, itt, it1, it2Objects of type I
t Object of type T tObject of type T
c Object of type C
-

Definitions

-

Valid expressions

-

In addition to the expressions defined for Indexed Bidirectional Column/Row Iterator , the following expressions must be valid.

- - +
@@ -1215,49 +1039,42 @@ valid.

- - + - - + - - + - + - - + - - + - - @@ -1266,15 +1083,12 @@ valid.

Name Type requirements Return type
Forward motion it += n  I & I &
Iterator additionit + n it + n   I
Backward motioni -= n i -= n  I & I &
Iterator subtractionit - n it - n   I 
Difference it1 - it2  C::difference_type C::difference_type
Element operator it [n]   Convertible to T.
Element assignment it [n] = t
-

Expression Semantics

-

Semantics of an expression is defined only where it differs from, or is not defined in, Indexed Bidirectional Column/Row Iterator .

- - +
@@ -1283,10 +1097,9 @@ Column/Row Iterator .

- - + - - + - @@ -1320,55 +1131,47 @@ negative. - - + - - + +n - - + - - +
Name Semantics Postcondition
Forward motionit += n it += n Including it itself, there must be n dereferenceable or past-the-end iterators following or preceding it, depending on whether n is positive or @@ -1297,19 +1110,17 @@ equivalent to executing -- it n times. If n == 0, this is a null operation. it is dereferenceable or past-the-end.
Iterator addition it + n Same as for i += n.Equivalent to
- {
-  I itt = it;
-  return itt += n;
- }
Equivalent to
+{
+ I itt = it;
+ return itt += n;
+}
Result is dereferenceable or past-the-end.
Backward motion it -= n Equivalent to it += (-n). it is dereferenceable or past-the-end.
Iterator subtraction it - n Same as for i -= n.Equivalent to
- {
-  I itt = it;
-  return itt -= n;
- }
Equivalent to
+{
+ I itt = it;
+ return itt -= n;
+}
Result is dereferenceable or past-the-end.
Differenceit1 - it2 it1 - it2 Either it1 is reachable from it2 or it2 is reachable from it1, or both. Returns a number n such that it1 == it2 + -n  
Element operatorit [n] it [n] it + n exists and is dereferenceable. Equivalent to *(it + n)  
Element assignmenti[n] = t i[n] = t Same as for it [n]. Equivalent to *(it + n) = t  
-

Complexity guarantees

-

The complexity of operations on indexed random access Column/Row iterators is guaranteed to be amortized constant time.

-

Invariants

- - +
@@ -1378,13 +1181,11 @@ Similarly, if it - n is well-defined, then it -= n; it += n; and (it - n) + n are null operations. - -
Symmetry of addition and subtraction
Relation between distance and addition If it1 - it2 is well-defined, then it1 == it2 + (it1 - it2).
Reachability and distance If it1 is reachable from it2, then @@ -1392,24 +1193,18 @@ it2 + (it1 - it2).
-

Models

-
  • matrix<T>::iterator1
  • -
  • matrix<T>::iterator2
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/matrix.htm b/doc/matrix.htm index 57231136..d7bacb33 100644 --- a/doc/matrix.htm +++ b/doc/matrix.htm @@ -1,20 +1,19 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Matrix - -

c++boost.gif + +

c++boost.gif Matrix

- -

Matrix

- +

Matrix

Description

-

The templated class matrix<T, F, A> is the base container adaptor for dense matrices. For a (m x n)-dimensional matrix and 0 <= i < m, 0 @@ -23,510 +22,418 @@ j is mapped to the (i x n + j)-th element of the container for row major orientation or the (i + j x m)-th element of the container for column major orientation.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << m << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
+}
-

Definition

-

Defined in the header matrix.hpp.

-

Template parameters

- - +
- - + - + - +"#matrix_1">[1] - - +
Parameter Description Default
T T The type of object stored in the matrix. 
F Functor describing the storage organization. [1] row_major
AThe type of the adapted array. [2] -The type of the adapted array. [2] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<matrix<T, F, A> >

-

Members

- - +
- - + - - - - + - - + +rows of size2 elements. The existing elements of the +matrix are preseved when specified. - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
matrix () matrix () Allocates an uninitialized matrix that holds zero rows of zero elements.
matrix (size_type size1, size_type size2) Allocates an uninitialized matrix that holds size1 rows of size2 elements.
matrix (const matrix &m) The copy constructor.
template<class AE>
- matrix (const matrix_expression<AE> &ae)
template<class AE>
+matrix (const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type -size2)void resize (size_type size1, size_type size2, bool +preserve = true) Reallocates a matrix to hold size1 -rows of size2 elements. The content of the -matrix is not preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
matrix &operator = (const matrix &m) The assignment operator.
matrix &assign_temporary (matrix &m) Assigns a temporary. May change the matrix m.
template<class AE>
- matrix &operator = (const matrix_expression<AE> +
template<class AE>
+matrix &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix &assign (const matrix_expression<AE> +
template<class AE>
+matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix &operator += (const matrix_expression<AE> +
template<class AE>
+matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the matrix.
template<class AE>
- matrix &plus_assign (const matrix_expression<AE> +
template<class AE>
+matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix &operator -= (const matrix_expression<AE> +
template<class AE>
+matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the matrix.
template<class AE>
- matrix &minus_assign (const matrix_expression<AE> +
template<class AE>
+matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix &operator *= (const AT &at)
template<class AT>
+matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the matrix with a scalar.
template<class AT>
- matrix &operator /= (const AT &at)
template<class AT>
+matrix &operator /= (const AT &at)
A computed assignment operator. Divides the matrix through a scalar.
void swap (matrix &m) Swaps the contents of the matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th element of the i-th row.
void clear () Clears the matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed matrix.
-

Notes

- -

[1] Supported parameters for the storage -organization are row_major and +

[1] Supported parameters +for the storage organization are row_major and column_major.

- -

[2] Supported parameters for the adapted -array are unbounded_array<T> , +

[2] Supported parameters +for the adapted array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

- -

Identity Matrix

- +

Identity +Matrix

Description

-

The templated class identity_matrix<T> represents identity matrices. For a (m x n)-dimensional identity matrix and 0 <= i < m, 0 <= j < n holds idi, j = 0, if i <> j, and idi, i= 1.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- identity_matrix<double> m (3);
- std::cout << m << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ identity_matrix<double> m (3);
+ std::cout << m << std::endl;
+}
-

Definition

-

Defined in the header matrix.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
T T The type of object stored in the matrix. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<identity_matrix<T> >

-

Members

- - +
- - + - - - - + +size rows of size elements. Therefore the +existing elements of the itendity_matrix are always +preseved. - - - - - - - - - - - - - -
Member Description
identity_matrix () identity_matrix () Constructs an identity_matrix that holds zero rows of zero elements.
identity_matrix (size_type size) Constructs an identity_matrix that holds size rows of size elements.
identity_matrix (const identity_matrix &m) The copy constructor.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Resizes a identity_matrix to hold -size rows of size elements.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
identity_matrix &operator = (const identity_matrix &m) The assignment operator.
identity_matrix &assign_temporary (identity_matrix &m) Assigns a temporary. May change the identity matrix m .
void swap (identity_matrix &m) Swaps the contents of the identity matrices.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the identity_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the identity_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the identity_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the identity_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed identity_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed identity_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed identity_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -534,176 +441,141 @@ end of the reversed identity_matrix.
- -

Zero Matrix

- +

Zero Matrix

Description

-

The templated class zero_matrix<T> represents zero matrices. For a (m x n)-dimensional zero matrix and 0 <= i < m, 0 <= j < n holds zi, j = 0.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- zero_matrix<double> m (3, 3);
- std::cout << m << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ zero_matrix<double> m (3, 3);
+ std::cout << m << std::endl;
+}
-

Definition

-

Defined in the header matrix.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
T T The type of object stored in the matrix. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<zero_matrix<T> >

-

Members

- - +
- - + - - - - + +rows of size2 elements. Therefore the existing +elements of the zero_matrix are always preseved. - - - - - - - - - - - - - -
Member Description
zero_matrix () zero_matrix () Constructs a zero_matrix that holds zero rows of zero elements.
zero_matrix (size_type size1, size_type size2) Constructs a zero_matrix that holds size1 rows of size2 elements.
zero_matrix (const zero_matrix &m) The copy constructor.
void resize (size_type size1, size_type -size2)void resize (size_type size1, size_type size2, bool +preserve = true) Resizes a zero_matrix to hold size1 -rows of size2 elements.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
zero_matrix &operator = (const zero_matrix &m) The assignment operator.
zero_matrix &assign_temporary (zero_matrix &m) Assigns a temporary. May change the zero matrix m .
void swap (zero_matrix &m) Swaps the contents of the zero matrices.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the zero_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the zero_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the zero_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the zero_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed zero_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed zero_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed zero_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -711,16 +583,159 @@ end of the reversed zero_matrix.
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +

scalar +Matrix

+

Description

+

The templated class scalar_matrix<T> +represents scalar matrices. For a (m x n)-dimensional +scalar matrix and 0 <= i < m, 0 <= j < +n holds zi, j = s.

+

Example

+
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ scalar_matrix<double> m (3, 3);
+ std::cout << m << std::endl;
+}
+
+

Definition

+

Defined in the header matrix.hpp.

+

Template parameters

+ + + + + + + + + + + + + +
ParameterDescriptionDefault
TThe type of object stored in the matrix.
+

Model of

+

Matrix Expression +.

+

Type requirements

+

None, except for those imposed by the requirements of Matrix Expression .

+

Public base classes

+

matrix_expression<scalar_matrix<T> +>

+

Members

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MemberDescription
scalar_matrix ()Constructs a scalar_matrix that holds scalar rows +of zero elements.
scalar_matrix (size_type size1, size_type size2, const +value_type &value)Constructs a scalar_matrix that holds +size1 rows of size2 elements each of the +specified value.
scalar_matrix (const scalar_matrix &m)The copy constructor.
void resize (size_type size1, size_type size2, bool +preserve = true)Resizes a scalar_matrix to hold size1 +rows of size2 elements. Therefore the existing +elements of the scalar_matrix are always +preseved.
size_type size1 () constReturns the number of rows.
size_type size2 () constReturns the number of columns.
const_reference operator () (size_type i, size_type j) +constReturns the value of the j-th element in the +i-th row.
scalar_matrix &operator = (const scalar_matrix +&m)The assignment operator.
scalar_matrix &assign_temporary (scalar_matrix +&m)Assigns a temporary. May change the scalar matrix +m .
void swap (scalar_matrix &m)Swaps the contents of the scalar matrices.
const_iterator1 begin1 () constReturns a const_iterator1 pointing to the +beginning of the scalar_matrix.
const_iterator1 end1 () constReturns a const_iterator1 pointing to the end of +the scalar_matrix.
const_iterator2 begin2 () constReturns a const_iterator2 pointing to the +beginning of the scalar_matrix.
const_iterator2 end2 () constReturns a const_iterator2 pointing to the end of +the scalar_matrix.
const_reverse_iterator1 rbegin1 () constReturns a const_reverse_iterator1 pointing to the +beginning of the reversed scalar_matrix.
const_reverse_iterator1 rend1 () constReturns a const_reverse_iterator1 pointing to the +end of the reversed scalar_matrix.
const_reverse_iterator2 rbegin2 () constReturns a const_reverse_iterator2 pointing to the +beginning of the reversed scalar_matrix.
const_reverse_iterator2 rend2 () constReturns a const_reverse_iterator2 pointing to the +end of the reversed scalar_matrix.
+
+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/matrix_expression.htm b/doc/matrix_expression.htm index 9d40a5e7..b8dd2341 100644 --- a/doc/matrix_expression.htm +++ b/doc/matrix_expression.htm @@ -1,200 +1,157 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Matrix Expressions - -

c++boost.gif + +

c++boost.gif Matrix Expressions

- -

Matrix Expression

- +

Matrix +Expression

Description

-

The templated class matrix_expression<E> forms the base for all static derived matrix expression classes including class matrix itself.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
E E The type of the matrix expression.  
-

Model of

-

None.

-

Type requirements

-

None.

-

Public base classes

-

None.

-

Members

- - +
- -
Member Description
const expression_type &operator () () const Returns a const reference of the expression.
expression_type &operator () () Returns a reference of the expression.
- -

Matrix References

- +

Matrix +References

Constant Reference

-

Description

-

The templated class matrix_const_reference<E> contains a constant reference to a matrix expression.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
E E The type of the matrix expression.  
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_const_reference<E> >

-

Members

- - +
- +&e) - - - - - - - - - - -
Member Description
matrix_const_reference (const expression_type -&e) Constructs a constant reference of the expression.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -202,223 +159,176 @@ end of the reversed expression.
-

Reference

-

Description

-

The templated class matrix_reference<E> contains a reference to a matrix expression.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
E E The type of the matrix expression.  
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_reference<E> >

-

Members

- - +
- - + - - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
matrix_reference (expression_type &e) matrix_reference (expression_type &e) Constructs a constant reference of the expression.
void resize (size_type size1, size2) Resizes the expression to hold at most size1 rows of size2 elements.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the expression.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the expression.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed expression.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed expression.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed expression.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed expression.
- -

Matrix Operations

- +

Matrix +Operations

Unary Operation Description

-

Description

-

The templated classes matrix_unary1<E, F> and matrix_unary2<E, F> describe unary matrix operations.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - + - @@ -426,101 +336,80 @@ operations.

Parameter Description Default
E E The type of the matrix expression.  
F The type of the operation.
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_unary1<E, F> > and matrix_expression<matrix_unary2<E, F> > resp.

-

Members

- - +
- - + - - - - - - - - - - - -
Member Description
matrix_unary1 (const expression_type &e) matrix_unary1 (const expression_type &e) Constructs a description of the expression.
matrix_unary2 (const expression_type &e) Constructs a description of the expression.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -528,57 +417,52 @@ end of the reversed expression.
-

Unary Operations

-

Prototypes

-
-template<class E, class F>
- struct matrix_unary1_traits {
- typedef matrix_unary1<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (- m) [i] [j] = - m [i] [j]
- template<class E>
- typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type
- operator - (const matrix_expression<E> &e);
-
- // (conj m) [i] [j] = conj (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type
- conj (const matrix_expression<E> &e);
-
- // (real m) [i] [j] = real (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type
- real (const matrix_expression<E> &e);
-
- // (imag m) [i] [j] = imag (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type
- imag (const matrix_expression<E> &e);
-
- template<class E, class F>
- struct matrix_unary2_traits {
- typedef matrix_unary2<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (trans m) [i] [j] = m [j] [i]
- template<class E>
- typename matrix_unary2_traits<E, scalar_identity<typename E::value_type> >::result_type
- trans (const matrix_expression<E> &e);
-
- // (herm m) [i] [j] = conj (m [j] [i])
- template<class E>
- typename matrix_unary2_traits<E, scalar_conj<typename E::value_type> >::result_type
+template<class E, class F>
+ struct matrix_unary1_traits {
+ typedef matrix_unary1<typename E::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (- m) [i] [j] = - m [i] [j]
+ template<class E>
+ typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type
+ operator - (const matrix_expression<E> &e);
+
+ // (conj m) [i] [j] = conj (m [i] [j])
+ template<class E>
+ typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type
+ conj (const matrix_expression<E> &e);
+
+ // (real m) [i] [j] = real (m [i] [j])
+ template<class E>
+ typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type
+ real (const matrix_expression<E> &e);
+
+ // (imag m) [i] [j] = imag (m [i] [j])
+ template<class E>
+ typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type
+ imag (const matrix_expression<E> &e);
+
+ template<class E, class F>
+ struct matrix_unary2_traits {
+ typedef matrix_unary2<typename E::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (trans m) [i] [j] = m [j] [i]
+ template<class E>
+ typename matrix_unary2_traits<E, scalar_identity<typename E::value_type> >::result_type
+ trans (const matrix_expression<E> &e);
+
+ // (herm m) [i] [j] = conj (m [j] [i])
+ template<class E>
+ typename matrix_unary2_traits<E, scalar_conj<typename E::value_type> >::result_type
herm (const matrix_expression<E> &e);
-

Description

-

operator - computes the additive inverse of a matrix expression. conj computes the complex conjugate of a matrix expression. real and imag @@ -586,178 +470,138 @@ compute the real and imaginary parts of a matrix expression. trans computes the transpose of a matrix expression. herm computes the hermitian, i.e. the complex conjugate of the transpose of a matrix expression.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Type requirements

- -

Preconditions

-

None.

-

Complexity

-

Quadratic depending from the size of the matrix expression.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<std::complex<double> > m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
-
- std::cout << - m << std::endl;
- std::cout << conj (m) << std::endl;
- std::cout << real (m) << std::endl;
- std::cout << imag (m) << std::endl;
- std::cout << trans (m) << std::endl;
- std::cout << herm (m) << std::endl;
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<std::complex<double> > m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
+
+ std::cout << - m << std::endl;
+ std::cout << conj (m) << std::endl;
+ std::cout << real (m) << std::endl;
+ std::cout << imag (m) << std::endl;
+ std::cout << trans (m) << std::endl;
+ std::cout << herm (m) << std::endl;
}
-

Binary Operation Description

-

Description

-

The templated class matrix_binary<E1, E2, F> describes a binary matrix operation.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - - +
Parameter Description Default
E1 E1 The type of the first matrix expression. 
E2 The type of the second matrix expression. 
F The type of the operation. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_binary<E1, E2, F> >.

-

Members

- - +
- +expression2_type &e2) - - - - - - - - - - -
Member Description
matrix_binary (const expression1_type &e1, const -expression2_type &e2) Constructs a description of the expression.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -765,224 +609,176 @@ end of the reversed expression.
-

Binary Operations

-

Prototypes

-
-template<class E1, class E2, class F>
- struct matrix_binary_traits {
- typedef matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (m1 + m2) [i] [j] = m1 [i] [j] + m2 [i] [j]
- template<class E1, class E2>
- typename matrix_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator + (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- // (m1 - m2) [i] [j] = m1 [i] [j] - m2 [i] [j]
- template<class E1, class E2>
- typename matrix_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator - (const matrix_expression<E1> &e1,
+template<class E1, class E2, class F>
+ struct matrix_binary_traits {
+ typedef matrix_binary<typename E1::const_closure_type,
+ typename E2::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (m1 + m2) [i] [j] = m1 [i] [j] + m2 [i] [j]
+ template<class E1, class E2>
+ typename matrix_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
+ typename E2::value_type> >::result_type
+ operator + (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ // (m1 - m2) [i] [j] = m1 [i] [j] - m2 [i] [j]
+ template<class E1, class E2>
+ typename matrix_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
+ typename E2::value_type> >::result_type
+ operator - (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
-

Description

-

operator + computes the sum of two matrix expressions. operator - computes the difference of two matrix expressions.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size1 () == e2 ().size1 ()
  • -
  • e1 ().size2 () == e2 ().size2 ()
-

Complexity

-

Quadratic depending from the size of the matrix expressions.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m1 (3, 3), m2 (3, 3);
- for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
-
- std::cout << m1 + m2 << std::endl;
- std::cout << m1 - m2 << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m1 (3, 3), m2 (3, 3);
+ for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
+ for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
+ m1 (i, j) = m2 (i, j) = 3 * i + j;
+
+ std::cout << m1 + m2 << std::endl;
+ std::cout << m1 - m2 << std::endl;
+}
-

Scalar Matrix Operation Description

-

Description

-

The templated classes matrix_binary_scalar1<E1, E2, F> and matrix_binary_scalar2<E1, E2, F> describe binary operations between a scalar and a matrix.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - - +
Parameter Description Default
E1/E2 E1/E2 The type of the scalar expression. 
E2/E1 The type of the matrix expression. 
F The type of the operation. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_binary_scalar1<E1, E2, F> > and matrix_expression<matrix_binary_scalar2<E1, E2, F> > resp.

-

Members

- - +
- +const expression2_type &e2) - +const expression2_type &e2) - - - - - - - - - - -
Member Description
matrix_binary_scalar1 (const expression1_type &e1, -const expression2_type &e2) Constructs a description of the expression.
matrix_binary_scalar1 (const expression1_type &e1, -const expression2_type &e2) Constructs a description of the expression.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -990,203 +786,160 @@ end of the reversed expression.
-

Scalar Matrix Operations

-

Prototypes

-
-template<class T1, class E2, class F>
- struct matrix_binary_scalar1_traits {
- typedef matrix_binary_scalar1<scalar_const_reference<T1>,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (t * m) [i] [j] = t * m [i] [j]
- template<class T1, class E2>
- typename matrix_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
- operator * (const T1 &e1,
- const matrix_expression<E2> &e2);
-
- template<class E1, class T2, class F>
- struct matrix_binary_scalar2_traits {
- typedef matrix_binary_scalar2<typename E1::const_closure_type,
- scalar_const_reference<T2>, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (m * t) [i] [j] = m [i] [j] * t
- template<class E1, class T2>
- typename matrix_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
- operator * (const matrix_expression<E1> &e1,
- const T2 &e2);
-
- // (m / t) [i] [j] = m [i] [j] / t
- template<class E1, class T2>
- typename matrix_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
- operator / (const matrix_expression<E1> &e1,
+template<class T1, class E2, class F>
+ struct matrix_binary_scalar1_traits {
+ typedef matrix_binary_scalar1<scalar_const_reference<T1>,
+ typename E2::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (t * m) [i] [j] = t * m [i] [j]
+ template<class T1, class E2>
+ typename matrix_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
+ operator * (const T1 &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class E1, class T2, class F>
+ struct matrix_binary_scalar2_traits {
+ typedef matrix_binary_scalar2<typename E1::const_closure_type,
+ scalar_const_reference<T2>, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (m * t) [i] [j] = m [i] [j] * t
+ template<class E1, class T2>
+ typename matrix_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
+ operator * (const matrix_expression<E1> &e1,
+ const T2 &e2);
+
+ // (m / t) [i] [j] = m [i] [j] / t
+ template<class E1, class T2>
+ typename matrix_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
+ operator / (const matrix_expression<E1> &e1,
const T2 &e2);
-

Description

-

operator * computes the product of a scalar and a matrix expression. operator / multiplies the matrix with the reciprocal of the scalar.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Type requirements

- -

Preconditions

-

None.

-

Complexity

-

Quadratic depending from the size of the matrix expression.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
-
- std::cout << 2.0 * m << std::endl;
- std::cout << m * 2.0 << std::endl;
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+
+ std::cout << 2.0 * m << std::endl;
+ std::cout << m * 2.0 << std::endl;
}
- -

Matrix Vector -Operations

- +

Matrix Vector Operations

Binary Operation Description

-

Description

-

The templated classes matrix_vector_binary1<E1, E2, F> and matrix_vector_binary2<E1, E2, F> describe binary matrix vector operations.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - + - - + - +
Parameter Description Default
E1 E1 The type of the matrix or vector expression. 
E2 E2 The type of the vector or matrix expression. 
F F The type of the operation. 
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<matrix_vector_binary1<E1, E2, F> > and vector_expression<matrix_vector_binary2<E1, E2, F> > resp.

-

Members

- - +
- - - - - - - -
Member Description
matrix_vector_binary1 (const expression1_type &e1, const expression2_type &e2) Constructs a description of the expression.
matrix_vector_binary2 (const expression1_type &e1, const expression2_type &e2) Constructs a description of the expression.
size_type size () const Returns the size of the expression.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the expression.
const_iterator end () const Returns a const_iterator pointing to the end of the expression.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed expression.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -1194,425 +947,358 @@ end of the reversed expression.
-

Binary Operations

-

Prototypes

-
-template<class T1, class E1, class T2, class E2>
- struct matrix_vector_binary1_traits {
- typedef row_major_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_vector_binary1<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_vector_prod1<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
-
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- row_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- row_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class T1, class E1, class T2, class E2>
- struct matrix_vector_binary2_traits {
- typedef column_major_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_vector_binary2<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_vector_prod2<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
-
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- column_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- column_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prec_prod (const vector_expression<E1> &e1,
+template<class T1, class E1, class T2, class E2>
+ struct matrix_vector_binary1_traits {
+ typedef row_major_tag dispatch_category;
+ typedef typename promote_traits<T1, T2>::promote_type promote_type;
+ typedef matrix_vector_binary1<typename E1::const_closure_type,
+ typename E2::const_closure_type,
+ matrix_vector_prod1<T1, T2, promote_type> > expression_type;
+ typedef expression_type result_type;
+ };
+
+ template<class E1, class E2>
+ typename matrix_vector_binary1_traits<typename E1::value_type, E1,
+ typename E2::value_type, E2>::result_type
+ prod (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2,
+ row_major_tag);
+
+ // Dispatcher
+ template<class E1, class E2>
+ typename matrix_vector_binary1_traits<typename E1::value_type, E1,
+ typename E2::value_type, E2>::result_type
+ prod (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2);
+
+ template<class E1, class E2>
+ typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
+ typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
+ prec_prod (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2,
+ row_major_tag);
+
+ // Dispatcher
+ template<class E1, class E2>
+ typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
+ typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
+ prec_prod (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2);
+
+ template<class V, class E1, class E2>
+ V
+ prod (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2);
+
+ template<class V, class E1, class E2>
+ V
+ prec_prod (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2);
+
+ template<class T1, class E1, class T2, class E2>
+ struct matrix_vector_binary2_traits {
+ typedef column_major_tag dispatch_category;
+ typedef typename promote_traits<T1, T2>::promote_type promote_type;
+ typedef matrix_vector_binary2<typename E1::const_closure_type,
+ typename E2::const_closure_type,
+ matrix_vector_prod2<T1, T2, promote_type> > expression_type;
+ typedef expression_type result_type;
+ };
+
+ template<class E1, class E2>
+ typename matrix_vector_binary2_traits<typename E1::value_type, E1,
+ typename E2::value_type, E2>::result_type
+ prod (const vector_expression<E1> &e1,
+ const matrix_expression<E2> &e2,
+ column_major_tag);
+
+ // Dispatcher
+ template<class E1, class E2>
+ typename matrix_vector_binary2_traits<typename E1::value_type, E1,
+ typename E2::value_type, E2>::result_type
+ prod (const vector_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class E1, class E2>
+ typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
+ typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
+ prec_prod (const vector_expression<E1> &e1,
+ const matrix_expression<E2> &e2,
+ column_major_tag);
+
+ // Dispatcher
+ template<class E1, class E2>
+ typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
+ typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
+ prec_prod (const vector_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class V, class E1, class E2>
+ V
+ prod (const vector_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class V, class E1, class E2>
+ V
+ prec_prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2);
-

Description

-

prod computes the product of the matrix and the vector expression. prec_prod computes the double precision product of the matrix and the vector expression.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size2 () == e2 ().size ()
  • -
  • e1 ().size () == e2 ().size1 ()
-

Complexity

-

Quadratic depending from the size of the matrix expression.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- vector<double> v (3);
- for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- v (i) = i;
- }
-
- std::cout << prod (m, v) << std::endl;
- std::cout << prod (v, m) << std::endl;
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ vector<double> v (3);
+ for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ v (i) = i;
+ }
+
+ std::cout << prod (m, v) << std::endl;
+ std::cout << prod (v, m) << std::endl;
}
-

Triangular Solver

-

Prototypes

-
-template<class E1, class E2>
- struct matrix_vector_solve_traits {
- typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
- typedef vector<promote_type> result_type;
- };
-
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- lower_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- upper_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_lower_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_upper_tag,
- vector_tag);
-
- template<class E1, class E2, class C>
- typename matrix_vector_solve_traits<E1, E2>::result_type
- solve (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- C);
-
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- lower_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- upper_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- unit_lower_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- unit_upper_tag);
-
- template<class E1, class E2, class C>
- typename matrix_vector_solve_traits<E1, E2>::result_type
- solve (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
+template<class E1, class E2>
+ struct matrix_vector_solve_traits {
+ typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
+ typedef vector<promote_type> result_type;
+ };
+
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ lower_tag,
+ vector_tag);
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ upper_tag,
+ vector_tag);
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ unit_lower_tag,
+ vector_tag);
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ unit_upper_tag,
+ vector_tag);
+
+ template<class E1, class E2, class C>
+ typename matrix_vector_solve_traits<E1, E2>::result_type
+ solve (const matrix_expression<E1> &e1,
+ const vector_expression<E2> &e2,
+ C);
+
+ template<class E1, class E2>
+ void inplace_solve (E1 &e1,
+ const matrix_expression<E2> &e2,
+ vector_tag,
+ lower_tag);
+ template<class E1, class E2>
+ void inplace_solve (E1 &e1,
+ const matrix_expression<E2> &e2,
+ vector_tag,
+ upper_tag);
+ template<class E1, class E2>
+ void inplace_solve (E1 &e1,
+ const matrix_expression<E2> &e2,
+ vector_tag,
+ unit_lower_tag);
+ template<class E1, class E2>
+ void inplace_solve (E1 &e1,
+ const matrix_expression<E2> &e2,
+ vector_tag,
+ unit_upper_tag);
+
+ template<class E1, class E2, class C>
+ typename matrix_vector_solve_traits<E1, E2>::result_type
+ solve (const vector_expression<E1> &e1,
+ const matrix_expression<E2> &e2,
C);
-

Description

-

solve solves a linear equation for lower or upper (unit) triangular matrices.

-

Definition

-

Defined in the header triangular.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size1 () == e1 ().size2 ()
  • -
  • e1 ().size2 () == e2 ().size ()
  • -
  • e1 ().size () == e2 ().size1 ()
  • -
  • e2 ().size1 () == e2 ().size2 ()
-

Complexity

-

Quadratic depending from the size of the matrix expression.

-

Examples

-
-#include <boost/numeric/ublas/triangular.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- vector<double> v (3);
- for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
- for (unsigned j = 0; j <= i; ++ j)
- m (i, j) = 3 * i + j + 1;
- v (i) = i;
- }
-
- std::cout << solve (m, v, lower_tag ()) << std::endl;
- std::cout << solve (v, m, lower_tag ()) << std::endl;
-}
+#include <boost/numeric/ublas/triangular.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ vector<double> v (3);
+ for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
+ for (unsigned j = 0; j <= i; ++ j)
+ m (i, j) = 3 * i + j + 1;
+ v (i) = i;
+ }
+
+ std::cout << solve (m, v, lower_tag ()) << std::endl;
+ std::cout << solve (v, m, lower_tag ()) << std::endl;
+}
- -

Matrix Matrix -Operations

- +

Matrix Matrix Operations

Binary Operation Description

-

Description

-

The templated class matrix_matrix_binary<E1, E2, F> describes a binary matrix operation.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - - +
Parameter Description Default
E1 E1 The type of the first matrix expression. 
E2 The type of the second matrix expression. 
F The type of the operation. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_matrix_binary<E1, E2, F> > .

-

Members

- - +
- +const expression2_type &e2) - - - - - - - - - - -
Member Description
matrix_matrix_binary (const expression1_type &e1, -const expression2_type &e2) Constructs a description of the expression.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -1620,204 +1306,168 @@ end of the reversed expression.
-

Binary Operations

-

Prototypes

-
-template<class T1, class E1, class T2, class E2>
- struct matrix_matrix_binary_traits {
- typedef unknown_orientation_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_matrix_prod<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
-
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- unknown_orientation_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- unknown_orientation_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class M, class E1, class E2>
- M
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class M, class E1, class E2>
- M
- prec_prod (const matrix_expression<E1> &e1,
+template<class T1, class E1, class T2, class E2>
+ struct matrix_matrix_binary_traits {
+ typedef unknown_orientation_tag dispatch_category;
+ typedef typename promote_traits<T1, T2>::promote_type promote_type;
+ typedef matrix_matrix_binary<typename E1::const_closure_type,
+ typename E2::const_closure_type,
+ matrix_matrix_prod<T1, T2, promote_type> > expression_type;
+ typedef expression_type result_type;
+ };
+
+ template<class E1, class E2>
+ typename matrix_matrix_binary_traits<typename E1::value_type, E1,
+ typename E2::value_type, E2>::result_type
+ prod (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2,
+ unknown_orientation_tag);
+
+ // Dispatcher
+ template<class E1, class E2>
+ typename matrix_matrix_binary_traits<typename E1::value_type, E1,
+ typename E2::value_type, E2>::result_type
+ prod (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class E1, class E2>
+ typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
+ typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
+ prec_prod (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2,
+ unknown_orientation_tag);
+
+ // Dispatcher
+ template<class E1, class E2>
+ typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
+ typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
+ prec_prod (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class M, class E1, class E2>
+ M
+ prod (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2);
+
+ template<class M, class E1, class E2>
+ M
+ prec_prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
-

Description

-

prod computes the product of the matrix expressions. prec_prod computes the double precision product of the matrix expressions.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size2 () == e2 ().size1 ()
-

Complexity

-

Cubic depending from the size of the matrix expression.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m1 (3, 3), m2 (3, 3);
- for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
-
- std::cout << prod (m1, m2) << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m1 (3, 3), m2 (3, 3);
+ for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
+ for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
+ m1 (i, j) = m2 (i, j) = 3 * i + j;
+
+ std::cout << prod (m1, m2) << std::endl;
+}
-

Triangular Solvers

-

Prototypes

-
-template<class E1, class E2>
- struct matrix_matrix_solve_traits {
- typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
- typedef matrix<promote_type> result_type;
- };
-
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- lower_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- upper_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_lower_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_upper_tag,
- matrix_tag);
-
- template<class E1, class E2, class C>
- typename matrix_matrix_solve_traits<E1, E2>::result_type
- solve (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
+template<class E1, class E2>
+ struct matrix_matrix_solve_traits {
+ typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
+ typedef matrix<promote_type> result_type;
+ };
+
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ lower_tag,
+ matrix_tag);
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ upper_tag,
+ matrix_tag);
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ unit_lower_tag,
+ matrix_tag);
+ template<class E1, class E2>
+ void inplace_solve (const matrix_expression<E1> &e1,
+ E2 &e2,
+ unit_upper_tag,
+ matrix_tag);
+
+ template<class E1, class E2, class C>
+ typename matrix_matrix_solve_traits<E1, E2>::result_type
+ solve (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2,
C);
-

Description

-

solve solves a linear equation for lower or upper (unit) triangular matrices.

-

Definition

-

Defined in the header triangular.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size1 () == e1 ().size2 ()
  • -
  • e1 ().size2 () == e2 ().size1 ()
-

Complexity

-

Cubic depending from the size of the matrix expressions.

-

Examples

-
-#include <boost/numeric/ublas/triangular.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m1 (3, 3), m2 (3, 3);
- for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (unsigned j = 0; j <= i; ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j + 1;
-
- std::cout << solve (m1, m2, lower_tag ()) << std::endl;
-}
+#include <boost/numeric/ublas/triangular.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m1 (3, 3), m2 (3, 3);
+ for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
+ for (unsigned j = 0; j <= i; ++ j)
+ m1 (i, j) = m2 (i, j) = 3 * i + j + 1;
+
+ std::cout << solve (m1, m2, lower_tag ()) << std::endl;
+}
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/matrix_proxy.htm b/doc/matrix_proxy.htm index 2001e1d8..599ca08d 100644 --- a/doc/matrix_proxy.htm +++ b/doc/matrix_proxy.htm @@ -1,1704 +1,1376 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Matrix Proxies - -

c++boost.gif + +

c++boost.gif Matrix Proxies

- -

Matrix Row

- +

Matrix Row

Description

-

The templated class matrix_row<M> allows addressing a row of a matrix.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i) {
- matrix_row<matrix<double> > mr (m, i);
- for (unsigned j = 0; j < mr.size (); ++ j)
- mr (j) = 3 * i + j;
- std::cout << mr << std::endl;
- }
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i) {
+ matrix_row<matrix<double> > mr (m, i);
+ for (unsigned j = 0; j < mr.size (); ++ j)
+ mr (j) = 3 * i + j;
+ std::cout << mr << std::endl;
+ }
}
-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
M M The type of matrix referenced. 
-

Model of

-

Vector Expression .

- +

If the specified row falls outside that of the row index range +of the matrix, then the matrix_row is not a well +formed Vector Expression. That is, access to an element which is +outside of the matrix is undefined.

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<matrix_row<M> >

-

Members

- - +
- - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - +
Member Description
matrix_row (matrix_type &data, size_type i) Constructs a sub vector.
size_type size () const Returns the size of the sub vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
matrix_row &operator = (const matrix_row &mr) The assignment operator.
matrix_row &assign_temporary (matrix_row &mr) Assigns a temporary. May change the matrix row mr .
template<class AE>
- matrix_row &operator = (const vector_expression<AE> +
template<class AE>
+matrix_row &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix_row &assign (const vector_expression<AE> +
template<class AE>
+matrix_row &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_row &operator += (const vector_expression<AE> +
template<class AE>
+matrix_row &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sub vector.
template<class AE>
- matrix_row &plus_assign (const vector_expression<AE> +
template<class AE>
+matrix_row &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_row &operator -= (const vector_expression<AE> +
template<class AE>
+matrix_row &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sub vector.
template<class AE>
- matrix_row &minus_assign (const vector_expression<AE> +
template<class AE>
+matrix_row &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix_row &operator *= (const AT &at)
template<class AT>
+matrix_row &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub vector with a scalar.
template<class AT>
- matrix_row &operator /= (const AT &at)
template<class AT>
+matrix_row &operator /= (const AT &at)
A computed assignment operator. Divides the sub vector through a scalar.
void swap (matrix_row &mr) Swaps the contents of the sub vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the matrix_row.
const_iterator end () const Returns a const_iterator pointing to the end of the matrix_row.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the matrix_row.
iterator end () iterator end () Returns a iterator pointing to the end of the matrix_row.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed matrix_row.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed matrix_row.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed matrix_row.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed matrix_row.
-

Projections

-

Prototypes

-
-template<class M>
- matrix_row<M> row (M &data, std::size_t i);
- template<class M>
+template<class M>
+ matrix_row<M> row (M &data, std::size_t i);
+ template<class M>
const matrix_row<const M> row (const M &data, std::size_t i);
-

Description

-

The free row functions support the construction of matrix rows.

-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Type requirements

- - -

Preconditions

- -
    -
  • i < data.size1 ()
  • -
-

Complexity

-

Linear depending from the size of the row.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i) {
- for (unsigned j = 0; j < m.size2 (); ++ j)
- row (m, i) (j) = 3 * i + j;
- std::cout << row (m, i) << std::endl;
- }
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i) {
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ row (m, i) (j) = 3 * i + j;
+ std::cout << row (m, i) << std::endl;
+ }
+}
- -

Matrix Column

- +

Matrix +Column

Description

-

The templated class matrix_column<M> allows addressing a column of a matrix.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned j = 0; j < m.size2 (); ++ j) {
- matrix_column<matrix<double> > mc (m, j);
- for (unsigned i = 0; i < mc.size (); ++ i)
- mc (i) = 3 * i + j;
- std::cout << mc << std::endl;
- }
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned j = 0; j < m.size2 (); ++ j) {
+ matrix_column<matrix<double> > mc (m, j);
+ for (unsigned i = 0; i < mc.size (); ++ i)
+ mc (i) = 3 * i + j;
+ std::cout << mc << std::endl;
+ }
+}
-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
M M The type of matrix referenced. 
-

Model of

-

Vector Expression .

- +

If the specified row falls outside that of the column index +range of the matrix, then the matrix_column is not a +well formed Vector Expression. That is, access to an element which +is outside of the matrix is undefined.

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<matrix_column<M> >

-

Members

- - +
- - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - +
Member Description
matrix_column (matrix_type &data, size_type j) Constructs a sub vector.
size_type size () const Returns the size of the sub vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
matrix_column &operator = (const matrix_column &mc) The assignment operator.
matrix_column &assign_temporary (matrix_column &mc) Assigns a temporary. May change the matrix column mc .
template<class AE>
- matrix_column &operator = (const vector_expression<AE> +
template<class AE>
+matrix_column &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix_column &assign (const vector_expression<AE> +
template<class AE>
+matrix_column &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_column &operator += (const vector_expression<AE> +
template<class AE>
+matrix_column &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sub vector.
template<class AE>
- matrix_column &plus_assign (const vector_expression<AE> +
template<class AE>
+matrix_column &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_column &operator -= (const vector_expression<AE> +
template<class AE>
+matrix_column &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sub vector.
template<class AE>
- matrix_column &minus_assign (const vector_expression<AE> +
template<class AE>
+matrix_column &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix_column &operator *= (const AT &at)
template<class AT>
+matrix_column &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub vector with a scalar.
template<class AT>
- matrix_column &operator /= (const AT &at)
template<class AT>
+matrix_column &operator /= (const AT &at)
A computed assignment operator. Divides the sub vector through a scalar.
void swap (matrix_column &mc) Swaps the contents of the sub vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the matrix_column.
const_iterator end () const Returns a const_iterator pointing to the end of the matrix_column.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the matrix_column.
iterator end () iterator end () Returns a iterator pointing to the end of the matrix_column.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed matrix_column.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed matrix_column.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed matrix_column.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed matrix_column.
-

Projections

-

Prototypes

-
-template<class M>
- matrix_column<M> column (M &data, std::size_t j);
- template<class M>
+template<class M>
+ matrix_column<M> column (M &data, std::size_t j);
+ template<class M>
const matrix_column<const M> column (const M &data, std::size_t j);
-

Description

-

The free column functions support the construction of matrix columns.

-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Type requirements

- - -

Preconditions

- -
    -
  • j < data.size2 ()
  • -
-

Complexity

-

Linear depending from the size of the column.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned j = 0; j < m.size2 (); ++ j) {
- for (unsigned i = 0; i < m.size1 (); ++ i)
- column (m, j) (i) = 3 * i + j;
- std::cout << column (m, j) << std::endl;
- }
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned j = 0; j < m.size2 (); ++ j) {
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ column (m, j) (i) = 3 * i + j;
+ std::cout << column (m, j) << std::endl;
+ }
+}
- -

Vector Range

- +

Vector Range

Description

-

The templated class matrix_vector_range<M> allows addressing a sub vector of a matrix.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
-
- matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3));
- std::cout << mvr << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+
+ matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3));
+ std::cout << mvr << std::endl;
+}
-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
M M The type of matrix referenced. 
-

Model of

-

Vector Expression .

- +

If the specified ranges fall outside that of the index range of +the matrix, then the matrix_vector_range is not a well +formed Vector Expression. That is, access to an element which is +outside of the matrix is undefined.

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<matrix_vector_range<M> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - +
Member Description
matrix_vector_range (matrix_type &data,
-  const range &r1, const range &r2)
matrix_vector_range (matrix_type &data,
+const range &r1, const range &r2)
Constructs a sub vector.
size_type size () const Returns the size of the sub vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
matrix_vector_range &operator = (const matrix_vector_range &mvr) The assignment operator.
matrix_vector_range &assign_temporary (matrix_vector_range &mvr) Assigns a temporary. May change the matrix vector range mvr.
template<class AE>
- matrix_vector_range &operator = (const +
template<class AE>
+matrix_vector_range &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix_vector_range &assign (const vector_expression<AE> +
template<class AE>
+matrix_vector_range &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_vector_range &operator += (const +
template<class AE>
+matrix_vector_range &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sub vector.
template<class AE>
- matrix_vector_range &plus_assign (const +
template<class AE>
+matrix_vector_range &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_vector_range &operator -= (const +
template<class AE>
+matrix_vector_range &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sub vector.
template<class AE>
- matrix_vector_range &minus_assign (const +
template<class AE>
+matrix_vector_range &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix_vector_range &operator *= (const AT -&at)
template<class AT>
+matrix_vector_range &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub vector with a scalar.
template<class AT>
- matrix_vector_range &operator /= (const AT -&at)
template<class AT>
+matrix_vector_range &operator /= (const AT &at)
A computed assignment operator. Divides the sub vector through a scalar.
void swap (matrix_vector_range &mvr) Swaps the contents of the sub vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the matrix_vector_range.
const_iterator end () const Returns a const_iterator pointing to the end of the matrix_vector_range.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the matrix_vector_range.
iterator end () iterator end () Returns a iterator pointing to the end of the matrix_vector_range.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the matrix_vector_range.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed matrix_vector_range.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed matrix_vector_range.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed matrix_vector_range.
- -

Vector Slice

- +

Vector Slice

Description

-

The templated class matrix_vector_slice<M> allows addressing a sliced sub vector of a matrix.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
-
- matrix_vector_slice<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3));
- std::cout << mvs << std::endl;
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+
+ matrix_vector_slice<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3));
+ std::cout << mvs << std::endl;
}
-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
M M The type of matrix referenced. 
-

Model of

-

Vector Expression .

- +

If the specified slices fall outside that of the index range of +the matrix, then the matrix_vector_slice is not a well +formed Vector Expression. That is, access to an element which is +outside of the matrix is undefined.

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<matrix_vector_slice<M> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - +
Member Description
matrix_vector_slice (matrix_type &data,
-  const slice &s1, const slice &s2)
matrix_vector_slice (matrix_type &data,
+const slice &s1, const slice &s2)
Constructs a sub vector.
size_type size () const Returns the size of the sub vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
matrix_vector_slice &operator = (const matrix_vector_slice &mvs) The assignment operator.
matrix_vector_slice &assign_temporary (matrix_vector_slice &mvs) Assigns a temporary. May change the matrix vector slice vs.
template<class AE>
- matrix_vector_slice &operator = (const +
template<class AE>
+matrix_vector_slice &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix_vector_slice &assign (const vector_expression<AE> +
template<class AE>
+matrix_vector_slice &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_vector_slice &operator += (const +
template<class AE>
+matrix_vector_slice &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sub vector.
template<class AE>
- matrix_vector_slice &plus_assign (const +
template<class AE>
+matrix_vector_slice &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_vector_slice &operator -= (const +
template<class AE>
+matrix_vector_slice &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sub vector.
template<class AE>
- matrix_vector_slice &minus_assign (const +
template<class AE>
+matrix_vector_slice &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix_vector_slice &operator *= (const AT -&at)
template<class AT>
+matrix_vector_slice &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub vector with a scalar.
template<class AT>
- matrix_vector_slice &operator /= (const AT -&at)
template<class AT>
+matrix_vector_slice &operator /= (const AT &at)
A computed assignment operator. Divides the sub vector through a scalar.
void swap (matrix_vector_slice &mvs) Swaps the contents of the sub vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the matrix_vector_slice.
const_iterator end () const Returns a const_iterator pointing to the end of the matrix_vector_slice.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the matrix_vector_slice.
iterator end () iterator end () Returns a iterator pointing to the end of the matrix_vector_slice.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed matrix_vector_slice.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed matrix_vector_slice.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed matrix_vector_slice.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed matrix_vector_slice.
- -

Matrix Range

- +

Matrix Range

Description

-

The templated class matrix_range<M> allows addressing a sub matrix of a matrix.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3));
- for (unsigned i = 0; i < mr.size1 (); ++ i)
- for (unsigned j = 0; j < mr.size2 (); ++ j)
- mr (i, j) = 3 * i + j;
- std::cout << mr << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3));
+ for (unsigned i = 0; i < mr.size1 (); ++ i)
+ for (unsigned j = 0; j < mr.size2 (); ++ j)
+ mr (i, j) = 3 * i + j;
+ std::cout << mr << std::endl;
+}
-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
M M The type of matrix referenced. 
-

Model of

-

Matrix Expression .

- +

If the specified ranges fall outside that of the index range of +the matrix, then the matrix_range is not a well formed +Matrix Expression. That is, access to an element which is outside +of the matrix is undefined.

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_range<M> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
matrix_range (matrix_type &data,
-  const range &r1, const range &r2)
matrix_range (matrix_type &data,
+const range &r1, const range &r2)
Constructs a sub matrix.
size_type start1 () const Returns the index of the first row.
size_type size1 () const Returns the number of rows.
size_type start2 () const Returns the index of the first column.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
matrix_range &operator = (const matrix_range &mr) The assignment operator.
matrix_range &assign_temporary (matrix_range &mr) Assigns a temporary. May change the matrix range mr .
template<class AE>
- matrix_range &operator = (const matrix_expression<AE> +
template<class AE>
+matrix_range &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix_range &assign (const matrix_expression<AE> +
template<class AE>
+matrix_range &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_range &operator += (const matrix_expression<AE> +
template<class AE>
+matrix_range &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the sub matrix.
template<class AE>
- matrix_range &plus_assign (const matrix_expression<AE> +
template<class AE>
+matrix_range &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_range &operator -= (const matrix_expression<AE> +
template<class AE>
+matrix_range &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the sub matrix.
template<class AE>
- matrix_range &minus_assign (const matrix_expression<AE> +
template<class AE>
+matrix_range &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the sub matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix_range &operator *= (const AT &at)
template<class AT>
+matrix_range &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub matrix with a scalar.
template<class AT>
- matrix_range &operator /= (const AT &at)
template<class AT>
+matrix_range &operator /= (const AT &at)
A computed assignment operator. Divides the sub matrix through a scalar.
void swap (matrix_range &mr) Swaps the contents of the sub matrices.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the matrix_range.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the matrix_range.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the matrix_range.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the matrix_range.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the matrix_range.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the matrix_range.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the matrix_range.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the matrix_range.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed matrix_range.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed matrix_range.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed matrix_range.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed matrix_range.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed matrix_range.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed matrix_range.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed matrix_range.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of reversed the matrix_range.
-

Projections

-

Prototypes

-
-template<class M>
- matrix_range<M> project (M &data, const range &r1, const range &r2);
- template<class M>
- const matrix_range<const M> project (const M &data, const range &r1, const range &r2);
- template<class M>
+template<class M>
+ matrix_range<M> project (M &data, const range &r1, const range &r2);
+ template<class M>
+ const matrix_range<const M> project (const M &data, const range &r1, const range &r2);
+ template<class M>
matrix_range<M> project (const matrix_range<M> &data, const range &r1, const range &r2);
-

Description

-

The free project functions support the construction of matrix ranges.

-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Type requirements

- - -

Preconditions

- -
    -
  • r1.start () + r1.size () <= data.size1 ()
  • - -
  • r2.start () + r2.size () <= data.size2 ()
  • -
-

Complexity

-

Quadratic depending from the size of the ranges.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;
- std::cout << project (m, range (0, 3), range (0, 3)) << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;
+ std::cout << project (m, range (0, 3), range (0, 3)) << std::endl;
+}
- -

Matrix Slice

- +

Matrix Slice

Description

-

The templated class matrix_slice<M> allows addressing a sliced sub matrix of a matrix.

-

Example

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));
- for (unsigned i = 0; i < ms.size1 (); ++ i)
- for (unsigned j = 0; j < ms.size2 (); ++ j)
- ms (i, j) = 3 * i + j;
- std::cout << ms << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));
+ for (unsigned i = 0; i < ms.size1 (); ++ i)
+ for (unsigned j = 0; j < ms.size2 (); ++ j)
+ ms (i, j) = 3 * i + j;
+ std::cout << ms << std::endl;
+}
-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
M M The type of matrix referenced. 
-

Model of

-

Matrix Expression .

- +

If the specified slices fall outside that of the index range of +the matrix, then the matrix_slice is not a well formed +Matrix Expression. That is, access to an element which is outside +of the matrix is undefined.

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<matrix_slice<M> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
matrix_slice (matrix_type &data,
-  const slice &s1, const slice &s2)
matrix_slice (matrix_type &data,
+const slice &s1, const slice &s2)
Constructs a sub matrix.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
matrix_slice &operator = (const matrix_slice &ms) The assignment operator.
matrix_slice &assign_temporary (matrix_slice &ms) Assigns a temporary. May change the matrix slice ms .
template<class AE>
- matrix_slice &operator = (const matrix_expression<AE> +
template<class AE>
+matrix_slice &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- matrix_slice &assign (const matrix_expression<AE> +
template<class AE>
+matrix_slice &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_slice &operator += (const matrix_expression<AE> +
template<class AE>
+matrix_slice &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the sub matrix.
template<class AE>
- matrix_slice &plus_assign (const matrix_expression<AE> +
template<class AE>
+matrix_slice &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- matrix_slice &operator -= (const matrix_expression<AE> +
template<class AE>
+matrix_slice &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the sub matrix.
template<class AE>
- matrix_slice &minus_assign (const matrix_expression<AE> +
template<class AE>
+matrix_slice &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the sub matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- matrix_slice &operator *= (const AT &at)
template<class AT>
+matrix_slice &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub matrix with a scalar.
template<class AT>
- matrix_slice &operator /= (const AT &at)
template<class AT>
+matrix_slice &operator /= (const AT &at)
A computed assignment operator. Multiplies the sub matrix through a scalar.
void swap (matrix_slice &ms) Swaps the contents of the sub matrices.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the matrix_slice.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the matrix_slice.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the matrix_slice.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the matrix_slice.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the matrix_slice.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the matrix_slice.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the matrix_slice.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the matrix_slice.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed matrix_slice.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed matrix_slice.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed matrix_slice.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed matrix_slice.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed matrix_slice.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed matrix_slice.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed matrix_slice.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed matrix_slice.
-

Projections

-

Prototypes

-
-template<class M>
- matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2);
- template<class M>
- matrix_slice<M> project (M &data, const slice &s1, const slice &s2);
- template<class M>
- const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2);
- template<class M>
+template<class M>
+ matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2);
+ template<class M>
+ matrix_slice<M> project (M &data, const slice &s1, const slice &s2);
+ template<class M>
+ const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2);
+ template<class M>
matrix_slice<M> project (const matrix_slice<M> &data, const slice &s1, const slice &s2);
-

Description

-

The free project functions support the construction of matrix slices.

-

Definition

-

Defined in the header matrix_proxy.hpp.

-

Type requirements

- - -

Preconditions

- -
    -
  • s1.start () + s1.stride () * s1.size () <= data.size1 -()
  • - -
  • s2.start () + s2.stride () * s2.size () <= data.size2 -()
  • -
-

Complexity

-

Quadratic depending from the size of the slices.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;
- std::cout << project (m, slice (0, 1, 3), slice (0, 1, 3)) << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;
+ std::cout << project (m, slice (0, 1, 3), slice (0, 1, 3)) << std::endl;
+}
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/matrix_sparse.htm b/doc/matrix_sparse.htm index d6e01a2a..4744cc3f 100644 --- a/doc/matrix_sparse.htm +++ b/doc/matrix_sparse.htm @@ -1,20 +1,21 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Sparse Matrix - -

c++boost.gif + +

c++boost.gif Sparse Matrix

- -

Sparse Matrix

- +

Sparse +Matrix

Description

- +

The templated class sparse_matrix<T, F, A> is the base container adaptor for sparse matrices. For a (m x n)-dimensional sparse matrix and 0 <= i < m, @@ -38,348 +39,290 @@ j2 or (j1 i1 < i2) with column major orientation.

-

Example

-
-#include <boost/numeric/ublas/matrix_sparse.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- sparse_matrix<double> m (3, 3, 3 * 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << m << std::endl;
+#include <boost/numeric/ublas/matrix_sparse.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ sparse_matrix<double> m (3, 3, 3 * 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
}
-

Definition

-

Defined in the header matrix_sparse.hpp.

-

Template parameters

- - +
- - + - + - +"#sparse_matrix_1">[1] - - +"#sparse_matrix_2">[2] +
Parameter Description Default
T T The type of object stored in the sparse matrix. 
F Functor describing the storage organization. [1] row_major
A The type of the adapted array. [2] map_array<std::size_t, T>map_std<std::size_t, T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<sparse_matrix<T, F, A> >

-

Members

- - +
- - + - - - - - +size1 rows of size2 elements. The +existing elements of the sparse_matrix are preseved +when specified. - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
sparse_matrix () sparse_matrix () Allocates a sparse_matrix that holds at most zero rows of zero elements.
sparse_matrix (size_type size1, size_type2, size_type non_zeros) Allocates a sparse_matrix that holds at most size1 rows of size2 elements.
sparse_matrix (const sparse_matrix &m) The copy constructor.
template<class AE>
- sparse_matrix (size_type non_zeros, const +
template<class AE>
+sparse_matrix (size_type non_zeros, const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type size2, size_type non_zeros) Reallocates a sparse_matrix to hold at most -size1 rows of size2 elements. The content -of the sparse_matrix is preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
sparse_matrix &operator = (const sparse_matrix &m) The assignment operator.
sparse_matrix &assign_temporary (sparse_matrix &m) Assigns a temporary. May change the sparse matrix m .
template<class AE>
- sparse_matrix &operator = (const matrix_expression<AE> +
template<class AE>
+sparse_matrix &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- sparse_matrix &assign (const matrix_expression<AE> +
template<class AE>
+sparse_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the sparse matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- sparse_matrix &operator += (const matrix_expression<AE> +
template<class AE>
+sparse_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the sparse matrix.
template<class AE>
- sparse_matrix &plus_assign (const matrix_expression<AE> +
template<class AE>
+sparse_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the sparse matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- sparse_matrix &operator -= (const matrix_expression<AE> +
template<class AE>
+sparse_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the sparse matrix.
template<class AE>
- sparse_matrix &minus_assign (const matrix_expression<AE> +
template<class AE>
+sparse_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the sparse matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- sparse_matrix &operator *= (const AT &at)
template<class AT>
+sparse_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the sparse matrix with a scalar.
template<class AT>
- sparse_matrix &operator /= (const AT &at)
template<class AT>
+sparse_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the sparse matrix through a scalar.
void swap (sparse_matrix &m) Swaps the contents of the sparse matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th element of the i-th row.
void clear () Clears the sparse matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the sparse_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the sparse_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the sparse_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the sparse_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the sparse_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the sparse_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the sparse_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the sparse_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed sparse_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed sparse_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed sparse_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed sparse_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed sparse_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed sparse_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed sparse_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed sparse_matrix.
-

Notes

- -

[1] Supported parameters for the -storage organization are row_major and -column_major.

- -

[2] Supported parameters for the -adapted array are map_array<std::size_t, T> and -std::map<std::size_t, T>.

- -

Compressed Matrix

- +

[1] Supported +parameters for the storage organization are row_major +and column_major.

+

[1] Supported +parameters for the adapted array are +map_array<std::size_t, T> and +map_std<std::size_t, T>. The latter is +equivalent to std::map<std::size_t, T>.

+

+Compressed Matrix

Description

-

The templated class compressed_matrix<T, F, IB, IA, TA> is the base container adaptor for compressed matrices. For a (m x n )-dimensional compressed matrix and @@ -403,367 +346,306 @@ j2 or (j1 i1 < i2) with column major orientation.

-

Example

-
-#include <boost/numeric/ublas/matrix_sparse.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- compressed_matrix<double> m (3, 3, 3 * 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << m << std::endl;
-}
+#include <boost/numeric/ublas/matrix_sparse.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ compressed_matrix<double> m (3, 3, 3 * 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
+}
-

Definition

-

Defined in the header matrix_sparse.hpp.

-

Template parameters

- - +
- - + - + - +"#compressed_matrix_1">[1] - +"#compressed_matrix_2">[2] - +"#compressed_matrix_3">[3] - +"#compressed_matrix_3">[3]
Parameter Description Default
T T The type of object stored in the compressed matrix. 
F Functor describing the storage organization. [1] row_major
IB The index base of the compressed vector. [2] 0
IA The type of the adapted array for indices. [3] unbounded_array<std::size_t>
TA The type of the adapted array for values. [3] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<compressed_matrix<T, F, IB, IA, TA> >

-

Members

- - +
- - + - - - - - +size1 rows of size2 elements. The +existing elements of the compressed_matrix are +preseved when specified. - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
compressed_matrix () compressed_matrix () Allocates a compressed_matrix that holds at most zero rows of zero elements.
compressed_matrix (size_type size1, size_type2, size_type non_zeros) Allocates a compressed_matrix that holds at most size1 rows of size2 elements.
compressed_matrix (const compressed_matrix &m) The copy constructor.
template<class AE>
- compressed_matrix (size_type non_zeros, const +
template<class AE>
+compressed_matrix (size_type non_zeros, const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type size2, size_type non_zeros) Reallocates a compressed_matrix to hold at most -size1 rows of size2 elements. The content -of the compressed_matrix is preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
compressed_matrix &operator = (const compressed_matrix &m) The assignment operator.
compressed_matrix &assign_temporary (compressed_matrix &m) Assigns a temporary. May change the compressed matrix m.
template<class AE>
- compressed_matrix &operator = (const +
template<class AE>
+compressed_matrix &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- compressed_matrix &assign (const matrix_expression<AE> +
template<class AE>
+compressed_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the compressed matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- compressed_matrix &operator += (const +
template<class AE>
+compressed_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the compressed matrix.
template<class AE>
- compressed_matrix &plus_assign (const +
template<class AE>
+compressed_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the compressed matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- compressed_matrix &operator -= (const +
template<class AE>
+compressed_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the compressed matrix.
template<class AE>
- compressed_matrix &minus_assign (const +
template<class AE>
+compressed_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the compressed matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- compressed_matrix &operator *= (const AT &at)
template<class AT>
+compressed_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the compressed matrix with a scalar.
template<class AT>
- compressed_matrix &operator /= (const AT &at)
template<class AT>
+compressed_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the compressed matrix through a scalar.
void swap (compressed_matrix &m) Swaps the contents of the compressed matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th element of the i-th row.
void clear () Clears the compressed matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the compressed_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the compressed_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the compressed_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the compressed_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the compressed_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the compressed_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the compressed_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the compressed_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed compressed_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed compressed_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed compressed_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed compressed_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed compressed_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed compressed_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed compressed_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed compressed_matrix.
-

Notes

- -

[1] Supported parameters for -the storage organization are row_major and -column_major.

- -

[2] Supported parameters for -the index base are 0 and 1 at least.

- -

[3] Supported parameters for -the adapted array are unbounded_array<> , +

[1] +Supported parameters for the storage organization are +row_major and column_major.

+

[2] +Supported parameters for the index base are 0 and +1 at least.

+

[3] +Supported parameters for the adapted array are +unbounded_array<> , bounded_array<> and std::vector<> .

- -

Coordinate Matrix

- +

+Coordinate Matrix

Description

-

The templated class coordinate_matrix<T, F, IB, IA, TA> is the base container adaptor for compressed matrices. For a (m x n )-dimensional sorted coordinate @@ -787,372 +669,310 @@ j2 or (j1 i1 < i2) with column major orientation.

-

Example

-
-#include <boost/numeric/ublas/matrix_sparse.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- coordinate_matrix<double> m (3, 3, 3 * 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << m << std::endl;
-}
+#include <boost/numeric/ublas/matrix_sparse.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ coordinate_matrix<double> m (3, 3, 3 * 3);
+ for (unsigned i = 0; i < m.size1 (); ++ i)
+ for (unsigned j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
+}
-

Definition

-

Defined in the header matrix_sparse.hpp.

-

Template parameters

- - +
- - + - + - +"#coordinate_matrix_1">[1] - +"#coordinate_matrix_2">[2] - +"#coordinate_matrix_3">[3] - +"#coordinate_matrix_3">[3]
Parameter Description Default
T T The type of object stored in the coordinate matrix. 
F Functor describing the storage organization. [1] row_major
IB The index base of the coordinate vector. [2] 0
IA The type of the adapted array for indices. [3] unbounded_array<std::size_t>
TA The type of the adapted array for values. [3] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<coordinate_matrix<T, F, IB, IA, TA> >

-

Members

- - +
- - + - - - - - +size1 rows of size2 elements. The +existing elements of the coordinate_matrix are +preseved when specified. - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
coordinate_matrix () coordinate_matrix () Allocates a coordinate_matrix that holds at most zero rows of zero elements.
coordinate_matrix (size_type size1, size_type2, size_type non_zeros) Allocates a coordinate_matrix that holds at most size1 rows of size2 elements.
coordinate_matrix (const coordinate_matrix &m) The copy constructor.
template<class AE>
- coordinate_matrix (size_type non_zeros, const +
template<class AE>
+coordinate_matrix (size_type non_zeros, const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type size2, size_type non_zeros) Reallocates a coordinate_matrix to hold at most -size1 rows of size2 elements. The content -of the coordinate_matrix is preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
coordinate_matrix &operator = (const coordinate_matrix &m) The assignment operator.
coordinate_matrix &assign_temporary (coordinate_matrix &m) Assigns a temporary. May change the coordinate matrix m.
template<class AE>
- coordinate_matrix &operator = (const +
template<class AE>
+coordinate_matrix &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- coordinate_matrix &assign (const matrix_expression<AE> +
template<class AE>
+coordinate_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the coordinate matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- coordinate_matrix &operator += (const +
template<class AE>
+coordinate_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the coordinate matrix.
template<class AE>
- coordinate_matrix &plus_assign (const +
template<class AE>
+coordinate_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the coordinate matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- coordinate_matrix &operator -= (const +
template<class AE>
+coordinate_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the coordinate matrix.
template<class AE>
- coordinate_matrix &minus_assign (const +
template<class AE>
+coordinate_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the coordinate matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- coordinate_matrix &operator *= (const AT &at)
template<class AT>
+coordinate_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the coordinate matrix with a scalar.
template<class AT>
- coordinate_matrix &operator /= (const AT &at)
template<class AT>
+coordinate_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the coordinate matrix through a scalar.
void swap (coordinate_matrix &m) Swaps the contents of the coordinate matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th element of the i-th row.
void clear () Clears the coordinate matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the coordinate_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the coordinate_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the coordinate_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the coordinate_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the coordinate_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the coordinate_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the coordinate_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the coordinate_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed coordinate_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed coordinate_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed coordinate_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed coordinate_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed coordinate_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed coordinate_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed coordinate_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed coordinate_matrix.
-

Notes

- -

[1] Supported parameters for -the storage organization are row_major and -column_major.

- -

[2] Supported parameters for -the index base are 0 and 1 at least.

- -

[3] Supported parameters for -the adapted array are unbounded_array<> , +

[1] +Supported parameters for the storage organization are +row_major and column_major.

+

[2] +Supported parameters for the index base are 0 and +1 at least.

+

[3] +Supported parameters for the adapted array are +unbounded_array<> , bounded_array<> and std::vector<> .

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/overview.htm b/doc/overview.htm index fc4ea382..1246c3aa 100644 --- a/doc/overview.htm +++ b/doc/overview.htm @@ -1,62 +1,49 @@ - - + + - + - +"text/html; charset=us-ascii" /> + uBLAS Overview - -

c++boost.gif + +

c++boost.gif uBLAS Overview

-

Rationale

-

It would be nice if every kind of numeric software could be written in C++ without loss of efficiency, but unless something can be found that achieves this without compromising the C++ type system it may be preferable to rely on Fortran, assembler or architecture-specific extensions (Bjarne Stroustrup).

-

This C++ library is directed towards scientific computing on the level of basic linear algebra constructions with matrices and vectors and their corresponding abstract operations. The primary design goals were:

-
  • mathematical notation
  • -
  • efficiency
  • -
  • functionality
  • -
  • compatibility
-

Another intention was to evaluate, if the abstraction penalty resulting from the use of such matrix and vector classes is acceptable.

-

Resources

-

The development of this library was guided by a couple of similar efforts:

-
  • BLAS by Jack Dongarra et al.
  • -
  • Blitz++ by Todd Veldhuizen
  • -
  • POOMA by Scott Haney et al.
  • -
  • MTL by Jeremy Siek et al.
-

BLAS seems to be the most widely used library for basic linear algebra constructions, so it could be called a de-facto standard. Its interface is procedural, the individual functions are somewhat @@ -67,7 +54,6 @@ decided to design and implement our library in an object-oriented way, the technical approaches are distinct. However anyone should be able to express BLAS abstractions in terms of our library operators and to compare the efficiency of the implementations.

-

Blitz++ is an impressive library implemented in C++. Its main design seems to be oriented towards multidimensional arrays and their associated operators including tensors. The author of Blitz++ @@ -82,12 +68,10 @@ advanced C++ compiler technology due to its implementation idioms. On the other hand, Blitz++ convinced us, that the use of expression templates is mandatory to reduce the abstraction penalty to an acceptable limit.

-

POOMA's design goals seem to parallel Blitz++'s in many parts . It extends Blitz++'s concepts with classes from the domains of partial differential equations and theoretical physics. The implementation supports even parallel architectures.

-

MTL is another approach supporting basic linear algebra operations in C++. Its design mainly seems to be influenced by BLAS and the C++ Standard Template Library. We share the insight that a @@ -98,128 +82,109 @@ computations as needed. As another difference MTL currently does not seem to use expression templates. This may result in one of two consequences: a possible loss of expressiveness or a possible loss of performance.

-

Concepts

-

Mathematical Notation

-

The usage of mathematical notation may ease the development of scientific algorithms. So a C++ library implementing basic linear algebra concepts carefully should overload selected C++ operators on matrix and vector classes.

-

We decided to use operator overloading for the following primitives:

- - +
- - + + - - + - - + - - -
DescriptionOperatorDescriptionOperator
Indexing of vectors and matricesvector::operator(size_t i);
- matrix::operator(size_t i, size_t j);
vector::operator(size_t i);
+matrix::operator(size_t i, size_t j);
Assignment of vectors and matricesvector::operator = (const vector_expression &);
- vector::operator += (const vector_expression &);
- vector::operator -= (const vector_expression &);
- vector::operator *= (const scalar_expression &);
- matrix::operator = (const matrix_expression &);
- matrix::operator += (const matrix_expression &);
- matrix::operator -= (const matrix_expression &);
- matrix::operator *= (const scalar_expression &);
vector::operator = (const vector_expression &);
+vector::operator += (const vector_expression &);
+vector::operator -= (const vector_expression &);
+vector::operator *= (const scalar_expression &);
+matrix::operator = (const matrix_expression &);
+matrix::operator += (const matrix_expression &);
+matrix::operator -= (const matrix_expression &);
+matrix::operator *= (const scalar_expression &);
Unary operations on vectors and matrices vector_expression operator - (const vector_expression -&);
- matrix_expression operator - (const matrix_expression +&);
+matrix_expression operator - (const matrix_expression &);
Binary operations on vectors and matrices vector_expression operator + (const vector_expression -&, const vector_expression &);
- vector_expression operator - (const vector_expression &, const -vector_expression &);
- matrix_expression operator + (const matrix_expression &, const -matrix_expression &);
- matrix_expression operator - (const matrix_expression &, const +&, const vector_expression &);
+vector_expression operator - (const vector_expression &, const +vector_expression &);
+matrix_expression operator + (const matrix_expression &, const +matrix_expression &);
+matrix_expression operator - (const matrix_expression &, const matrix_expression &);
Multiplication of vectors and matrices with a scalar vector_expression operator * (const scalar_expression -&, const vector_expression &);
- vector_expression operator * (const vector_expression &, const -scalar_expression &);
- matrix_expression operator * (const scalar_expression &, const -matrix_expression &);
- matrix_expression operator * (const matrix_expression &, const +&, const vector_expression &);
+vector_expression operator * (const vector_expression &, const +scalar_expression &);
+matrix_expression operator * (const scalar_expression &, const +matrix_expression &);
+matrix_expression operator * (const matrix_expression &, const scalar_expression &);
-

We decided to use no operator overloading for the following other primitives:

- - +
- - + + - - +vector_expression &, const matrix_expression &);
+vector_expression prod (const vector_expression &, const +matrix_expression &);
- - - -
DescriptionFunctionDescriptionFunction
Left multiplication of vectors with a matrix vector_expression prod<vector_type > (const -matrix_expression &, const vector_expression &);
- vector_expression prod (const matrix_expression &, const +matrix_expression &, const vector_expression &);
+vector_expression prod (const matrix_expression &, const vector_expression &);
Right multiplication of vectors with a matrix vector_expression prod<vector_type > (const -vector_expression &, const matrix_expression &);
- vector_expression prod (const vector_expression &, const -matrix_expression &);
-
Multiplication of matrices matrix_expression prod<matrix_type > (const -matrix_expression &, const matrix_expression &);
- matrix_expression prod (const matrix_expression &, const +matrix_expression &, const matrix_expression &);
+matrix_expression prod (const matrix_expression &, const matrix_expression &);
Inner product of vectors scalar_expression inner_prod (const vector_expression &, const vector_expression &);
Outer product of vectors matrix_expression outer_prod (const vector_expression &, const vector_expression &);
Transpose of a matrix matrix_expression trans (const matrix_expression @@ -227,17 +192,13 @@ matrix_expression &);
-

Efficiency

-

To achieve the goal of efficiency for numerical computing, one has to overcome two difficulties in formulating abstractions with C++, namely temporaries and virtual function calls. Expression templates solve these problems, but tend to slow down compilation times.

-

Eliminating Temporaries

-

Abstract formulas on vectors and matrices normally compose a couple of unary and binary operations. The conventional way of evaluating such a formula is first to evaluate every leaf operation @@ -249,9 +210,7 @@ to use lazy evaluation as known from modern functional programming languages. The principle of this approach is to evaluate a complex expression element wise and to assign it directly to the target.

-

Two interesting and dangerous facts result.

-

First one may get serious side effects using element wise evaluation on vectors or matrices. Consider the matrix vector product x = A x. Evaluation of @@ -266,7 +225,6 @@ for every assignment operator. By using this member function a programmer can confirm, that the left and right hand sides of an assignment are independent, so that element wise evaluation and direct assignment to the target is safe.

-

Next one can get worse computational complexity under certain cirumstances. Consider the chained matrix vector product A (B x). Conventional evaluation of A (B x) is quadratic. @@ -276,9 +234,7 @@ linearly depending of the size, a completely deferred evaluation of the chained matrix vector product A (B x) is cubic. In such cases one needs to reintroduce temporaries in the expression.

-

Eliminating Virtual Function Calls

-

Lazy expression evaluation normally leads to the definition of a class hierarchy of terms. This results in the usage of dynamic polymorphism to access single elements of vectors and matrices, @@ -290,16 +246,12 @@ polymorphism with static, i.e. compile time polymorphism. Expression templates heavily depend on the famous Barton-Nackman trick, also coined 'curiously defined recursive templates' by Jim Coplien.

-

Expression templates form the base of our implementation.

-

Compilation times

-

It is also a well known fact, that expression templates challenge currently available compilers. We were able to significantly reduce the amount of needed expression templates using the Barton-Nackman trick consequently.

-

We also decided to support a dual conventional implementation (i.e. not using expression templates) with extensive bounds and type checking of vector and matrix operations to support the @@ -313,24 +265,25 @@ controlled by the NDEBUG preprocessor symbol of against the long-standing Fortran package BLAS. We now describe how BLAS calls may be mapped onto our classes.

-

Blas Level 1

+

The page Overview of Matrix and Vector Operations +gives a short summary of the most used operations on vectors and +matrices.

- +

Blas Level 1

+
- - - - + + + + - - + - @@ -338,310 +291,287 @@ BLAS calls may be mapped onto our classes.

|xi|2) - - + - - - - - - + + + + - - + - - + - + - - + - - + - + - - + - - - + + - - + - +
BLAS CallMapped Library ExpressionMathematical DescriptionCommentBLAS CallMapped Library ExpressionMathematical DescriptionComment
_asumnorm_1 (x) norm_1 (x) sum |xi| Computes the sum norm of a vector.
_nrm2 norm_2 (x) Computes the euclidean norm of a vector.
i_amaxnorm_inf (x)
- norm_inf_index (x)
norm_inf (x)
+norm_inf_index (x)
max |xi|Computes the maximum norm of a vector.
- BLAS computes the index of the first element having this +
Computes the maximum norm of a vector.
+BLAS computes the index of the first element having this value.
_dot
- _dotu
- _dotc
inner_prod (x, y)or
- inner_prod (conj (x), y)
xT y or
- xH y
Computes the inner product of two vectors.
- BLAS implements certain loop unrollment.
_dot
+_dotu
+_dotc
inner_prod (x, y)or
+inner_prod (conj (x), y)
xT y or
+xH y
Computes the inner product of two vectors.
+BLAS implements certain loop unrollment.
dsdot
- sdsdot
dsdot
+sdsdot
a + prec_inner_prod (x, y) a + xT y Computes the inner product in double precision.
_copyx = y
- y.assign (x)
x = y
+y.assign (x)
x <- yCopies one vector to another.
- BLAS implements certain loop unrollment.
Copies one vector to another.
+BLAS implements certain loop unrollment.
_swap swap (x, y) x <-> ySwaps two vectors.
- BLAS implements certain loop unrollment.
Swaps two vectors.
+BLAS implements certain loop unrollment.
_scal
- csscal
- zdscal
_scal
+csscal
+zdscal
x *= a x <- a xScales a vector.
- BLAS implements certain loop unrollment.
Scales a vector.
+BLAS implements certain loop unrollment.
_axpy y += a * x y <- a x + yAdds a scaled vector.
- BLAS implements certain loop unrollment.
Adds a scaled vector.
+BLAS implements certain loop unrollment.
_rot
- _rotm
- csrot
- zdrot
t.assign (a * x + b * y),
- y.assign (- b * x + a * y),
- x.assign (t)
_rot
+_rotm
+csrot
+zdrot
t.assign (a * x + b * y),
+y.assign (- b * x + a * y),
+x.assign (t)
(x, y) <- (a x + b y, -b x + a y) Applies a plane rotation.
_rotg
- _rotmg
_rotg
+_rotmg
 (a, b) <-
-   (? a / sqrt (a
2 + -b2),
-     ? b / sqrt (a
2 + -b2)) or
- (1, 0) <- (0, 0)
(a, b) <-
+  (? a / sqrt (a
2 + +b2),
+    ? b / sqrt (a
2 + +b2)) or
+(1, 0) <- (0, 0)
Constructs a plane rotation.
-

Blas Level 2

- - +
- - - - + + + + - - - + + - - - + + - - - - + + + - - - + + +or
+A <- a x y
H+ A - - - + + +or
+A <- a x x
H+ A - - - + + +A
BLAS CallMapped Library ExpressionMathematical DescriptionCommentBLAS CallMapped Library ExpressionMathematical DescriptionComment
_t_mvx = prod (A, x) or
- x = prod (trans (A), x)
or
- x = prod (herm (A), x)
x <- A x or
- x <- A
T x or
- x <- A
H x
x = prod (A, x) or
+x = prod (trans (A), x)
or
+x = prod (herm (A), x)
x <- A x or
+x <- A
T x or
+x <- A
H x
Computes the product of a matrix with a vector.
_t_svy = solve (A, x, tag) or
- inplace_solve (A, x, tag) or
- y = solve (trans (A), x, tag) or
- inplace_solve (trans (A), x, tag)
or
-
y = solve (herm (A), x, -tag)or
- inplace_solve (herm (A), x, tag)
y <- A-1 x or
- x <- A
-1 x or
- y <- +
y = solve (A, x, tag) or
+inplace_solve (A, x, tag) or
+y = solve (trans (A), x, tag) or
+inplace_solve (trans (A), x, tag) or
+y = solve (herm (A), x, tag)or
+inplace_solve (herm (A), x, tag)
y <- A-1 x +or
+x <- A
-1 x or
+y <- A
T-1 -x or
- x <- +x or
+x <- A
T-1 -x or
- y <- +x or
+y <- A
H-1 -x or
- x <- +x or
+x <- A
H-1 x
Solves a system of linear equations with triangular form, i.e. A is triangular.
_g_mv
- _s_mv
- _h_mv
y = a * prod (A, x) + b * y or
- y = a * prod (trans (A), x) + b * y
or
- y = a * prod (herm (A), x) + b * y
y <- a A x + b y or
- y <- a A
T x + b y
- y <- a A
H x + b y
_g_mv
+_s_mv
+_h_mv
y = a * prod (A, x) + b * y or
+y = a * prod (trans (A), x) + b * y
or
+y = a * prod (herm (A), x) + b * y
y <- a A x + b y or
+y <- a A
T x + b y
+y <- a A
H x + b y
Adds the scaled product of a matrix with a vector.
_g_r
- _g_ru
- _g_rc
A += a * outer_prod (x, y) or
- A += a * outer_prod (x, conj (y))
_g_r
+_g_ru
+_g_rc
A += a * outer_prod (x, y) or
+A += a * outer_prod (x, conj (y))
A <- a x yT + A -or
- A <- a x y
H + A
Performs a rank 1 update.
_s_r
- _h_r
A += a * outer_prod (x, x) or
- A += a * outer_prod (x, conj (x))
_s_r
+_h_r
A += a * outer_prod (x, x) or
+A += a * outer_prod (x, conj (x))
A <- a x xT + A -or
- A <- a x x
H + A
Performs a symmetric or hermitian rank 1 update.
_s_r2
- _h_r2
A += a * outer_prod (x, y) +
-  a * outer_prod (y, x))
or
- A += a * outer_prod (x, conj (y)) +
-  conj (a) * outer_prod (y, conj (x)))
_s_r2
+_h_r2
A += a * outer_prod (x, y) +
+ a * outer_prod (y, x))
or
+A += a * outer_prod (x, conj (y)) +
+ conj (a) * outer_prod (y, conj (x)))
A <- a x yT + a y -xT + A or
- A <- a x y
H + +xT + A or
+A <- a x y
H + a- y xH + -A
Performs a symmetric or hermitian rank 2 update.
-

Blas Level 3

- - +
- - - - + + + + - - - + + - - - + - - - - + + + - - - + + +or
+B <- a A
TA + b B or
+B <- a A AH+ b B +or
+B <- a A
HA + b B - - - + +
BLAS CallMapped Library ExpressionMathematical DescriptionCommentBLAS CallMapped Library ExpressionMathematical DescriptionComment
_t_mmB = a * prod (A, B) or
- B = a * prod (trans (A), B) or
- B = a * prod (A, trans (B)) or
- B = a * prod (trans (A), trans (B)) or
- B = a * prod (herm (A), B) or
- B = a * prod (A, herm (B)) or
- B = a * prod (herm (A), trans (B)) or
- B = a * prod (trans (A), herm (B)) or
- B = a * prod (herm (A), herm (B))
B <- a op (A) op (B) with
-   op (X) = X or
-   op (X) = XT or
-   op (X) = XH
B = a * prod (A, B) or
+B = a * prod (trans (A), B) or
+B = a * prod (A, trans (B)) or
+B = a * prod (trans (A), trans (B)) or
+B = a * prod (herm (A), B) or
+B = a * prod (A, herm (B)) or
+B = a * prod (herm (A), trans (B)) or
+B = a * prod (trans (A), herm (B)) or
+B = a * prod (herm (A), herm (B))
B <- a op (A) op (B) with
op (X) = X or
op (X) = XT or
op (X) = XH
Computes the scaled product of two matrices.
_t_smC = solve (A, B, tag) or
- inplace_solve (A, B, tag) or
- C = solve (trans (A), B, tag) or
- inplace_solve (trans (A), B, tag)
or
- C = solve (herm (A), B, tag)
or
- inplace_solve (herm (A), B, tag)
C <- A-1 B or
- B <- A
-1 B or
- C <- +
C = solve (A, B, tag) or
+inplace_solve (A, B, tag) or
+C = solve (trans (A), B, tag) or
+inplace_solve (trans (A), B, tag)
or
+C = solve (herm (A), B, tag)
or
+inplace_solve (herm (A), B, tag)
C <- A-1 B +or
+B <- A
-1 B or
+C <- A
T-1 -B or
- B <- A
-1 B or
- C <- +B or
+B <- A
-1 B or
+C <- A
H-1 -B or
- B <- +B or
+B <- A
H-1 B
Solves a system of linear equations with triangular form, i.e. A is triangular.
_g_mm
- _s_mm
- _h_mm
C = a * prod (A, B) + b * C or
- C = a * prod (trans (A), B) + b * C or
- C = a * prod (A, trans (B)) + b * C or
- C = a * prod (trans (A), trans (B)) + b * C or
- C = a * prod (herm (A), B) + b * C or
- C = a * prod (A, herm (B)) + b * C or
- C = a * prod (herm (A), trans (B)) + b * C or
- C = a * prod (trans (A), herm (B)) + b * C or
- C = a * prod (herm (A), herm (B)) + b * C
C <- a op (A) op (B) + b C with
-   op (X) = X or
-   op (X) = XT or
-   op (X) = XH
_g_mm
+_s_mm
+_h_mm
C = a * prod (A, B) + b * C or
+C = a * prod (trans (A), B) + b * C or
+C = a * prod (A, trans (B)) + b * C or
+C = a * prod (trans (A), trans (B)) + b * C or
+C = a * prod (herm (A), B) + b * C or
+C = a * prod (A, herm (B)) + b * C or
+C = a * prod (herm (A), trans (B)) + b * C or
+C = a * prod (trans (A), herm (B)) + b * C or
+C = a * prod (herm (A), herm (B)) + b * C
C <- a op (A) op (B) + b C with
op (X) = X or
op (X) = XT or
op (X) = XH
Adds the scaled product of two matrices.
_s_rk
- _h_rk
B = a * prod (A, trans (A)) + b * B or
- B = a * prod (trans (A), A) + b * B or
- B = a * prod (A, herm (A)) + b * B or
- B = a * prod (herm (A), A) + b * B
_s_rk
+_h_rk
B = a * prod (A, trans (A)) + b * B or
+B = a * prod (trans (A), A) + b * B or
+B = a * prod (A, herm (A)) + b * B or
+B = a * prod (herm (A), A) + b * B
B <- a A AT + b B -or
- B <- a A
T A + b B or
- B <- a A AH + b B -or
- B <- a A
H A + b B
Performs a symmetric or hermitian rank k update.
_s_r2k
- _h_r2k
C = a * prod (A, trans (B)) +
-  a * prod (B, trans (A)) + b * C
or
- C = a * prod (trans (A), B) +
-  a * prod (trans (B), A) + b * C
or
- C = a * prod (A, herm (B)) +
-  conj (a) * prod (B, herm (A)) + b * C
or
- C = a * prod (herm (A), B) +
-  conj (a) * prod (herm (B), A) + b * C
_s_r2k
+_h_r2k
C = a * prod (A, trans (B)) +
+ a * prod (B, trans (A)) + b * C
or
+C = a * prod (trans (A), B) +
+ a * prod (trans (B), A) + b * C
or
+C = a * prod (A, herm (B)) +
+ conj (a) * prod (B, herm (A)) + b * C
or
+C = a * prod (herm (A), B) +
+ conj (a) * prod (herm (B), A) + b * C
C <- a A BT + a B -AT + b C or
- C <- a A
T B + a -BT A + b C or
- C <- a A B
H + +AT + b C or
+C <- a A
T B + a +BT A + b C or
+C <- a A B
H + a- B AH + -b C or
- C <- a A
H B + +b C or
+C <- a A
H B + a- BH A + b C
Performs a symmetric or hermitian rank 2 k @@ -650,625 +580,34 @@ update.
-

Storage Layouts

+

Storage Layout

-

The library supports conventional dense, packed and basic sparse -vector and matrix storage layouts. The description of the most -common constructions of vectors and matrices comes next.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ConstructionComment
vector<T,
-  std::vector<T> >
-   v (size)
Constructs a dense vector, storage is provided by a standard -vector.
- The storage layout usually is BLAS compliant.
vector<T,
-  unbounded_array<T> >
-   v (size)
Constructs a dense vector, storage is provided by a heap-based -array.
- The storage layout usually is BLAS compliant.
vector<T,
-  bounded_array<T, N> >
-   v (size)
Constructs a dense vector, storage is provided by a stack-based -array.
- The storage layout usually is BLAS compliant.
unit_vector<T>
-   v (size, index)
Constructs the index-th canonical unit -vector.
zero_vector<T>
-   v (size)
Constructs a zero vector.
sparse_vector<T,
-  std::map<std::size_t, T> >
-   v (size, non_zeros)
Constructs a sparse vector, storage is provided by a standard -map.
sparse_vector<T,
-  map_array<std::size_t, T> >
-   v (size, non_zeros)
Constructs a sparse vector, storage is provided by a map -array.
compressed_vector<T>
-   v (size, non_zeros)
Constructs a compressed vector.
- The storage layout usually is BLAS compliant.
coordinate_vector<T>
-   v (size, non_zeros)
Constructs a coordinate vector.
- The storage layout usually is BLAS compliant.
vector_range<V>
-   vr (v, range)
Constructs a sub vector of a dense, packed or sparse -vector.
vector_slice<V>
-   vs (v, slice)
Constructs a sub vector of a dense, packed or sparse -vector.
- This class usually can be used to emulate BLAS vector slices.
matrix<T,
-  row_major,
-  std::vector<T> >
-   m (size1, size2)
Constructs a dense matrix, orientation is row major, storage is -provided by a standard vector.
matrix<T,
-  column_major,
-  std::vector<T> >
-   m (size1, size2)
Constructs a dense matrix, orientation is column major, storage -is provided by a standard vector.
- The storage layout usually is BLAS compliant.
matrix<T,
-  row_major,
-  unbounded_array<T> >
-   m (size1, size2)
Constructs a dense matrix, orientation is row major, storage is -provided by a heap-based array.
matrix<T,
-  column_major,
-  unbounded_array<T> >
-   m (size1, size2)
Constructs a dense matrix, orientation is column major, storage -is provided by a heap-based array.
- The storage layout usually is BLAS compliant.
matrix<T,
-  row_major,
-  bounded_array<T, N1 * N2> >
-   m (size1, size2)
Constructs a dense matrix, orientation is row major, storage is -provided by a stack-based array.
matrix<T,
-  column_major,
-  bounded_array<T, N1 * N2> >
-   m (size1, size2)
Constructs a dense matrix, orientation is column major, storage -is provided by a stack-based array.
- The storage layout usually is BLAS compliant.
identity_matrix<T>
-   m (size)
Constructs an identity matrix.
zero_matrix<T>
-   m (size1, size2)
Constructs a zero matrix.
triangular_matrix<T,
-  row_major, F, A>
-   m (size)
Constructs a packed triangular matrix, orientation is row -major.
triangular_matrix<T,
-  column_major, F, A>
-   m (size)
Constructs a packed triangular matrix, orientation is column -major.
- The storage layout usually is BLAS compliant.
banded_matrix<T,
-  row_major, A>
-   m (size1, size2, lower, upper)
Constructs a packed banded matrix, orientation is row -major.
banded_matrix<T,
-  column_major, A>
-   m (size1, size2, lower, upper)
Constructs a packed banded matrix, orientation is column -major.
- The storage layout usually is BLAS compliant.
symmetric_matrix<T,
-  row_major, F, A>
-   m (size)
Constructs a packed symmetric matrix, orientation is row -major.
symmetric_matrix<T,
-  column_major, F, A>
-   m (size)
Constructs a packed symmetric matrix, orientation is column -major.
- The storage layout usually is BLAS compliant.
hermitian_matrix<T,
-  row_major, F, A>
-   m (size)
Constructs a packed hermitian matrix, orientation is row -major.
hermitian_matrix<T,
-  column_major, F, A>
-   m (size)
Constructs a packed hermitian matrix, orientation is column -major.
- The storage layout usually is BLAS compliant.
sparse_matrix<T,
-  row_major,
-  std::map<std::size_t, T> >
-   m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is row major, storage -is provided by a standard map.
sparse_matrix<T,
-  column_major,
-  std::map<std::size_t, T> >
-   m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is column major, -storage is provided by a standard map.
sparse_matrix<T,
-  row_major,
-  map_array<std::size_t, T> >
-   m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is row major, storage -is provided by a map array.
sparse_matrix<T,
-  column_major,
-  map_array<std::size_t, T> >
-   m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is column major, -storage is provided by a map array.
compressed_matrix<T,
-  row_major>
-   m (size1, size2, non_zeros)
Constructs a compressed matrix, orientation is row major.
- The storage layout usually is BLAS compliant.
compressed_matrix<T,
-  column_major>
-   m (size1, size2, non_zeros)
Constructs a compressed matrix, orientation is column -major.
- The storage layout usually is BLAS compliant.
coordinate_matrix<T,
-  row_major>
-   m (size1, size2, non_zeros)
Constructs a coordinate matrix, orientation is row major.
- The storage layout usually is BLAS compliant.
coordinate_matrix<T,
-  column_major>
-   m (size1, size2, non_zeros)
Constructs a coordinate matrix, orientation is column -major.
- The storage layout usually is BLAS compliant.
matrix_row<M>
-   mr (m, i)
Constructs a sub vector of a dense, packed or sparse matrix, -containing the i-th row.
matrix_column<M>
-   mc (m, j)
Constructs a sub vector of a dense, packed or sparse matrix, -containing the j-th column.
matrix_range<M>
-   mr (m, range1, range2)
Constructs a sub matrix of a dense, packed or sparse -matrix.
- This class usually can be used to emulate BLAS leading -dimensions.
matrix_slice<M>
-   ms (m, slice1, slice2)
Constructs a sub matrix of a dense, packed or sparse -matrix.
triangular_adaptor<M, F>
-   ta (m)
Constructs a triangular view of a dense, packed or sparse -matrix.
- This class usually can be used to generate corresponding BLAS -matrix types.
banded_adaptor<M>
-   ba (m, lower, upper)
Constructs a banded view of a dense, packed or sparse -matrix.
- This class usually can be used to generate corresponding BLAS -matrix types.
symmetric_adaptor<M>
-   sa (m)
Constructs a symmetric view of a dense, packed or sparse -matrix.
- This class usually can be used to generate corresponding BLAS -matrix types.
hermitian_adaptor<M>
-   ha (m)
Constructs a hermitian view of a dense, packed or sparse -matrix.
- This class usually can be used to generate corresponding BLAS -matrix types.
- -

Compatibility

+

uBLAS supports may different storage layouts. The full details can be +found at the Overview of Types. Most types like +vector<double> and matrix<double> are +by default compatible to C arrays, but can also be configured to contain +FORTAN compatible data. +

+

Compatibility

For compatibility reasons we provide array like indexing for vectors and matrices, although this could be expensive for matrices due to the needed temporary proxy objects.

-

To support the most widely used C++ compilers our design and implementation do not depend on partial template specialization essentially.

-

The library presumes standard compliant allocation through operator new and operator delete. So programs which are intended to run under MSVC 6.0 should set a correct new handler throwing a std::bad_alloc exception via _set_new_handler to detect out of memory conditions.

-

To get the most performance out of the box with MSVC 6.0, you should change the preprocessor definition of BOOST_UBLAS_INLINE to __forceinline in the header file config.hpp. But we suspect this optimization to be fragile.

- -

Reference

- - -

Benchmark Results

-

The following tables contain results of one of our benchmarks. This benchmark compares a native C implementation ('C array') and some library based implementations. The safe variants based on the @@ -1278,559 +617,472 @@ Besides the generic vector and matrix classes the benchmark utilizes special classes c_vector and c_matrix, which are intended to avoid every overhead through genericity.

-

The benchmark program was compiled with MSVC 6.0 and run on an Intel Pentium II with 333 Mhz. First we comment the results for double vectors and matrices of dimension 3 and 3 x 3, respectively.

- - +
- - - - - + + + + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + +
OperationImplementationElapsed [s]MFLOP/sCommentOperationImplementationElapsed [s]MFLOP/sComment
inner_prod C array0.147.68370.147.6837 No significant abstraction penalty
c_vector0.0679.47290.0679.4729
vector<unbounded_array>0.1143.34880.1143.3488
vector<std::vector>0.1143.34880.1143.3488
vector + vector C array0.05114.4410.05114.441 Abstraction penalty: factor 2
c_vector safe0.2226.00930.2226.0093
c_vector fast0.1152.01860.1152.0186
vector<unbounded_array> safe1.055.449571.055.44957
vector<unbounded_array> fast0.1635.76280.1635.7628
vector<std::vector> safe1.164.93281.164.9328
vector<std::vector> fast0.1635.76280.1635.7628
outer_prod C array0.0685.83070.0685.8307 Abstraction penalty: factor 2
c_matrix, c_vector safe0.2223.40840.2223.4084
c_matrix, c_vector fast0.1146.81670.1146.8167
matrix<unbounded_array>, vector<unbounded_array> safe0.3813.55220.3813.5522
matrix<unbounded_array>, vector<unbounded_array> fast0.1632.18650.1632.1865
matrix<std::vector>, vector<std::vector> safe0.510.29970.510.2997
matrix<std::vector>, vector<std::vector> fast0.1146.81670.1146.8167
prod (matrix, vector) C array0.0671.52560.0671.5256 No significant abstraction penalty
c_matrix, c_vector safe0.1139.01390.1139.0139
c_matrix, c_vector fast0.1139.01390.1139.0139
matrix<unbounded_array>, vector<unbounded_array> safe0.3313.00460.3313.0046
matrix<unbounded_array>, vector<unbounded_array> fast0.1139.01390.1139.0139
matrix<std::vector>, vector<std::vector> safe0.3811.29350.3811.2935
matrix<std::vector>, vector<std::vector> fast0.0585.83070.0585.8307
matrix + matrix C array0.1146.81670.1146.8167 No significant abstraction penalty
c_matrix safe0.1730.29320.1730.2932
c_matrix fast0.1146.81670.1146.8167
matrix<unbounded_array> safe0.4411.70420.4411.7042
matrix<unbounded_array> fast0.1632.18650.1632.1865
matrix<std::vector> safe0.68.583070.68.58307
matrix<std::vector> fast0.1730.29320.1730.2932
prod (matrix, matrix) C array0.1139.01390.1139.0139 No significant abstraction penalty
c_matrix safe0.1139.01390.1139.0139
c_matrix fast0.1139.01390.1139.0139
matrix<unbounded_array> safe0.2219.5070.2219.507
matrix<unbounded_array> fast0.1139.01390.1139.0139
matrix<std::vector> safe0.2715.89460.2715.8946
matrix<std::vector> fast0.1139.01390.1139.0139
-

We notice a twofold performance loss for small vectors and matrices: first the general abstraction penalty for using classes, and then a small loss when using the generic vector and matrix classes. The difference w.r.t. alias assumptions is also significant.

-

Next we comment the results for double vectors and matrices of dimension 100 and 100 x 100, respectively.

- - +
- - - - - + + + + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + +
OperationImplementationElapsed [s]MFLOP/sCommentOperationImplementationElapsed [s]MFLOP/sComment
inner_prod C array0.05113.8690.05113.869 No significant abstraction penalty
c_vector0.0694.89060.0694.8906
vector<unbounded_array>0.05113.8690.05113.869
vector<std::vector>0.0694.89060.0694.8906
vector + vector C array0.05114.4410.05114.441 No significant abstraction penalty
c_vector safe0.1152.01860.1152.0186
c_vector fast0.1152.01860.1152.0186
vector<unbounded_array> safe0.1152.01860.1152.0186
vector<unbounded_array> fast0.0695.36740.0695.3674
vector<std::vector> safe0.1733.65910.1733.6591
vector<std::vector> fast0.1152.01860.1152.0186
outer_prod C array0.05114.4410.05114.441 No significant abstraction penalty
c_matrix, c_vector safe0.2820.43590.2820.4359
c_matrix, c_vector fast0.1152.01860.1152.0186
matrix<unbounded_array>, vector<unbounded_array> safe0.2721.19280.2721.1928
matrix<unbounded_array>, vector<unbounded_array> fast0.0695.36740.0695.3674
matrix<std::vector>, vector<std::vector> safe0.2820.43590.2820.4359
matrix<std::vector>, vector<std::vector> fast0.1152.01860.1152.0186
prod (matrix, vector) C array0.1151.75850.1151.7585 No significant abstraction penalty
c_matrix, c_vector safe0.1151.75850.1151.7585
c_matrix, c_vector fast0.05113.8690.05113.869
matrix<unbounded_array>, vector<unbounded_array> safe0.1151.75850.1151.7585
matrix<unbounded_array>, vector<unbounded_array> fast0.0694.89060.0694.8906
matrix<std::vector>, vector<std::vector> safe0.156.93440.156.9344
matrix<std::vector>, vector<std::vector> fast0.0694.89060.0694.8906
matrix + matrix C array0.2226.00930.2226.0093 No significant abstraction penalty
c_matrix safe0.4911.67760.4911.6776
c_matrix fast0.2226.00930.2226.0093
matrix<unbounded_array> safe0.3914.67190.3914.6719
matrix<unbounded_array> fast0.2226.00930.2226.0093
matrix<std::vector> safe0.4413.00460.4413.0046
matrix<std::vector> fast0.2721.19280.2721.1928
prod (matrix, matrix) C array0.0694.89060.0694.8906 No significant abstraction penalty
c_matrix safe0.0694.89060.0694.8906
c_matrix fast0.05113.8690.05113.869
matrix<unbounded_array> safe0.1151.75850.1151.7585
matrix<unbounded_array> fast0.1733.49080.1733.4908
matrix<std::vector> safe0.1151.75850.1151.7585
matrix<std::vector> fast0.1635.5840.1635.584
-

For larger vectors and matrices the general abstraction penalty for using classes seems to decrease, the small loss when using generic vector and matrix classes seems to remain. The difference w.r.t. alias assumptions remains visible, too.

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

- -

Last revised: 1/15/2003

+

Last revised: 2004-07-05

- diff --git a/doc/readme.txt b/doc/readme.txt index c70c8ed9..27224f7c 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,10 +1,5 @@ Welcome to the evaluation of our C++ matrix library. -Installation: -Extract the zip-file to a (new) directory of your choice. Workspace and -project files for MSVC and Jamfiles for the Boost build system are contained -within the archive. - Tests and benchmarks: Test1 contains a couple of basic tests for dense vectors and matrices. Test2 demonstrates how to emulate BLAS with this matrix library. @@ -20,6 +15,3 @@ Bench2 measures the performance of sparse matrix and vector operations. Bench3 measures the performance of vector and matrix proxy's operations. Bench4 measures the abstraction penalty using certain dense matrix and vector operations with boost::numeric::interval(s). - -If you have any problems installing or using the library, please feel free to contact -us at mailto:ublas@genesys-e.org diff --git a/doc/samples/banded_adaptor.cpp b/doc/samples/banded_adaptor.cpp index 08f8f7f5..61552021 100644 --- a/doc/samples/banded_adaptor.cpp +++ b/doc/samples/banded_adaptor.cpp @@ -22,7 +22,7 @@ int main () { matrix m (3, 3); banded_adaptor > ba (m, 1, 1); for (signed i = 0; i < signed (ba.size1 ()); ++ i) - for (signed j = (std::max)(i - 1, 0); j < (std::min)(i + 2, signed (ba.size2 ())); ++ j) + for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (ba.size2 ())); ++ j) ba (i, j) = 3 * i + j; std::cout << ba << std::endl; } diff --git a/doc/samples/banded_matrix.cpp b/doc/samples/banded_matrix.cpp index 7289a99c..68ee4d39 100644 --- a/doc/samples/banded_matrix.cpp +++ b/doc/samples/banded_matrix.cpp @@ -21,7 +21,7 @@ int main () { using namespace boost::numeric::ublas; banded_matrix m (3, 3, 1, 1); for (signed i = 0; i < signed (m.size1 ()); ++ i) - for (signed j = (std::max)(i - 1, 0); j < (std::min)(i + 2, signed (m.size2 ())); ++ j) + for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (m.size2 ())); ++ j) m (i, j) = 3 * i + j; std::cout << m << std::endl; } diff --git a/doc/samples/matrix_binary.cpp b/doc/samples/matrix_binary.cpp index 9ec41455..e4f67bf1 100644 --- a/doc/samples/matrix_binary.cpp +++ b/doc/samples/matrix_binary.cpp @@ -20,8 +20,8 @@ int main () { using namespace boost::numeric::ublas; matrix m1 (3, 3), m2 (3, 3); - for (unsigned i = 0; i < (std::min)(m1.size1 (), m2.size1 ()); ++ i) - for (unsigned j = 0; j < (std::min)(m1.size2 (), m2.size2 ()); ++ j) + for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i) + for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j) m1 (i, j) = m2 (i, j) = 3 * i + j; std::cout << m1 + m2 << std::endl; diff --git a/doc/samples/matrix_matrix_binary.cpp b/doc/samples/matrix_matrix_binary.cpp index 6a8957d4..45b58efc 100644 --- a/doc/samples/matrix_matrix_binary.cpp +++ b/doc/samples/matrix_matrix_binary.cpp @@ -20,8 +20,8 @@ int main () { using namespace boost::numeric::ublas; matrix m1 (3, 3), m2 (3, 3); - for (unsigned i = 0; i < (std::min)(m1.size1 (), m2.size1 ()); ++ i) - for (unsigned j = 0; j < (std::min)(m1.size2 (), m2.size2 ()); ++ j) + for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i) + for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j) m1 (i, j) = m2 (i, j) = 3 * i + j; std::cout << prod (m1, m2) << std::endl; diff --git a/doc/samples/matrix_matrix_solve.cpp b/doc/samples/matrix_matrix_solve.cpp index 3bb89fce..7b92c6d3 100644 --- a/doc/samples/matrix_matrix_solve.cpp +++ b/doc/samples/matrix_matrix_solve.cpp @@ -20,7 +20,7 @@ int main () { using namespace boost::numeric::ublas; matrix m1 (3, 3), m2 (3, 3); - for (unsigned i = 0; i < (std::min)(m1.size1 (), m2.size1 ()); ++ i) + for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i) for (unsigned j = 0; j <= i; ++ j) m1 (i, j) = m2 (i, j) = 3 * i + j + 1; diff --git a/doc/samples/matrix_vector_binary.cpp b/doc/samples/matrix_vector_binary.cpp index d1028042..39e4edf6 100644 --- a/doc/samples/matrix_vector_binary.cpp +++ b/doc/samples/matrix_vector_binary.cpp @@ -21,7 +21,7 @@ int main () { using namespace boost::numeric::ublas; matrix m (3, 3); vector v (3); - for (unsigned i = 0; i < (std::min)(m.size1 (), v.size ()); ++ i) { + for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) { for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; v (i) = i; diff --git a/doc/samples/matrix_vector_solve.cpp b/doc/samples/matrix_vector_solve.cpp index b5487329..1f432482 100644 --- a/doc/samples/matrix_vector_solve.cpp +++ b/doc/samples/matrix_vector_solve.cpp @@ -21,7 +21,7 @@ int main () { using namespace boost::numeric::ublas; matrix m (3, 3); vector v (3); - for (unsigned i = 0; i < (std::min)(m.size1 (), v.size ()); ++ i) { + for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) { for (unsigned j = 0; j <= i; ++ j) m (i, j) = 3 * i + j + 1; v (i) = i; diff --git a/doc/samples/vector_binary.cpp b/doc/samples/vector_binary.cpp index 5ab27b19..d664c1d4 100644 --- a/doc/samples/vector_binary.cpp +++ b/doc/samples/vector_binary.cpp @@ -20,7 +20,7 @@ int main () { using namespace boost::numeric::ublas; vector v1 (3), v2 (3); - for (unsigned i = 0; i < (std::min)(v1.size (), v2.size ()); ++ i) + for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i) v1 (i) = v2 (i) = i; std::cout << v1 + v2 << std::endl; diff --git a/doc/samples/vector_binary_outer.cpp b/doc/samples/vector_binary_outer.cpp index 95482fb2..42fa2569 100644 --- a/doc/samples/vector_binary_outer.cpp +++ b/doc/samples/vector_binary_outer.cpp @@ -20,7 +20,7 @@ int main () { using namespace boost::numeric::ublas; vector v1 (3), v2 (3); - for (unsigned i = 0; i < (std::min)(v1.size (), v2.size ()); ++ i) + for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i) v1 (i) = v2 (i) = i; std::cout << outer_prod (v1, v2) << std::endl; diff --git a/doc/samples/vector_binary_redux.cpp b/doc/samples/vector_binary_redux.cpp index a481aae3..754c6154 100644 --- a/doc/samples/vector_binary_redux.cpp +++ b/doc/samples/vector_binary_redux.cpp @@ -19,7 +19,7 @@ int main () { using namespace boost::numeric::ublas; vector v1 (3), v2 (3); - for (unsigned i = 0; i < (std::min)(v1.size (), v2.size ()); ++ i) + for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i) v1 (i) = v2 (i) = i; std::cout << inner_prod (v1, v2) << std::endl; diff --git a/doc/storage.htm b/doc/storage.htm index 331d3bd6..a4fbcb82 100644 --- a/doc/storage.htm +++ b/doc/storage.htm @@ -1,518 +1,416 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Storage - -

c++boost.gif + +

c++boost.gif Storage

- -

Unbounded Array

- +

Unbounded +Array

Description

-

The templated class unbounded_array<T> implements a simple C-like array using allocation via new/delete.

-

Example

-
-#include <boost/numeric/ublas/storage.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- unbounded_array<double> a (3);
- for (unsigned i = 0; i < a.size (); ++ i) {
- a [i] = i;
- std::cout << a [i] << std::endl;
- }
+#include <boost/numeric/ublas/storage.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ unbounded_array<double> a (3);
+ for (unsigned i = 0; i < a.size (); ++ i) {
+ a [i] = i;
+ std::cout << a [i] << std::endl;
+ }
}
-

Definition

-

Defined in the header storage.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
T The type of object stored in the array. 
-

Model of

-

Random Access Container.

-

Type requirements

-

None, except for those imposed by the requirements of Random Access Container.

-

Public base classes

-

None.

-

Members

- - +
- - - - - - + +size elements. When preserve == false the +elements values after resize are undefined. - - - - - - - - - - - - - + - - + - - - - + - - +
Member Description
unbounded_array () Allocates an uninitialized unbounded_array that holds at most zero elements.
unbounded_array (size_type size) Allocates an uninitialized unbounded_array that holds at most size elements.
unbounded_array (const unbounded_array &a) The copy constructor.
~unbounded_array () Deallocates the unbounded_array itself.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Reallocates an unbounded_array to hold at most -size elements. The content of the -unbounded_array is not preserved.
size_type size () const Returns the size of the unbounded_array.
const_reference operator [] (size_type i) const Returns a const reference of the i -th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
unbounded_array &operator = (const unbounded_array &a) The assignment operator.
unbounded_array &assign_temporary (unbounded_array &a) Assigns a temporary. May change the array a.
void swap (unbounded_array &a) Swaps the contents of the arrays.
pointer insert (pointer it, const value_type &t) Inserts the value t at it.
void erase (pointer it) Erases the value at it.
void clear () Clears the array.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the unbounded_array.
const_iterator end () const Returns a const_iterator pointing to the end of the unbounded_array.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the unbounded_array.
iterator end () iterator end () Returns a iterator pointing to the end of the unbounded_array.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed unbounded_array.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed unbounded_array.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed unbounded_array.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed unbounded_array.
- -

Bounded Array

- +

Bounded +Array

Description

-

The templated class bounded_array<T, N> implements a simple C-like array.

-

Example

-
-#include <boost/numeric/ublas/storage.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- bounded_array<double, 3> a (3);
- for (unsigned i = 0; i < a.size (); ++ i) {
- a [i] = i;
- std::cout << a [i] << std::endl;
- }
-}
+#include <boost/numeric/ublas/storage.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ bounded_array<double, 3> a (3);
+ for (unsigned i = 0; i < a.size (); ++ i) {
+ a [i] = i;
+ std::cout << a [i] << std::endl;
+ }
+}
-

Definition

-

Defined in the header storage.hpp.

-

Template parameters

- - +
- - + - - +
Parameter Description Default
T The type of object stored in the array. 
N The allocation size of the array. 
-

Model of

-

Random Access Container.

-

Type requirements

-

None, except for those imposed by the requirements of Random Access Container.

-

Public base classes

-

None.

-

Members

- - +
- - - - - +size elements. When preserve == false the +elements values after resize are undefined. - - - - - - - - - - - - - + - - + - - - - + - - +
Member Description
bounded_array () Allocates an uninitialized bounded_array that holds at most zero elements.
bounded_array (size_type size) Allocates an uninitialized bounded_array that holds at most size elements.
bounded_array (const bounded_array &a) The copy constructor.
~bounded_array () Deallocates the bounded_array itself.
void resize (size_type size) Reallocates a bounded_array to hold at most -size elements. The content of the -bounded_array is preserved.
size_type size () const Returns the size of the bounded_array.
const_reference operator [] (size_type i) const Returns a const reference of the i -th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
bounded_array &operator = (const bounded_array &a) The assignment operator.
bounded_array &assign_temporary (bounded_array &a) Assigns a temporary. May change the array a.
void swap (bounded_array &a) Swaps the contents of the arrays.
pointer insert (pointer it, const value_type &t) Inserts the value t at it.
void erase (pointer it) Erases the value at it.
void clear () Clears the array.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the bounded_array.
const_iterator end () const Returns a const_iterator pointing to the end of the bounded_array.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the bounded_array.
iterator end () iterator end () Returns a iterator pointing to the end of the bounded_array.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed bounded_array.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed bounded_array.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed bounded_array.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed bounded_array.
- -

Range

- +

Range

Description

-

The class range implements base functionality needed to address ranges of vectors and matrices.

-

Example

-
-#include <boost/numeric/ublas/storage.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- range r (0, 3);
- for (unsigned i = 0; i < r.size (); ++ i) {
- std::cout << r (i) << std::endl;
- }
-}
+#include <boost/numeric/ublas/storage.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ range r (0, 3);
+ for (unsigned i = 0; i < r.size (); ++ i) {
+ std::cout << r (i) << std::endl;
+ }
+}
-

Definition

-

Defined in the header storage.hpp.

-

Model of

-

Reversible Container.

-

Type requirements

-

None, except for those imposed by the requirements of Reversible Container.

-

Public base classes

-

None.

-

Members

- - +
- - - - - - - - - - -
Member Description
range (size_type start, size_type stop) Constructs a range from start to stop .
size_type start () const Returns the beginning of the range.
size_type size () const Returns the size of the range.
const_reference operator [] (size_type i) const Returns the value start + i of the i -th element.
range compose (const range &r) const Returns the composite range from start + r.start () to start + r.start () + r.size ().
bool operator == (const range &r) const Tests two ranges for equality.
bool operator != (const range &r) const Tests two ranges for inequality.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the range.
const_iterator end () const Returns a const_iterator pointing to the end of the range.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed range.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -520,90 +418,72 @@ end of the reversed range.
- -

Slice

- +

Preconditions

+
    +
  • start () <= stop ()
  • +
+

Slice

Description

-

The class slice implements base functionality needed to address slices of vectors and matrices.

-

Example

-
-#include <boost/numeric/ublas/storage.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- slice s (0, 1, 3);
- for (unsigned i = 0; i < s.size (); ++ i) {
- std::cout << s (i) << std::endl;
- }
-}
+#include <boost/numeric/ublas/storage.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ slice s (0, 1, 3);
+ for (unsigned i = 0; i < s.size (); ++ i) {
+ std::cout << s (i) << std::endl;
+ }
+}
-

Definition

-

Defined in the header storage.hpp.

-

Model of

-

Reversible Container.

-

Type requirements

-

None, except for those imposed by the requirements of Reversible Container.

-

Public base classes

-

None.

-

Members

- - +
- - - - - - - s.size ()) with stride stride * s.stride () . - - - - - -
Member Description
slice (size_type start, size_type stride, size_type size) Constructs a slice from start to start + size with stride stride.
size_type start () const Returns the beginning of the slice.
size_type stride () const Returns the stride of the slice.
size_type size () const Returns the size of the slice.
const_reference operator [] (size_type i) const Returns the value start + i * stride of the i-th element.
slice compose (const range &r) const Returns the composite slice from start + stride * r.start () to start + stride * (r.start () + r.size ()) with stride stride.
slice compose (const slice &s) const Returns the composite slice from start + stride * s.start @@ -611,35 +491,29 @@ with stride stride.
bool operator == (const slice &s) const Tests two slices for equality.
bool operator != (const slice &s) const Tests two slices for inequality.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the slice.
const_iterator end () const Returns a const_iterator pointing to the end of the slice.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed slice.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -647,16 +521,19 @@ end of the reversed slice.
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +

Preconditions

+
    +
  • start () + i *.stride () >= 0 && start () + i +* stride () <= maximum value(difference_type) for +all 0 <= i < size ()
  • +
+
+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

- -

Last revised: 1/15/2003

+

Last revised: 24/06/2004

- diff --git a/doc/storage_sparse.htm b/doc/storage_sparse.htm index ee2f4a1a..b29cfc88 100644 --- a/doc/storage_sparse.htm +++ b/doc/storage_sparse.htm @@ -1,123 +1,148 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Sparse Storage - -

c++boost.gif + +

c++boost.gif Sparse Storage

- -

Map Array

- +

Default Standard Map

Description

- -

The templated class map_array<I, T> -implements a simple std::map-like associative container as a sorted -array.

- +

The templated class map_std<I, T> provides a +wrapper for the standard library associative container +std::map. The wrapper has one simple purpose. It +allows the definition of a default template parameter (for the +adapted array) when declaring the sparse container types.

Example

-
-#include <boost/numeric/ublas/storage_sparse.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- map_array<int, double> a (3);
- for (unsigned i = 0; i < a.size (); ++ i) {
- a [i] = i;
- std::cout << a [i] << std::endl;
- }
-}
+#include <boost/numeric/ublas/storage_sparse.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ map_std<int, double> a (3);
+ for (unsigned i = 0; i < a.size (); ++ i) {
+ a [i] = i;
+ std::cout << a [i] << std::endl;
+ }
+}
-

Definition

-

Defined in the header storage_sparse.hpp.

-

Template parameters

- - +
- - + - - + - + + + +
Parameter Description Default
I The type of index stored in the array. 
T T The type of object stored in the array. 
+

Model of

+

Reversible Container.

+

Type requirements

+

None, except for those imposed by the requirements of Reversible +Container.

+

Public base classes

+

std::map

+

Map Array

+

Description

+

The templated class map_array<I, T> +implements a simple std::map-like associative container as a sorted +array.

+

Example

+
+#include <boost/numeric/ublas/storage_sparse.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ map_array<int, double> a (3);
+ for (unsigned i = 0; i < a.size (); ++ i) {
+ a [i] = i;
+ std::cout << a [i] << std::endl;
+ }
+}
+
+

Definition

+

Defined in the header storage_sparse.hpp.

+

Template parameters

+ + + + + + + + + + + + + + + +
ParameterDescriptionDefault
IThe type of index stored in the array.
TThe type of object stored in the array.
-

Model of

-

Reversible Container.

-

Type requirements

-

None, except for those imposed by the requirements of Reversible Container.

-

Public base classes

-

None.

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - + - - +
Member Description
map_array () map_array () Allocates a map_array that holds at most zero elements.
map_array (size_type size) Allocates a map_array that holds at most size elements.
map_array (const map_array &a) The copy constructor.
~map_array () Deallocates the map_array itself.
void resize (size_type size) Reallocates a map_array to hold at most size elements. The content of the map_array is preserved.
size_type size () const Returns the size of the map_array.
data_reference operator [] (index_type i) Returns a reference of the element that is associated with a @@ -125,136 +150,113 @@ particular index. If the map_array does not already contain such an element, operator[] inserts the default T ().
map_array &operator = (const map_array &a) The assignment operator.
map_array &assign_temporary (map_array &a) Assigns a temporary. May change the array a.
void swap (map_array &a) Swaps the contents of the arrays.
pointer insert (pointer it, const value_type &p) Inserts p into the array, using it as a hint to where it will be inserted.
void erase (pointer it) Erases the value at it.
void clear () Clears the array.
const_pointer find (index_type i) const Finds an element whose index is i.
pointer find (index_type i) Finds an element whose index is i.
const_pointer lower_bound (index_type i) const Finds the first element whose index is not less than i .
pointer lower_bound (index_type i) Finds the first element whose index is not less than i .
const_pointer upper_bound (index_type i) const Finds the first element whose index is greater than i .
pointer upper_bound (index_type i) Finds the first element whose index is greater than i .
const_iterator begin () const Returns a const_iterator pointing to the beginning of the map_array.
const_iterator end () const Returns a const_iterator pointing to the end of the map_array.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the map_array.
iterator end () iterator end () Returns a iterator pointing to the end of the map_array.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed map_array.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed map_array.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed map_array.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed map_array.
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/symmetric.htm b/doc/symmetric.htm index 404b0f4f..2c48ea46 100644 --- a/doc/symmetric.htm +++ b/doc/symmetric.htm @@ -1,702 +1,586 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Symmetric Matrix - -

c++boost.gif + +

c++boost.gif Symmetric Matrix

- -

Symmetric Matrix

- +

Symmetric +Matrix

Description

-

The templated class symmetric_matrix<T, F1, F2, A> is the base container adaptor for symmetric matrices. For a (n x n )-dimensional symmetric matrix and 0 <= i < n, 0 <= j < n holds si, j = sj, i. The storage of symmetric matrices is packed.

-

Example

-
-#include <boost/numeric/ublas/symmetric.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- symmetric_matrix<double, lower> ml (3, 3);
- for (unsigned i = 0; i < ml.size1 (); ++ i)
- for (unsigned j = 0; j <= i; ++ j)
- ml (i, j) = 3 * i + j;
- std::cout << ml << std::endl;
- symmetric_matrix<double, upper> mu (3, 3);
- for (unsigned i = 0; i < mu.size1 (); ++ i)
- for (unsigned j = i; j < mu.size2 (); ++ j)
- mu (i, j) = 3 * i + j;
- std::cout << mu << std::endl;
+#include <boost/numeric/ublas/symmetric.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ symmetric_matrix<double, lower> ml (3, 3);
+ for (unsigned i = 0; i < ml.size1 (); ++ i)
+ for (unsigned j = 0; j <= i; ++ j)
+ ml (i, j) = 3 * i + j;
+ std::cout << ml << std::endl;
+ symmetric_matrix<double, upper> mu (3, 3);
+ for (unsigned i = 0; i < mu.size1 (); ++ i)
+ for (unsigned j = i; j < mu.size2 (); ++ j)
+ mu (i, j) = 3 * i + j;
+ std::cout << mu << std::endl;
}
-

Definition

-

Defined in the header symmetric.hpp.

-

Template parameters

- - +
- - + - + - +"#symmetric_matrix_1" id="#symmetric_matrix_1">[1] - +"#symmetric_matrix_2" id="#symmetric_matrix_2">[2] - - +
Parameter Description Default
T T The type of object stored in the matrix. 
F1 Functor describing the type of the symmetric matrix. [1] lower
F2 Functor describing the storage organization. [2] row_major
AThe type of the adapted array. [3] The type of the adapted array. [3] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<symmetric_matrix<T, F1, F2, A> >

-

Members

- - +
- - + - - - - - - + +size rows of size elements. The existing +elements of the symmetric_matrix are preseved when +specified. - - - - - - - - + - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
symmetric_matrix () symmetric_matrix () Allocates an uninitialized symmetric_matrix that holds zero rows of zero elements.
symmetric_matrix (size_type size) Allocates an uninitialized symmetric_matrix that holds size rows of size elements.
symmetric_matrix (const symmetric_matrix &m) The copy constructor.
template<class AE>
- symmetric_matrix (const matrix_expression<AE> +
template<class AE>
+symmetric_matrix (const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Reallocates a symmetric_matrix to hold -size rows of size elements. The content -of the symmetric_matrix is not preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
symmetric_matrix &operator = (const symmetric_matrix &m) The assignment operator.
symmetric_matrix &assign_temporary (symmetric_matrix &m) Assigns a temporary. May change the symmetric matrix m .
template<class AE>
- symmetric_matrix &operator = (const -matrix_expression<AE> &ae)
template<class AE>
+symmetric_matrix &operator = (const matrix_expression<AE> +&ae)
The extended assignment operator.
template<class AE>
- symmetric_matrix &assign (const matrix_expression<AE> +
template<class AE>
+symmetric_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the symmetric matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- symmetric_matrix &operator += (const +
template<class AE>
+symmetric_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the symmetric matrix.
template<class AE>
- symmetric_matrix &plus_assign (const +
template<class AE>
+symmetric_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the symmetric matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- symmetric_matrix &operator -= (const +
template<class AE>
+symmetric_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the symmetric matrix.
template<class AE>
- symmetric_matrix &minus_assign (const +
template<class AE>
+symmetric_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the symmetric matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- symmetric_matrix &operator *= (const AT &at)
template<class AT>
+symmetric_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the symmetric matrix with a scalar.
template<class AT>
- symmetric_matrix &operator /= (const AT &at)
template<class AT>
+symmetric_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the symmetric matrix through a scalar.
void swap (symmetric_matrix &m) Swaps the contents of the symmetric matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th elemenst of the i-th row.
void clear () Clears the matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the symmetric_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the symmetric_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the symmetric_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the symmetric_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the symmetric_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the symmetric_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the symmetric_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the symmetric_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed symmetric_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed symmetric_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed symmetric_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed symmetric_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed symmetric_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed symmetric_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed symmetric_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed symmetric_matrix.
-

Notes

- -

[1] Supported parameters for -the type of the symmetric matrix are lower and -upper.

- -

[2] Supported parameters for -the storage organization are row_major and -column_major.

- -

[3] Supported parameters for -the adapted array are unbounded_array<T> , +

[1] +Supported parameters for the type of the symmetric matrix are +lower and upper.

+

[2] +Supported parameters for the storage organization are +row_major and column_major.

+

[3] +Supported parameters for the adapted array are +unbounded_array<T> , bounded_array<T> and std::vector<T> .

- -

Symmetric Adaptor

- +

+Symmetric Adaptor

Description

-

The templated class symmetric_adaptor<M, F> is a symmetric matrix adaptor for other matrices.

-

Example

-
-#include <boost/numeric/ublas/symmetric.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- symmetric_adaptor<matrix<double>, lower> sal (m);
- for (unsigned i = 0; i < sal.size1 (); ++ i)
- for (unsigned j = 0; j <= i; ++ j)
- sal (i, j) = 3 * i + j;
- std::cout << sal << std::endl;
- symmetric_adaptor<matrix<double>, upper> sau (m);
- for (unsigned i = 0; i < sau.size1 (); ++ i)
- for (unsigned j = i; j < sau.size2 (); ++ j)
- sau (i, j) = 3 * i + j;
- std::cout << sau << std::endl;
+#include <boost/numeric/ublas/symmetric.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ symmetric_adaptor<matrix<double>, lower> sal (m);
+ for (unsigned i = 0; i < sal.size1 (); ++ i)
+ for (unsigned j = 0; j <= i; ++ j)
+ sal (i, j) = 3 * i + j;
+ std::cout << sal << std::endl;
+ symmetric_adaptor<matrix<double>, upper> sau (m);
+ for (unsigned i = 0; i < sau.size1 (); ++ i)
+ for (unsigned j = i; j < sau.size2 (); ++ j)
+ sau (i, j) = 3 * i + j;
+ std::cout << sau << std::endl;
}
-

Definition

-

Defined in the header symmetric.hpp.

-

Template parameters

- - +
- - + - +"#symmetric_adaptor_1">[1]
Parameter Description Default
M The type of the adapted matrix. 
F Functor describing the type of the symmetric adaptor. [1] lower
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<symmetric_adaptor<M, F> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
symmetric_adaptor () symmetric_adaptor () Constructs a symmetric_adaptor that holds zero rows of zero elements.
symmetric_adaptor (matrix_type &data) Constructs a symmetric_adaptor of a matrix.
symmetric_adaptor (const symmetric_adaptor &m) The copy constructor.
template<class AE>
- symmetric_adaptor (const matrix_expression<AE> +
template<class AE>
+symmetric_adaptor (const matrix_expression<AE> &ae)
The extended copy constructor.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
symmetric_adaptor &operator = (const symmetric_adaptor &m) The assignment operator.
symmetric_adaptor &assign_temporary (symmetric_adaptor &m) Assigns a temporary. May change the symmetric adaptor m.
template<class AE>
- symmetric_adaptor &operator = (const +
template<class AE>
+symmetric_adaptor &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- symmetric_adaptor &assign (const matrix_expression<AE> +
template<class AE>
+symmetric_adaptor &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the symmetric adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- symmetric_adaptor &operator += (const +
template<class AE>
+symmetric_adaptor &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the symmetric adaptor.
template<class AE>
- symmetric_adaptor &plus_assign (const +
template<class AE>
+symmetric_adaptor &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the symmetric adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- symmetric_adaptor &operator -= (const +
template<class AE>
+symmetric_adaptor &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the symmetric adaptor.
template<class AE>
- symmetric_adaptor &minus_assign (const +
template<class AE>
+symmetric_adaptor &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the symmetric adaptor. Left and right hand side of the assignment should be independent.
template<class AT>
- symmetric_adaptor &operator *= (const AT &at)
template<class AT>
+symmetric_adaptor &operator *= (const AT &at)
A computed assignment operator. Multiplies the symmetric adaptor with a scalar.
template<class AT>
- symmetric_adaptor &operator /= (const AT &at)
template<class AT>
+symmetric_adaptor &operator /= (const AT &at)
A computed assignment operator. Divides the symmetric adaptor through a scalar.
void swap (symmetric_adaptor &m) Swaps the contents of the symmetric adaptors.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the symmetric_adaptor.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the symmetric_adaptor.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the symmetric_adaptor.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the symmetric_adaptor.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the symmetric_adaptor.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the symmetric_adaptor.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the symmetric_adaptor.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the symmetric_adaptor.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed symmetric_adaptor.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed symmetric_adaptor.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed symmetric_adaptor.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed symmetric_adaptor.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed symmetric_adaptor.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed symmetric_adaptor.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed symmetric_adaptor.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed symmetric_adaptor.
-

Notes

- -

[1] Supported parameters for -the type of the symmetric adaptor are lower and -upper.

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +

[1] +Supported parameters for the type of the symmetric adaptor are +lower and upper.

+
+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/triangular.htm b/doc/triangular.htm index f51457ca..eafc4972 100644 --- a/doc/triangular.htm +++ b/doc/triangular.htm @@ -1,20 +1,20 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Triangular Matrix - -

c++boost.gif + +

c++boost.gif Triangular Matrix

- -

Triangular Matrix

- +

+Triangular Matrix

Description

-

The templated class triangular_matrix<T, F1, F2, A> is the base container adaptor for triangular matrices. For a (n x n )-dimensional lower triangular matrix and @@ -28,686 +28,569 @@ j = 0 , if i < j. If furthermore holds ti, i= 1 the matrix is called unit lower triangular. The storage of triangular matrices is packed.

-

Example

-
-#include <boost/numeric/ublas/triangular.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- triangular_matrix<double, lower> ml (3, 3);
- for (unsigned i = 0; i < ml.size1 (); ++ i)
- for (unsigned j = 0; j <= i; ++ j)
- ml (i, j) = 3 * i + j;
- std::cout << ml << std::endl;
- triangular_matrix<double, upper> mu (3, 3);
- for (unsigned i = 0; i < mu.size1 (); ++ i)
- for (unsigned j = i; j < mu.size2 (); ++ j)
- mu (i, j) = 3 * i + j;
- std::cout << mu << std::endl;
-}
+#include <boost/numeric/ublas/triangular.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ triangular_matrix<double, lower> ml (3, 3);
+ for (unsigned i = 0; i < ml.size1 (); ++ i)
+ for (unsigned j = 0; j <= i; ++ j)
+ ml (i, j) = 3 * i + j;
+ std::cout << ml << std::endl;
+ triangular_matrix<double, upper> mu (3, 3);
+ for (unsigned i = 0; i < mu.size1 (); ++ i)
+ for (unsigned j = i; j < mu.size2 (); ++ j)
+ mu (i, j) = 3 * i + j;
+ std::cout << mu << std::endl;
+}
-

Definition

-

Defined in the header triangular.hpp.

-

Template parameters

- - +
- - + - + - +"#triangular_matrix_1">[1] - +"#triangular_matrix_2">[2] - +"#triangular_matrix_3">[3]
Parameter Description Default
T T The type of object stored in the matrix. 
F1 Functor describing the type of the triangular matrix. [1] lower
F2 Functor describing the storage organization. [2] row_major
A The type of the adapted array. [3] unbounded_array<T>
-

Model of

-

Matrix .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix .

-

Public base classes

-

matrix_expression<triangular_matrix<T, F1, F2, A> >

-

Members

- - +
- - + - - - - - - + +size1 rows of size2 elements. The +existing elements of the triangular_matrix are +preseved when specified. - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
triangular_matrix () triangular_matrix () Allocates an uninitialized triangular_matrix that holds zero rows of zero elements.
triangular_matrix (size_type size1, size_type size2) Allocates an uninitialized triangular_matrix that holds size1 rows of size2 elements.
triangular_matrix (const triangular_matrix &m) The copy constructor.
template<class AE>
- triangular_matrix (const matrix_expression<AE> +
template<class AE>
+triangular_matrix (const matrix_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size1, size_type -size2)void resize (size_type size1, size_type size2, bool +preserve = true) Reallocates a triangular_matrix to hold -size1 rows of size2 elements. The content -of the triangular_matrix is not preserved.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
triangular_matrix &operator = (const triangular_matrix &m) The assignment operator.
triangular_matrix &assign_temporary (triangular_matrix &m) Assigns a temporary. May change the triangular matrix m.
template<class AE>
- triangular_matrix &operator = (const +
template<class AE>
+triangular_matrix &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- triangular_matrix &assign (const matrix_expression<AE> +
template<class AE>
+triangular_matrix &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the triangular matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- triangular_matrix &operator += (const +
template<class AE>
+triangular_matrix &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the triangular matrix.
template<class AE>
- triangular_matrix &plus_assign (const +
template<class AE>
+triangular_matrix &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the triangular matrix. Left and right hand side of the assignment should be independent.
template<class AE>
- triangular_matrix &operator -= (const +
template<class AE>
+triangular_matrix &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the triangular matrix.
template<class AE>
- triangular_matrix &minus_assign (const +
template<class AE>
+triangular_matrix &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the triangular matrix. Left and right hand side of the assignment should be independent.
template<class AT>
- triangular_matrix &operator *= (const AT &at)
template<class AT>
+triangular_matrix &operator *= (const AT &at)
A computed assignment operator. Multiplies the triangular matrix with a scalar.
template<class AT>
- triangular_matrix &operator /= (const AT &at)
template<class AT>
+triangular_matrix &operator /= (const AT &at)
A computed assignment operator. Divides the triangular matrix through a scalar.
void swap (triangular_matrix &m) Swaps the contents of the triangular matrices.
void insert (size_type i, size_type j, const_reference t) Inserts the value t at the j-th element of the i-th row.
void erase (size_type i, size_type j) Erases the value at the j-th elemenst of the i-th row.
void clear () Clears the matrix.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the triangular_matrix.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the triangular_matrix.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the triangular_matrix.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the triangular_matrix.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the triangular_matrix.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the triangular_matrix.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the triangular_matrix.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the triangular_matrix.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed triangular_matrix.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed triangular_matrix.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed triangular_matrix.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed triangular_matrix.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed triangular_matrix.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed triangular_matrix.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed triangular_matrix.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed triangular_matrix.
-

Notes

- -

[1] Supported parameters for -the type of the triangular matrix are lower , -unit_lower, upper and -unit_upper .

- -

[2] Supported parameters for -the storage organization are row_major and -column_major.

- -

[3] Supported parameters for -the adapted array are unbounded_array<T> , +

[1] +Supported parameters for the type of the triangular matrix are +lower , unit_lower, upper +and unit_upper .

+

[2] +Supported parameters for the storage organization are +row_major and column_major.

+

[3] +Supported parameters for the adapted array are +unbounded_array<T> , bounded_array<T> and std::vector<T> .

- -

Triangular Adaptor

- +

+Triangular Adaptor

Description

-

The templated class triangular_adaptor<M, F> is a triangular matrix adaptor for other matrices.

-

Example

-
-#include <boost/numeric/ublas/triangular.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- triangular_adaptor<matrix<double>, lower> tal (m);
- for (unsigned i = 0; i < tal.size1 (); ++ i)
- for (unsigned j = 0; j <= i; ++ j)
- tal (i, j) = 3 * i + j;
- std::cout << tal << std::endl;
- triangular_adaptor<matrix<double>, upper> tau (m);
- for (unsigned i = 0; i < tau.size1 (); ++ i)
- for (unsigned j = i; j < tau.size2 (); ++ j)
- tau (i, j) = 3 * i + j;
- std::cout << tau << std::endl;
-}
+#include <boost/numeric/ublas/triangular.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ matrix<double> m (3, 3);
+ triangular_adaptor<matrix<double>, lower> tal (m);
+ for (unsigned i = 0; i < tal.size1 (); ++ i)
+ for (unsigned j = 0; j <= i; ++ j)
+ tal (i, j) = 3 * i + j;
+ std::cout << tal << std::endl;
+ triangular_adaptor<matrix<double>, upper> tau (m);
+ for (unsigned i = 0; i < tau.size1 (); ++ i)
+ for (unsigned j = i; j < tau.size2 (); ++ j)
+ tau (i, j) = 3 * i + j;
+ std::cout << tau << std::endl;
+}
-

Definition

-

Defined in the header triangular.hpp.

-

Template parameters

- - +
- - + - +"#triangular_adaptor_1">[1]
Parameter Description Default
M The type of the adapted matrix. 
F Functor describing the type of the triangular adaptor. [1] lower
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<triangular_adaptor<M, F> >

-

Members

- - +
- - + - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - + - - - - + - - + - - - - + - - +
Member Description
triangular_adaptor () triangular_adaptor () Constructs a triangular_adaptor that holds zero rows of zero elements.
triangular_adaptor (matrix_type &data) Constructs a triangular_adaptor of a matrix.
triangular_adaptor (const triangular_adaptor &m) The copy constructor.
template<class AE>
- triangular_adaptor (const matrix_expression<AE> +
template<class AE>
+triangular_adaptor (const matrix_expression<AE> &ae)
The extended copy constructor.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns a const reference of the j -th element in the i-th row.
reference operator () (size_type i, size_type j) Returns a reference of the j-th element in the i-th row.
triangular_adaptor &operator = (const triangular_adaptor &m) The assignment operator.
triangular_adaptor &assign_temporary (triangular_adaptor &m) Assigns a temporary. May change the triangular adaptor m.
template<class AE>
- triangular_adaptor &operator = (const +
template<class AE>
+triangular_adaptor &operator = (const matrix_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- triangular_adaptor &assign (const matrix_expression<AE> +
template<class AE>
+triangular_adaptor &assign (const matrix_expression<AE> &ae)
Assigns a matrix expression to the triangular adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- triangular_adaptor &operator += (const +
template<class AE>
+triangular_adaptor &operator += (const matrix_expression<AE> &ae)
A computed assignment operator. Adds the matrix expression to the triangular adaptor.
template<class AE>
- triangular_adaptor &plus_assign (const +
template<class AE>
+triangular_adaptor &plus_assign (const matrix_expression<AE> &ae)
Adds a matrix expression to the triangular adaptor. Left and right hand side of the assignment should be independent.
template<class AE>
- triangular_adaptor &operator -= (const +
template<class AE>
+triangular_adaptor &operator -= (const matrix_expression<AE> &ae)
A computed assignment operator. Subtracts the matrix expression from the triangular adaptor.
template<class AE>
- triangular_adaptor &minus_assign (const +
template<class AE>
+triangular_adaptor &minus_assign (const matrix_expression<AE> &ae)
Subtracts a matrix expression from the triangular adaptor. Left and right hand side of the assignment should be independent.
template<class AT>
- triangular_adaptor &operator *= (const AT &at)
template<class AT>
+triangular_adaptor &operator *= (const AT &at)
A computed assignment operator. Multiplies the triangular adaptor with a scalar.
template<class AT>
- triangular_adaptor &operator /= (const AT &at)
template<class AT>
+triangular_adaptor &operator /= (const AT &at)
A computed assignment operator. Divides the triangular adaptor through a scalar.
void swap (triangular_adaptor &m) Swaps the contents of the triangular adaptors.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the triangular_adaptor.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the triangular_adaptor.
iterator1 begin1 () iterator1 begin1 () Returns a iterator1 pointing to the beginning of the triangular_adaptor.
iterator1 end1 () iterator1 end1 () Returns a iterator1 pointing to the end of the triangular_adaptor.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the triangular_adaptor.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the triangular_adaptor.
iterator2 begin2 () iterator2 begin2 () Returns a iterator2 pointing to the beginning of the triangular_adaptor.
iterator2 end2 () iterator2 end2 () Returns a iterator2 pointing to the end of the triangular_adaptor.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed triangular_adaptor.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed triangular_adaptor.
reverse_iterator1 rbegin1 () reverse_iterator1 rbegin1 () Returns a reverse_iterator1 pointing to the beginning of the reversed triangular_adaptor.
reverse_iterator1 rend1 () reverse_iterator1 rend1 () Returns a reverse_iterator1 pointing to the end of the reversed triangular_adaptor.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed triangular_adaptor.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the end of the reversed triangular_adaptor.
reverse_iterator2 rbegin2 () reverse_iterator2 rbegin2 () Returns a reverse_iterator2 pointing to the beginning of the reversed triangular_adaptor.
reverse_iterator2 rend2 () reverse_iterator2 rend2 () Returns a reverse_iterator2 pointing to the end of the reversed triangular_adaptor.
-

Notes

- -

[1] Supported parameters for -the type of the triangular adaptor are lower , -unit_lower, upper and -unit_upper .

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +

[1] +Supported parameters for the type of the triangular adaptor are +lower , unit_lower, upper +and unit_upper .

+
+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/types.htm b/doc/types.htm new file mode 100644 index 00000000..bd8a34c5 --- /dev/null +++ b/doc/types.htm @@ -0,0 +1,561 @@ + + + + + + + +Types Overview + + +

c++boost.gif +Overview of Matrix- and Vector-Types

+ +
+
Contents:
+
Vectors
+
Vector Proxies
+
Matrices
+
Matrix Proxies
+
Special Storage Layouts
+
+ + +

Notation:

+ + + + + + + + + + + + + + + + + +
Tis the data type, e.g. double, ...
Fis the orientation type (functor), either +row_major or column_major
C is a container type, e.g. std::vector, +bounded_array, unbounded_array, ...
TRIis a triangular functor: lower, +unit_lower, strict_lower, upper, unit_upper, +strict_upper
M, Nare unsinged integer values +(std::size_t)
VECis any vector type
MAT is any matrix type
[...]denote optional arguments - for more details +look at the section "storage layout".
+ +

Vectors

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DefinitionDescription
vector<T [, C]> v(size);a dense vector of values of type T of arbitrary +size - only depending on the underlying container type +C which defaults to unbounded_array.
bounded_vector<T, N> v;a dense vector of values of type T of maximal size +N. The default contructor initialises c +to a zero vector of size N.
zero_vector<T> v(size);the zero vector of type T with arbitrary +size.
unit_vector<T> v(size, index);the unit vector of type T with arbitrary size. The +vector is v(i) = (i==index)?T(1):T(). +index should be less than size.
sparse_vector<T [, C]> v(size);a sparse vector of values of type T of arbitrary +size. The container type can be std::map<size_t, +T> or map_array<size_t, T>.
compressed_vector<T [, C]> v(size);a sparse vector of values of type T of arbitrary +size. The non zero values are stored as two seperate arrays - an +index array and a value array. The index array is always sorted and +the is at most one entry for each index.
coordinate_vector<T [, C]> v(size);a sparse vector of values of type T of arbitrary +size. The non zero values are stored as two seperate arrays - an +index array and a value array. The arrays may be out of order with +multiple entries for each vector element. If there are multiple +values for the same index the sum of these values is the real +value.
+

Note: the default types are defined in +boost/numeric/ublas/fwd.hpp.

+ +

Vector Proxies

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
DefinitionDescription
vector_range<VEC> vr(v, range);a vector referencing a continuous subvector of elements of +vector v containing all elements specified by +range.
vector_slice<VEC> vs(v, slice);a vector referencing a non continuous subvector of elements of +vector v containing all elements specified by +slice.
matrix_row<MAT> vr(m, index);a vector referencing the index-th row of matrix +m
matrix_column<MAT> vc(m, index);a vector referencing the index-th column of matrix +m
+ +

Matrices

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DefinitionDescription
matrix<T [, F, C]> m(rows, columns);a dense matrix of values of type T of arbitrary +size - only depending on the underlying container type +C which defaults to unbounded_array. The +orientation functor F defaults to +row_major.
bounded_matrix<T, M, N [, F]> m;a dense matrix of M-by-N values of +type T. The orientation functor F +defaults to row_major. The default constructor creates +a M-by-N zero matrix.
c_matrix<T, M, N> m(rows, columns);a dense matrix of values of type T of given size. +The data is stored as a usual c array T +data_[N][M]
vector_of_vector<T [, F, C]> m(rows, +columns);a dense matrix of values of type T of given size. +The data is stored as a vector of vectors. The orientation +F defaults to row_major. The container +type C defaults to +unbounded_array<unbounded_array<T> >
zero_matrix<T> m(rows, columns);a zero matrix of type T of arbitrary size.
identity_matrix<T> m(rows, columns);an identity matrix of type T of arbitrary size. +The values are v(i,j) = (i==j)?T(1):T().
scalar_matrix<T> m(rows, columns, +value);a matrix of type T of arbitrary size that has the +value value everywhere.
triangular_matrix<T [, TRI, F, C]> +m(size);a triangular matrix of values of type T of +arbitrary size. Only the nonzero elements are stored in the given +order F. ("triangular packed storage") The triangular +type F defaults to lower, the orientation +type F defaults to row_major.
banded_matrix<T [, F, C]> m(size1, size2, n_lower, +n_upper);a banded matrix of values of type T of arbitrary +size with n_lower sub diagonals and +n_upper super diagonals. Only the nonzero elements are +stored in the given order F. ("packed storage")
symmetric_matrix<T [, TRI, F, C]> +m(size);a symmetric matrix of values of type T of +arbitrary size. Only the given triangular matrix is stored in the +given order F.
hermitian_matrix<T [, TRI, F, C]> +m(size);a hermitian matrix of values of type T of +arbitrary size. Only the given triangular matrix is stored using +the order F.
sparse_matrix<T, [F, C]> m(size1, size2 [, +nnz]);a sparse matrix of values of type T of arbitrary +size. The container type can be either std::map<size_t, +std::map<size_t, T> > or +map_array<size_t, map_array<size_t, +T> >.
sparse_vector_of_sparse_vector<T, [F, C]> m(size1, +size2 [, nnz]);a sparse matrix of values of type T of arbitrary +size.
compressed_matrix<T, [F, IB, IA, TA]> m(size1, +size2 [, nnz]);a sparse matrix of values of type T of arbitrary +size. The values are stored in compressed row/column storage.
coordinate_matrix<T, [F, IB, IA, TA]> m(size1, +size2 [, nnz]);a sparse matrix of values of type T of arbitrary +size. The values are stored in 3 parallel array as triples (i, j, +value). More than one value for each pair of indices is possible, +the real value is the sum of all.
generalized_vector_of_vector<T, F, A> m(size1, +size2 [, nnz]);a sparse matrix of values of type T of arbitrary +size. The values are stored as a vector of sparse vectors, e.g. +generalized_vector_of_vector<double, row_major, +unbounded_array<coordinate_vector<double> > >
+

Note: the default types are defined in +boost/numeric/ublas/fwd.hpp.

+ +

Matrix Proxies

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DefinitionDescription
triangular_adaptor<MAT, TRI> ta(m);a triangular matrix referencing a selection of elements of the +matrix m.
symmetric_adaptor<MAT, TRI> sa(m);a symmetric matrix referencing a selection of elements of the +matrix m.
hermitian_adaptor<MAT, TRI> ha(m);a hermitian matrix referencing a selection of elements of the +matrix m.
banded_adaptor<MAT> ba(m, n_lower, +n_upper);a banded matrix referencing a selection of elements of the +matrix m.
matrix_range<MAT, TRI> mr(m, range1, +range2);a matrix referencing a submatrix of elements in the matrix +m.
matrix_slice<MAT, TRI> ms(m, slice1, +slice2);a matrix referencing a non continues submatrix of elements in +the matrix m.
+ + + +

Special Storage Layouts

+ + +

The library supports conventional dense, packed and basic sparse +vector and matrix storage layouts. The description of the most +common constructions of vectors and matrices comes next.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConstructionComment
vector<T,
+ std::vector<T> >
+  v (size)
Constructs a dense vector, storage is provided by a standard +vector.
+The storage layout usually is BLAS compliant.
vector<T,
+ unbounded_array<T> >
+  v (size)
Constructs a dense vector, storage is provided by a heap-based +array.
+The storage layout usually is BLAS compliant.
vector<T,
+ bounded_array<T, N> >
+  v (size)
Constructs a dense vector, storage is provided by a stack-based +array.
+The storage layout usually is BLAS compliant.
sparse_vector<T,
+ std::map<std::size_t, T> >
+  v (size, non_zeros)
Constructs a sparse vector, storage is provided by a standard +map.
sparse_vector<T,
+ map_array<std::size_t, T> >
+  v (size, non_zeros)
Constructs a sparse vector, storage is provided by a map +array.
matrix<T,
+ row_major,
+ std::vector<T> >
+  m (size1, size2)
Constructs a dense matrix, orientation is row major, storage is +provided by a standard vector.
matrix<T,
+ column_major,
+ std::vector<T> >
+  m (size1, size2)
Constructs a dense matrix, orientation is column major, storage +is provided by a standard vector.
+The storage layout usually is BLAS compliant.
matrix<T,
+ row_major,
+ unbounded_array<T> >
+  m (size1, size2)
Constructs a dense matrix, orientation is row major, storage is +provided by a heap-based array.
matrix<T,
+ column_major,
+ unbounded_array<T> >
+  m (size1, size2)
Constructs a dense matrix, orientation is column major, storage +is provided by a heap-based array.
+The storage layout usually is BLAS compliant.
matrix<T,
+ row_major,
+ bounded_array<T, N1 * N2> >
+  m (size1, size2)
Constructs a dense matrix, orientation is row major, storage is +provided by a stack-based array.
matrix<T,
+ column_major,
+ bounded_array<T, N1 * N2> >
+  m (size1, size2)
Constructs a dense matrix, orientation is column major, storage +is provided by a stack-based array.
+The storage layout usually is BLAS compliant.
triangular_matrix<T,
+ row_major, F, A>
+  m (size)
Constructs a packed triangular matrix, orientation is row +major.
triangular_matrix<T,
+ column_major, F, A>
+  m (size)
Constructs a packed triangular matrix, orientation is column +major.
+The storage layout usually is BLAS compliant.
banded_matrix<T,
+ row_major, A>
+  m (size1, size2, lower, upper)
Constructs a packed banded matrix, orientation is row +major.
banded_matrix<T,
+ column_major, A>
+  m (size1, size2, lower, upper)
Constructs a packed banded matrix, orientation is column +major.
+The storage layout usually is BLAS compliant.
symmetric_matrix<T,
+ row_major, F, A>
+  m (size)
Constructs a packed symmetric matrix, orientation is row +major.
symmetric_matrix<T,
+ column_major, F, A>
+  m (size)
Constructs a packed symmetric matrix, orientation is column +major.
+The storage layout usually is BLAS compliant.
hermitian_matrix<T,
+ row_major, F, A>
+  m (size)
Constructs a packed hermitian matrix, orientation is row +major.
hermitian_matrix<T,
+ column_major, F, A>
+  m (size)
Constructs a packed hermitian matrix, orientation is column +major.
+The storage layout usually is BLAS compliant.
sparse_matrix<T,
+ row_major,
+ std::map<std::size_t, T> >
+  m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is row major, storage +is provided by a standard map.
sparse_matrix<T,
+ column_major,
+ std::map<std::size_t, T> >
+  m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is column major, +storage is provided by a standard map.
sparse_matrix<T,
+ row_major,
+ map_array<std::size_t, T> >
+  m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is row major, storage +is provided by a map array.
sparse_matrix<T,
+ column_major,
+ map_array<std::size_t, T> >
+  m (size1, size2, non_zeros)
Constructs a sparse matrix, orientation is column major, +storage is provided by a map array.
compressed_matrix<T,
+ row_major>
+  m (size1, size2, non_zeros)
Constructs a compressed matrix, orientation is row major.
+The storage layout usually is BLAS compliant.
compressed_matrix<T,
+ column_major>
+  m (size1, size2, non_zeros)
Constructs a compressed matrix, orientation is column +major.
+The storage layout usually is BLAS compliant.
coordinate_matrix<T,
+ row_major>
+  m (size1, size2, non_zeros)
Constructs a coordinate matrix, orientation is row major.
+The storage layout usually is BLAS compliant.
coordinate_matrix<T,
+ column_major>
+  m (size1, size2, non_zeros)
Constructs a coordinate matrix, orientation is column +major.
+The storage layout usually is BLAS compliant.
+ + + +
+

Copyright (©) 2000-2004 Joerg Walter, Mathias Koch, Gunter +Winkler, Michael Stevens
+Permission to copy, use, modify, sell and distribute this document +is granted provided this copyright notice appears in all copies. +This document is provided ``as is'' without express or implied +warranty, and with no claim as to its suitability for any +purpose.

+

Last revised: 2004-07-05

+ + diff --git a/doc/ublas.css b/doc/ublas.css new file mode 100644 index 00000000..be6854e1 --- /dev/null +++ b/doc/ublas.css @@ -0,0 +1,14 @@ +table { + border-width: medium; + background-color: #F8F8F8; + margin:1em; +} + +td { + padding-left: 0.5em; + padding-right:0.5em; +} + +th { + text-align:left; +} diff --git a/doc/vector.htm b/doc/vector.htm index f6c84ffe..3b469947 100644 --- a/doc/vector.htm +++ b/doc/vector.htm @@ -1,304 +1,250 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Vector - -

c++boost.gif + +

c++boost.gif Vector

- -

Vector

- +

Vector

Description

-

The templated class vector<T, A> is the base container adaptor for dense vectors. For a n-dimensional vector and 0 <= i < n every element vi is mapped to the i-th element of the container.

-

Example

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = i;
- std::cout << v << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = i;
+ std::cout << v << std::endl;
+}
-

Definition

-

Defined in the header vector.hpp.

-

Template parameters

- - +
- - + - + - - +
Parameter Description Default
T T The type of object stored in the vector. 
AThe type of the adapted array. [1] -The type of the adapted array. [1] unbounded_array<T>
-

Model of

-

Vector .

-

Type requirements

-

None, except for those imposed by the requirements of Vector .

-

Public base classes

-

vector_expression<vector<T, A> >

-

Members

- - +
- - + - - - - + - - + +elements. The existing elements of the vector are +preseved when specified. - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - +
Member Description
vector () vector () Allocates an uninitialized vector that holds zero elements.
vector (size_type size) Allocates an uninitialized vector that holds size elements.
vector (const vector &v) The copy constructor.
template<class AE>
- vector (const vector_expression<AE> &ae)
template<class AE>
+vector (const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Reallocates a vector to hold size -elements. The content of the vector is not -preserved.
size_type size () const Returns the size of the vector.
const_reference operator () (size_type i) const Returns a const reference of the i -th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns a const reference of the i -th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
vector &operator = (const vector &v) The assignment operator.
vector &assign_temporary (vector &v) Assigns a temporary. May change the vector v.
template<class AE>
- vector &operator = (const vector_expression<AE> +
template<class AE>
+vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- vector &assign (const vector_expression<AE> +
template<class AE>
+vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the vector. Left and right hand side of the assignment should be independent.
template<class AE>
- vector &operator += (const vector_expression<AE> +
template<class AE>
+vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the vector.
template<class AE>
- vector &plus_assign (const vector_expression<AE> +
template<class AE>
+vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the vector. Left and right hand side of the assignment should be independent.
template<class AE>
- vector &operator -= (const vector_expression<AE> +
template<class AE>
+vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the vector.
template<class AE>
- vector &minus_assign (const vector_expression<AE> +
template<class AE>
+vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the vector. Left and right hand side of the assignment should be independent.
template<class AT>
- vector &operator *= (const AT &at)
template<class AT>
+vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the vector with a scalar.
template<class AT>
- vector &operator /= (const AT &at)
template<class AT>
+vector &operator /= (const AT &at)
A computed assignment operator. Divides the vector through a scalar.
void swap (vector &v) Swaps the contents of the vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the vector.
const_iterator end () const Returns a const_iterator pointing to the end of the vector.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the vector.
iterator end () iterator end () Returns a iterator pointing to the end of the vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed vector.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed vector.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed vector.
-

Notes

- -

[1] Supported parameters for the adapted -array are unbounded_array<T> , +

[1] Supported parameters +for the adapted array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

- -

Unit Vector

- +

Unit Vector

Description

-

The templated class unit_vector<T> represents canonical unit vectors. For the k-th n-dimensional canonical unit vector and 0 <= i < @@ -306,148 +252,120 @@ n holds uki = 0, if i <> k, and uki = 1.

-

Example

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- for (int i = 0; i < 3; ++ i) {
- unit_vector<double> v (3, i);
- std::cout << v << std::endl;
- }
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ for (int i = 0; i < 3; ++ i) {
+ unit_vector<double> v (3, i);
+ std::cout << v << std::endl;
+ }
+}
-

Definition

-

Defined in the header vector.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
T T The type of object stored in the vector. 
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<unit_vector<T> >

-

Members

- - +
- - + - - - - + +elements. Therefore the existing elements of the +unit_vector are always preseved. - - - - - - - - - - -
Member Description
unit_vector () unit_vector () Constructs an unit_vector that holds zero elements.
unit_vector (size_type size, size_type index) Constructs the index-th unit_vector that holds size elements.
unit_vector (const unit_vector &v) The copy constructor.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Resizes a unit_vector to hold size -elements.
size_type size () const Returns the size of the unit_vector.
size_type index () const Returns the index of the unit_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
unit_vector &operator = (const unit_vector &v) The assignment operator.
unit_vector &assign_temporary (unit_vector &v) Assigns a temporary. May change the unit vector v .
void swap (unit_vector &v) Swaps the contents of the unit vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the unit_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the unit_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed unit_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -455,150 +373,120 @@ end of the reversed unit_vector.
- -

Zero Vector

- +

Zero Vector

Description

-

The templated class zero_vector<T> represents zero vectors. For a n-dimensional zero vector and 0 <= i < n holds zi = 0.

-

Example

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- zero_vector<double> v (3);
- std::cout << v << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ zero_vector<double> v (3);
+ std::cout << v << std::endl;
+}
-

Definition

-

Defined in the header vector.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
T T The type of object stored in the vector. 
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<zero_vector<T> >

-

Members

- - +
- - + - - - - + +elements. Therefore the existing elements of the +zero_vector are always preseved. - - - - - - - - - -
Member Description
zero_vector () zero_vector () Constructs a zero_vector that holds zero elements.
zero_vector (size_type size) Constructs a zero_vector that holds size elements.
zero_vector (const zero_vector &v) The copy constructor.
void resize (size_type size)void resize (size_type size, bool preserve = +true) Resizes a zero_vector to hold size -elements.
size_type size () const Returns the size of the zero_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
zero_vector &operator = (const zero_vector &v) The assignment operator.
zero_vector &assign_temporary (zero_vector &v) Assigns a temporary. May change the zero vector v .
void swap (zero_vector &v) Swaps the contents of the zero vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the zero_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the zero_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed zero_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -606,16 +494,137 @@ end of the reversed zero_vector.
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +

Scalar +Vector

+

Description

+

The templated class scalar_vector<T> +represents scalar vectors. For a n-dimensional scalar +vector and 0 <= i < n holds +zi = s.

+

Example

+
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ scalar_vector<double> v (3);
+ std::cout << v << std::endl;
+}
+
+

Definition

+

Defined in the header vector.hpp.

+

Template parameters

+ + + + + + + + + + + + + +
ParameterDescriptionDefault
TThe type of object stored in the vector.
+

Model of

+

Vector Expression +.

+

Type requirements

+

None, except for those imposed by the requirements of Vector Expression .

+

Public base classes

+

vector_expression<scalar_vector<T> +>

+

Members

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MemberDescription
scalar_vector ()Constructs a scalar_vector that holds zero +elements.
scalar_vector (size_type size, const value_type +&value)Constructs a scalar_vector that holds +size elements each of the specified value.
scalar_vector (const scalar_vector &v)The copy constructor.
void resize (size_type size, bool preserve = +true)Resizes a scalar_vector to hold size +elements. Therefore the existing elements of the +scalar_vector are always preseved.
size_type size () constReturns the size of the scalar_vector.
const_reference operator () (size_type i) +constReturns the value of the i-th element.
const_reference operator [] (size_type i) +constReturns the value of the i-th element.
scalar_vector &operator = (const scalar_vector +&v)The assignment operator.
scalar_vector &assign_temporary (scalar_vector +&v)Assigns a temporary. May change the scalar vector +v .
void swap (scalar_vector &v)Swaps the contents of the scalar vectors.
const_iterator begin () constReturns a const_iterator pointing to the beginning +of the scalar_vector.
const_iterator end () constReturns a const_iterator pointing to the end of +the scalar_vector.
const_reverse_iterator rbegin () constReturns a const_reverse_iterator pointing to the +beginning of the reversed scalar_vector.
const_reverse_iterator rend () constReturns a const_reverse_iterator pointing to the +end of the reversed scalar_vector.
+
+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/vector_expression.htm b/doc/vector_expression.htm index 0f0a3860..cffa756f 100644 --- a/doc/vector_expression.htm +++ b/doc/vector_expression.htm @@ -1,170 +1,132 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Vector Expressions - -

c++boost.gif + +

c++boost.gif Vector Expressions

- -

Vector Expression

- +

Vector +Expression

Description

-

The templated class vector_expression<E> forms the base for all static derived vector expression classes including class vector itself.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
E E The type of the vector expression.  
-

Model of

-

None.

-

Type requirements

-

None.

-

Public base classes

-

None.

-

Members

- - +
- -
Member Description
const expression_type &operator () () const Returns a const reference of the expression.
expression_type &operator () () Returns a reference of the expression.
- -

Vector References

- +

Vector +References

Constant Reference

-

Description

-

The templated class vector_const_reference<E> contains a constant reference to a vector expression.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
E E The type of the vector expression.  
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_const_reference<E> >

-

Members

- - +
- +&e) - - - - - -
Member Description
vector_const_reference (const expression_type -&e) Constructs a constant reference of the expression.
size_type size () const Returns the size of the expression.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the expression.
const_iterator end () const Returns a const_iterator pointing to the end of the expression.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed expression.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -172,166 +134,128 @@ end of the reversed expression.
-

Reference

-

Description

-

The templated class vector_reference<E> contains a reference to a vector expression.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Template parameters

- - +
- - +
Parameter Description Default
E E The type of the vector expression.  
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_reference<E> >

-

Members

- - +
- - - - - - - - - + - - + - - - - + - - +
Member Description
vector_reference (expression_type &e) Constructs a reference of the expression.
void resize (size_type size) Resizes the expression to hold at most size elements.
size_type size () const Returns the size of the expression.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the expression.
const_iterator end () const Returns a const_iterator pointing to the end of the expression.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the expression.
iterator end () iterator end () Returns a iterator pointing to the end of the expression.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed expression.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed expression.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed expression.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed expression.
- -

Vector Operations

- +

Vector +Operations

Unary Operation Description

-

Description

-

The templated class vector_unary<E, F> describes a unary vector operation.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Template parameters

- - +
- - + - @@ -339,65 +263,50 @@ describes a unary vector operation.

Parameter Description Default
E E The type of the vector expression.  
F The type of the operation.
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_unary<E, F> >

-

Members

- - +
- - - - - - -
Member Description
vector_unary (const expression_type &e) Constructs a description of the expression.
size_type size () const Returns the size of the expression.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the expression.
const_iterator end () const Returns a const_iterator pointing to the end of the expression.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed expression.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -405,51 +314,46 @@ end of the reversed expression.
-

Unary Operations

-

Prototypes

-
-template<class E, class F>
- struct vector_unary_traits {
- typedef vector_unary<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (- v) [i] = - v [i]
- template<class E>
- typename vector_unary_traits<E, scalar_negate<typename E::value_type> >::result_type
- operator - (const vector_expression<E> &e);
-
- // (conj v) [i] = conj (v [i])
- template<class E>
- typename vector_unary_traits<E, scalar_conj<typename E::value_type> >::result_type
- conj (const vector_expression<E> &e);
-
- // (real v) [i] = real (v [i])
- template<class E>
- typename vector_unary_traits<E, scalar_real<typename E::value_type> >::result_type
- real (const vector_expression<E> &e);
-
- // (imag v) [i] = imag (v [i])
- template<class E>
- typename vector_unary_traits<E, scalar_imag<typename E::value_type> >::result_type
- imag (const vector_expression<E> &e);
-
- // (trans v) [i] = v [i]
- template<class E>
- typename vector_unary_traits<E, scalar_identity<typename E::value_type> >::result_type
- trans (const vector_expression<E> &e);
-
- // (herm v) [i] = conj (v [i])
- template<class E>
- typename vector_unary_traits<E, scalar_conj<typename E::value_type> >::result_type
+template<class E, class F>
+ struct vector_unary_traits {
+ typedef vector_unary<typename E::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (- v) [i] = - v [i]
+ template<class E>
+ typename vector_unary_traits<E, scalar_negate<typename E::value_type> >::result_type
+ operator - (const vector_expression<E> &e);
+
+ // (conj v) [i] = conj (v [i])
+ template<class E>
+ typename vector_unary_traits<E, scalar_conj<typename E::value_type> >::result_type
+ conj (const vector_expression<E> &e);
+
+ // (real v) [i] = real (v [i])
+ template<class E>
+ typename vector_unary_traits<E, scalar_real<typename E::value_type> >::result_type
+ real (const vector_expression<E> &e);
+
+ // (imag v) [i] = imag (v [i])
+ template<class E>
+ typename vector_unary_traits<E, scalar_imag<typename E::value_type> >::result_type
+ imag (const vector_expression<E> &e);
+
+ // (trans v) [i] = v [i]
+ template<class E>
+ typename vector_unary_traits<E, scalar_identity<typename E::value_type> >::result_type
+ trans (const vector_expression<E> &e);
+
+ // (herm v) [i] = conj (v [i])
+ template<class E>
+ typename vector_unary_traits<E, scalar_conj<typename E::value_type> >::result_type
herm (const vector_expression<E> &e);
-

Description

-

operator - computes the additive inverse of a vector expression. conj computes the complex conjugate of a vector expression. real and imag @@ -457,147 +361,112 @@ compute the real and imaginary parts of a vector expression. trans computes the transpose of a vector expression. herm computes the hermitian, i.e. the complex conjugate of the transpose of a vector expression.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Type requirements

- -

Preconditions

-

None.

-

Complexity

-

Linear depending from the size of the vector expression.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<std::complex<double> > v (3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = std::complex<double> (i, i);
-
- std::cout << - v << std::endl;
- std::cout << conj (v) << std::endl;
- std::cout << real (v) << std::endl;
- std::cout << imag (v) << std::endl;
- std::cout << trans (v) << std::endl;
- std::cout << herm (v) << std::endl;
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<std::complex<double> > v (3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = std::complex<double> (i, i);
+
+ std::cout << - v << std::endl;
+ std::cout << conj (v) << std::endl;
+ std::cout << real (v) << std::endl;
+ std::cout << imag (v) << std::endl;
+ std::cout << trans (v) << std::endl;
+ std::cout << herm (v) << std::endl;
}
-

Binary Operation Description

-

Description

-

The templated class vector_binary<E1, E2, F> describes a binary vector operation.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - - +
Parameter Description Default
E1 E1 The type of the first vector expression. 
E2 The type of the second vector expression. 
F The type of the operation. 
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_binary<E1, E2, F> >

-

Members

- - +
- - - - - - -
Member Description
vector_binary (const expression1_type &e1, const expression2_type &e2) Constructs a description of the expression.
size_type size () const Returns the size of the expression.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the expression.
const_iterator end () const Returns a const_iterator pointing to the end of the expression.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed expression.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -605,211 +474,165 @@ end of the reversed expression.
-

Binary Operations

-

Prototypes

-
-template<class E1, class E2, class F>
- struct vector_binary_traits {
- typedef vector_binary<typename E1::const_closure_type,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (v1 + v2) [i] = v1 [i] + v2 [i]
- template<class E1, class E2>
- typename vector_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator + (const vector_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- // (v1 - v2) [i] = v1 [i] - v2 [i]
- template<class E1, class E2>
- typename vector_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator - (const vector_expression<E1> &e1,
+template<class E1, class E2, class F>
+ struct vector_binary_traits {
+ typedef vector_binary<typename E1::const_closure_type,
+ typename E2::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (v1 + v2) [i] = v1 [i] + v2 [i]
+ template<class E1, class E2>
+ typename vector_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
+ typename E2::value_type> >::result_type
+ operator + (const vector_expression<E1> &e1,
+ const vector_expression<E2> &e2);
+
+ // (v1 - v2) [i] = v1 [i] - v2 [i]
+ template<class E1, class E2>
+ typename vector_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
+ typename E2::value_type> >::result_type
+ operator - (const vector_expression<E1> &e1,
const vector_expression<E2> &e2);
-

Description

-

operator + computes the sum of two vector expressions. operator - computes the difference of two vector expressions.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size () == e2 ().size ()
-

Complexity

-

Linear depending from the size of the vector expressions.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v1 (3), v2 (3);
- for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i)
- v1 (i) = v2 (i) = i;
-
- std::cout << v1 + v2 << std::endl;
- std::cout << v1 - v2 << std::endl;
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v1 (3), v2 (3);
+ for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i)
+ v1 (i) = v2 (i) = i;
+
+ std::cout << v1 + v2 << std::endl;
+ std::cout << v1 - v2 << std::endl;
}
-

Binary Outer Operation Description

-

Description

-

The templated class vector_matrix_binary<E1, E2, F> describes a binary outer vector operation.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - - +
Parameter Description Default
E1 E1 The type of the first vector expression. 
E2 The type of the second vector expression. 
F The type of the operation. 
-

Model of

-

Matrix Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Matrix Expression .

-

Public base classes

-

matrix_expression<vector_matrix_binary<E1, E2, F> >

-

Members

- - +
- +const expression2_type &e2) - - - - - - - - - - -
Member Description
vector_matrix_binary (const expression1_type &e1, -const expression2_type &e2) Constructs a description of the expression.
size_type size1 () const Returns the number of rows.
size_type size2 () const Returns the number of columns.
const_reference operator () (size_type i, size_type j) const Returns the value of the j-th element in the i-th row.
const_iterator1 begin1 () const Returns a const_iterator1 pointing to the beginning of the expression.
const_iterator1 end1 () const Returns a const_iterator1 pointing to the end of the expression.
const_iterator2 begin2 () const Returns a const_iterator2 pointing to the beginning of the expression.
const_iterator2 end2 () const Returns a const_iterator2 pointing to the end of the expression.
const_reverse_iterator1 rbegin1 () const Returns a const_reverse_iterator1 pointing to the beginning of the reversed expression.
const_reverse_iterator1 rend1 () const Returns a const_reverse_iterator1 pointing to the end of the reversed expression.
const_reverse_iterator2 rbegin2 () const Returns a const_reverse_iterator2 pointing to the beginning of the reversed expression.
const_reverse_iterator2 rend2 () const Returns a const_reverse_iterator2 pointing to the @@ -817,179 +640,137 @@ end of the reversed expression.
-

Binary Outer Operations

-

Prototypes

-
-template<class E1, class E2, class F>
- struct vector_matrix_binary_traits {
- typedef vector_matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (outer_prod (v1, v2)) [i] [j] = v1 [i] * v2 [j]
- template<class E1, class E2>
- typename vector_matrix_binary_traits<E1, E2, scalar_multiplies<typename E1::value_type, typename E2::value_type> >::result_type
- outer_prod (const vector_expression<E1> &e1,
+template<class E1, class E2, class F>
+ struct vector_matrix_binary_traits {
+ typedef vector_matrix_binary<typename E1::const_closure_type,
+ typename E2::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (outer_prod (v1, v2)) [i] [j] = v1 [i] * v2 [j]
+ template<class E1, class E2>
+ typename vector_matrix_binary_traits<E1, E2, scalar_multiplies<typename E1::value_type, typename E2::value_type> >::result_type
+ outer_prod (const vector_expression<E1> &e1,
const vector_expression<E2> &e2);
-

Description

-

outer_prod computes the outer product of two vector expressions.

-

Definition

-

Defined in the header matrix_expression.hpp.

-

Type requirements

- -

Preconditions

-

None.

-

Complexity

-

Quadratic depending from the size of the vector expressions.

-

Examples

-
-#include <boost/numeric/ublas/matrix.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v1 (3), v2 (3);
- for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i)
- v1 (i) = v2 (i) = i;
-
- std::cout << outer_prod (v1, v2) << std::endl;
-}
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v1 (3), v2 (3);
+ for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i)
+ v1 (i) = v2 (i) = i;
+
+ std::cout << outer_prod (v1, v2) << std::endl;
+}
-

Scalar Vector Operation Description

-

Description

-

The templated classes vector_binary_scalar1<E1, E2, F> and vector_binary_scalar2<E1, E2, F> describe binary operations between a scalar and a vector.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Template parameters

- - +
- - + - + - - + - - +
Parameter Description Default
E1/E2 E1/E2 The type of the scalar expression. 
E2/E1 The type of the vector expression. 
F The type of the operation. 
-

Model of

-

Vector Expression .

-

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_binary_scalar1<E1, E2, F> > and vector_expression<vector_binary_scalar2<E1, E2, F> > resp.

-

Members

- - +
- - - - - - - -
Member Description
vector_binary_scalar1 (const expression1_type &e1, const expression2_type &e2) Constructs a description of the expression.
vector_binary_scalar2 (const expression1_type &e1, const expression2_type &e2) Constructs a description of the expression.
size_type size () const Returns the size of the expression.
const_reference operator () (size_type i) const Returns the value of the i-th element.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the expression.
const_iterator end () const Returns a const_iterator pointing to the end of the expression.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed expression.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the @@ -997,130 +778,109 @@ end of the reversed expression.
-

Scalar Vector Operations

-

Prototypes

-
-template<class T1, class E2, class F>
- struct vector_binary_scalar1_traits {
- typedef vector_binary_scalar1<scalar_const_reference<T1>,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (t * v) [i] = t * v [i]
- template<class T1, class E2>
- typename vector_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
- operator * (const T1 &e1,
- const vector_expression<E2> &e2);
-
- template<class E1, class T2, class F>
- struct vector_binary_scalar2_traits {
- typedef vector_binary_scalar2<typename E1::const_closure_type,
- scalar_const_reference<T2>, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (v * t) [i] = v [i] * t
- template<class E1, class T2>
- typename vector_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
- operator * (const vector_expression<E1> &e1,
- const T2 &e2);
-
- // (v / t) [i] = v [i] / t
- template<class E1, class T2>
- typename vector_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
- operator / (const vector_expression<E1> &e1,
+template<class T1, class E2, class F>
+ struct vector_binary_scalar1_traits {
+ typedef vector_binary_scalar1<scalar_const_reference<T1>,
+ typename E2::const_closure_type, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (t * v) [i] = t * v [i]
+ template<class T1, class E2>
+ typename vector_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
+ operator * (const T1 &e1,
+ const vector_expression<E2> &e2);
+
+ template<class E1, class T2, class F>
+ struct vector_binary_scalar2_traits {
+ typedef vector_binary_scalar2<typename E1::const_closure_type,
+ scalar_const_reference<T2>, F> expression_type;
+ typedef expression_type result_type;
+ };
+
+ // (v * t) [i] = v [i] * t
+ template<class E1, class T2>
+ typename vector_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
+ operator * (const vector_expression<E1> &e1,
+ const T2 &e2);
+
+ // (v / t) [i] = v [i] / t
+ template<class E1, class T2>
+ typename vector_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
+ operator / (const vector_expression<E1> &e1,
const T2 &e2);
-

Description

-

operator * computes the product of a scalar and a vector expression. operator / multiplies the vector with the reciprocal of the scalar.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Type requirements

- -

Preconditions

-

None.

-

Complexity

-

Linear depending from the size of the vector expression.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = i;
-
- std::cout << 2.0 * v << std::endl;
- std::cout << v * 2.0 << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = i;
+
+ std::cout << 2.0 * v << std::endl;
+ std::cout << v * 2.0 << std::endl;
+}
- -

Vector Reductions

- +

Vector +Reductions

Unary Reductions

-

Prototypes

-
-template<class E, class F>
- struct vector_scalar_unary_traits {
- typedef typename F::result_type result_type;
- };
-
- // sum v = sum (v [i])
- template<class E>
- typename vector_scalar_unary_traits<E, vector_sum<typename E::value_type> >::result_type
- sum (const vector_expression<E> &e);
-
- // norm_1 v = sum (abs (v [i]))
- template<class E>
- typename vector_scalar_unary_traits<E, vector_norm_1<typename E::value_type> >::result_type
- norm_1 (const vector_expression<E> &e);
-
- // norm_2 v = sqrt (sum (v [i] * v [i]))
- template<class E>
- typename vector_scalar_unary_traits<E, vector_norm_2<typename E::value_type> >::result_type
- norm_2 (const vector_expression<E> &e);
-
- // norm_inf v = max (abs (v [i]))
- template<class E>
- typename vector_scalar_unary_traits<E, vector_norm_inf<typename E::value_type> >::result_type
- norm_inf (const vector_expression<E> &e);
-
- // index_norm_inf v = min (i: abs (v [i]) == max (abs (v [i])))
- template<class E>
- typename vector_scalar_unary_traits<E, vector_index_norm_inf<typename E::value_type> >::result_type
+template<class E, class F>
+ struct vector_scalar_unary_traits {
+ typedef typename F::result_type result_type;
+ };
+
+ // sum v = sum (v [i])
+ template<class E>
+ typename vector_scalar_unary_traits<E, vector_sum<typename E::value_type> >::result_type
+ sum (const vector_expression<E> &e);
+
+ // norm_1 v = sum (abs (v [i]))
+ template<class E>
+ typename vector_scalar_unary_traits<E, vector_norm_1<typename E::value_type> >::result_type
+ norm_1 (const vector_expression<E> &e);
+
+ // norm_2 v = sqrt (sum (v [i] * v [i]))
+ template<class E>
+ typename vector_scalar_unary_traits<E, vector_norm_2<typename E::value_type> >::result_type
+ norm_2 (const vector_expression<E> &e);
+
+ // norm_inf v = max (abs (v [i]))
+ template<class E>
+ typename vector_scalar_unary_traits<E, vector_norm_inf<typename E::value_type> >::result_type
+ norm_inf (const vector_expression<E> &e);
+
+ // index_norm_inf v = min (i: abs (v [i]) == max (abs (v [i])))
+ template<class E>
+ typename vector_scalar_unary_traits<E, vector_index_norm_inf<typename E::value_type> >::result_type
index_norm_inf (const vector_expression<E> &e);
-

Description

-

sum computes the sum of the vector expression's elements. norm_1, norm_2 and norm_inf compute the corresponding @@ -1129,127 +889,98 @@ elements. norm_1, norm_2 and ||.||inf vector norms. index_norm_1 computes the index of the vector expression's first element having maximal absolute value.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Type requirements

- -

Preconditions

-

None.

-

Complexity

-

Linear depending from the size of the vector expression.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = i;
-
- std::cout << sum (v) << std::endl;
- std::cout << norm_1 (v) << std::endl;
- std::cout << norm_2 (v) << std::endl;
- std::cout << norm_inf (v) << std::endl;
- std::cout << index_norm_inf (v) << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = i;
+
+ std::cout << sum (v) << std::endl;
+ std::cout << norm_1 (v) << std::endl;
+ std::cout << norm_2 (v) << std::endl;
+ std::cout << norm_inf (v) << std::endl;
+ std::cout << index_norm_inf (v) << std::endl;
+}
-

Binary Reductions

-

Prototypes

-
-template<class E1, class E2, class F>
- struct vector_scalar_binary_traits {
- typedef typename F::result_type result_type;
- };
-
- // inner_prod (v1, v2) = sum (v1 [i] * v2 [i])
- template<class E1, class E2>
- typename vector_scalar_binary_traits<E1, E2, vector_inner_prod<typename E1::value_type,
- typename E2::value_type,
- typename promote_traits<typename E1::value_type,
- typename E2::value_type>::promote_type> >::result_type
- inner_prod (const vector_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class E1, class E2>
- typename vector_scalar_binary_traits<E1, E2, vector_inner_prod<typename E1::value_type,
- typename E2::value_type,
- typename type_traits<typename promote_traits<typename E1::value_type,
- typename E2::value_type>::promote_type>::precision_type> >::result_type
- prec_inner_prod (const vector_expression<E1> &e1,
+template<class E1, class E2, class F>
+ struct vector_scalar_binary_traits {
+ typedef typename F::result_type result_type;
+ };
+
+ // inner_prod (v1, v2) = sum (v1 [i] * v2 [i])
+ template<class E1, class E2>
+ typename vector_scalar_binary_traits<E1, E2, vector_inner_prod<typename E1::value_type,
+ typename E2::value_type,
+ typename promote_traits<typename E1::value_type,
+ typename E2::value_type>::promote_type> >::result_type
+ inner_prod (const vector_expression<E1> &e1,
+ const vector_expression<E2> &e2);
+
+ template<class E1, class E2>
+ typename vector_scalar_binary_traits<E1, E2, vector_inner_prod<typename E1::value_type,
+ typename E2::value_type,
+ typename type_traits<typename promote_traits<typename E1::value_type,
+ typename E2::value_type>::promote_type>::precision_type> >::result_type
+ prec_inner_prod (const vector_expression<E1> &e1,
const vector_expression<E2> &e2);
-

Description

-

inner_prod computes the inner product of the vector expressions. prec_inner_prod computes the double precision inner product of the vector expressions.

-

Definition

-

Defined in the header vector_expression.hpp.

-

Type requirements

- -

Preconditions

-
  • e1 ().size () == e2 ().size ()
-

Complexity

-

Linear depending from the size of the vector expressions.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v1 (3), v2 (3);
- for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i)
- v1 (i) = v2 (i) = i;
-
- std::cout << inner_prod (v1, v2) << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v1 (3), v2 (3);
+ for (unsigned i = 0; i < std::min (v1.size (), v2.size ()); ++ i)
+ v1 (i) = v2 (i) = i;
+
+ std::cout << inner_prod (v1, v2) << std::endl;
+}
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/doc/vector_proxy.htm b/doc/vector_proxy.htm index 0867df05..46448860 100644 --- a/doc/vector_proxy.htm +++ b/doc/vector_proxy.htm @@ -1,601 +1,482 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Vector Proxies - -

c++boost.gif + +

c++boost.gif Vector Proxies

- -

Vector Range

- +

Vector Range

Description

-

The templated class vector_range<V> allows -addressing a range of a vector.

- +addressing a sub-range of a vector's element.

Example

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- vector_range<vector<double> > vr (v, range (0, 3));
- for (unsigned i = 0; i < vr.size (); ++ i)
- vr (i) = i;
- std::cout << vr << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ vector_range<vector<double> > vr (v, range (0, 3));
+ for (unsigned i = 0; i < vr.size (); ++ i)
+ vr (i) = i;
+ std::cout << vr << std::endl;
+}
-

Definition

-

Defined in the header vector_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
V V The type of vector referenced. 
-

Model of

-

Vector Expression .

- +

If the specified range falls outside that of the index range of +the vector, then the vector_range is not a well formed +Vector Expression. That is, access to an element which is outside +of index range of the vector is undefined.

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_range<V> >

-

Members

- - +
- - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - +
Member Description
vector_range (vector_type &data, const range &r) Constructs a sub vector.
size_type start () const Returns the start of the sub vector.
size_type size () const Returns the size of the sub vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
vector_range &operator = (const vector_range &vr) The assignment operator.
vector_range &assign_temporary (vector_range &vr) Assigns a temporary. May change the vector range vr .
template<class AE>
- vector_range &operator = (const vector_expression<AE> +
template<class AE>
+vector_range &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- vector_range &assign (const vector_expression<AE> +
template<class AE>
+vector_range &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- vector_range &operator += (const vector_expression<AE> +
template<class AE>
+vector_range &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sub vector.
template<class AE>
- vector_range &plus_assign (const vector_expression<AE> +
template<class AE>
+vector_range &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- vector_range &operator -= (const vector_expression<AE> +
template<class AE>
+vector_range &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sub vector.
template<class AE>
- vector_range &minus_assign (const vector_expression<AE> +
template<class AE>
+vector_range &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent.
template<class AT>
- vector_range &operator *= (const AT &at)
template<class AT>
+vector_range &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub vector with a scalar.
template<class AT>
- vector_range &operator /= (const AT &at)
template<class AT>
+vector_range &operator /= (const AT &at)
A computed assignment operator. Divides the sub vector through a scalar.
void swap (vector_range &vr) Swaps the contents of the sub vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the vector_range.
const_iterator end () const Returns a const_iterator pointing to the end of the vector_range.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the vector_range.
iterator end () iterator end () Returns a iterator pointing to the end of the vector_range.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed vector_range.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed vector_range.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed vector_range.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed vector_range.
-

Projections

-

Prototypes

-
-template<class V>
- vector_range<V> project (V &data, const range &r);
- template<class V>
- const vector_range<const V> project (const V &data, const range &r);
- template<class V>
+template<class V>
+ vector_range<V> project (V &data, const range &r);
+ template<class V>
+ const vector_range<const V> project (const V &data, const range &r);
+ template<class V>
vector_range<V> project (const vector_range<V> &data, const range &r);
-

Description

-

The free project functions support the construction of vector ranges.

-

Definition

-

Defined in the header vector_proxy.hpp.

-

Type requirements

- - -

Preconditions

- -
    -
  • r.start () + r.size () <= data.size ()
  • -
-

Complexity

-

Linear depending from the size of the range.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- for (int i = 0; i < 3; ++ i)
- project (v, range (0, 3)) (i) = i;
- std::cout << project (v, range (0, 3)) << std::endl;
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ for (int i = 0; i < 3; ++ i)
+ project (v, range (0, 3)) (i) = i;
+ std::cout << project (v, range (0, 3)) << std::endl;
}
- -

Vector Slice

- +

Vector Slice

Description

-

The templated class vector_slice<V> allows addressing a slice of a vector.

-

Example

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- vector_slice<vector<double> > vs (v, slice (0, 1, 3));
- for (unsigned i = 0; i < vs.size (); ++ i)
- vs (i) = i;
- std::cout << vs << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ vector_slice<vector<double> > vs (v, slice (0, 1, 3));
+ for (unsigned i = 0; i < vs.size (); ++ i)
+ vs (i) = i;
+ std::cout << vs << std::endl;
+}
-

Definition

-

Defined in the header vector_proxy.hpp.

-

Template parameters

- - +
- - + - +
Parameter Description Default
V V The type of vector referenced. 
-

Model of

-

Vector Expression .

- +

If the specified slice falls outside that of the index range of +the vector, then the vector_slice is not a well formed +Vector Expression. That is, access to an element which is outside +of index range of the vector is undefined.

Type requirements

-

None, except for those imposed by the requirements of Vector Expression .

-

Public base classes

-

vector_expression<vector_slice<V> >

-

Members

- - +
- - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - + - - + - - - - + - - +
Member Description
vector_slice (vector_type &data, const slice &s) Constructs a sub vector.
size_type size () const Returns the size of the sub vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
vector_slice &operator = (const vector_slice &vs) The assignment operator.
vector_slice &assign_temporary (vector_slice &vs) Assigns a temporary. May change the vector slice vs .
template<class AE>
- vector_slice &operator = (const vector_expression<AE> +
template<class AE>
+vector_slice &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- vector_slice &assign (const vector_expression<AE> +
template<class AE>
+vector_slice &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- vector_slice &operator += (const vector_expression<AE> +
template<class AE>
+vector_slice &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sub vector.
template<class AE>
- vector_slice &plus_assign (const vector_expression<AE> +
template<class AE>
+vector_slice &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent.
template<class AE>
- vector_slice &operator -= (const vector_expression<AE> +
template<class AE>
+vector_slice &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sub vector.
template<class AE>
- vector_slice &minus_assign (const vector_expression<AE> +
template<class AE>
+vector_slice &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent.
template<class AT>
- vector_slice &operator *= (const AT &at)
template<class AT>
+vector_slice &operator *= (const AT &at)
A computed assignment operator. Multiplies the sub vector with a scalar.
template<class AT>
- vector_slice &operator /= (const AT &at)
template<class AT>
+vector_slice &operator /= (const AT &at)
A computed assignment operator. Divides the sub vector through a scalar.
void swap (vector_slice &vs) Swaps the contents of the sub vectors.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the vector_slice.
const_iterator end () const Returns a const_iterator pointing to the end of the vector_slice.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the vector_slice.
iterator end () iterator end () Returns a iterator pointing to the end of the vector_slice.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed vector_slice.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed vector_slice.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed vector_slice.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed vector_slice.
-

Projections

-

Prototypes

-
-template<class V>
- vector_slice<V> project (const vector_slice<V> &data, const range &r);
- template<class V>
- vector_slice<V> project (V &data, const slice &s);
- template<class V>
- const vector_slice<const V> project (const V &data, const slice &s);
- template<class V>
+template<class V>
+ vector_slice<V> project (const vector_slice<V> &data, const range &r);
+ template<class V>
+ vector_slice<V> project (V &data, const slice &s);
+ template<class V>
+ const vector_slice<const V> project (const V &data, const slice &s);
+ template<class V>
vector_slice<V> project (const vector_slice<V> &data, const slice &s);
-

Description

-

The free project functions support the construction of vector slices.

-

Definition

-

Defined in the header vector_proxy.hpp.

-

Type requirements

- - -

Preconditions

- -
    -
  • s.start () + s.stride () * s.size () <= data.size -()
  • -
-

Complexity

-

Linear depending from the size of the slice.

-

Examples

-
-#include <boost/numeric/ublas/vector.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- vector<double> v (3);
- for (int i = 0; i < 3; ++ i)
- project (v, slice (0, 1, 3)) (i) = i;
- std::cout << project (v, slice (0, 1, 3)) << std::endl;
-}
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ vector<double> v (3);
+ for (int i = 0; i < 3; ++ i)
+ project (v, slice (0, 1, 3)) (i) = i;
+ std::cout << project (v, slice (0, 1, 3)) << std::endl;
+}
- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

- -

Last revised: 1/15/2003

+

Last revised: 15/04/2004

- diff --git a/doc/vector_sparse.htm b/doc/vector_sparse.htm index 15916e6a..f81fb369 100644 --- a/doc/vector_sparse.htm +++ b/doc/vector_sparse.htm @@ -1,20 +1,21 @@ - - + + - + - +"text/html; charset=us-ascii" /> + Sparse Vector - -

c++boost.gif + +

c++boost.gif Sparse Vector

- -

Sparse Vector

- +

Sparse +Vector

Description

- +

The templated class sparse_vector<T, A> is the base container adaptor for sparse vectors. For a n-dimensional sparse vector and 0 <= i < n @@ -26,289 +27,239 @@ elements k = vi2of the container holds i1 < i2.

-

Example

-
-#include <boost/numeric/ublas/vector_sparse.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- sparse_vector<double> v (3, 3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = i;
- std::cout << v << std::endl;
-}
+#include <boost/numeric/ublas/vector_sparse.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ sparse_vector<double> v (3, 3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = i;
+ std::cout << v << std::endl;
+}
-

Definition

-

Defined in the header vector_sparse.hpp.

-

Template parameters

- - +
- - + - + - - +"#sparse_vector_1">[1] +
Parameter Description Default
T T The type of object stored in the sparse vector. 
A The type of the adapted array. [1] map_array<std::size_t, T>map_std<std::size_t, T>
-

Model of

-

Vector .

-

Type requirements

-

None, except for those imposed by the requirements of Vector .

-

Public base classes

-

vector_expression<sparse_vector<T, A> >

-

Members

- - +
- - + - - - - - - + +size elements. The existing elements of the +sparse_vector are preseved when specified. - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - +
Member Description
sparse_vector () sparse_vector () Allocates a sparse_vector that holds zero elements.
sparse_vector (size_type size, size_type non_zeros) Allocates a sparse_vector that holds at most size elements.
sparse_vector (const sparse_vector &v) The copy constructor.
template<class AE>
- sparse_vector (size_type non_zeros, const +
template<class AE>
+sparse_vector (size_type non_zeros, const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size, size_type -non_zeros)void resize (size_type size, size_type non_zeros, bool +preserve = true) Reallocates a sparse_vector to hold at most -size elements. The content of the -sparse_vector is preserved.
size_type size () const Returns the size of the sparse_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
sparse_vector &operator = (const sparse_vector &v) The assignment operator.
sparse_vector &assign_temporary (sparse_vector &v) Assigns a temporary. May change the sparse vector v .
template<class AE>
- sparse_vector &operator = (const vector_expression<AE> +
template<class AE>
+sparse_vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- sparse_vector &assign (const vector_expression<AE> +
template<class AE>
+sparse_vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sparse vector. Left and right hand side of the assignment should be independent.
template<class AE>
- sparse_vector &operator += (const vector_expression<AE> +
template<class AE>
+sparse_vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sparse vector.
template<class AE>
- sparse_vector &plus_assign (const vector_expression<AE> +
template<class AE>
+sparse_vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sparse vector. Left and right hand side of the assignment should be independent.
template<class AE>
- sparse_vector &operator -= (const vector_expression<AE> +
template<class AE>
+sparse_vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sparse vector.
template<class AE>
- sparse_vector &minus_assign (const vector_expression<AE> +
template<class AE>
+sparse_vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sparse vector. Left and right hand side of the assignment should be independent.
template<class AT>
- sparse_vector &operator *= (const AT &at)
template<class AT>
+sparse_vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the sparse vector with a scalar.
template<class AT>
- sparse_vector &operator /= (const AT &at)
template<class AT>
+sparse_vector &operator /= (const AT &at)
A computed assignment operator. Divides the sparse vector through a scalar.
void swap (sparse_vector &v) Swaps the contents of the sparse vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the sparse vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the sparse_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the sparse_vector.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the sparse_vector.
iterator end () iterator end () Returns a iterator pointing to the end of the sparse_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed sparse_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed sparse_vector.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed sparse_vector.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed sparse_vector.
-

Notes

- -

[1] Supported parameters for the -adapted array are map_array<std::size_t, T> and -std::map<std::size_t, T>.

- -

Compressed Vector

- +

[1] Supported +parameters for the adapted array are +map_array<std::size_t, T> and +map_std<std::size_t, T>. The latter is +equivalent to std::map<std::size_t, T>.

+

+Compressed Vector

Description

-

The templated class compressed_vector<T, IB, IA, TA> is the base container adaptor for compressed vectors. For a n-dimensional compressed vector and 0 <= i @@ -320,308 +271,255 @@ container, i.e. for elements k = vi2of these containers holds i1 < i2.

-

Example

-
-#include <boost/numeric/ublas/vector_sparse.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- compressed_vector<double> v (3, 3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = i;
- std::cout << v << std::endl;
+#include <boost/numeric/ublas/vector_sparse.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ compressed_vector<double> v (3, 3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = i;
+ std::cout << v << std::endl;
}
-

Definition

-

Defined in the header vector_sparse.hpp.

-

Template parameters

- - +
- - + - + - +"#compressed_vector_1">[1] - +"#compressed_vector_2">[2] - +"#compressed_vector_2">[2]
Parameter Description Default
T T The type of object stored in the compressed vector. 
IB The index base of the compressed vector. [1] 0
IA The type of the adapted array for indices. [2] unbounded_array<std::size_t>
TA The type of the adapted array for values. [2] unbounded_array<T>
-

Model of

-

Vector .

-

Type requirements

-

None, except for those imposed by the requirements of Vector .

-

Public base classes

-

vector_expression<compressed_vector<T, IB, IA, TA> >

-

Members

- - +
- - + - - - - - - + +size elements. The existing elements of the +compress_vector are preseved when specified. - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - +
Member Description
compressed_vector () compressed_vector () Allocates a compressed_vector that holds zero elements.
compressed_vector (size_type size, size_type non_zeros) Allocates a compressed_vector that holds at most size elements.
compressed_vector (const compressed_vector &v) The copy constructor.
template<class AE>
- compressed_vector (size_type non_zeros, const +
template<class AE>
+compressed_vector (size_type non_zeros, const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size, size_type -non_zeros)void resize (size_type size, size_type non_zeros, bool +preserve = true) Reallocates a compressed_vector to hold at most -size elements. The content of the -compressed_vector is preserved.
size_type size () const Returns the size of the compressed_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
compressed_vector &operator = (const compressed_vector &v) The assignment operator.
compressed_vector &assign_temporary (compressed_vector &v) Assigns a temporary. May change the compressed vector v.
template<class AE>
- compressed_vector &operator = (const +
template<class AE>
+compressed_vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- compressed_vector &assign (const vector_expression<AE> +
template<class AE>
+compressed_vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the compressed vector. Left and right hand side of the assignment should be independent.
template<class AE>
- compressed_vector &operator += (const +
template<class AE>
+compressed_vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the compressed vector.
template<class AE>
- compressed_vector &plus_assign (const +
template<class AE>
+compressed_vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the compressed vector. Left and right hand side of the assignment should be independent.
template<class AE>
- compressed_vector &operator -= (const +
template<class AE>
+compressed_vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the compressed vector.
template<class AE>
- compressed_vector &minus_assign (const +
template<class AE>
+compressed_vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the compressed vector. Left and right hand side of the assignment should be independent.
template<class AT>
- compressed_vector &operator *= (const AT &at)
template<class AT>
+compressed_vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the compressed vector with a scalar.
template<class AT>
- compressed_vector &operator /= (const AT &at)
template<class AT>
+compressed_vector &operator /= (const AT &at)
A computed assignment operator. Divides the compressed vector through a scalar.
void swap (compressed_vector &v) Swaps the contents of the compressed vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the compressed vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the compressed_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the compressed_vector.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the compressed_vector.
iterator end () iterator end () Returns a iterator pointing to the end of the compressed_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed compressed_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed compressed_vector.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed compressed_vector.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed compressed_vector.
-

Notes

- -

[1] Supported parameters for -the index base are 0 and 1 at least.

- -

[2] Supported parameters for -the adapted array are unbounded_array<> , +

[1] +Supported parameters for the index base are 0 and +1 at least.

+

[2] +Supported parameters for the adapted array are +unbounded_array<> , bounded_array<> and std::vector<> .

- -

Coordinate Vector

- +

+Coordinate Vector

Description

-

The templated class coordinate_vector<T, IB, IA, TA> is the base container adaptor for compressed vectors. For a n-dimensional sorted coordinate vector and 0 @@ -633,313 +531,259 @@ of the index and value container, i.e. for elements k = vi2of these containers holds i1 < i2.

-

Example

-
-#include <boost/numeric/ublas/vector_sparse.hpp>
-#include <boost/numeric/ublas/io.hpp>
-
-int main () {
- using namespace boost::numeric::ublas;
- coordinate_vector<double> v (3, 3);
- for (unsigned i = 0; i < v.size (); ++ i)
- v (i) = i;
- std::cout << v << std::endl;
-}
+#include <boost/numeric/ublas/vector_sparse.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+int main () {
+ using namespace boost::numeric::ublas;
+ coordinate_vector<double> v (3, 3);
+ for (unsigned i = 0; i < v.size (); ++ i)
+ v (i) = i;
+ std::cout << v << std::endl;
+}
-

Definition

-

Defined in the header vector_sparse.hpp.

-

Template parameters

- - +
- - + - + - +"#coordinate_vector_1">[1] - +"#coordinate_vector_2">[2] - +"#coordinate_vector_2">[2]
Parameter Description Default
T T The type of object stored in the coordinate vector. 
IB The index base of the coordinate vector. [1] 0
IA The type of the adapted array for indices. [2] unbounded_array<std::size_t>
TA The type of the adapted array for values. [2] unbounded_array<T>
-

Model of

-

Vector .

-

Type requirements

-

None, except for those imposed by the requirements of Vector .

-

Public base classes

-

vector_expression<coordinate_vector<T, IB, IA, TA> >

-

Members

- - +
- - + - - - - - +size elements. The existing elements of the +coordinate_vector are preseved when specified. - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - + - - + - - - - + - - +
Member Description
coordinate_vector () coordinate_vector () Allocates a coordinate_vector that holds zero elements.
coordinate_vector (size_type size, size_type non_zeros) Allocates a coordinate_vector that holds at most size elements.
coordinate_vector (const coordinate_vector &v) The copy constructor.
template<class AE>
- coordinate_vector (size_type non_zeros, const +
template<class AE>
+coordinate_vector (size_type non_zeros, const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size, size_type non_zeros) Reallocates a coordinate_vector to hold at most -size elements. The content of the -coordinate_vector is preserved.
size_type size () const Returns the size of the coordinate_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
coordinate_vector &operator = (const coordinate_vector &v) The assignment operator.
coordinate_vector &assign_temporary (coordinate_vector &v) Assigns a temporary. May change the coordinate vector v.
template<class AE>
- coordinate_vector &operator = (const +
template<class AE>
+coordinate_vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
- coordinate_vector &assign (const vector_expression<AE> +
template<class AE>
+coordinate_vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the coordinate vector. Left and right hand side of the assignment should be independent.
template<class AE>
- coordinate_vector &operator += (const +
template<class AE>
+coordinate_vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the coordinate vector.
template<class AE>
- coordinate_vector &plus_assign (const +
template<class AE>
+coordinate_vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the coordinate vector. Left and right hand side of the assignment should be independent.
template<class AE>
- coordinate_vector &operator -= (const +
template<class AE>
+coordinate_vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the coordinate vector.
template<class AE>
- coordinate_vector &minus_assign (const +
template<class AE>
+coordinate_vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the coordinate vector. Left and right hand side of the assignment should be independent.
template<class AT>
- coordinate_vector &operator *= (const AT &at)
template<class AT>
+coordinate_vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the coordinate vector with a scalar.
template<class AT>
- coordinate_vector &operator /= (const AT &at)
template<class AT>
+coordinate_vector &operator /= (const AT &at)
A computed assignment operator. Divides the coordinate vector through a scalar.
void swap (coordinate_vector &v) Swaps the contents of the coordinate vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the coordinate vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the coordinate_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the coordinate_vector.
iterator begin () iterator begin () Returns a iterator pointing to the beginning of the coordinate_vector.
iterator end () iterator end () Returns a iterator pointing to the end of the coordinate_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed coordinate_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed coordinate_vector.
reverse_iterator rbegin () reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed coordinate_vector.
reverse_iterator rend () reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed coordinate_vector.
-

Notes

- -

[1] Supported parameters for -the index base are 0 and 1 at least.

- -

[2] Supported parameters for -the adapted array are unbounded_array<> , +

[1] +Supported parameters for the index base are 0 and +1 at least.

+

[2] +Supported parameters for the adapted array are +unbounded_array<> , bounded_array<> and std::vector<> .

- -
-

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
- Permission to copy, use, modify, sell and distribute this document +


+

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

-

Last revised: 1/15/2003

- diff --git a/index.html b/index.html index 6576c881..0fd3a57a 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ -Automatic redirection failed, please go to +Awaiting automatic redirection, please go to doc/index.htm. \ No newline at end of file diff --git a/test4/test4.hpp b/test4/test4.hpp index e097197d..98d465db 100644 --- a/test4/test4.hpp +++ b/test4/test4.hpp @@ -35,10 +35,10 @@ void initialize_matrix (M &m) { int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) #ifdef USE_BANDED - for (int j = (std::max)(i - 1, 0); j < (std::min)(i + 2, size2); ++ j) + for (int j = std::max (i - 1, 0); j < std::min (i + 2, size2); ++ j) #endif #ifdef USE_DIAGONAL - for (int j = (std::max)(i, 0); j < (std::min)(i + 1, size2); ++ j) + for (int j = std::max (i, 0); j < std::min (i + 1, size2); ++ j) #endif m (i, j) = i * size1 + j + 1.f; }