2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-23 04:02:10 +00:00

New doxygen doc for ublas

svn path=/branches/ublas-doxygen/; revision=61380
This commit is contained in:
David Bellot
2010-04-18 20:05:09 +00:00
parent 0eff28d13a
commit 5ffda9aec3
214 changed files with 0 additions and 30242 deletions

View File

@@ -1,10 +0,0 @@
# Copyright (c) 2004 Michael Stevens
# Use, modification and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# bench1 - measure the abstraction penalty of dense matrix and vector operations.
exe bench1
: bench1.cpp bench11.cpp bench12.cpp bench13.cpp
;

View File

@@ -1,122 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench1.hpp"
void header (std::string text) {
std::cout << text << std::endl;
}
template<class T>
struct peak_c_plus {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (0);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s += T (0);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
struct peak_c_multiplies {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s *= T (1);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
void peak<T>::operator () (int runs) {
header ("peak");
header ("plus");
peak_c_plus<T> () (runs);
header ("multiplies");
peak_c_multiplies<T> () (runs);
}
template <typename scalar>
void do_bench (std::string type_string, int scale)
{
header (type_string);
peak<scalar> () (1000000 * scale);
header (type_string + ", 3");
bench_1<scalar, 3> () (1000000 * scale);
bench_2<scalar, 3> () (300000 * scale);
bench_3<scalar, 3> () (100000 * scale);
header (type_string + ", 10");
bench_1<scalar, 10> () (300000 * scale);
bench_2<scalar, 10> () (30000 * scale);
bench_3<scalar, 10> () (3000 * scale);
header (type_string + ", 30");
bench_1<scalar, 30> () (100000 * scale);
bench_2<scalar, 30> () (3000 * scale);
bench_3<scalar, 30> () (100 * scale);
header (type_string + ", 100");
bench_1<scalar, 100> () (30000 * scale);
bench_2<scalar, 100> () (300 * scale);
bench_3<scalar, 100> () (3 * scale);
}
int main (int argc, char *argv []) {
int scale = 1;
if (argc > 1)
scale = std::atoi (argv [1]);
#ifdef USE_FLOAT
do_bench<float> ("FLOAT", scale);
#endif
#ifdef USE_DOUBLE
do_bench<double> ("DOUBLE", scale);
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
do_bench<std::complex<float> > ("COMPLEX<FLOAT>", scale);
#endif
#ifdef USE_DOUBLE
do_bench<std::complex<double> > ("COMPLEX<DOUBLE>", scale);
#endif
#endif
return 0;
}

View File

@@ -1,156 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#ifndef BENCH1_H
#define BENCH1_H
#include <iostream>
#include <string>
#include <valarray>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/timer.hpp>
namespace ublas = boost::numeric::ublas;
void header (std::string text);
template<class T>
struct footer {
void operator () (int multiplies, int plus, int runs, double elapsed) {
std::cout << "elapsed: " << elapsed << " s, "
<< (multiplies * ublas::type_traits<T>::multiplies_complexity +
plus * ublas::type_traits<T>::plus_complexity) * runs /
(1024 * 1024 * elapsed) << " Mflops" << std::endl;
}
};
template<class T, int N>
struct c_vector_traits {
typedef T type [N];
};
template<class T, int N, int M>
struct c_matrix_traits {
typedef T type [N] [M];
};
template<class T, int N>
struct initialize_c_vector {
void operator () (typename c_vector_traits<T, N>::type &v) {
for (int i = 0; i < N; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
};
template<class V>
BOOST_UBLAS_INLINE
void initialize_vector (V &v) {
int size = v.size ();
for (int i = 0; i < size; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
template<class T, int N, int M>
struct initialize_c_matrix {
void operator () (typename c_matrix_traits<T, N, M>::type &m) {
for (int i = 0; i < N; ++ i)
for (int j = 0; j < M; ++ j)
m [i] [j] = std::rand () * 1.f;
// m [i] [j] = 0.f;
}
};
template<class M>
BOOST_UBLAS_INLINE
void initialize_matrix (M &m) {
int size1 = m.size1 ();
int size2 = m.size2 ();
for (int i = 0; i < size1; ++ i)
for (int j = 0; j < size2; ++ j)
m (i, j) = std::rand () * 1.f;
// m (i, j) = 0.f;
}
template<class T>
BOOST_UBLAS_INLINE
void sink_scalar (const T &s) {
static T g_s = s;
}
template<class T, int N>
struct sink_c_vector {
void operator () (const typename c_vector_traits<T, N>::type &v) {
static typename c_vector_traits<T, N>::type g_v;
for (int i = 0; i < N; ++ i)
g_v [i] = v [i];
}
};
template<class V>
BOOST_UBLAS_INLINE
void sink_vector (const V &v) {
static V g_v (v);
}
template<class T, int N, int M>
struct sink_c_matrix {
void operator () (const typename c_matrix_traits<T, N, M>::type &m) {
static typename c_matrix_traits<T, N, M>::type g_m;
for (int i = 0; i < N; ++ i)
for (int j = 0; j < M; ++ j)
g_m [i] [j] = m [i] [j];
}
};
template<class M>
BOOST_UBLAS_INLINE
void sink_matrix (const M &m) {
static M g_m (m);
}
template<class T>
struct peak {
void operator () (int runs);
};
template<class T, int N>
struct bench_1 {
void operator () (int runs);
};
template<class T, int N>
struct bench_2 {
void operator () (int runs);
};
template<class T, int N>
struct bench_3 {
void operator () (int runs);
};
struct safe_tag {};
struct fast_tag {};
//#define USE_FLOAT
#define USE_DOUBLE
// #define USE_STD_COMPLEX
#define USE_C_ARRAY
// #define USE_BOUNDED_ARRAY
#define USE_UNBOUNDED_ARRAY
// #define USE_STD_VALARRAY
//#define USE_STD_VECTOR
#endif

View File

@@ -1,285 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench1.hpp"
template<class T, int N>
struct bench_c_inner_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
for (int j = 0; j < N; ++ j) {
s += v1 [j] * v2 [j];
}
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_my_inner_prod {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
s = ublas::inner_prod (v1, v2);
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_cpp_inner_prod {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
s = (v1 * v2).sum ();
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_vector_add {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_vector_traits<T, N>::type v1, v2, v3;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
v3 [j] = - (v1 [j] + v2 [j]);
}
// sink_c_vector<T, N> () (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_my_vector_add {
typedef typename V::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static V v1 (N), v2 (N), v3 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3 = - (v1 + v2);
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static V v1 (N), v2 (N), v3 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3.assign (- (v1 + v2));
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_cpp_vector_add {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N), v3 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3 = - (v1 + v2);
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n)
template<class T, int N>
void bench_1<T, N>::operator () (int runs) {
header ("bench_1");
header ("inner_prod");
header ("C array");
bench_c_inner_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_vector");
bench_my_inner_prod<ublas::c_vector<T, N>, N> () (runs);
#endif
#ifdef USE_BOUNDED_ARRAY
header ("vector<bounded_array>");
bench_my_inner_prod<ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs);
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("vector<unbounded_array>");
bench_my_inner_prod<ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs);
#endif
#ifdef USE_STD_VALARRAY
header ("vector<std::valarray>");
bench_my_inner_prod<ublas::vector<T, std::valarray<T> >, N> () ();
#endif
#ifdef USE_STD_VECTOR
header ("vector<std::vector>");
bench_my_inner_prod<ublas::vector<T, std::vector<T> >, N> () (runs);
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_inner_prod<std::valarray<T>, N> () (runs);
#endif
header ("vector + vector");
header ("C array");
bench_c_vector_add<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_vector safe");
bench_my_vector_add<ublas::c_vector<T, N>, N> () (runs, safe_tag ());
header ("c_vector fast");
bench_my_vector_add<ublas::c_vector<T, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("vector<bounded_array> safe");
bench_my_vector_add<ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ());
header ("vector<bounded_array> fast");
bench_my_vector_add<ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("vector<unbounded_array> safe");
bench_my_vector_add<ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("vector<unbounded_array> fast");
bench_my_vector_add<ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("vector<std::valarray> safe");
bench_my_vector_add<ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ());
header ("vector<std::valarray> fast");
bench_my_vector_add<ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("vector<std::vector> safe");
bench_my_vector_add<ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ());
header ("vector<std::vector> fast");
bench_my_vector_add<ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_vector_add<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_1<float, 3>;
template struct bench_1<float, 10>;
template struct bench_1<float, 30>;
template struct bench_1<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<double, 3>;
template struct bench_1<double, 10>;
template struct bench_1<double, 30>;
template struct bench_1<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_1<std::complex<float>, 3>;
template struct bench_1<std::complex<float>, 10>;
template struct bench_1<std::complex<float>, 30>;
template struct bench_1<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<std::complex<double>, 3>;
template struct bench_1<std::complex<double>, 10>;
template struct bench_1<std::complex<double>, 30>;
template struct bench_1<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,487 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench1.hpp"
template<class T, int N>
struct bench_c_outer_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m;
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m [j] [k] = - v1 [j] * v2 [k];
}
}
// sink_c_matrix<T, N, N> () (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_my_outer_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m (N, N);
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m = - ublas::outer_prod (v1, v2);
// sink_matrix (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m (N, N);
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m.assign (- ublas::outer_prod (v1, v2));
// sink_matrix (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_cpp_outer_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m (N * N);
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m [N * j + k] = - v1 [j] * v2 [k];
}
}
// sink_vector (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_matrix_vector_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m;
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_matrix<T, N, N> () (m);
initialize_c_vector<T, N> () (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
v2 [j] = 0;
for (int k = 0; k < N; ++ k) {
v2 [j] += m [j] [k] * v1 [k];
}
}
// sink_c_vector<T, N> () (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_my_matrix_vector_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m (N, N);
static V v1 (N), v2 (N);
initialize_matrix (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v2 = ublas::prod (m, v1);
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m (N, N);
static V v1 (N), v2 (N);
initialize_matrix (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v2.assign (ublas::prod (m, v1));
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_cpp_matrix_vector_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m (N * N);
static V v1 (N), v2 (N);
initialize_vector (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
std::valarray<value_type> row (m [std::slice (N * j, N, 1)]);
v2 [j] = (row * v1).sum ();
}
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_matrix_add {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m1, m2, m3;
initialize_c_matrix<T, N, N> () (m1);
initialize_c_matrix<T, N, N> () (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m3 [j] [k] = - (m1 [j] [k] + m2 [j] [k]);
}
}
// sink_c_matrix<T, N, N> () (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_my_matrix_add {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = - (m1 + m2);
// sink_matrix (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3.assign (- (m1 + m2));
// sink_matrix (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_cpp_matrix_add {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m1 (N * N), m2 (N * N), m3 (N * N);
initialize_vector (m1);
initialize_vector (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = - (m1 + m2);
// sink_vector (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n ^ 2)
template<class T, int N>
void bench_2<T, N>::operator () (int runs) {
header ("bench_2");
header ("outer_prod");
header ("C array");
bench_c_outer_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix, c_vector safe");
bench_my_outer_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, safe_tag ());
header ("c_matrix, c_vector fast");
bench_my_outer_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array>, vector<bounded_array> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array>, vector<bounded_array> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array>, vector<unbounded_array> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array>, vector<unbounded_array> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray>, vector<std::valarray> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray>, vector<std::valarray> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector>, vector<std::vector> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector>, vector<std::vector> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_outer_prod<std::valarray<T>, std::valarray<T>, N> () (runs);
#endif
header ("prod (matrix, vector)");
header ("C array");
bench_c_matrix_vector_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix, c_vector safe");
bench_my_matrix_vector_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, safe_tag ());
header ("c_matrix, c_vector fast");
bench_my_matrix_vector_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array>, vector<bounded_array> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array>, vector<bounded_array> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array>, vector<unbounded_array> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array>, vector<unbounded_array> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray>, vector<std::valarray> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray>, vector<std::valarray> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector>, vector<std::vector> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector>, vector<std::vector> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_vector_prod<std::valarray<T>, std::valarray<T>, N> () (runs);
#endif
header ("matrix + matrix");
header ("C array");
bench_c_matrix_add<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix safe");
bench_my_matrix_add<ublas::c_matrix<T, N, N>, N> () (runs, safe_tag ());
header ("c_matrix fast");
bench_my_matrix_add<ublas::c_matrix<T, N, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_add<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_2<float, 3>;
template struct bench_2<float, 10>;
template struct bench_2<float, 30>;
template struct bench_2<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<double, 3>;
template struct bench_2<double, 10>;
template struct bench_2<double, 30>;
template struct bench_2<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_2<std::complex<float>, 3>;
template struct bench_2<std::complex<float>, 10>;
template struct bench_2<std::complex<float>, 30>;
template struct bench_2<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<std::complex<double>, 3>;
template struct bench_2<std::complex<double>, 10>;
template struct bench_2<std::complex<double>, 30>;
template struct bench_2<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,192 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench1.hpp"
template<class T, int N>
struct bench_c_matrix_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m1, m2, m3;
initialize_c_matrix<T, N, N> () (m1);
initialize_c_matrix<T, N, N> () (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m3 [j] [k] = 0;
for (int l = 0; l < N; ++ l) {
m3 [j] [k] += m1 [j] [l] * m2 [l] [k];
}
}
}
// sink_c_matrix<T, N, N> () (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_my_matrix_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = ublas::prod (m1, m2);
// sink_matrix (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3.assign (ublas::prod (m1, m2));
// sink_matrix (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_cpp_matrix_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m1 (N * N), m2 (N * N), m3 (N * N);
initialize_vector (m1);
initialize_vector (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
std::valarray<value_type> row (m1 [std::slice (N * j, N, 1)]);
for (int k = 0; k < N; ++ k) {
std::valarray<value_type> column (m2 [std::slice (k, N, N)]);
m3 [N * j + k] = (row * column).sum ();
}
}
// sink_vector (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n ^ 3)
template<class T, int N>
void bench_3<T, N>::operator () (int runs) {
header ("bench_3");
header ("prod (matrix, matrix)");
header ("C array");
bench_c_matrix_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix safe");
bench_my_matrix_prod<ublas::c_matrix<T, N, N>, N> () (runs, safe_tag ());
header ("c_matrix fast");
bench_my_matrix_prod<ublas::c_matrix<T, N, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_prod<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_3<float, 3>;
template struct bench_3<float, 10>;
template struct bench_3<float, 30>;
template struct bench_3<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<double, 3>;
template struct bench_3<double, 10>;
template struct bench_3<double, 30>;
template struct bench_3<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_3<std::complex<float>, 3>;
template struct bench_3<std::complex<float>, 10>;
template struct bench_3<std::complex<float>, 30>;
template struct bench_3<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<std::complex<double>, 3>;
template struct bench_3<std::complex<double>, 10>;
template struct bench_3<std::complex<double>, 30>;
template struct bench_3<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,10 +0,0 @@
# Copyright (c) 2004 Michael Stevens
# Use, modification and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# bench2 - measurs the performance of sparse matrix and vector operations.
exe bench2
: bench2.cpp bench21.cpp bench22.cpp bench23.cpp
;

View File

@@ -1,122 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench2.hpp"
void header (std::string text) {
std::cout << text << std::endl;
}
template<class T>
struct peak_c_plus {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (0);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s += T (0);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
struct peak_c_multiplies {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s *= T (1);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
void peak<T>::operator () (int runs) {
header ("peak");
header ("plus");
peak_c_plus<T> () (runs);
header ("multiplies");
peak_c_multiplies<T> () (runs);
}
template <typename scalar>
void do_bench (std::string type_string, int scale)
{
header (type_string);
peak<scalar> () (1000000 * scale);
header (type_string + ", 3");
bench_1<scalar, 3> () (1000000 * scale);
bench_2<scalar, 3> () (300000 * scale);
bench_3<scalar, 3> () (100000 * scale);
header (type_string + ", 10");
bench_1<scalar, 10> () (300000 * scale);
bench_2<scalar, 10> () (30000 * scale);
bench_3<scalar, 10> () (3000 * scale);
header (type_string + ", 30");
bench_1<scalar, 30> () (100000 * scale);
bench_2<scalar, 30> () (3000 * scale);
bench_3<scalar, 30> () (100 * scale);
header (type_string + ", 100");
bench_1<scalar, 100> () (30000 * scale);
bench_2<scalar, 100> () (300 * scale);
bench_3<scalar, 100> () (3 * scale);
}
int main (int argc, char *argv []) {
int scale = 1;
if (argc > 1)
scale = std::atoi (argv [1]);
#ifdef USE_FLOAT
do_bench<float> ("FLOAT", scale);
#endif
#ifdef USE_DOUBLE
do_bench<double> ("DOUBLE", scale);
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
do_bench<std::complex<float> > ("COMPLEX<FLOAT>", scale);
#endif
#ifdef USE_DOUBLE
do_bench<std::complex<double> > ("COMPLEX<DOUBLE>", scale);
#endif
#endif
return 0;
}

View File

@@ -1,178 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#ifndef BENCH2_H
#define BENCH2_H
#include <iostream>
#include <string>
#include <valarray>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/timer.hpp>
namespace ublas = boost::numeric::ublas;
void header (std::string text);
template<class T>
struct footer {
void operator () (int multiplies, int plus, int runs, double elapsed) {
std::cout << "elapsed: " << elapsed << " s, "
<< (multiplies * ublas::type_traits<T>::multiplies_complexity +
plus * ublas::type_traits<T>::plus_complexity) * runs /
(1024 * 1024 * elapsed) << " Mflops" << std::endl;
}
};
template<class T, int N>
struct c_vector_traits {
typedef T type [N];
};
template<class T, int N, int M>
struct c_matrix_traits {
typedef T type [N] [M];
};
template<class T, int N>
struct initialize_c_vector {
void operator () (typename c_vector_traits<T, N>::type &v) {
for (int i = 0; i < N; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
};
template<class V>
BOOST_UBLAS_INLINE
void initialize_vector (V &v) {
int size = v.size ();
for (int i = 0; i < size; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
template<class T, int N, int M>
struct initialize_c_matrix {
void operator () (typename c_matrix_traits<T, N, M>::type &m) {
for (int i = 0; i < N; ++ i)
for (int j = 0; j < M; ++ j)
m [i] [j] = std::rand () * 1.f;
// m [i] [j] = 0.f;
}
};
template<class M>
BOOST_UBLAS_INLINE
void initialize_matrix (M &m, ublas::row_major_tag) {
int size1 = m.size1 ();
int size2 = m.size2 ();
for (int i = 0; i < size1; ++ i)
for (int j = 0; j < size2; ++ j)
m (i, j) = std::rand () * 1.f;
// m (i, j) = 0.f;
}
template<class M>
BOOST_UBLAS_INLINE
void initialize_matrix (M &m, ublas::column_major_tag) {
int size1 = m.size1 ();
int size2 = m.size2 ();
for (int j = 0; j < size2; ++ j)
for (int i = 0; i < size1; ++ i)
m (i, j) = std::rand () * 1.f;
// m (i, j) = 0.f;
}
template<class M>
BOOST_UBLAS_INLINE
void initialize_matrix (M &m) {
typedef typename M::orientation_category orientation_category;
initialize_matrix (m, orientation_category ());
}
template<class T>
BOOST_UBLAS_INLINE
void sink_scalar (const T &s) {
static T g_s = s;
}
template<class T, int N>
struct sink_c_vector {
void operator () (const typename c_vector_traits<T, N>::type &v) {
static typename c_vector_traits<T, N>::type g_v;
for (int i = 0; i < N; ++ i)
g_v [i] = v [i];
}
};
template<class V>
BOOST_UBLAS_INLINE
void sink_vector (const V &v) {
static V g_v (v);
}
template<class T, int N, int M>
struct sink_c_matrix {
void operator () (const typename c_matrix_traits<T, N, M>::type &m) {
static typename c_matrix_traits<T, N, M>::type g_m;
for (int i = 0; i < N; ++ i)
for (int j = 0; j < M; ++ j)
g_m [i] [j] = m [i] [j];
}
};
template<class M>
BOOST_UBLAS_INLINE
void sink_matrix (const M &m) {
static M g_m (m);
}
template<class T>
struct peak {
void operator () (int runs);
};
template<class T, int N>
struct bench_1 {
void operator () (int runs);
};
template<class T, int N>
struct bench_2 {
void operator () (int runs);
};
template<class T, int N>
struct bench_3 {
void operator () (int runs);
};
struct safe_tag {};
struct fast_tag {};
// #define USE_FLOAT
#define USE_DOUBLE
// #define USE_STD_COMPLEX
#define USE_MAP_ARRAY
// #define USE_STD_MAP
// #define USE_STD_VALARRAY
#define USE_MAPPED_VECTOR
#define USE_COMPRESSED_VECTOR
#define USE_COORDINATE_VECTOR
#define USE_MAPPED_MATRIX
// #define USE_SPARSE_VECTOR_OF_SPARSE_VECTOR
#define USE_COMPRESSED_MATRIX
#define USE_COORDINATE_MATRIX
#endif

View File

@@ -1,280 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench2.hpp"
template<class T, int N>
struct bench_c_inner_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
for (int j = 0; j < N; ++ j) {
s += v1 [j] * v2 [j];
}
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_my_inner_prod {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N, N), v2 (N, N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
s = ublas::inner_prod (v1, v2);
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_cpp_inner_prod {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
s = (v1 * v2).sum ();
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_vector_add {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_vector_traits<T, N>::type v1, v2, v3;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
v3 [j] = - (v1 [j] + v2 [j]);
}
// sink_c_vector<T, N> () (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_my_vector_add {
typedef typename V::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static V v1 (N, N), v2 (N, N), v3 (N, N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3 = - (v1 + v2);
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static V v1 (N, N), v2 (N, N), v3 (N, N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3.assign (- (v1 + v2));
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_cpp_vector_add {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N), v3 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3 = - (v1 + v2);
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n)
template<class T, int N>
void bench_1<T, N>::operator () (int runs) {
header ("bench_1");
header ("inner_prod");
header ("C array");
bench_c_inner_prod<T, N> () (runs);
#ifdef USE_MAPPED_VECTOR
#ifdef USE_MAP_ARRAY
header ("mapped_vector<map_array>");
bench_my_inner_prod<ublas::mapped_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs);
#endif
#ifdef USE_STD_MAP
header ("mapped_vector<std::map>");
bench_my_inner_prod<ublas::mapped_vector<T, std::map<std::size_t, T> >, N> () (runs);
#endif
#endif
#ifdef USE_COMPRESSED_VECTOR
header ("compressed_vector");
bench_my_inner_prod<ublas::compressed_vector<T>, N> () (runs);
#endif
#ifdef USE_COORDINATE_VECTOR
header ("coordinate_vector");
bench_my_inner_prod<ublas::coordinate_vector<T>, N> () (runs);
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_inner_prod<std::valarray<T>, N> () (runs);
#endif
header ("vector + vector");
header ("C array");
bench_c_vector_add<T, N> () (runs);
#ifdef USE_MAPPED_VECTOR
#ifdef USE_MAP_ARRAY
header ("mapped_vector<map_array> safe");
bench_my_vector_add<ublas::mapped_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs, safe_tag ());
header ("maped_vector<map_array> fast");
bench_my_vector_add<ublas::mapped_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_MAP
header ("mapped_vector<std::map> safe");
bench_my_vector_add<ublas::mapped_vector<T, std::map<std::size_t, T> >, N> () (runs, safe_tag ());
header ("mapped_vector<std::map> fast");
bench_my_vector_add<ublas::mapped_vector<T, std::map<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_COMPRESSED_VECTOR
#ifdef USE_MAP_ARRAY
header ("compressed_vector safe");
bench_my_vector_add<ublas::compressed_vector<T>, N> () (runs, safe_tag ());
header ("compressed_vector fast");
bench_my_vector_add<ublas::compressed_vector<T>, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_COORDINATE_VECTOR
#ifdef USE_MAP_ARRAY
header ("coordinate_vector safe");
bench_my_vector_add<ublas::coordinate_vector<T>, N> () (runs, safe_tag ());
header ("coordinate_vector fast");
bench_my_vector_add<ublas::coordinate_vector<T>, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_vector_add<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_1<float, 3>;
template struct bench_1<float, 10>;
template struct bench_1<float, 30>;
template struct bench_1<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<double, 3>;
template struct bench_1<double, 10>;
template struct bench_1<double, 30>;
template struct bench_1<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_1<std::complex<float>, 3>;
template struct bench_1<std::complex<float>, 10>;
template struct bench_1<std::complex<float>, 30>;
template struct bench_1<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<std::complex<double>, 3>;
template struct bench_1<std::complex<double>, 10>;
template struct bench_1<std::complex<double>, 30>;
template struct bench_1<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,465 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench2.hpp"
template<class T, int N>
struct bench_c_outer_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m;
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m [j] [k] = - v1 [j] * v2 [k];
}
}
// sink_c_matrix<T, N, N> () (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_my_outer_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m (N, N, N * N);
static V v1 (N, N), v2 (N, N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m = - ublas::outer_prod (v1, v2);
// sink_matrix (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m (N, N, N * N);
static V v1 (N, N), v2 (N, N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m.assign (- ublas::outer_prod (v1, v2));
// sink_matrix (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_cpp_outer_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m (N * N);
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m [N * j + k] = - v1 [j] * v2 [k];
}
}
// sink_vector (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_matrix_vector_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m;
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_matrix<T, N, N> () (m);
initialize_c_vector<T, N> () (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
v2 [j] = 0;
for (int k = 0; k < N; ++ k) {
v2 [j] += m [j] [k] * v1 [k];
}
}
// sink_c_vector<T, N> () (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_my_matrix_vector_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m (N, N, N * N);
static V v1 (N, N), v2 (N, N);
initialize_matrix (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v2 = ublas::prod (m, v1);
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m (N, N, N * N);
static V v1 (N, N), v2 (N, N);
initialize_matrix (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v2.assign (ublas::prod (m, v1));
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_cpp_matrix_vector_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m (N * N);
static V v1 (N), v2 (N);
initialize_vector (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
std::valarray<value_type> row (m [std::slice (N * j, N, 1)]);
v2 [j] = (row * v1).sum ();
}
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_matrix_add {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m1, m2, m3;
initialize_c_matrix<T, N, N> () (m1);
initialize_c_matrix<T, N, N> () (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m3 [j] [k] = - (m1 [j] [k] + m2 [j] [k]);
}
}
// sink_c_matrix<T, N, N> () (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_my_matrix_add {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m1 (N, N, N * N), m2 (N, N, N * N), m3 (N, N, N * N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = - (m1 + m2);
// sink_matrix (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m1 (N, N, N * N), m2 (N, N, N * N), m3 (N, N, N * N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3.assign (- (m1 + m2));
// sink_matrix (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_cpp_matrix_add {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m1 (N * N), m2 (N * N), m3 (N * N);
initialize_vector (m1);
initialize_vector (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = - (m1 + m2);
// sink_vector (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n ^ 2)
template<class T, int N>
void bench_2<T, N>::operator () (int runs) {
header ("bench_2");
header ("outer_prod");
header ("C array");
bench_c_outer_prod<T, N> () (runs);
#ifdef USE_SPARSE_MATRIX
#ifdef USE_MAP_ARRAY
header ("sparse_matrix<map_array>, sparse_vector<map_array> safe");
bench_my_outer_prod<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >,
ublas::sparse_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<map_array>, sparse_vector<map_array> fast");
bench_my_outer_prod<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >,
ublas::sparse_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_MAP
header ("sparse_matrix<std::map>, sparse_vector<std::map> safe");
bench_my_outer_prod<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >,
ublas::sparse_vector<T, std::map<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<std::map>, sparse_vector<std::map> fast");
bench_my_outer_prod<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >,
ublas::sparse_vector<T, std::map<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_COMPRESSED_MATRIX
header ("compressed_matrix, compressed_vector safe");
bench_my_outer_prod<ublas::compressed_matrix<T, ublas::row_major>,
ublas::compressed_vector<T>, N> () (runs, safe_tag ());
header ("compressed_matrix, compressed_vector fast");
bench_my_outer_prod<ublas::compressed_matrix<T, ublas::row_major>,
ublas::compressed_vector<T>, N> () (runs, fast_tag ());
#endif
#ifdef USE_COORDINATE_MATRIX
header ("coordinate_matrix, coordinate_vector safe");
bench_my_outer_prod<ublas::coordinate_matrix<T, ublas::row_major>,
ublas::coordinate_vector<T>, N> () (runs, safe_tag ());
header ("coordinate_matrix, coordinate_vector fast");
bench_my_outer_prod<ublas::coordinate_matrix<T, ublas::row_major>,
ublas::coordinate_vector<T>, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_outer_prod<std::valarray<T>, std::valarray<T>, N> () (runs);
#endif
header ("prod (matrix, vector)");
header ("C array");
bench_c_matrix_vector_prod<T, N> () (runs);
#ifdef USE_SPARSE_MATRIX
#ifdef USE_MAP_ARRAY
header ("sparse_matrix<map_array>, sparse_vector<map_array> safe");
bench_my_matrix_vector_prod<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >,
ublas::sparse_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<map_array>, sparse_vector<map_array> fast");
bench_my_matrix_vector_prod<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >,
ublas::sparse_vector<T, ublas::map_array<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_MAP
header ("sparse_matrix<std::map>, sparse_vector<std::map> safe");
bench_my_matrix_vector_prod<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >,
ublas::sparse_vector<T, std::map<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<std::map>, sparse_vector<std::map> fast");
bench_my_matrix_vector_prod<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >,
ublas::sparse_vector<T, std::map<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_COMPRESSED_MATRIX
header ("compressed_matrix, compressed_vector safe");
bench_my_matrix_vector_prod<ublas::compressed_matrix<T, ublas::row_major>,
ublas::compressed_vector<T>, N> () (runs, safe_tag ());
header ("compressed_matrix, compressed_vector fast");
bench_my_matrix_vector_prod<ublas::compressed_matrix<T, ublas::row_major>,
ublas::compressed_vector<T>, N> () (runs, fast_tag ());
#endif
#ifdef USE_COORDINATE_MATRIX
header ("coordinate_matrix, coordinate_vector safe");
bench_my_matrix_vector_prod<ublas::coordinate_matrix<T, ublas::row_major>,
ublas::coordinate_vector<T>, N> () (runs, safe_tag ());
header ("coordinate_matrix, coordinate_vector fast");
bench_my_matrix_vector_prod<ublas::coordinate_matrix<T, ublas::row_major>,
ublas::coordinate_vector<T>, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_vector_prod<std::valarray<T>, std::valarray<T>, N> () (runs);
#endif
header ("matrix + matrix");
header ("C array");
bench_c_matrix_add<T, N> () (runs);
#ifdef USE_SPARSE_MATRIX
#ifdef USE_MAP_ARRAY
header ("sparse_matrix<map_array> safe");
bench_my_matrix_add<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<map_array> fast");
bench_my_matrix_add<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_MAP
header ("sparse_matrix<std::map> safe");
bench_my_matrix_add<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<std::map> fast");
bench_my_matrix_add<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_COMPRESSED_MATRIX
header ("compressed_matrix safe");
bench_my_matrix_add<ublas::compressed_matrix<T, ublas::row_major>, N> () (runs, safe_tag ());
header ("compressed_matrix fast");
bench_my_matrix_add<ublas::compressed_matrix<T, ublas::row_major>, N> () (runs, fast_tag ());
#endif
#ifdef USE_COORDINATE_MATRIX
header ("coordinate_matrix safe");
bench_my_matrix_add<ublas::coordinate_matrix<T, ublas::row_major>, N> () (runs, safe_tag ());
header ("coordinate_matrix fast");
bench_my_matrix_add<ublas::coordinate_matrix<T, ublas::row_major>, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_add<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_2<float, 3>;
template struct bench_2<float, 10>;
template struct bench_2<float, 30>;
template struct bench_2<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<double, 3>;
template struct bench_2<double, 10>;
template struct bench_2<double, 30>;
template struct bench_2<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_2<std::complex<float>, 3>;
template struct bench_2<std::complex<float>, 10>;
template struct bench_2<std::complex<float>, 30>;
template struct bench_2<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<std::complex<double>, 3>;
template struct bench_2<std::complex<double>, 10>;
template struct bench_2<std::complex<double>, 30>;
template struct bench_2<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,196 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench2.hpp"
template<class T, int N>
struct bench_c_matrix_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m1, m2, m3;
initialize_c_matrix<T, N, N> () (m1);
initialize_c_matrix<T, N, N> () (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m3 [j] [k] = 0;
for (int l = 0; l < N; ++ l) {
m3 [j] [k] += m1 [j] [l] * m2 [l] [k];
}
}
}
// sink_c_matrix<T, N, N> () (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M1, class M2, int N>
struct bench_my_matrix_prod {
typedef typename M1::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M1 m1 (N, N, N * N), m3 (N, N, N * N);
static M2 m2 (N, N, N * N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = ublas::prod (m1, m2);
// sink_matrix (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M1 m1 (N, N, N * N), m3 (N, N, N * N);
static M2 m2 (N, N, N * N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3.assign (ublas::prod (m1, m2));
// sink_matrix (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_cpp_matrix_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m1 (N * N), m2 (N * N), m3 (N * N);
initialize_vector (m1);
initialize_vector (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
std::valarray<value_type> row (m1 [std::slice (N * j, N, 1)]);
for (int k = 0; k < N; ++ k) {
std::valarray<value_type> column (m2 [std::slice (k, N, N)]);
m3 [N * j + k] = (row * column).sum ();
}
}
// sink_vector (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n ^ 3)
template<class T, int N>
void bench_3<T, N>::operator () (int runs) {
header ("bench_3");
header ("prod (matrix, matrix)");
header ("C array");
bench_c_matrix_prod<T, N> () (runs);
#ifdef USE_SPARSE_MATRIX
#ifdef USE_MAP_ARRAY
header ("sparse_matrix<row_major, map_array>, sparse_matrix<column_major, map_array> safe");
bench_my_matrix_prod<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >,
ublas::sparse_matrix<T, ublas::column_major, ublas::map_array<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<row_major, map_array>, sparse_matrix<column_major, map_array> fast");
bench_my_matrix_prod<ublas::sparse_matrix<T, ublas::row_major, ublas::map_array<std::size_t, T> >,
ublas::sparse_matrix<T, ublas::column_major, ublas::map_array<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_MAP
header ("sparse_matrix<row_major, std::map>, sparse_matrix<column_major, std::map> safe");
bench_my_matrix_prod<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >,
ublas::sparse_matrix<T, ublas::column_major, std::map<std::size_t, T> >, N> () (runs, safe_tag ());
header ("sparse_matrix<row_major, std::map>, sparse_matrix<column_major, std::map> fast");
bench_my_matrix_prod<ublas::sparse_matrix<T, ublas::row_major, std::map<std::size_t, T> >,
ublas::sparse_matrix<T, ublas::column_major, std::map<std::size_t, T> >, N> () (runs, fast_tag ());
#endif
#endif
#ifdef USE_COMPRESSED_MATRIX
header ("compressed_matrix<row_major>, compressed_matrix<column_major> safe");
bench_my_matrix_prod<ublas::compressed_matrix<T, ublas::row_major>,
ublas::compressed_matrix<T, ublas::column_major>, N> () (runs, safe_tag ());
header ("compressed_matrix<row_major>, compressed_matrix<column_major> fast");
bench_my_matrix_prod<ublas::compressed_matrix<T, ublas::row_major>,
ublas::compressed_matrix<T, ublas::column_major>, N> () (runs, fast_tag ());
#endif
#ifdef USE_COORDINATE_MATRIX
header ("coordinate_matrix<row_major>, coordinate_matrix<column_major> safe");
bench_my_matrix_prod<ublas::coordinate_matrix<T, ublas::row_major>,
ublas::coordinate_matrix<T, ublas::column_major>, N> () (runs, safe_tag ());
header ("coordinate_matrix<row_major>, coordinate_matrix<column_major> fast");
bench_my_matrix_prod<ublas::coordinate_matrix<T, ublas::row_major>,
ublas::coordinate_matrix<T, ublas::column_major>, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_prod<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_3<float, 3>;
template struct bench_3<float, 10>;
template struct bench_3<float, 30>;
template struct bench_3<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<double, 3>;
template struct bench_3<double, 10>;
template struct bench_3<double, 30>;
template struct bench_3<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_3<std::complex<float>, 3>;
template struct bench_3<std::complex<float>, 10>;
template struct bench_3<std::complex<float>, 30>;
template struct bench_3<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<std::complex<double>, 3>;
template struct bench_3<std::complex<double>, 10>;
template struct bench_3<std::complex<double>, 30>;
template struct bench_3<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,10 +0,0 @@
# Copyright (c) 2004 Michael Stevens
# Use, modification and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# bench3 - measure the performance of vector and matrix proxy's operations.
exe bench3
: bench3.cpp bench31.cpp bench32.cpp bench33.cpp
;

View File

@@ -1,122 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench3.hpp"
void header (std::string text) {
std::cout << text << std::endl;
}
template<class T>
struct peak_c_plus {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (0);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s += T (0);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
struct peak_c_multiplies {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s *= T (1);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
void peak<T>::operator () (int runs) {
header ("peak");
header ("plus");
peak_c_plus<T> () (runs);
header ("multiplies");
peak_c_multiplies<T> () (runs);
}
template <typename scalar>
void do_bench (std::string type_string, int scale)
{
header (type_string);
peak<scalar> () (1000000 * scale);
header (type_string + ", 3");
bench_1<scalar, 3> () (1000000 * scale);
bench_2<scalar, 3> () (300000 * scale);
bench_3<scalar, 3> () (100000 * scale);
header (type_string + ", 10");
bench_1<scalar, 10> () (300000 * scale);
bench_2<scalar, 10> () (30000 * scale);
bench_3<scalar, 10> () (3000 * scale);
header (type_string + ", 30");
bench_1<scalar, 30> () (100000 * scale);
bench_2<scalar, 30> () (3000 * scale);
bench_3<scalar, 30> () (100 * scale);
header (type_string + ", 100");
bench_1<scalar, 100> () (30000 * scale);
bench_2<scalar, 100> () (300 * scale);
bench_3<scalar, 100> () (3 * scale);
}
int main (int argc, char *argv []) {
int scale = 1;
if (argc > 1)
scale = std::atoi (argv [1]);
#ifdef USE_FLOAT
do_bench<float> ("FLOAT", scale);
#endif
#ifdef USE_DOUBLE
do_bench<double> ("DOUBLE", scale);
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
do_bench<std::complex<float> > ("COMPLEX<FLOAT>", scale);
#endif
#ifdef USE_DOUBLE
do_bench<std::complex<double> > ("COMPLEX<DOUBLE>", scale);
#endif
#endif
return 0;
}

View File

@@ -1,155 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#ifndef BENCH3_H
#define BENCH3_H
#include <iostream>
#include <string>
#include <valarray>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/timer.hpp>
namespace ublas = boost::numeric::ublas;
void header (std::string text);
template<class T>
struct footer {
void operator () (int multiplies, int plus, int runs, double elapsed) {
std::cout << "elapsed: " << elapsed << " s, "
<< (multiplies * ublas::type_traits<T>::multiplies_complexity +
plus * ublas::type_traits<T>::plus_complexity) * runs /
(1024 * 1024 * elapsed) << " Mflops" << std::endl;
}
};
template<class T, int N>
struct c_vector_traits {
typedef T type [N];
};
template<class T, int N, int M>
struct c_matrix_traits {
typedef T type [N] [M];
};
template<class T, int N>
struct initialize_c_vector {
void operator () (typename c_vector_traits<T, N>::type &v) {
for (int i = 0; i < N; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
};
template<class V>
BOOST_UBLAS_INLINE
void initialize_vector (V &v) {
int size = v.size ();
for (int i = 0; i < size; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
template<class T, int N, int M>
struct initialize_c_matrix {
void operator () (typename c_matrix_traits<T, N, M>::type &m) {
for (int i = 0; i < N; ++ i)
for (int j = 0; j < M; ++ j)
m [i] [j] = std::rand () * 1.f;
// m [i] [j] = 0.f;
}
};
template<class M>
BOOST_UBLAS_INLINE
void initialize_matrix (M &m) {
int size1 = m.size1 ();
int size2 = m.size2 ();
for (int i = 0; i < size1; ++ i)
for (int j = 0; j < size2; ++ j)
m (i, j) = std::rand () * 1.f;
// m (i, j) = 0.f;
}
template<class T>
BOOST_UBLAS_INLINE
void sink_scalar (const T &s) {
static T g_s = s;
}
template<class T, int N>
struct sink_c_vector {
void operator () (const typename c_vector_traits<T, N>::type &v) {
static typename c_vector_traits<T, N>::type g_v;
for (int i = 0; i < N; ++ i)
g_v [i] = v [i];
}
};
template<class V>
BOOST_UBLAS_INLINE
void sink_vector (const V &v) {
static V g_v (v);
}
template<class T, int N, int M>
struct sink_c_matrix {
void operator () (const typename c_matrix_traits<T, N, M>::type &m) {
static typename c_matrix_traits<T, N, M>::type g_m;
for (int i = 0; i < N; ++ i)
for (int j = 0; j < M; ++ j)
g_m [i] [j] = m [i] [j];
}
};
template<class M>
BOOST_UBLAS_INLINE
void sink_matrix (const M &m) {
static M g_m (m);
}
template<class T>
struct peak {
void operator () (int runs);
};
template<class T, int N>
struct bench_1 {
void operator () (int runs);
};
template<class T, int N>
struct bench_2 {
void operator () (int runs);
};
template<class T, int N>
struct bench_3 {
void operator () (int runs);
};
struct safe_tag {};
struct fast_tag {};
// #define USE_FLOAT
#define USE_DOUBLE
// #define USE_STD_COMPLEX
#define USE_C_ARRAY
// #define USE_BOUNDED_ARRAY
#define USE_UNBOUNDED_ARRAY
// #define USE_STD_VALARRAY
#define USE_STD_VECTOR
#endif

View File

@@ -1,294 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench3.hpp"
template<class T, int N>
struct bench_c_inner_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
for (int j = 0; j < N; ++ j) {
s += v1 [j] * v2 [j];
}
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_my_inner_prod {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N));
initialize_vector (vr1);
initialize_vector (vr2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
s = ublas::inner_prod (vr1, vr2);
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_cpp_inner_prod {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
static value_type s (0);
s = (v1 * v2).sum ();
// sink_scalar (s);
}
footer<value_type> () (N, N - 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_vector_add {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_vector_traits<T, N>::type v1, v2, v3;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
v3 [j] = - (v1 [j] + v2 [j]);
}
// sink_c_vector<T, N> () (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_my_vector_add {
typedef typename V::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static V v1 (N), v2 (N), v3 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N)),
vr3 (v2, ublas::range (0, N));
initialize_vector (vr1);
initialize_vector (vr2);
initialize_vector (vr3);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
vr3 = - (vr1 + vr2);
// sink_vector (vr3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static V v1 (N), v2 (N), v3 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N)),
vr3 (v2, ublas::range (0, N));
initialize_vector (vr1);
initialize_vector (vr2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
vr3.assign (- (vr1 + vr2));
// sink_vector (vr3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class V, int N>
struct bench_cpp_vector_add {
typedef typename V::value_type value_type;
void operator () (int runs) const {
try {
static V v1 (N), v2 (N), v3 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
v3 = - (v1 + v2);
// sink_vector (v3);
}
footer<value_type> () (0, 2 * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n)
template<class T, int N>
void bench_1<T, N>::operator () (int runs) {
header ("bench_1");
header ("inner_prod");
header ("C array");
bench_c_inner_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_vector");
bench_my_inner_prod<ublas::c_vector<T, N>, N> () (runs);
#endif
#ifdef USE_BOUNDED_ARRAY
header ("vector<bounded_array>");
bench_my_inner_prod<ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs);
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("vector<unbounded_array>");
bench_my_inner_prod<ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs);
#endif
#ifdef USE_STD_VALARRAY
header ("vector<std::valarray>");
bench_my_inner_prod<ublas::vector<T, std::valarray<T> >, N> () ();
#endif
#ifdef USE_STD_VECTOR
header ("vector<std::vector>");
bench_my_inner_prod<ublas::vector<T, std::vector<T> >, N> () (runs);
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_inner_prod<std::valarray<T>, N> () (runs);
#endif
header ("vector + vector");
header ("C array");
bench_c_vector_add<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_vector safe");
bench_my_vector_add<ublas::c_vector<T, N>, N> () (runs, safe_tag ());
header ("c_vector fast");
bench_my_vector_add<ublas::c_vector<T, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("vector<bounded_array> safe");
bench_my_vector_add<ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ());
header ("vector<bounded_array> fast");
bench_my_vector_add<ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("vector<unbounded_array> safe");
bench_my_vector_add<ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("vector<unbounded_array> fast");
bench_my_vector_add<ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("vector<std::valarray> safe");
bench_my_vector_add<ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ());
header ("vector<std::valarray> fast");
bench_my_vector_add<ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("vector<std::vector> safe");
bench_my_vector_add<ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ());
header ("vector<std::vector> fast");
bench_my_vector_add<ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_vector_add<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_1<float, 3>;
template struct bench_1<float, 10>;
template struct bench_1<float, 30>;
template struct bench_1<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<double, 3>;
template struct bench_1<double, 10>;
template struct bench_1<double, 30>;
template struct bench_1<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_1<std::complex<float>, 3>;
template struct bench_1<std::complex<float>, 10>;
template struct bench_1<std::complex<float>, 30>;
template struct bench_1<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<std::complex<double>, 3>;
template struct bench_1<std::complex<double>, 10>;
template struct bench_1<std::complex<double>, 30>;
template struct bench_1<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,499 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench3.hpp"
template<class T, int N>
struct bench_c_outer_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m;
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_vector<T, N> () (v1);
initialize_c_vector<T, N> () (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m [j] [k] = - v1 [j] * v2 [k];
}
}
// sink_c_matrix<T, N, N> () (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_my_outer_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m (N, N);
ublas::matrix_range<M> mr (m, ublas::range (0, N), ublas::range (0, N));
static V v1 (N), v2 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N));
initialize_vector (vr1);
initialize_vector (vr2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
mr = - ublas::outer_prod (vr1, vr2);
// sink_matrix (mr);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m (N, N);
ublas::matrix_range<M> mr (m, ublas::range (0, N), ublas::range (0, N));
static V v1 (N), v2 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N));
initialize_vector (vr1);
initialize_vector (vr2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
mr.assign (- ublas::outer_prod (vr1, vr2));
// sink_matrix (mr);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_cpp_outer_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m (N * N);
static V v1 (N), v2 (N);
initialize_vector (v1);
initialize_vector (v2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m [N * j + k] = - v1 [j] * v2 [k];
}
}
// sink_vector (m);
}
footer<value_type> () (N * N, N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_matrix_vector_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m;
static typename c_vector_traits<T, N>::type v1, v2;
initialize_c_matrix<T, N, N> () (m);
initialize_c_vector<T, N> () (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
v2 [j] = 0;
for (int k = 0; k < N; ++ k) {
v2 [j] += m [j] [k] * v1 [k];
}
}
// sink_c_vector<T, N> () (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_my_matrix_vector_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m (N, N);
ublas::matrix_range<M> mr (m, ublas::range (0, N), ublas::range (0, N));
static V v1 (N), v2 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N));
initialize_matrix (mr);
initialize_vector (vr1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
vr2 = ublas::prod (mr, vr1);
// sink_vector (vr2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m (N, N);
ublas::matrix_range<M> mr (m, ublas::range (0, N), ublas::range (0, N));
static V v1 (N), v2 (N);
ublas::vector_range<V> vr1 (v1, ublas::range (0, N)),
vr2 (v2, ublas::range (0, N));
initialize_matrix (mr);
initialize_vector (vr1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
vr2.assign (ublas::prod (mr, vr1));
// sink_vector (vr2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, class V, int N>
struct bench_cpp_matrix_vector_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m (N * N);
static V v1 (N), v2 (N);
initialize_vector (m);
initialize_vector (v1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
std::valarray<value_type> row (m [std::slice (N * j, N, 1)]);
v2 [j] = (row * v1).sum ();
}
// sink_vector (v2);
}
footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T, int N>
struct bench_c_matrix_add {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m1, m2, m3;
initialize_c_matrix<T, N, N> () (m1);
initialize_c_matrix<T, N, N> () (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m3 [j] [k] = - (m1 [j] [k] + m2 [j] [k]);
}
}
// sink_c_matrix<T, N, N> () (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_my_matrix_add {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = - (m1 + m2);
// sink_matrix (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
initialize_matrix (m1);
initialize_matrix (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3.assign (- (m1 + m2));
// sink_matrix (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_cpp_matrix_add {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m1 (N * N), m2 (N * N), m3 (N * N);
initialize_vector (m1);
initialize_vector (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
m3 = - (m1 + m2);
// sink_vector (m3);
}
footer<value_type> () (0, 2 * N * N, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n ^ 2)
template<class T, int N>
void bench_2<T, N>::operator () (int runs) {
header ("bench_2");
header ("outer_prod");
header ("C array");
bench_c_outer_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix, c_vector safe");
bench_my_outer_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, safe_tag ());
header ("c_matrix, c_vector fast");
bench_my_outer_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array>, vector<bounded_array> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array>, vector<bounded_array> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array>, vector<unbounded_array> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array>, vector<unbounded_array> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray>, vector<std::valarray> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray>, vector<std::valarray> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector>, vector<std::vector> safe");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector>, vector<std::vector> fast");
bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_outer_prod<std::valarray<T>, std::valarray<T>, N> () (runs);
#endif
header ("prod (matrix, vector)");
header ("C array");
bench_c_matrix_vector_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix, c_vector safe");
bench_my_matrix_vector_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, safe_tag ());
header ("c_matrix, c_vector fast");
bench_my_matrix_vector_prod<ublas::c_matrix<T, N, N>,
ublas::c_vector<T, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array>, vector<bounded_array> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array>, vector<bounded_array> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >,
ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array>, vector<unbounded_array> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array>, vector<unbounded_array> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >,
ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray>, vector<std::valarray> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray>, vector<std::valarray> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >,
ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector>, vector<std::vector> safe");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector>, vector<std::vector> fast");
bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >,
ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_vector_prod<std::valarray<T>, std::valarray<T>, N> () (runs);
#endif
header ("matrix + matrix");
header ("C array");
bench_c_matrix_add<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix safe");
bench_my_matrix_add<ublas::c_matrix<T, N, N>, N> () (runs, safe_tag ());
header ("c_matrix fast");
bench_my_matrix_add<ublas::c_matrix<T, N, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector> safe");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector> fast");
bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_add<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_2<float, 3>;
template struct bench_2<float, 10>;
template struct bench_2<float, 30>;
template struct bench_2<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<double, 3>;
template struct bench_2<double, 10>;
template struct bench_2<double, 30>;
template struct bench_2<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_2<std::complex<float>, 3>;
template struct bench_2<std::complex<float>, 10>;
template struct bench_2<std::complex<float>, 30>;
template struct bench_2<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<std::complex<double>, 3>;
template struct bench_2<std::complex<double>, 10>;
template struct bench_2<std::complex<double>, 30>;
template struct bench_2<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,198 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include "bench3.hpp"
template<class T, int N>
struct bench_c_matrix_prod {
typedef T value_type;
void operator () (int runs) const {
try {
static typename c_matrix_traits<T, N, N>::type m1, m2, m3;
initialize_c_matrix<T, N, N> () (m1);
initialize_c_matrix<T, N, N> () (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
for (int k = 0; k < N; ++ k) {
m3 [j] [k] = 0;
for (int l = 0; l < N; ++ l) {
m3 [j] [k] += m1 [j] [l] * m2 [l] [k];
}
}
}
// sink_c_matrix<T, N, N> () (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_my_matrix_prod {
typedef typename M::value_type value_type;
void operator () (int runs, safe_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
ublas::matrix_range<M> mr1 (m1, ublas::range (0, N), ublas::range (0, N)),
mr2 (m2, ublas::range (0, N), ublas::range (0, N)),
mr3 (m3, ublas::range (0, N), ublas::range (0, N));
initialize_matrix (mr1);
initialize_matrix (mr2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
mr3 = ublas::prod (mr1, mr2);
// sink_matrix (mr3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
void operator () (int runs, fast_tag) const {
try {
static M m1 (N, N), m2 (N, N), m3 (N, N);
ublas::matrix_range<M> mr1 (m1, ublas::range (0, N), ublas::range (0, N)),
mr2 (m2, ublas::range (0, N), ublas::range (0, N)),
mr3 (m3, ublas::range (0, N), ublas::range (0, N));
initialize_matrix (mr1);
initialize_matrix (mr2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
mr3.assign (ublas::prod (mr1, mr2));
// sink_matrix (mr3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class M, int N>
struct bench_cpp_matrix_prod {
typedef typename M::value_type value_type;
void operator () (int runs) const {
try {
static M m1 (N * N), m2 (N * N), m3 (N * N);
initialize_vector (m1);
initialize_vector (m2);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
for (int j = 0; j < N; ++ j) {
std::valarray<value_type> row (m1 [std::slice (N * j, N, 1)]);
for (int k = 0; k < N; ++ k) {
std::valarray<value_type> column (m2 [std::slice (k, N, N)]);
m3 [N * j + k] = (row * column).sum ();
}
}
// sink_vector (m3);
}
footer<value_type> () (N * N * N, N * N * (N - 1), runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
// Benchmark O (n ^ 3)
template<class T, int N>
void bench_3<T, N>::operator () (int runs) {
header ("bench_3");
header ("prod (matrix, matrix)");
header ("C array");
bench_c_matrix_prod<T, N> () (runs);
#ifdef USE_C_ARRAY
header ("c_matrix safe");
bench_my_matrix_prod<ublas::c_matrix<T, N, N>, N> () (runs, safe_tag ());
header ("c_matrix fast");
bench_my_matrix_prod<ublas::c_matrix<T, N, N>, N> () (runs, fast_tag ());
#endif
#ifdef USE_BOUNDED_ARRAY
header ("matrix<bounded_array> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, safe_tag ());
header ("matrix<bounded_array> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_UNBOUNDED_ARRAY
header ("matrix<unbounded_array> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, safe_tag ());
header ("matrix<unbounded_array> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("matrix<std::valarray> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, safe_tag ());
header ("matrix<std::valarray> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VECTOR
header ("matrix<std::vector> safe");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, safe_tag ());
header ("matrix<std::vector> fast");
bench_my_matrix_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, fast_tag ());
#endif
#ifdef USE_STD_VALARRAY
header ("std::valarray");
bench_cpp_matrix_prod<std::valarray<T>, N> () (runs);
#endif
}
#ifdef USE_FLOAT
template struct bench_3<float, 3>;
template struct bench_3<float, 10>;
template struct bench_3<float, 30>;
template struct bench_3<float, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<double, 3>;
template struct bench_3<double, 10>;
template struct bench_3<double, 30>;
template struct bench_3<double, 100>;
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
template struct bench_3<std::complex<float>, 3>;
template struct bench_3<std::complex<float>, 10>;
template struct bench_3<std::complex<float>, 30>;
template struct bench_3<std::complex<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<std::complex<double>, 3>;
template struct bench_3<std::complex<double>, 10>;
template struct bench_3<std::complex<double>, 30>;
template struct bench_3<std::complex<double>, 100>;
#endif
#endif

View File

@@ -1,12 +0,0 @@
# Copyright (c) 2004 Michael Stevens
# Use, modification and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# bench4 measurs the abstraction penalty of dense matrix and vector
# operations with boost::numeric::interval(s).
exe bench4
: bench4.cpp bench41.cpp bench42.cpp bench43.cpp
: <define>BOOST_UBLAS_USE_INTERVAL
;

View File

@@ -1,135 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include "../bench1/bench1.hpp"
void header (std::string text) {
std::cout << text << std::endl;
}
template<class T>
struct peak_c_plus {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (0);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s += T (0);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
struct peak_c_multiplies {
typedef T value_type;
void operator () (int runs) const {
try {
static T s (1);
boost::timer t;
for (int i = 0; i < runs; ++ i) {
s *= T (1);
// sink_scalar (s);
}
footer<value_type> () (0, 1, runs, t.elapsed ());
}
catch (std::exception &e) {
std::cout << e.what () << std::endl;
}
}
};
template<class T>
void peak<T>::operator () (int runs) {
header ("peak");
header ("plus");
peak_c_plus<T> () (runs);
header ("multiplies");
peak_c_multiplies<T> () (runs);
}
template struct peak<boost::numeric::interval<float> >;
template struct peak<boost::numeric::interval<double> >;
#ifdef USE_BOOST_COMPLEX
template struct peak<boost::complex<boost::numeric::interval<float> > >;
template struct peak<boost::complex<boost::numeric::interval<double> > >;
#endif
template <typename scalar>
void do_bench (std::string type_string, int scale)
{
header (type_string);
peak<scalar> () (1000000 * scale);
header (type_string + ", 3");
bench_1<scalar, 3> () (1000000 * scale);
bench_2<scalar, 3> () (300000 * scale);
bench_3<scalar, 3> () (100000 * scale);
header (type_string + ", 10");
bench_1<scalar, 10> () (300000 * scale);
bench_2<scalar, 10> () (30000 * scale);
bench_3<scalar, 10> () (3000 * scale);
header (type_string + ", 30");
bench_1<scalar, 30> () (100000 * scale);
bench_2<scalar, 30> () (3000 * scale);
bench_3<scalar, 30> () (100 * scale);
header (type_string + ", 100");
bench_1<scalar, 100> () (30000 * scale);
bench_2<scalar, 100> () (300 * scale);
bench_3<scalar, 100> () (3 * scale);
}
int main (int argc, char *argv []) {
int scale = 1;
if (argc > 1)
scale = std::atoi (argv [1]);
#ifdef USE_FLOAT
do_bench<boost::numeric::interval<float> > ("boost::numeric::interval<FLOAT>", scale);
#endif
#ifdef USE_DOUBLE
do_bench<boost::numeric::interval<double> > ("boost::numeric::interval<DOUBLE>", scale);
#endif
#ifdef USE_STD_COMPLEX
#ifdef USE_FLOAT
do_bench<std::complex<boost::numeric::interval<float> > > ("boost::numeric::interval<COMPLEX<FLOAT>>", scale);
#endif
#ifdef USE_DOUBLE
do_bench<std::complex<doublboost::numeric::interval<double> > > ("boost::numeric::interval<COMPLEX<DOUBLE>>", scale);
#endif
#endif
return 0;
}

View File

@@ -1,46 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include "../bench1/bench11.cpp"
#ifdef USE_FLOAT
template struct bench_1<boost::numeric::interval<float>, 3>;
template struct bench_1<boost::numeric::interval<float>, 10>;
template struct bench_1<boost::numeric::interval<float>, 30>;
template struct bench_1<boost::numeric::interval<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<boost::numeric::interval<double>, 3>;
template struct bench_1<boost::numeric::interval<double>, 10>;
template struct bench_1<boost::numeric::interval<double>, 30>;
template struct bench_1<boost::numeric::interval<double>, 100>;
#endif
#ifdef USE_BOOST_COMPLEX
#ifdef USE_FLOAT
template struct bench_1<boost::complex<boost::numeric::interval<float> >, 3>;
template struct bench_1<boost::complex<boost::numeric::interval<float> >, 10>;
template struct bench_1<boost::complex<boost::numeric::interval<float> >, 30>;
template struct bench_1<boost::complex<boost::numeric::interval<float> >, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_1<boost::complex<boost::numeric::interval<double> >, 3>;
template struct bench_1<boost::complex<boost::numeric::interval<double> >, 10>;
template struct bench_1<boost::complex<boost::numeric::interval<double> >, 30>;
template struct bench_1<boost::complex<boost::numeric::interval<double> >, 100>;
#endif
#endif

View File

@@ -1,46 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include "../bench1/bench12.cpp"
#ifdef USE_FLOAT
template struct bench_2<boost::numeric::interval<float>, 3>;
template struct bench_2<boost::numeric::interval<float>, 10>;
template struct bench_2<boost::numeric::interval<float>, 30>;
template struct bench_2<boost::numeric::interval<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<boost::numeric::interval<double>, 3>;
template struct bench_2<boost::numeric::interval<double>, 10>;
template struct bench_2<boost::numeric::interval<double>, 30>;
template struct bench_2<boost::numeric::interval<double>, 100>;
#endif
#ifdef USE_BOOST_COMPLEX
#ifdef USE_FLOAT
template struct bench_2<boost::complex<boost::numeric::interval<float> >, 3>;
template struct bench_2<boost::complex<boost::numeric::interval<float> >, 10>;
template struct bench_2<boost::complex<boost::numeric::interval<float> >, 30>;
template struct bench_2<boost::complex<boost::numeric::interval<float> >, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_2<boost::complex<boost::numeric::interval<double> >, 3>;
template struct bench_2<boost::complex<boost::numeric::interval<double> >, 10>;
template struct bench_2<boost::complex<boost::numeric::interval<double> >, 30>;
template struct bench_2<boost::complex<boost::numeric::interval<double> >, 100>;
#endif
#endif

View File

@@ -1,46 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include "../bench1/bench13.cpp"
#ifdef USE_FLOAT
template struct bench_3<boost::numeric::interval<float>, 3>;
template struct bench_3<boost::numeric::interval<float>, 10>;
template struct bench_3<boost::numeric::interval<float>, 30>;
template struct bench_3<boost::numeric::interval<float>, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<boost::numeric::interval<double>, 3>;
template struct bench_3<boost::numeric::interval<double>, 10>;
template struct bench_3<boost::numeric::interval<double>, 30>;
template struct bench_3<boost::numeric::interval<double>, 100>;
#endif
#ifdef USE_BOOST_COMPLEX
#ifdef USE_FLOAT
template struct bench_3<boost::complex<boost::numeric::interval<float> >, 3>;
template struct bench_3<boost::complex<boost::numeric::interval<float> >, 10>;
template struct bench_3<boost::complex<boost::numeric::interval<float> >, 30>;
template struct bench_3<boost::complex<boost::numeric::interval<float> >, 100>;
#endif
#ifdef USE_DOUBLE
template struct bench_3<boost::complex<boost::numeric::interval<double> >, 3>;
template struct bench_3<boost::complex<boost::numeric::interval<double> >, 10>;
template struct bench_3<boost::complex<boost::numeric::interval<double> >, 30>;
template struct bench_3<boost::complex<boost::numeric::interval<double> >, 100>;
#endif
#endif

View File

@@ -1,16 +0,0 @@
UBLAS
~~~~~
Copyright (c) 2000-2004 Joerg Walter, Mathias Koch
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
1.35.0
Updated all files to BSL v1 with permission of the authors.
PRE 1.34.0
FIX size_type and difference_type can be non defaults and uBLAS
expressions use the correct types.

View File

@@ -1,580 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C/utf-8XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Banded Matrix</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Banded Matrix</h1>
<div class="toc" id="toc"></div>
<h2 id="banded_matrix"><a name="banded_matrix" id="banded_matrix"></a>Banded Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>banded_matrix&lt;T, F, A&gt;</code> is
the base container adaptor for banded matrices. For a <em>(m x
n</em>)-dimensional banded matrix with <em>l</em> lower and
<em>u</em> upper diagonals and <em>0 &lt;= i &lt; m</em>, <em>0
&lt;= j &lt; n</em> holds <em>b</em><sub><em>i, j</em></sub> <em>=
0</em>, if <em>i &gt; j + l</em> or <em>i &lt; j - u</em>. The
storage of banded matrices is packed.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/banded.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
banded_matrix&lt;double&gt; m (3, 3, 1, 1);
for (signed i = 0; i &lt; signed (m.size1 ()); ++ i)
for (signed j = std::max (i - 1, 0); j &lt; std::min (i + 2, signed (m.size2 ())); ++ j)
m (i, j) = 3 * i + j;
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header banded.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F</code></td>
<td>Functor describing the storage organization. <a href=
"#banded_matrix_1">[1]</a></td>
<td><code>row_major</code></td>
</tr>
<tr>
<td><code>A</code></td>
<td>The type of the adapted array. <a href=
"#banded_matrix_2">[2]</a></td>
<td><code>unbounded_array&lt;T&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;banded_matrix&lt;T, F, A&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>banded_matrix ()</code></td>
<td>Allocates an uninitialized <code>banded_matrix</code> that
holds zero rows of zero elements.</td>
</tr>
<tr>
<td><code>banded_matrix (size_type size1, size_type size2,
size_type lower = 0, size_type upper = 0)</code></td>
<td>Allocates an uninitialized <code>banded_matrix</code> that
holds <code>(lower + 1 + upper)</code> diagonals around the main
diagonal of a matrix with <code>size1</code> rows of
<code>size2</code> elements.</td>
</tr>
<tr>
<td><code>banded_matrix (const banded_matrix &amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, size_type
lower = 0, size_type upper = 0, bool preserve = true)</code></td>
<td>Reallocates a <code>banded_matrix</code> to hold <code>(lower +
1 + upper)</code> diagonals around the main diagonal of a matrix
with <code>size1</code> rows of <code>size2</code> elements. The
existing elements of the <code>banded_matrix</code> are preseved
when specified.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>size_type lower () const</code></td>
<td>Returns the number of diagonals below the main diagonal.</td>
</tr>
<tr>
<td><code>size_type upper () const</code></td>
<td>Returns the number of diagonals above the main diagonal.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>j</code>
-th element in the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>banded_matrix &amp;operator = (const banded_matrix
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>banded_matrix &amp;assign_temporary (banded_matrix
&amp;m)</code></td>
<td>Assigns a temporary. May change the banded matrix
<code>m</code> .</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix &amp;operator = (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the banded matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix &amp;operator += (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the banded matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix &amp;plus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Adds a matrix expression to the banded matrix. Left and right
hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix &amp;operator -= (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the banded matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_matrix &amp;minus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Subtracts a matrix expression from the banded matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
banded_matrix &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the banded matrix
with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
banded_matrix &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the banded matrix
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (banded_matrix &amp;m)</code></td>
<td>Swaps the contents of the banded matrices.</td>
</tr>
<tr>
<td><code>void insert (size_type i, size_type j, const_reference
t)</code></td>
<td>Inserts the value <code>t</code> at the <code>j</code>-th
element of the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void erase (size_type i, size_type j)</code></td>
<td>Erases the value at the <code>j</code>-th elemenst of the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the matrix.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>banded_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>banded_matrix</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="banded_matrix_1" id="banded_matrix_1">[1]</a> Supported
parameters for the storage organization are <code>row_major</code>
and <code>column_major</code>.</p>
<p><a name="banded_matrix_2" id="banded_matrix_2">[2]</a> Supported
parameters for the adapted array are
<code>unbounded_array&lt;T&gt;</code> ,
<code>bounded_array&lt;T&gt;</code> and
<code>std::vector&lt;T&gt;</code> .</p>
<h2 id="banded_adaptor"><a name="banded_adaptor" id="banded_adaptor"></a>Banded Adaptor</h2>
<h4>Description</h4>
<p>The templated class <code>banded_adaptor&lt;M&gt;</code> is a
banded matrix adaptor for other matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/banded.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
matrix&lt;double&gt; m (3, 3);
banded_adaptor&lt;matrix&lt;double&gt; &gt; ba (m, 1, 1);
for (signed i = 0; i &lt; signed (ba.size1 ()); ++ i)
for (signed j = std::max (i - 1, 0); j &lt; std::min (i + 2, signed (ba.size2 ())); ++ j)
ba (i, j) = 3 * i + j;
std::cout &lt;&lt; ba &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header banded.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>M</code></td>
<td>The type of the adapted matrix.</td>
<td></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="expression_concept.htm#matrix_expression">Matrix Expression</a>
.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"expression_concept.htm#matrix_expression">Matrix Expression</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_expression&lt;banded_adaptor&lt;M&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>banded_adaptor (matrix_type &amp;data, size_type lower =
0, size_type upper = 0)</code></td>
<td>Constructs a <code>banded_adaptor</code> that holds
<code>(lower + 1 + upper)</code> diagonals around the main diagonal
of a matrix.</td>
</tr>
<tr>
<td><code>banded_adaptor (const banded_adaptor &amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>size_type lower () const</code></td>
<td>Returns the number of diagonals below the main diagonal.</td>
</tr>
<tr>
<td><code>size_type upper () const</code></td>
<td>Returns the number of diagonals above the main diagonal.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>j</code>
-th element in the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>banded_adaptor &amp;operator = (const banded_adaptor
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>banded_adaptor &amp;assign_temporary (banded_adaptor
&amp;m)</code></td>
<td>Assigns a temporary. May change the banded adaptor
<code>m</code> .</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor &amp;operator = (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the banded adaptor. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor &amp;operator += (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the banded adaptor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor &amp;plus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Adds a matrix expression to the banded adaptor. Left and right
hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor &amp;operator -= (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the banded adaptor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
banded_adaptor &amp;minus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Subtracts a matrix expression from the banded adaptor. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
banded_adaptor &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the banded adaptor
with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
banded_adaptor &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the banded adaptor
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (banded_adaptor &amp;m)</code></td>
<td>Swaps the contents of the banded adaptors.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>banded_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>banded_adaptor</code>.</td>
</tr>
</tbody>
</table>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,453 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BLAS</title>
<meta name="GENERATOR" content="Quanta Plus" />
<meta name="AUTHOR" content="Gunter Winkler" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<link rel="stylesheet" type="text/css" href="doxygen.css" />
</head>
<body>
<h1>Level 3 BLAS</h1>
<div class="toc" id="toc"></div>
<hr />
<a name="_details"></a>
<table summary="" border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br /><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T, class M2, class M3&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga0">boost::numeric::ublas::blas_3::tmm</a> (M1 &amp;m1, const T &amp;t, const M2 &amp;m2, const M3 &amp;m3)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">triangular matrix multiplication <a href="#ga0"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T, class M2, class C&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga1">boost::numeric::ublas::blas_3::tsm</a> (M1 &amp;m1, const T &amp;t, const M2 &amp;m2, C)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">triangular solve <em>m2</em> * <em>x</em> = <em>t</em> * <em>m1</em> in place, <em>m2</em> is a triangular matrix <a href="#ga1"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T1, class T2, class M2, class M3&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga2">boost::numeric::ublas::blas_3::gmm</a> (M1 &amp;m1, const T1 &amp;t1, const T2 &amp;t2, const M2 &amp;m2, const M3 &amp;m3)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">general matrix multiplication <a href="#ga2"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T1, class T2, class M2&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga3">boost::numeric::ublas::blas_3::srk</a> (M1 &amp;m1, const T1 &amp;t1, const T2 &amp;t2, const M2 &amp;m2)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">symmetric rank k update: <em>m1</em> = <em>t</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m2<sup>T</sup></em>) <a href="#ga3"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T1, class T2, class M2&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga4">boost::numeric::ublas::blas_3::hrk</a> (M1 &amp;m1, const T1 &amp;t1, const T2 &amp;t2, const M2 &amp;m2)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">hermitian rank k update: <em>m1</em> = <em>t</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m2<sup>H</sup></em>) <a href="#ga4"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T1, class T2, class M2, class M3&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga5">boost::numeric::ublas::blas_3::sr2k</a> (M1 &amp;m1, const T1 &amp;t1, const T2 &amp;t2, const M2 &amp;m2, const M3 &amp;m3)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">generalized symmetric rank k update: <em>m1</em> = <em>t1</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m3<sup>T</sup></em>) + <em>t2</em> * (<em>m3</em> * <em>m2<sup>T</sup></em>) <a href="#ga5"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M1, class T1, class T2, class M2, class M3&gt; M1 &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="#ga6">boost::numeric::ublas::blas_3::hr2k</a> (M1 &amp;m1, const T1 &amp;t1, const T2 &amp;t2, const M2 &amp;m2, const M3 &amp;m3)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">generalized hermitian rank k update: <em>m1</em> = <em>t1</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m3<sup>H</sup></em>) + (<em>m3</em> * (<em>t2</em> * <em>m2</em>)<sup>H</sup>) <a href="#ga6"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M, class E1, class E2&gt; BOOST_UBLAS_INLINE M &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="products.htm#ga7">boost::numeric::ublas::axpy_prod</a> (const matrix_expression&lt; E1 &gt; &amp;e1, const matrix_expression&lt; E2 &gt; &amp;e2, M &amp;m, bool init=true)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">computes <code>M += A X</code> or <code>M = A X</code> in an optimized fashion. <a href="products.htm#ga7"></a><br /><br /></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template&lt;class M, class E1, class E2&gt; BOOST_UBLAS_INLINE M &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="products.htm#ga8">boost::numeric::ublas::opb_prod</a> (const matrix_expression&lt; E1 &gt; &amp;e1, const matrix_expression&lt; E2 &gt; &amp;e2, M &amp;m, bool init=true)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">computes <code>M += A X</code> or <code>M = A X</code> in an optimized fashion. <a href="products.htm#ga8"></a><br /><br /></td></tr>
</table>
<hr />
<h2>Function Documentation</h2>
<a class="anchor" name="ga0" doxytag="boost::numeric::ublas::blas_3::tmm" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; tmm </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M3 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m3</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>triangular matrix multiplication </p>
</td>
</tr>
</table>
<a class="anchor" name="ga1" doxytag="boost::numeric::ublas::blas_3::tsm" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; tsm </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>C&nbsp;</td>
<td class="mdname" nowrap></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
triangular solve <em>m2</em> * <em>x</em> = <em>t</em> * <em>m1</em> in place, <em>m2</em> is a triangular matrix
</p>
</td>
</tr>
</table>
<a class="anchor" name="ga2" doxytag="boost::numeric::ublas::blas_3::gmm" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; gmm </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M3 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m3</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
general matrix multiplication
</p>
</td>
</tr>
</table>
<a class="anchor" name="ga3" doxytag="boost::numeric::ublas::blas_3::srk" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; srk </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
symmetric rank k update: <em>m1</em> = <em>t</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m2<sup>T</sup></em>)
</p>
<dl compact><dt><b>Todo:</b></dt><dd>use opb_prod() </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="ga4" doxytag="boost::numeric::ublas::blas_3::hrk" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; hrk </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
hermitian rank k update: <em>m1</em> = <em>t</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m2<sup>H</sup></em>)
</p>
<dl compact><dt><b>Todo:</b></dt><dd>use opb_prod()</dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="ga5" doxytag="boost::numeric::ublas::blas_3::sr2k" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; sr2k </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M3 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m3</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
generalized symmetric rank k update: <em>m1</em> = <em>t1</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m3<sup>T</sup></em>) + <em>t2</em> * (<em>m3</em> * <em>m2<sup>T</sup></em>)
</p>
<dl compact><dt><b>Todo:</b></dt><dd>use opb_prod()</dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="ga6" doxytag="boost::numeric::ublas::blas_3::hr2k" ></a>
<table summary="" class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> M1&amp; hr2k </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">M1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T1 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const T2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>t2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M2 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const M3 &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m3</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
generalized hermitian rank k update: <em>m1</em> = <em>t1</em> * <em>m1</em> + <em>t2</em> * (<em>m2</em> * <em>m3<sup>H</sup></em>) + (<em>m3</em> * (<em>t2</em> * <em>m2</em>)<sup>H</sup>)
</p>
<dl compact><dt><b>Todo:</b></dt><dd>use opb_prod()</dd></dl>
</td>
</tr>
</table>
<hr />
<p>Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
Joerg Walter, Gunter Winkler<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,219 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Bounded Array;</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Bounded Array Storage</h1>
<div class="toc" id="toc"></div>
<h2 id="bounded_array"><a name="bounded_array" id="bounded_array"></a>Bounded Array</h2>
<h4>Description</h4>
<p>The templated class <code>bounded_array&lt;T, N, ALLOC&gt;</code> implements a bounded storage array. The bounded array is similar to a C++ array type in that its maximum size is bounded by N and is allocated on the stack instead of the heap. Similarly a <code>bounded_array</code> requires no secondary storage and ALLOC is only used to specify <code>size_type</code> and <code>difference_type</code>.
</p>
<p>When resized <code>bounded_array</code> never reallocated the storage. It is therefore always efficient to resize a <code>bounded_array</code> but the size bound N must not be exceeded.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
bounded_array&lt;double, 3&gt; a (3);
for (unsigned i = 0; i &lt; a.size (); ++ i) {
a [i] = i;
std::cout &lt;&lt; a [i] &lt;&lt; std::endl;
}
}
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the array.</td>
<td></td>
</tr>
<tr>
<td><code>N</code></td>
<td>The allocation size of the array.</td>
<td></td>
</tr>
<tr>
<td><code>ALLOC</code></td>
<td>An STL Allocator</td>
<td>std::allocator</td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="storage_concept.htm">Storage</a></p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Storage.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<ul>
<li>The description does not describe what the member actually does, this can be looked up
in the corresponding concept documentation, but instead contains a remark on the implementation of the
member inside this model of the concept.</li>
<li>Typography:
<ul>
<li>Members that are not part of the implemented concepts are <font color="blue">in blue</font>.</li>
</ul>
</li>
</ul>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Where defined</th>
<th>Description</th>
</tr>
<tr><td><code>value_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td></tr>
<tr><td><code>pointer</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>value_type*</code></td></tr>
<tr><td><code>const_pointer</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>const value_type*</code></td></tr>
<tr><td><code>reference</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>value_type&amp;</code></td></tr>
<tr><td><code>const_reference</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>const value_type&amp;</code></td></tr>
<tr><td><code>size_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>Alloc::size_type</code></td></tr>
<tr><td><code>difference_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>Alloc::difference_type</code></td></tr>
<tr><td><code>iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>pointer</code></td></tr>
<tr><td><code>const_iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>const_pointer</code></td></tr>
<tr><td><code>revere_iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>std::reverse_iterator&lt;iterator&gt;</code></td></tr>
<tr><td><code>const_revere_iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>std::reverse_iterator&lt;const_iterator&gt;</code></td></tr>
<tr>
<td><code>bounded_array ()</code></td>
<td><a href="storage_concept.htm">Storage</a></td>
<td>Creates an <code>unbounded_array</code> that holds <strong>zero</strong> elements.</td>
</tr>
<tr>
<td><code>bounded_array (size_type size)</code></td>
<td><a href="storage_concept.htm">Storage</a></td>
<td>Creates a uninitialized <code>bounded_array</code> that holds <code>size</code> elements. All the elements are default constructed.</td>
</tr>
<tr>
<td><code>bounded_array (size_type size, const T&amp; init)</code></td>
<td><a href="storage_concept.htm">Storage</a></td>
<td>Creates an initialized <code>bounded_array</code> that holds <code>size</code> elements. All the elements are constructed from the <code>init</code> value.</td>
</tr>
<tr>
<td><code>bounded_array (const bounded_array &amp;c)</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>~bounded_array ()</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Deallocates the <code>bounded_array</code> itself.</td>
</tr>
<tr>
<td><code>void resize (size_type size)</code></td>
<td><a href="storage_concept.htm">Storage</a>
<td>Reallocates a <code>bounded_array</code> to hold <code>size</code> elements.</td>
</tr>
<tr>
<td><code>void resize (size_type size, const T&amp; t)</code></td>
<td><a href="storage_concept.htm">Storage</a>
<td>Reallocates a <code>bounded_array</code> to hold <code>size</code> elements.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns the size of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i) const</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns a <code>const</code> reference of the <code>i</code> -th element.</td>
</tr>
<tr>
<td><code>reference operator [] (size_type i)</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>bounded_array &amp;operator = (const bounded_array &amp;a)</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><font color="blue"><code>bounded_array &amp;assign_temporary (bounded_array &amp;a)</code></font></td>
<td></td>
<td>Assigns a temporary. May change the array <code>a</code>.</td>
</tr>
<tr>
<td><code>void swap (bounded_array &amp;a)</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Swaps the contents of the arrays.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns a <code>const_iterator</code> pointing to the end of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>iterator begin ()</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns a <code>iterator</code> pointing to the beginning of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>iterator end ()</code></td>
<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
<td>Returns a <code>iterator</code> pointing to the end of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the beginning of the reversed <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the end of the reversed <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rbegin ()</code></td>
<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
<td>Returns a <code>reverse_iterator</code> pointing to the beginning of the reversed <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rend ()</code></td>
<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
<td>Returns a <code>reverse_iterator</code> pointing to the end of the reversed <code>bounded_array</code>.</td>
</tr>
</tbody>
</table>
<hr />
<p>
Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
Joerg Walter, Gunter Winkler<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,424 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Container Concepts</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Container Concepts</h1>
<div class="toc" id="toc"></div>
<h2 id="vector"><a name="vector" id="vector"></a>Vector</h2>
<h4>Description</h4>
<p>A Vector describes common aspects of dense, packed and sparse
vectors.</p>
<h4>Refinement of</h4>
<p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
<a href="expression_concept.htm#vector_expression">Vector Expression</a>
<a href="#vector_expression_note">[1]</a>.</p>
<h4>Associated types</h4>
<p>In addition to the types defined by <a href="expression_concept.htm#vector_expression">Vector Expression</a></p>
<table border="1" summary="types">
<tbody>
<tr>
<td>Public base</td>
<td>vector_container&lt;V&gt;</td>
<td>V must be derived from this public base type.</td>
</tr>
<tr>
<td>Storage array</td>
<td>V::array_type</td>
<td>
Dense Vector ONLY. The type of underlying storage array used to store the elements. The array_type must model the
<a href="storage_concept.htm"><b>Storage</b></a> concept.</td>
</tr>
</tbody>
</table>
<h4>Notation</h4>
<table border="0" summary="notation">
<tbody>
<tr>
<td><code>V</code></td>
<td>A type that is a model of Vector</td>
</tr>
<tr>
<td><code>v</code></td>
<td>Objects of type <code>V</code></td>
</tr>
<tr>
<td><code>n, i</code></td>
<td>Objects of a type convertible to <code>size_type</code></td>
</tr>
<tr>
<td><code>t</code></td>
<td>Object of a type convertible to <code>value_type</code></td>
</tr>
<tr>
<td><code>p</code></td>
<td>Object of a type convertible to <code>bool</code></td>
</tr>
</tbody>
</table>
<h4>Definitions</h4>
<h4>Valid expressions</h4>
<p>In addition to the expressions defined in <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
<a href="expression_concept.htm#vector_expression">Vector Expression</a> the following expressions must be valid.</p>
<table border="1" summary="expressions">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th>
</tr>
<tr>
<td>Sizing constructor</td>
<td><code>V v (n)</code></td>
<td>&nbsp;</td>
<td><code>V</code></td>
</tr>
<tr>
<td>Insert</td>
<td><code>v.insert_element (i, t)</code></td>
<td><code>v</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Erase</td>
<td><code>v.erase_element (i)</code></td>
<td><code>v</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Clear</td>
<td><code>v.clear ()</code></td>
<td><code>v</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Resize</td>
<td><code>v.resize (n)</code><br />
<code>v.resize (n, p)</code></td>
<td><code>v</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Storage</td>
<td><code>v.data()</code></td>
<td><code>v</code> is mutable and Dense.</td>
<td><code>array_type&amp;</code> if <code>v</code> is mutable, <code>const array_type&amp;</code> otherwise</td>
</tr>
</tbody>
</table>
<h4>Expression semantics</h4>
<p>Semantics of an expression is defined only where it differs
from, or is not defined in <a href=
"expression_concept.htm#vector_expression">Vector Expression</a> .</p>
<table border="1" summary="semantics">
<tr>
<th>Name</th>
<th>Expression</th>
<th>Precondition</th>
<th>Semantics</th>
<th>Postcondition</th>
</tr>
<tr>
<td>Sizing constructor</td>
<td><code>V v (n)</code></td>
<td><code>n &gt;= 0</code></td>
<td>Allocates a vector of<code>n</code> elements.</td>
<td><code>v.size () == n</code>.</td>
</tr>
<tr>
<td>Element access <a href="#element_access_note">[2]</a></td>
<td><code>v[n]</code></td>
<td><code>0&lt;n&gt;v.size()</code></td>
<td>returns the n-th element in v</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Insert</td>
<td><code>v.insert_element (i, t)</code></td>
<td><code>0 &lt;= i &lt; v.size ()</code>.</td>
<td>Inserts an element at <code>v (i)</code> with value <code>t</code>.
The storage requirement of the Vector may be increased.</td>
<td><code>v (i)</code> is equal to <code>t</code>.</td>
</tr>
<tr>
<td>Erase</td>
<td><code>v.erase_element (i)</code></td>
<td><code>0 &lt;= i &lt; v.size ()</code></td>
<td>Destroys the element as <code>v (i)</code> and replaces it with the default
<code>value_type ()</code>.
The storage requirement of the Vector may be decreased.</td>
<td><code>v (i)</code> is equal to <code>value_type ()</code>.</td>
</tr>
<tr>
<td>Clear</td>
<td><code>v.clear ()</code></td>
<td>&nbsp;</td>
<td>Equivalent to<br />
<code>for (i = 0; i &lt; v.size (); ++ i)</code><br />
&nbsp; <code>v.erase_element (i);</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Resize</td>
<td><code>v.resize (n)
<br />v.resize (n, p)</code></td>
<td>&nbsp;</td>
<td>Reallocates the vector so that it can hold <code>n</code>
elements.<br />
Erases or appends elements in order to bring the vector to the prescribed size. Appended elements copies of <code>value_type()</code>.
<br />
When <code>p == false</code> then existing elements are not preserved and elements will not appended as normal. Instead the vector is in the same state as that after an equivalent sizing constructor.</td>
<td><code>v.size () == n</code>.</td>
</tr>
<tr>
<td>Storage</td>
<td><code>v.data()</code></td>
<td></td>
<td>Returns a reference to the underlying dense storage.</td>
<td>&nbsp;</td>
</tr>
</table>
<h4>Complexity guarantees</h4>
<p>The run-time complexity of the sizing constructor is linear in
the vector's size.</p>
<p>The run-time complexity of insert_element and erase_element is specific for the
Vector model and it depends on increases/decreases in storage requirements.</p>
<p>The run-time complexity of resize is linear in the vector's
size.</p>
<h4>Invariants</h4>
<h4>Models</h4>
<ul>
<li><code>vector</code>, <code>bounded_vector</code>, <code>c_vector</code></li>
<li><code>unit_vector</code>, <code>zero_vector</code>, <code>scalar_vector</code></li>
<li><code>mapped_vector;</code>, <code>compressed_vector</code>, <code>coordinate_vector</code></li>
</ul>
<h4>Notes</h4>
<p><a name="vector_expression_note">[1]</a>
As a user you need not care about <tt>Vector</tt> being a refinement of the VectorExpression. Being a refinement of the VectorExpression is only important for the template-expression engine but not the user.</p>
<p><a name="element_access_note">[2]</a>
The <code>operator[]</code> is added purely for convenience
and compatibility with the <code>std::vector</code>. In uBLAS however,
generally <code>operator()</code> is used for indexing because this can be
used for both vectors and matrices.</p>
<h2 id="matrix"><a name="matrix" id="matrix"></a>Matrix</h2>
<h4>Description</h4>
<p>A Matrix describes common aspects of dense, packed and sparse
matrices.</p>
<h4>Refinement of</h4>
<p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
<a href="expression_concept.htm#matrix_expression">Matrix Expression</a>
<a href="#matrix_expression_note">[1]</a>
.</p>
<h4>Associated types</h4>
<p>In addition to the types defined by <a href="expression_concept.htm#matrix_expression">Matrix Expression</a></p>
<table border="1" summary="types">
<tbody>
<tr>
<td>Public base</td>
<td>matrix_container&lt;M&gt;</td>
<td>M must be derived from this public base type.</td>
</tr>
<tr>
<td>Storage array</td>
<td>M::array_type</td>
<td>Dense Matrix ONLY. The type of underlying storage array used to store the elements. The array_type must model
the <a href="storage_concept.htm"><b>Storage</b></a> concept.</td>
</tr>
</tbody>
</table>
<h4>Notation</h4>
<table border="0" summary="notation">
<tbody>
<tr>
<td><code>M</code></td>
<td>A type that is a model of Matrix</td>
</tr>
<tr>
<td><code>m</code></td>
<td>Objects of type <code>M</code></td>
</tr>
<tr>
<td><code>n1, n2, i, j</code></td>
<td>Objects of a type convertible to <code>size_type</code></td>
</tr>
<tr>
<td><code>t</code></td>
<td>Object of a type convertible to <code>value_type</code></td>
</tr>
<tr>
<td><code>p</code></td>
<td>Object of a type convertible to <code>bool</code></td>
</tr>
</tbody>
</table>
<h4>Definitions</h4>
<h4>Valid expressions</h4>
<p>In addition to the expressions defined in <a href=
"expression_concept.htm#matrix_expression">Matrix Expression</a> the
following expressions must be valid.</p>
<table border="1" summary="expressions">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th>
</tr>
<tr>
<td>Sizing constructor</td>
<td><code>M m (n1, n2)</code></td>
<td>&nbsp;</td>
<td><code>M</code></td>
</tr>
<tr>
<td>Insert</td>
<td><code>m.insert_element (i, j, t)</code></td>
<td><code>m</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Erase</td>
<td><code>m.erase_element (i, j)</code></td>
<td><code>m</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Clear</td>
<td><code>m.clear ()</code></td>
<td><code>m</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Resize</td>
<td><code>m.resize (n1, n2)</code><br />
<code>m.resize (n1, n2, p)</code></td>
<td><code>m</code> is mutable.</td>
<td><code>void</code></td>
</tr>
<tr>
<td>Storage</td>
<td><code>m.data()</code></td>
<td><code>m</code> is mutable and Dense.</td>
<td><code>array_type&amp;</code> if <code>m</code> is mutable, <code>const array_type&amp;</code> otherwise</td>
</tr>
</tbody>
</table>
<h4>Expression semantics</h4>
<p>Semantics of an expression is defined only where it differs
from, or is not defined in <a href=
"expression_concept.htm#matrix_expression">Matrix Expression</a> .</p>
<table border="1" summary="semantics">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Precondition</th>
<th>Semantics</th>
<th>Postcondition</th>
</tr>
<tr>
<td>Sizing constructor</td>
<td><code>M m (n1, n2)</code></td>
<td><code>n1 &gt;= 0</code> and <code>n2 &gt;= 0</code></td>
<td>Allocates a matrix of <code>n1</code> rows and <code>n2</code>
columns.</td>
<td><code>m.size1 () == n1</code> and <code>m.size2 () ==
n2</code>.</td>
</tr>
<tr>
<td>Insert</td>
<td><code>m.insert_element (i, j, t)</code></td>
<td><code>0 &lt;= i &lt; m.size1 ()</code>,<br />
<code>0 &lt;= j &lt; m.size2 ()</code>.</td>
<td>Inserts an element at <code>m (i, j)</code> with value <code>t</code>.
The storage requirement of the Matrix may be increased.</td>
<td><code>m (i, j)</code> is equal to <code>t</code>.</td>
</tr>
<tr>
<td>Erase</td>
<td><code>m.erase_element (i, j)</code></td>
<td><code>0 &lt;= i &lt; m.size1 ()</code>and <code><br />
0 &lt;= j &lt; m.size2</code></td>
<td>Destroys the element as <code>m (i, j)</code> and replaces it with the default
<code>value_type ()</code>.
The storage requirement of the Matrix may be decreased.</td>
<td><code>m (i, j)</code> is equal to <code>value_type ()</code>.</td>
</tr>
<tr>
<td>Clear</td>
<td><code>m.clear ()</code></td>
<td>&nbsp;</td>
<td>Equivalent to<br />
<code>for (i = 0; i &lt; m.size1 (); ++ i)</code><br />
&nbsp; <code>for (j = 0; j &lt; m.size2 (); ++ j)</code><br />
&nbsp; &nbsp; <code>m.erase_element (i, j);</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Resize</td>
<td><code>m.resize (n1, n2)
<br />
m.resize (n1, n2, p)
</code></td>
<td>&nbsp;</td>
<td>Reallocate the matrix so that it can hold <code>n1</code> rows
and <code>n2</code> columns.<br />
Erases or appends elements in order to bring the matrix to the
prescribed size. Appended elements are <code>value_type()</code>
copies.<br />
When <code>p == false</code> then existing elements are not preserved and elements will not appended as normal. Instead the matrix is in the same state as that after an equivalent sizing constructor.</td>
<td><code>m.size1 () == n1</code> and <code>m.size2 () == n2</code>.</td>
</tr>
<tr>
<td>Storage</td>
<td><code>m.data()</code></td>
<td></td>
<td>Returns a reference to the underlying dense storage.</td>
<td>&nbsp;</td>
</tbody>
</table>
<h4>Complexity guarantees</h4>
<p>The run-time complexity of the sizing constructor is quadratic
in the matrix's size.</p>
<p>The run-time complexity of insert_element and erase_element is specific for the
Matrix model and it depends on increases/decreases in storage requirements.</p>
<p>The run-time complexity of resize is quadratic in the matrix's
size.</p>
<h4>Invariants</h4>
<h4>Models</h4>
<ul>
<li><code>matrix</code>, <code>bounded_matrix</code>, <code>c_matrix</code></li>
<li><code>identity_matrix</code> , <code>zero_matrix</code> , <code>scalar_matrix</code></li>
<li><code>triangular_matrix</code> , <code>symmetric_matrix</code> , <code>banded_matrix</code></li>
<li><code>mapped_matrix</code> , <code>compressed_matrix</code> , <code>coordinate_matrix</code></li>
</ul>
<h4>Notes</h4>
<p><a name="matrix_expression_note">[1]</a>
As a user you need not care about <tt>Matrix</tt> being a refinement of the MatrixExpression. Being a refinement of the MatrixExpression is only important for the template-expression engine but not the user.</p>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,229 +0,0 @@
/*
* Copyright 2000-2004 Michael Stevens, Mathias Koch,
* Joerg Walter, Gunter Winkler.
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt
* or copy at http://www.boost.org/LICENSE_1_0.txt).
*/
H1 {
text-align: center;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
H2 {
font-family: Geneva, Arial, Helvetica, sans-serif;
}
CAPTION { font-weight: bold }
DIV.qindex {
width: 100%;
background-color: #eeeeff;
border: 1px solid #B0B0B0;
text-align: center;
margin: 2px;
padding: 2px;
line-height: 120%;
}
A.qindex {
text-decoration: none;
font-weight: bold;
color: #1A419D;
padding: 2px;
}
A.qindex:visited {
text-decoration: none;
font-weight: bold;
color: #1A419D
padding: 2px;
}
A.qindex:hover {
text-decoration: none;
background-color: #ddddff;
padding: 2px;
}
A.qindexHL {
text-decoration: none;
font-weight: bold;
background-color: #6666cc;
color: #ffffff;
padding: 2px 6px;
border: 1px double #9295C2;
}
A.qindexHL:hover {
text-decoration: none;
background-color: #6666cc;
color: #ffffff;
padding: 2px 6px;
}
A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff }
A.el { text-decoration: none; font-weight: bold }
A.elRef { font-weight: bold }
A.code { text-decoration: none; font-weight: normal; color: #1A419D}
A.codeRef { font-weight: normal; color: #1A419D}
A:hover { text-decoration: none; background-color: #f2f2ff }
DL.el { margin-left: -1cm }
PRE.fragment {
border: 1px solid #CCCCCC;
background-color: #f5f5f5;
margin-top: 4px;
margin-bottom: 4px;
margin-left: 2px;
margin-right: 8px;
padding-left: 6px;
padding-right: 6px;
padding-top: 4px;
padding-bottom: 4px;
}
DIV.fragment {
border: 1px solid #CCCCCC;
background-color: #f5f5f5;
padding: 6px;
}
DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
TD.md { background-color: #F4F4FB; font-weight: bold; }
TD.mdname1 { background-color: #F4F4FB; font-weight: bold; color: #602020; }
TD.mdname { background-color: #F4F4FB; font-weight: bold; color: #602020; width: 600px; }
DIV.groupHeader {
margin-left: 16px;
margin-top: 12px;
margin-bottom: 6px;
font-weight: bold;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
BODY {
background: white;
color: black;
margin-right: 20px;
margin-left: 20px;
}
TD.indexkey {
background-color: #eeeeff;
font-weight: bold;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px;
border: 1px solid #CCCCCC;
}
TD.indexvalue {
background-color: #eeeeff;
font-style: italic;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px;
border: 1px solid #CCCCCC;
}
TR.memlist {
background-color: #f0f0f0;
}
P.formulaDsp { text-align: center; }
IMG.formulaDsp { }
IMG.formulaInl { vertical-align: middle; }
SPAN.keyword { color: #008000 }
SPAN.keywordtype { color: #604020 }
SPAN.keywordflow { color: #e08000 }
SPAN.comment { color: #800000 }
SPAN.preprocessor { color: #806020 }
SPAN.stringliteral { color: #002080 }
SPAN.charliteral { color: #008080 }
.mdTable {
border: 1px solid #868686;
background-color: #F4F4FB;
}
.mdRow {
padding: 8px 10px;
}
.mdescLeft {
font-size: smaller;
font-style: italic;
background-color: #FAFAFA;
padding-left: 8px;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.mdescRight {
font-size: smaller;
font-style: italic;
background-color: #FAFAFA;
padding-left: 4px;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
padding-bottom: 0px;
padding-right: 8px;
}
.memItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.memItemRight {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.search { color: #003399;
font-weight: bold;
}
FORM.search {
margin-bottom: 0px;
margin-top: 0px;
}
INPUT.search { font-size: 75%;
color: #000080;
font-weight: normal;
background-color: #eeeeff;
}
TD.tiny { font-size: 75%;
}
a {
color: #252E78;
}
a:visited {
color: #3D2185;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,597 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Hermitian Matrix</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Hermitian Matrix</h1>
<div class="toc" id="toc"></div>
<h2 id="hermitian_matrix"><a name="hermitian_matrix" id="hermitian_matrix"></a>Hermitian Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>hermitian_matrix&lt;T, F1, F2,
A&gt;</code> is the base container adaptor for hermitian matrices.
For a <em>(n x n</em> )-dimensional hermitian matrix and <em>0
&lt;= i &lt; n</em>, <em>0 &lt;= j &lt; n</em> holds
<em>h</em><sub><em>i, j</em></sub> <em>= h</em><sub><em>j,
i</em></sub><sup><em>-</em></sup>. The storage of hermitian
matrices is packed.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/hermitian.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
hermitian_matrix&lt;std::complex&lt;double&gt;, lower&gt; ml (3, 3);
for (unsigned i = 0; i &lt; ml.size1 (); ++ i) {
for (unsigned j = 0; j &lt; i; ++ j)
ml (i, j) = std::complex&lt;double&gt; (3 * i + j, 3 * i + j);
ml (i, i) = std::complex&lt;double&gt; (4 * i, 0);
}
std::cout &lt;&lt; ml &lt;&lt; std::endl;
hermitian_matrix&lt;std::complex&lt;double&gt;, upper&gt; mu (3, 3);
for (unsigned i = 0; i &lt; mu.size1 (); ++ i) {
mu (i, i) = std::complex&lt;double&gt; (4 * i, 0);
for (unsigned j = i + 1; j &lt; mu.size2 (); ++ j)
mu (i, j) = std::complex&lt;double&gt; (3 * i + j, 3 * i + j);
}
std::cout &lt;&lt; mu &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header hermitian.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F1</code></td>
<td>Functor describing the type of the hermitian matrix. <a href=
"#hermitian_matrix_1">[1]</a></td>
<td><code>lower</code></td>
</tr>
<tr>
<td><code>F2</code></td>
<td>Functor describing the storage organization. <a href=
"#hermitian_matrix_2">[2]</a></td>
<td><code>row_major</code></td>
</tr>
<tr>
<td><code>A</code></td>
<td>The type of the adapted array. <a href=
"#hermitian_matrix_3">[3]</a></td>
<td><code>unbounded_array&lt;T&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;hermitian_matrix&lt;T, F1, F2, A&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>hermitian_matrix ()</code></td>
<td>Allocates an uninitialized <code>hermitian_matrix</code> that
holds zero rows of zero elements.</td>
</tr>
<tr>
<td><code>hermitian_matrix (size_type size)</code></td>
<td>Allocates an uninitialized <code>hermitian_matrix</code> that
holds <code>size</code> rows of <code>size</code> elements.</td>
</tr>
<tr>
<td><code>hermitian_matrix (const hermitian_matrix
&amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size, bool preserve =
true)</code></td>
<td>Reallocates a <code>hermitian_matrix</code> to hold
<code>size</code> rows of <code>size</code> elements. The existing
elements of the <code>hermitian_matrix</code> are preseved when
specified.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>j</code>
-th element in the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>hermitian_matrix &amp;operator = (const hermitian_matrix
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>hermitian_matrix &amp;assign_temporary (hermitian_matrix
&amp;m)</code></td>
<td>Assigns a temporary. May change the hermitian matrix
<code>m</code> .</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix &amp;operator = (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the hermitian matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix &amp;operator += (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the hermitian matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix &amp;plus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Adds a matrix expression to the hermitian matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix &amp;operator -= (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the hermitian matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_matrix &amp;minus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Subtracts a matrix expression from the hermitian matrix. Left
and right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
hermitian_matrix &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the hermitian matrix
with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
hermitian_matrix &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the hermitian matrix
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (hermitian_matrix &amp;m)</code></td>
<td>Swaps the contents of the hermitian matrices.</td>
</tr>
<tr>
<td><code>void insert (size_type i, size_type j, const_reference
t)</code></td>
<td>Inserts the value <code>t</code> at the <code>j</code>-th
element of the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void erase (size_type i, size_type j)</code></td>
<td>Erases the value at the <code>j</code>-th elemenst of the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the matrix.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>hermitian_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>hermitian_matrix</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="hermitian_matrix_1" id="hermitian_matrix_1">[1]</a>
Supported parameters for the type of the hermitian matrix are
<code>lower</code> and <code>upper</code>.</p>
<p><a name="hermitian_matrix_2" id="hermitian_matrix_2">[2]</a>
Supported parameters for the storage organization are
<code>row_major</code> and <code>column_major</code>.</p>
<p><a name="hermitian_matrix_3" id="hermitian_matrix_3">[3]</a>
Supported parameters for the adapted array are
<code>unbounded_array&lt;T&gt;</code> ,
<code>bounded_array&lt;T&gt;</code> and
<code>std::vector&lt;T&gt;</code> .</p>
<h2 id="hermitian_adaptor"><a name="hermitian_adaptor" id="hermitian_adaptor"></a>Hermitian Adaptor</h2>
<h4>Description</h4>
<p>The templated class <code>hermitian_adaptor&lt;M, F&gt;</code>
is a hermitian matrix adaptor for other matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/hermitian.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
matrix&lt;std::complex&lt;double&gt; &gt; m (3, 3);
hermitian_adaptor&lt;matrix&lt;std::complex&lt;double&gt; &gt;, lower&gt; hal (m);
for (unsigned i = 0; i &lt; hal.size1 (); ++ i) {
for (unsigned j = 0; j &lt; i; ++ j)
hal (i, j) = std::complex&lt;double&gt; (3 * i + j, 3 * i + j);
hal (i, i) = std::complex&lt;double&gt; (4 * i, 0);
}
std::cout &lt;&lt; hal &lt;&lt; std::endl;
hermitian_adaptor&lt;matrix&lt;std::complex&lt;double&gt; &gt;, upper&gt; hau (m);
for (unsigned i = 0; i &lt; hau.size1 (); ++ i) {
hau (i, i) = std::complex&lt;double&gt; (4 * i, 0);
for (unsigned j = i + 1; j &lt; hau.size2 (); ++ j)
hau (i, j) = std::complex&lt;double&gt; (3 * i + j, 3 * i + j);
}
std::cout &lt;&lt; hau &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header hermitian.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>M</code></td>
<td>The type of the adapted matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F</code></td>
<td>Functor describing the type of the hermitian adaptor. <a href=
"#hermitian_adaptor_1">[1]</a></td>
<td><code>lower</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="expression_concept.htm#matrix_expression">Matrix Expression</a>
.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"expression_concept.htm#matrix_expression">Matrix Expression</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_expression&lt;hermitian_adaptor&lt;M, F&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>hermitian_adaptor (matrix_type &amp;data)</code></td>
<td>Constructs a <code>hermitian_adaptor</code> of a matrix.</td>
</tr>
<tr>
<td><code>hermitian_adaptor (const hermitian_adaptor
&amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>j</code>
-th element in the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>hermitian_adaptor &amp;operator = (const
hermitian_adaptor &amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>hermitian_adaptor &amp;assign_temporary
(hermitian_adaptor &amp;m)</code></td>
<td>Assigns a temporary. May change the hermitian adaptor
<code>m</code>.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor &amp;operator = (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the hermitian adaptor. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor &amp;operator += (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the hermitian adaptor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor &amp;plus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Adds a matrix expression to the hermitian adaptor. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor &amp;operator -= (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the hermitian adaptor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
hermitian_adaptor &amp;minus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Subtracts a matrix expression from the hermitian adaptor. Left
and right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
hermitian_adaptor &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the hermitian
adaptor with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
hermitian_adaptor &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the hermitian adaptor
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (hermitian_adaptor &amp;m)</code></td>
<td>Swaps the contents of the hermitian adaptors.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>hermitian_adaptor</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>hermitian_adaptor</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="hermitian_adaptor_1" id="hermitian_adaptor_1">[1]</a>
Supported parameters for the type of the hermitian adaptor are
<code>lower</code> and <code>upper</code>.</p>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,415 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<!-- tidy options: -w 120 -asxhtml -clean - - vertical-space yes -f index.htm.err -m index.htm -->
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Boost Basic Linear Algebra</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" alt="logo"/> Basic Linear Algebra</h1>
<div class="toc" id="toc"></div>
<p>uBLAS is a C++ template class library that provides <a href="http://www.netlib.org/blas">BLAS</a> 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.</p>
<h2>Functionality</h2>
<p>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 constructed via ranges or slices and
adaptor classes. The library covers the usual basic linear algebra operations on vectors and matrices: reductions like
different norms, addition and subtraction of vectors and matrices and multiplication with a scalar, inner and outer
products of vectors, matrix vector and matrix matrix products and triangular solver. The glue between containers, views
and expression templated operations is a mostly <a href="http://www.sgi.com/tech/stl">STL</a> conforming iterator
interface.</p>
<p>Please consult the <a href="release_notes.htm">release notes</a> for details on the latest changes.</p>
<h2>Documentation</h2>
<ul>
<li><big><a href="overview.htm">Overview</a></big>
<ul>
<li><a href="overview.htm#rationale">Rationale</a>
</li>
<li><a href="overview.htm#functionality">Functionality</a>
</li>
<li><a href="types_overview.htm">Overview of Matrix- and Vector-Types</a>
</li>
<li><a href="operations_overview.htm">Overview of Matrix and Vector Operations</a>
</li>
<li><a href="#further_information">Effective uBLAS and further information</a>
</li>
<li><a href="options.htm">Macros and Preprocessor Options</a>
</li>
</ul>
</li>
<li><a href="vector.htm">Vector</a>
<ul>
<li><a href="vector.htm#vector">Vector</a>
</li>
<li><a href="vector.htm#unit_vector">Unit Vector</a>
</li>
<li><a href="vector.htm#zero_vector">Zero Vector</a>
</li>
<li><a href="vector.htm#scalar_vector">Scalar Vector</a>
</li>
</ul>
</li>
<li><a href="vector_sparse.htm">Sparse Vector</a>
<ul>
<li><a href="vector_sparse.htm#mapped_vector">Mapped Vector</a>
</li>
<li><a href="vector_sparse.htm#compressed_vector">Compressed Vector</a>
</li>
<li><a href="vector_sparse.htm#coordinate_vector">Coordinate Vector</a>
</li>
</ul>
</li>
<li><a href="vector_proxy.htm">Vector Proxies</a>
<ul>
<li><a href="vector_proxy.htm#vector_range">Vector Range</a>
</li>
<li><a href="vector_proxy.htm#vector_slice">Vector Slice</a>
</li>
</ul>
</li>
<li><a href="vector_expression.htm">Vector Expressions</a>
<ul>
<li><a href="vector_expression.htm#vector_expression">Vector Expression</a>
</li>
<li><a href="vector_expression.htm#vector_references">Vector References</a>
</li>
<li><a href="vector_expression.htm#vector_operations">Vector Operations</a>
</li>
<li><a href="vector_expression.htm#vector_reductions">Vector Reductions</a>
</li>
</ul>
</li>
<li><a href="matrix.htm">Matrix</a>
<ul>
<li><a href="matrix.htm#matrix">Matrix</a>
</li>
<li><a href="matrix.htm#identity_matrix">Identity Matrix</a>
</li>
<li><a href="matrix.htm#zero_matrix">Zero Matrix</a>
</li>
<li><a href="matrix.htm#scalar_matrix">Scalar Matrix</a>
</li>
</ul>
</li>
<li><a href="triangular.htm">Triangular Matrix</a>
<ul>
<li><a href="triangular.htm#triangular_matrix">Triangular Matrix</a>
</li>
<li><a href="triangular.htm#triangular_adaptor">Triangular Adaptor</a>
</li>
</ul>
</li>
<li><a href="symmetric.htm">Symmetric Matrix</a>
<ul>
<li><a href="symmetric.htm#symmetric_matrix">Symmetric Matrix</a>
</li>
<li><a href="symmetric.htm#symmetric_adaptor">Symmetric Adaptor</a>
</li>
</ul>
</li>
<li><a href="hermitian.htm">Hermitian Matrix</a>
<ul>
<li><a href="hermitian.htm#hermitian_matrix">Hermitian Matrix</a>
</li>
<li><a href="hermitian.htm#hermitian_adaptor">Hermitian Adaptor</a>
</li>
</ul>
</li>
<li><a href="banded.htm">Banded Matrix</a>
<ul>
<li><a href="banded.htm#banded_matrix">Banded Matrix</a>
</li>
<li><a href="banded.htm#banded_adaptor">Banded Adaptor</a>
</li>
</ul>
</li>
<li><a href="matrix_sparse.htm">Sparse Matrix</a>
<ul>
<li><a href="matrix_sparse.htm#mapped_matrix">Mapped Matrix</a>
</li>
<li><a href="matrix_sparse.htm#compressed_matrix">Compressed Matrix</a>
</li>
<li><a href="matrix_sparse.htm#coordinate_matrix">Coordinate Matrix</a>
</li>
</ul>
</li>
<li><a href="matrix_proxy.htm">Matrix Proxies</a>
<ul>
<li><a href="matrix_proxy.htm#matrix_row">Matrix Row</a>
</li>
<li><a href="matrix_proxy.htm#matrix_column">Matrix Column</a>
</li>
<li><a href="matrix_proxy.htm#vector_range">Vector Range</a>
</li>
<li><a href="matrix_proxy.htm#vector_slice">Vector Slice</a>
</li>
<li><a href="matrix_proxy.htm#matrix_range">Matrix Range</a>
</li>
<li><a href="matrix_proxy.htm#matrix_slice">Matrix Slice</a>
</li>
</ul>
</li>
<li><a href="matrix_expression.htm">Matrix Expressions</a>
<ul>
<li><a href="matrix_expression.htm#matrix_expression">Matrix Expression</a>
</li>
<li><a href="matrix_expression.htm#matrix_references">Matrix References</a>
</li>
<li><a href="matrix_expression.htm#matrix_operations">Matrix Operations</a>
</li>
<li><a href="matrix_expression.htm#matrix_vector_operations">Matrix Vector Operations</a>
</li>
<li><a href="matrix_expression.htm#matrix_matrix_operations">Matrix Matrix Operations</a>
</li>
</ul>
</li>
<li>Storage and special containers
<ul>
<li><a href="unbounded_array.htm">Unbounded Array</a>
</li>
<li><a href="bounded_array.htm">Bounded Array</a>
</li>
<li><a href="range.htm#range">Range</a>
</li>
<li><a href="range.htm#slice">Slice</a>
</li>
</ul></li>
<li><a href="storage_sparse.htm">Sparse Storage</a>
<ul>
<li><a href="storage_sparse.htm#map_std">Default Standard Map</a>
</li>
<li><a href="storage_sparse.htm#map_array">Map Array</a>
</li>
</ul>
</li>
<li>Operations &amp; Functions
<ul>
<li><a href="products.htm">Special Products</a>
</li>
<li><a href="blas.htm">BLAS</a>
</li>
</ul></li>
<li>uBLAS Concept definitions
<ul>
<li><a href="container_concept.htm">Container Concepts</a>
<ul>
<li><a href="container_concept.htm#vector">Vector</a>
</li>
<li><a href="container_concept.htm#matrix">Matrix</a>
</li>
</ul>
</li>
<li><a href="expression_concept.htm">Expression Concepts</a>
<ul>
<li><a href="expression_concept.htm#scalar_expression">Scalar Expression</a>
</li>
<li><a href="expression_concept.htm#vector_expression">Vector Expression</a>
</li>
<li><a href="expression_concept.htm#matrix_expression">Matrix Expression</a>
</li>
</ul>
</li>
<li><a href="storage_concept.htm">Storage Concept</a>
</li>
<li><a href="iterator_concept.htm">Iterator Concepts</a>
<ul>
<li><a href="iterator_concept.htm#indexed_bidirectional_iterator">Indexed Bidirectional Iterator</a>
</li>
<li><a href="iterator_concept.htm#indexed_random_access_iterator">Indexed Random Access Iterator</a>
</li>
<li><a href="iterator_concept.htm#indexed_bidirectional_cr_iterator">Indexed Bidirectional Column/Row Iterator</a>
</li>
<li><a href="iterator_concept.htm#indexed_random_access_cr_iterator">Indexed Random Access Column/Row Iterator</a>
</li>
</ul>
</li>
</ul></li>
</ul>
<h2>Supported Platforms</h2>
<p>The current version of uBLAS expects a modern (ISO standard compliant) compiler. Compilers targeted and tested with
this release are:</p>
<ul>
<li>GCC 3.2.3, 3.3.x, 3.4.x, 4.0.x</li>
<li>MSVC 7.1, 8.0</li>
<li>ICC 8.0, 8.1</li>
<li>Visual age 6</li>
<li>Codewarrior 9.4, 9.5</li>
</ul>
<p>The version of uBLAS in Boost 1.32.0 (and earlier) support many older compilers. If you are using such a compiler
please use this version of uBLAS. Compilers known to accept this older library are:</p>
<ul>
<li>MSVC 6.0 with STLPort-4.5.3, 7.0, 7.1</li>
<li>GCC 2.95.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x</li>
<li>ICC 7.0, 7.1 8.0</li>
<li>Comeau 4.2.x</li>
<li>Codewarrior 8.3</li>
</ul>
<p>For possible problems please consider to consult the Boost regression tests.</p>
<a name="further_information" id="further_information"></a>
<h2>Known limitations:</h2>
<ul type="disc">
<li>The implementation assumes a linear memory address model.</li>
<li>Tuning was focussed on dense matrices.</li>
</ul>
<h2>Further Information</h2>
<h3>Project Location and Download</h3>
<p>The latest stable release of uBLAS is part of the <a href="http://www.boost.org">Boost</a> libraries.</p>
<h3>Documentation and Discussion</h3>
<p>Visit the <a href="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS">Effective
uBLAS</a> wiki for up to date information and contributions.</p>
<p>There is also an active uBLAS <a href="http://lists.boost.org/">mailing list</a> where uBLAS specific user and
development questions are answered.</p>
<h3>uBLAS and Boost Project</h3>
<p>There is also an active uBLAS <a href="http://lists.boost.org/">mailing list</a> where uBLAS specific from the
latest uBLAS project code. You can <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/boost">view</a> the Boost
CVS archive directly. You will find the library <a href=
"http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/boost/boost/boost/numeric/ublas/">here</a>. Documentation and test
programs reside <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/boost/boost/libs/numeric/ublas/">here</a>.</p>
<h2>Authors and Credits</h2>
<p>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 <a href=
"http://www.boost.org">Boost</a></p>
<h2>Frequently Asked Questions</h2>
<p>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?<br />
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 <code>NDEBUG</code> of <code>cassert</code> is defined. <code>NDEBUG</code> enables release mode, which in turn
uses expression templates. You can optionally define <code>BOOST_UBLAS_NDEBUG</code> to disable all bounds, structure
and similar checks of uBLAS.</p>
<p>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?<br />
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 <code>NDEBUG</code> of <code>cassert</code> is defined. <code>NDEBUG</code> disables debug mode, which is needed
to get size and type conformance checks.</p>
<p>Q: I've written some uBLAS benchmarks to measure the performance of matrix chain multiplications like <code>prod (A,
prod (B, C))</code> and see a significant performance penalty due to the use of expression templates. How can I disable
expression templates?<br />
A: You do not need to disable expression templates. Please try reintroducing temporaries using either <code>prod
(A,</code> <code><em>matrix_type</em></code> <code>(prod (B, C)))</code> or <code>prod (A,
prod&lt;</code><code><em>matrix_type</em></code> <code>&gt; (B, C))</code>.</p>
<hr />
<p>Copyright (&copy;) 2000-2009 Joerg Walter, Mathias Koch, Gunter Winkler<br />
Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>
).</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,22 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org" />
<meta http-equiv="refresh" content="0;URL=index.htm" />
<title>index.html not found</title>
</head>
<body>
<p>Please update your bookmarks to point to <a href="index.htm">index.htm</a>. You will be redirected in a second.</p>
<p>
Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
Joerg Walter, Gunter Winkler<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,166 +0,0 @@
/*!
* jQuery TOC Plugin v1.1.x based on
* samaxesJS JavaScript Library
* http://code.google.com/p/samaxesjs/
*
* Copyright (c) 2008 samaxes.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* 2009-10-04, guwi17: modified and extended to meet uBLAS' needs
*/
(function($) {
/*
* The TOC plugin dynamically builds a table of contents from the headings in
* a document and prepends legal-style section numbers to each of the headings.
*/
$.fn.toc = function(options) {
var opts = $.extend({}, $.fn.toc.defaults, options);
return this.each(function() {
var toc = $(this).append('<ul></ul>').children('ul');
var headers = {h1: 0, h2: 0, h3: 0, h4: 0, h5: 0, h6: 0};
var index = 0;
var indexes = {
h1: (opts.exclude.match('h1') == null && $('h1').length > 0) ? ++index : 0,
h2: (opts.exclude.match('h2') == null && $('h2').length > 0) ? ++index : 0,
h3: (opts.exclude.match('h3') == null && $('h3').length > 0) ? ++index : 0,
h4: (opts.exclude.match('h4') == null && $('h4').length > 0) ? ++index : 0,
h5: (opts.exclude.match('h5') == null && $('h5').length > 0) ? ++index : 0,
h6: (opts.exclude.match('h6') == null && $('h6').length > 0) ? ++index : 0
};
$(':header').not(opts.exclude).each(function() {
var linkId = "";
if ($(this).is('h6')) {
checkContainer(headers.h6, toc);
updateNumeration(headers, 'h6');
$(this).text(addNumeration(headers, 'h6', $(this).text()));
linkId = fixAnchor($(this));
appendToTOC(toc, indexes.h6, linkId, $(this).text(), headers);
} else if ($(this).is('h5')) {
checkContainer(headers.h5, toc);
updateNumeration(headers, 'h5');
$(this).text(addNumeration(headers, 'h5', $(this).text()));
linkId = fixAnchor($(this));
appendToTOC(toc, indexes.h5, linkId, $(this).text(), headers);
} else if ($(this).is('h4')) {
checkContainer(headers.h4, toc);
updateNumeration(headers, 'h4');
$(this).text(addNumeration(headers, 'h4', $(this).text()));
linkId = fixAnchor($(this));
appendToTOC(toc, indexes.h4, linkId, $(this).text(), headers);
} else if ($(this).is('h3')) {
checkContainer(headers.h3, toc);
updateNumeration(headers, 'h3');
$(this).text(addNumeration(headers, 'h3', $(this).text()));
linkId = fixAnchor($(this));
appendToTOC(toc, indexes.h3, linkId, $(this).text(), headers);
} else if ($(this).is('h2')) {
checkContainer(headers.h2, toc);
updateNumeration(headers, 'h2');
$(this).text(addNumeration(headers, 'h2', $(this).text()));
linkId = fixAnchor($(this));
appendToTOC(toc, indexes.h2, linkId, $(this).text(), headers);
} else if ($(this).is('h1')) {
updateNumeration(headers, 'h1');
$(this).text(addNumeration(headers, 'h1', $(this).text()));
linkId = fixAnchor($(this));
appendToTOC(toc, indexes.h1, linkId, $(this).text(), headers);
}
});
});
};
/*
* Checks if the last node is an 'ul' element.
* If not, a new one is created.
*/
function checkContainer(header, toc) {
if (header == 0 && !toc.find(':last').is('ul')) {
toc.find('li:last').append('<ul></ul>');
}
};
/*
* Updates headers numeration.
*/
function updateNumeration(headers, header) {
$.each(headers, function(i, val) {
if (i == header) {
++headers[i];
} else if (i > header) {
headers[i] = 0;
}
});
};
/*
* Prepends the numeration to a heading.
*/
function addNumeration(headers, header, text) {
var numeration = '';
$.each(headers, function(i, val) {
if (i <= header && headers[i] > 0) {
numeration += headers[i] + '.';
}
});
return removeFinalDot(numeration) + ' ' + text;
};
function removeFinalDot(text) {
return (text||"").replace(/\.$/g, "" )
}
function fixAnchor(element) {
// use existing id by default
var linkId = element.attr('id');
// next, look for an anchor and use its id or name
if ( !linkId ) {
element.find('> a:first').each( function() {
linkId = $(this).attr('id') || $(this).attr('name');
});
}
// next, use the text content as last resort
if ( !linkId ) {
linkId = (element.text()||"unknown").replace(/[^a-zA-Z0-9]/g,"");
}
element.attr('id',linkId);
return linkId;
}
/*
* Appends a new node to the TOC.
*/
function appendToTOC(toc, index, id, text, headers) {
var parent = toc;
for (var i = 1; i < index; i++) {
if (parent.find('> li:last > ul').length == 0) {
parent = parent.append('<li><ul></ul></li>');
}
parent = parent.find('> li:last > ul');
}
if (id) {
parent.append('<li><a href="#' + id + '">' + text + '</a></li>');
} else {
parent.append('<li>' + text + '</li>');
}
};
$.fn.toc.defaults = {exclude: 'h1, h5, h6'}
})(jQuery);

View File

@@ -1,768 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Matrix</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Matrix</h1>
<div class="toc" id="toc"></div>
<h2 id="matrix"><a name="matrix" id="matrix"></a>Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>matrix&lt;T, F, A&gt;</code> is the
base container adaptor for dense matrices. For a <em>(m x
n</em>)-dimensional matrix and <em>0 &lt;= i &lt; m</em>, <em>0
&lt;= j &lt; n</em> every element <em>m</em><sub><em>i,
j</em></sub> is mapped to the <em>(i x n + j)-</em>th element of
the container for row major orientation or the <em>(i + j x
m)-</em>th element of the container for column major
orientation.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
matrix&lt;double&gt; m (3, 3);
for (unsigned i = 0; i &lt; m.size1 (); ++ i)
for (unsigned j = 0; j &lt; m.size2 (); ++ j)
m (i, j) = 3 * i + j;
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F</code></td>
<td>Functor describing the storage organization. <a href=
"#matrix_1">[1]</a></td>
<td><code>row_major</code></td>
</tr>
<tr>
<td><code>A</code></td>
<td>The type of the <a href="storage_concept.htm">Storage</a> array. <a href="#matrix_2">[2]</a></td>
<td><code>unbounded_array&lt;T&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;matrix&lt;T, F, A&gt; &gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>matrix ()</code></td>
<td>Allocates an uninitialized <code>matrix</code> that holds zero
rows of zero elements.</td>
</tr>
<tr>
<td><code>matrix (size_type size1, size_type size2)</code></td>
<td>Allocates an uninitialized <code>matrix</code> that holds
<code>size1</code> rows of <code>size2</code> elements.</td>
</tr>
<tr>
<td><code>matrix (const matrix &amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix (const matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, bool
preserve = true)</code></td>
<td>Reallocates a <code>matrix</code> to hold <code>size1</code>
rows of <code>size2</code> elements. The existing elements of the
<code>matrix</code> are preseved when specified.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const array_type&amp; data () const</code></td>
<td></td>
</tr>
<tr>
<td><code>array_type&amp; data ()</code></td>
<td></td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>j</code>
-th element in the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>matrix &amp;operator = (const matrix &amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>matrix &amp;assign_temporary (matrix &amp;m)</code></td>
<td>Assigns a temporary. May change the matrix <code>m</code>.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix &amp;operator = (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the matrix. Left and right hand
side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix &amp;operator += (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix &amp;plus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Adds a matrix expression to the matrix. Left and right hand
side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix &amp;operator -= (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
matrix &amp;minus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Subtracts a matrix expression from the matrix. Left and right
hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
matrix &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the matrix with a
scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
matrix &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the matrix through a
scalar.</td>
</tr>
<tr>
<td><code>void swap (matrix &amp;m)</code></td>
<td>Swaps the contents of the matrices.</td>
</tr>
<tr>
<td><code>void insert_element (size_type i, size_type j, const_reference
t)</code></td>
<td>Inserts the value <code>t</code> at the <code>j</code>-th
element of the <code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void erase_element (size_type i, size_type j)</code></td>
<td>Erases the value at the <code>j</code>-th element of the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the matrix.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>matrix</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="matrix_1" id="matrix_1">[1]</a> Supported parameters
for the storage organization are <code>row_major</code> and
<code>column_major</code>.</p>
<p><a name="matrix_2" id="matrix_2">[2]</a> Common parameters
for the storage array are <code>unbounded_array&lt;T&gt;</code> ,
<code>bounded_array&lt;T&gt;</code> and
<code>std::vector&lt;T&gt;</code> .</p>
<h2 id="identity_matrix"><a name="identity_matrix" id="identity_matrix"></a>Identity Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>identity_matrix&lt;T, ALLOC&gt;</code>
represents identity matrices. For a <em>(m x n</em>)-dimensional
identity matrix and <em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt;
n</em> holds <em>id</em><sub><em>i, j</em></sub> <em>= 0</em>, if
<em>i &lt;&gt; j</em>, and <em>id</em><sub><em>i, i</em></sub><em>=
1</em>.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
identity_matrix&lt;double&gt; m (3);
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the matrix.</td>
<td><code>int</code></td>
</tr>
<tr>
<td><code>ALLOC</code></td>
<td>An STL Allocator for size_type and difference_type.</td>
<td>std::allocator</td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of
<a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;identity_matrix&lt;T&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>identity_matrix ()</code></td>
<td>Constructs an <code>identity_matrix</code> that holds zero rows
of zero elements.</td>
</tr>
<tr>
<td><code>identity_matrix (size_type size)</code></td>
<td>Constructs an <code>identity_matrix</code> that holds
<code>size</code> rows of <code>size</code> elements.</td>
</tr>
<tr>
<td><code>identity_matrix (const identity_matrix
&amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size, bool preserve =
true)</code></td>
<td>Resizes a <code>identity_matrix</code> to hold
<code>size</code> rows of <code>size</code> elements. Therefore the
existing elements of the <code>itendity_matrix</code> are always
preseved.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns the value of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>identity_matrix &amp;operator = (const identity_matrix
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>identity_matrix &amp;assign_temporary (identity_matrix
&amp;m)</code></td>
<td>Assigns a temporary. May change the identity matrix
<code>m</code> .</td>
</tr>
<tr>
<td><code>void swap (identity_matrix &amp;m)</code></td>
<td>Swaps the contents of the identity matrices.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>identity_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>identity_matrix</code>.</td>
</tr>
</tbody>
</table>
<h2 id="zero_matrix"><a name="zero_matrix" id="zero_matrix"></a>Zero Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>zero_matrix&lt;T, ALLOC&gt;</code> represents
zero matrices. For a <em>(m x n</em>)-dimensional zero matrix and
<em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt; n</em> holds
<em>z</em><sub><em>i, j</em></sub> <em>= 0</em>.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
zero_matrix&lt;double&gt; m (3, 3);
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the matrix.</td>
<td><code>int</code></td>
</tr>
<tr>
<td><code>ALLOC</code></td>
<td>An STL Allocator for size_type and difference_type.</td>
<td>std::allocator</td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of
<a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;zero_matrix&lt;T&gt; &gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>zero_matrix ()</code></td>
<td>Constructs a <code>zero_matrix</code> that holds zero rows of
zero elements.</td>
</tr>
<tr>
<td><code>zero_matrix (size_type size1, size_type
size2)</code></td>
<td>Constructs a <code>zero_matrix</code> that holds
<code>size1</code> rows of <code>size2</code> elements.</td>
</tr>
<tr>
<td><code>zero_matrix (const zero_matrix &amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, bool
preserve = true)</code></td>
<td>Resizes a <code>zero_matrix</code> to hold <code>size1</code>
rows of <code>size2</code> elements. Therefore the existing
elements of the <code>zero_matrix</code> are always preseved.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns the value of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>zero_matrix &amp;operator = (const zero_matrix
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>zero_matrix &amp;assign_temporary (zero_matrix
&amp;m)</code></td>
<td>Assigns a temporary. May change the zero matrix <code>m</code>
.</td>
</tr>
<tr>
<td><code>void swap (zero_matrix &amp;m)</code></td>
<td>Swaps the contents of the zero matrices.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>zero_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>zero_matrix</code>.</td>
</tr>
</tbody>
</table>
<h2 id="scalar_matrix"><a name="scalar_matrix" id="scalar_matrix"></a>Scalar Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>scalar_matrix&lt;T, ALLOC&gt;</code>
represents scalar matrices. For a <em>(m x n</em>)-dimensional
scalar matrix and <em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt;
n</em> holds <em>z</em><sub><em>i, j</em></sub> <em>= s</em>.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
scalar_matrix&lt;double&gt; m (3, 3);
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the matrix.</td>
<td><code>int</code></td>
</tr>
<tr>
<td><code>ALLOC</code></td>
<td>An STL Allocator for size_type and difference_type.</td>
<td>std::allocator</td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of
<a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;scalar_matrix&lt;T&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>scalar_matrix ()</code></td>
<td>Constructs a <code>scalar_matrix</code> that holds scalar rows
of zero elements.</td>
</tr>
<tr>
<td><code>scalar_matrix (size_type size1, size_type size2, const
value_type &amp;value)</code></td>
<td>Constructs a <code>scalar_matrix</code> that holds
<code>size1</code> rows of <code>size2</code> elements each of the
specified value.</td>
</tr>
<tr>
<td><code>scalar_matrix (const scalar_matrix &amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, bool
preserve = true)</code></td>
<td>Resizes a <code>scalar_matrix</code> to hold <code>size1</code>
rows of <code>size2</code> elements. Therefore the existing
elements of the <code>scalar_matrix</code> are always
preseved.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns the value of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>scalar_matrix &amp;operator = (const scalar_matrix
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>scalar_matrix &amp;assign_temporary (scalar_matrix
&amp;m)</code></td>
<td>Assigns a temporary. May change the scalar matrix
<code>m</code> .</td>
</tr>
<tr>
<td><code>void swap (scalar_matrix &amp;m)</code></td>
<td>Swaps the contents of the scalar matrices.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>scalar_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>scalar_matrix</code>.</td>
</tr>
</tbody>
</table>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,983 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Sparse Matrix</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Sparse Matricies</h1>
<div class="toc" id="toc"></div>
<h2 id="mapped_matrix"><a name="mapped_matrix" id="mapped_matrix"></a>Mapped Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>mapped_matrix&lt;T, F, A&gt;</code> is
the base container adaptor for sparse matricies using element maps.
For a <em>(m xn</em>)-dimensional sparse matrix and <em>0 &lt;= i &lt; m</em>,
<em>0 &lt;= j &lt; n</em> the non-zero elements
<em>m</em><sub><em>i, j</em></sub> are mapped via <em>(i x n +
j)</em> for row major orientation or via <em>(i + j x m)</em> for
column major orientation to consecutive elements of the associative
container, i.e. for elements <em>k</em> =
<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub>
<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 =
m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em>
,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds
<em>i</em><sub><em>1</em></sub> <em>&lt;
i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub>
<em>= i</em><sub><em>2</em></sub> and
<em>j</em><sub><em>1</em></sub> <em>&lt;
j</em><sub><em>2</em></sub><em>)</em> with row major orientation or
<em>j</em><sub><em>1</em></sub> <em>&lt;
j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub>
<em>= j</em><sub><em>2</em></sub> and
<em>i</em><sub><em>1</em></sub> <em>&lt;
i</em><sub><em>2</em></sub><em>)</em> with column major
orientation.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
mapped_matrix&lt;double&gt; m (3, 3, 3 * 3);
for (unsigned i = 0; i &lt; m.size1 (); ++ i)
for (unsigned j = 0; j &lt; m.size2 (); ++ j)
m (i, j) = 3 * i + j;
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix_sparse.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the mapped matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F</code></td>
<td>Functor describing the storage organization. <a href=
"#mapped_matrix_1">[1]</a></td>
<td><code>row_major</code></td>
</tr>
<tr>
<td><code>A</code></td>
<td>The type of the adapted array. <a href=
"#mapped_matrix_2">[2]</a></td>
<td><code>map_std&lt;std::size_t, T&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;mapped_matrix&lt;T, F, A&gt;
&gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>mapped_matrix ()</code></td>
<td>Allocates a <code>mapped_matrix</code> that holds at most zero
rows of zero elements.</td>
</tr>
<tr>
<td><code>mapped_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td>
<td>Allocates a <code>mapped_matrix</code> that holds at most
<code>size1</code> rows of <code>size2</code> elements.</td>
</tr>
<tr>
<td><code>mapped_matrix (const mapped_matrix &amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix (size_type non_zeros, const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td>
<td>Reallocates a <code>mapped_matrix</code> to hold at most
<code>size1</code> rows of <code>size2</code> elements. The
existing elements of the <code>mapped_matrix</code> are preseved
when specified.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns the value of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>mapped_matrix &amp;operator = (const mapped_matrix
&amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>mapped_matrix &amp;assign_temporary (mapped_matrix
&amp;m)</code></td>
<td>Assigns a temporary. May change the mapped matrix
<code>m</code> .</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix &amp;operator = (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the mapped matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix &amp;operator += (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the mapped matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix &amp;plus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Adds a matrix expression to the mapped matrix. Left and right
hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix &amp;operator -= (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the mapped matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
mapped_matrix &amp;minus_assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Subtracts a matrix expression from the mapped matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
mapped_matrix &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the mapped matrix
with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
mapped_matrix &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the mapped matrix
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (mapped_matrix &amp;m)</code></td>
<td>Swaps the contents of the mapped matrices.</td>
</tr>
<tr>
<td><code>true_refrence insert_element (size_type i, size_type j, const_reference
t)</code></td>
<td>Inserts the value <code>t</code> at the <code>j</code>-th
element of the <code>i</code>-th row. Duplicates elements are not allowed.</td>
</tr>
<tr>
<td><code>void erase_element (size_type i, size_type j)</code></td>
<td>Erases the value at the <code>j</code>-th element of the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the mapped matrix.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>mapped_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>mapped_matrix</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="mapped_matrix_1" id="mapped_matrix_1">[1]</a> Supported
parameters for the storage organization are <code>row_major</code>
and <code>column_major</code>.</p>
<p><a name="mapped_matrix_2" id="mapped_matrix_2">[2]</a> Supported
parameters for the adapted array are
<code>map_array&lt;std::size_t, T&gt;</code> and
<code>map_std&lt;std::size_t, T&gt;</code>. The latter is
equivalent to <code>std::map&lt;std::size_t, T&gt;</code>.</p>
<h2 id="compressed_matrix"><a name="compressed_matrix" id="compressed_matrix"></a>Compressed Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>compressed_matrix&lt;T, F, IB, IA,
TA&gt;</code> is the base container adaptor for compressed
matrices. For a <em>(m x n</em> )-dimensional compressed matrix and
<em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt; n</em> the non-zero
elements <em>m</em><sub><em>i, j</em></sub> are mapped via <em>(i x
n + j)</em> for row major orientation or via <em>(i + j x m)</em>
for column major orientation to consecutive elements of the index
and value containers, i.e. for elements <em>k</em> =
<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub>
<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 =
m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em>
,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds
<em>i</em><sub><em>1</em></sub> <em>&lt;
i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub>
<em>= i</em><sub><em>2</em></sub> and
<em>j</em><sub><em>1</em></sub> <em>&lt;
j</em><sub><em>2</em></sub><em>)</em> with row major orientation or
<em>j</em><sub><em>1</em></sub> <em>&lt;
j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub>
<em>= j</em><sub><em>2</em></sub> and
<em>i</em><sub><em>1</em></sub> <em>&lt;
i</em><sub><em>2</em></sub><em>)</em> with column major
orientation.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
compressed_matrix&lt;double&gt; m (3, 3, 3 * 3);
for (unsigned i = 0; i &lt; m.size1 (); ++ i)
for (unsigned j = 0; j &lt; m.size2 (); ++ j)
m (i, j) = 3 * i + j;
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix_sparse.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the compressed matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F</code></td>
<td>Functor describing the storage organization. <a href=
"#compressed_matrix_1">[1]</a></td>
<td><code>row_major</code></td>
</tr>
<tr>
<td><code>IB</code></td>
<td>The index base of the compressed vector. <a href=
"#compressed_matrix_2">[2]</a></td>
<td><code>0</code></td>
</tr>
<tr>
<td><code>IA</code></td>
<td>The type of the adapted array for indices. <a href=
"#compressed_matrix_3">[3]</a></td>
<td><code>unbounded_array&lt;std::size_t&gt;</code></td>
</tr>
<tr>
<td><code>TA</code></td>
<td>The type of the adapted array for values. <a href=
"#compressed_matrix_3">[3]</a></td>
<td><code>unbounded_array&lt;T&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;compressed_matrix&lt;T, F, IB, IA,
TA&gt; &gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>compressed_matrix ()</code></td>
<td>Allocates a <code>compressed_matrix</code> that holds at most
zero rows of zero elements.</td>
</tr>
<tr>
<td><code>compressed_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td>
<td>Allocates a <code>compressed_matrix</code> that holds at most
<code>size1</code> rows of <code>size2</code> elements.</td>
</tr>
<tr>
<td><code>compressed_matrix (const compressed_matrix
&amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix (size_type non_zeros, const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td>
<td>Reallocates a <code>compressed_matrix</code> to hold at most
<code>size1</code> rows of <code>size2</code> elements. The
existing elements of the <code>compressed_matrix</code> are
preseved when specified.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns the value of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>compressed_matrix &amp;operator = (const
compressed_matrix &amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>compressed_matrix &amp;assign_temporary
(compressed_matrix &amp;m)</code></td>
<td>Assigns a temporary. May change the compressed matrix
<code>m</code>.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix &amp;operator = (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the compressed matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix &amp;operator += (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the compressed matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix &amp;plus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Adds a matrix expression to the compressed matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix &amp;operator -= (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the compressed matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
compressed_matrix &amp;minus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Subtracts a matrix expression from the compressed matrix. Left
and right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
compressed_matrix &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the compressed
matrix with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
compressed_matrix &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the compressed matrix
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (compressed_matrix &amp;m)</code></td>
<td>Swaps the contents of the compressed matrices.</td>
</tr>
<tr>
<td><code>true_reference insert_element (size_type i, size_type j, const_reference
t)</code></td>
<td>Inserts the value <code>t</code> at the <code>j</code>-th
element of the <code>i</code>-th row. Duplicates elements are not allowed.</td>
</tr>
<tr>
<td><code>void erase_element (size_type i, size_type j)</code></td>
<td>Erases the value at the <code>j</code>-th element of the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the compressed matrix.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>compressed_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>compressed_matrix</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="compressed_matrix_1" id="compressed_matrix_1">[1]</a>
Supported parameters for the storage organization are
<code>row_major</code> and <code>column_major</code>.</p>
<p><a name="compressed_matrix_2" id="compressed_matrix_2">[2]</a>
Supported parameters for the index base are <code>0</code> and
<code>1</code> at least.</p>
<p><a name="compressed_matrix_3" id="compressed_matrix_3">[3]</a>
Supported parameters for the adapted array are
<code>unbounded_array&lt;&gt;</code> ,
<code>bounded_array&lt;&gt;</code> and
<code>std::vector&lt;&gt;</code> .</p>
<h2 id="coordinate_matrix"><a name="coordinate_matrix" id="coordinate_matrix"></a>Coordinate Matrix</h2>
<h4>Description</h4>
<p>The templated class <code>coordinate_matrix&lt;T, F, IB, IA,
TA&gt;</code> is the base container adaptor for compressed
matrices. For a <em>(m x n</em> )-dimensional sorted coordinate
matrix and <em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt; n</em> the
non-zero elements <em>m</em><sub><em>i, j</em></sub> are mapped via
<em>(i x n + j)</em> for row major orientation or via <em>(i + j x
m)</em> for column major orientation to consecutive elements of the
index and value containers, i.e. for elements <em>k</em> =
<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub>
<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 =
m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em>
,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds
<em>i</em><sub><em>1</em></sub> <em>&lt;
i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub>
<em>= i</em><sub><em>2</em></sub> and
<em>j</em><sub><em>1</em></sub> <em>&lt;
j</em><sub><em>2</em></sub><em>)</em> with row major orientation or
<em>j</em><sub><em>1</em></sub> <em>&lt;
j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub>
<em>= j</em><sub><em>2</em></sub> and
<em>i</em><sub><em>1</em></sub> <em>&lt;
i</em><sub><em>2</em></sub><em>)</em> with column major
orientation.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
coordinate_matrix&lt;double&gt; m (3, 3, 3 * 3);
for (unsigned i = 0; i &lt; m.size1 (); ++ i)
for (unsigned j = 0; j &lt; m.size2 (); ++ j)
m (i, j) = 3 * i + j;
std::cout &lt;&lt; m &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header matrix_sparse.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the coordinate matrix.</td>
<td></td>
</tr>
<tr>
<td><code>F</code></td>
<td>Functor describing the storage organization. <a href=
"#coordinate_matrix_1">[1]</a></td>
<td><code>row_major</code></td>
</tr>
<tr>
<td><code>IB</code></td>
<td>The index base of the coordinate vector. <a href=
"#coordinate_matrix_2">[2]</a></td>
<td><code>0</code></td>
</tr>
<tr>
<td><code>IA</code></td>
<td>The type of the adapted array for indices. <a href=
"#coordinate_matrix_3">[3]</a></td>
<td><code>unbounded_array&lt;std::size_t&gt;</code></td>
</tr>
<tr>
<td><code>TA</code></td>
<td>The type of the adapted array for values. <a href=
"#coordinate_matrix_3">[3]</a></td>
<td><code>unbounded_array&lt;T&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"container_concept.htm#matrix">Matrix</a> .</p>
<h4>Public base classes</h4>
<p><code>matrix_container&lt;coordinate_matrix&lt;T, F, IB, IA,
TA&gt; &gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>coordinate_matrix ()</code></td>
<td>Allocates a <code>coordinate_matrix</code> that holds at most
zero rows of zero elements.</td>
</tr>
<tr>
<td><code>coordinate_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td>
<td>Allocates a <code>coordinate_matrix</code> that holds at most
<code>size1</code> rows of <code>size2</code> elements.</td>
</tr>
<tr>
<td><code>coordinate_matrix (const coordinate_matrix
&amp;m)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix (size_type non_zeros, const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended copy constructor.</td>
</tr>
<tr>
<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td>
<td>Reallocates a <code>coordinate_matrix</code> to hold at most
<code>size1</code> rows of <code>size2</code> elements. The
existing elements of the <code>coordinate_matrix</code> are
preseved when specified.</td>
</tr>
<tr>
<td><code>size_type size1 () const</code></td>
<td>Returns the number of rows.</td>
</tr>
<tr>
<td><code>size_type size2 () const</code></td>
<td>Returns the number of columns.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i, size_type j)
const</code></td>
<td>Returns the value of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i, size_type
j)</code></td>
<td>Returns a reference of the <code>j</code>-th element in the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>coordinate_matrix &amp;operator = (const
coordinate_matrix &amp;m)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>coordinate_matrix &amp;assign_temporary
(coordinate_matrix &amp;m)</code></td>
<td>Assigns a temporary. May change the coordinate matrix
<code>m</code>.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix &amp;operator = (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix &amp;assign (const matrix_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a matrix expression to the coordinate matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix &amp;operator += (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Adds the matrix expression to
the coordinate matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix &amp;plus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Adds a matrix expression to the coordinate matrix. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix &amp;operator -= (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the matrix expression
from the coordinate matrix.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
coordinate_matrix &amp;minus_assign (const
matrix_expression&lt;AE&gt; &amp;ae)</code></td>
<td>Subtracts a matrix expression from the coordinate matrix. Left
and right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
coordinate_matrix &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the coordinate
matrix with a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
coordinate_matrix &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the coordinate matrix
through a scalar.</td>
</tr>
<tr>
<td><code>void swap (coordinate_matrix &amp;m)</code></td>
<td>Swaps the contents of the coordinate matrices.</td>
</tr>
<tr>
<td><code>true_reference insert_element (size_type i, size_type j, const_reference
t)</code></td>
<td>Inserts the value <code>t</code> at the <code>j</code>-th
element of the <code>i</code>-th row. Duplicates elements are not allowed.</td>
</tr>
<tr>
<td><code>void append_element (size_type i, size_type j, const_reference t)</code></td>
<td>Appends the value <code>t</code> at the <code>j</code>-th element of the <code>i</code>-th row.
Duplicate elements can be appended to a <code>coordinate_matrix</code>. They are merged into a single
arithmetically summed element by the <code>sort</code> function.</td>
</tr>
<tr>
<td><code>void erase_element (size_type i, size_type j)</code></td>
<td>Erases the value at the <code>j</code>-th element of the
<code>i</code>-th row.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the coordinate matrix.</td>
</tr>
<tr>
<td><code>const_iterator1 begin1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the
beginning of the <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator1 end1 () const</code></td>
<td>Returns a <code>const_iterator1</code> pointing to the end of
the <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 begin1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the beginning of
the <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator1 end1 ()</code></td>
<td>Returns a <code>iterator1</code> pointing to the end of the
<code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 begin2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the
beginning of the <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_iterator2 end2 () const</code></td>
<td>Returns a <code>const_iterator2</code> pointing to the end of
the <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 begin2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the beginning of
the <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>iterator2 end2 ()</code></td>
<td>Returns a <code>iterator2</code> pointing to the end of the
<code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
beginning of the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator1 rend1 () const</code></td>
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
end of the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rbegin1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the
beginning of the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator1 rend1 ()</code></td>
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
beginning of the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator2 rend2 () const</code></td>
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
end of the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rbegin2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the
beginning of the reversed <code>coordinate_matrix</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator2 rend2 ()</code></td>
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
the reversed <code>coordinate_matrix</code>.</td>
</tr>
</tbody>
</table>
<h4>Notes</h4>
<p><a name="coordinate_matrix_1" id="coordinate_matrix_1">[1]</a>
Supported parameters for the storage organization are
<code>row_major</code> and <code>column_major</code>.</p>
<p><a name="coordinate_matrix_2" id="coordinate_matrix_2">[2]</a>
Supported parameters for the index base are <code>0</code> and
<code>1</code> at least.</p>
<p><a name="coordinate_matrix_3" id="coordinate_matrix_3">[3]</a>
Supported parameters for the adapted array are
<code>unbounded_array&lt;&gt;</code> ,
<code>bounded_array&lt;&gt;</code> and
<code>std::vector&lt;&gt;</code> .</p>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,261 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta name="GENERATOR" content="Quanta Plus" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>uBLAS operations overview</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Overview of Matrix and Vector Operations</h1>
<div class="toc" id="toc"></div>
<dl>
<dt>Contents:</dt>
<dd><a href="#blas">Basic Linear Algebra</a></dd>
<dd><a href="#advanced">Advanced Functions</a></dd>
<dd><a href="#sub">Submatrices, Subvectors</a></dd>
<dd><a href="#speed">Speed Improvements</a></dd>
</dl>
<h2>Definitions</h2>
<table style="" summary="notation">
<tr><td><code>A, B, C</code></td>
<td> are matrices</td></tr>
<tr><td><code>u, v, w</code></td>
<td>are vectors</td></tr>
<tr><td><code>i, j, k</code></td>
<td>are integer values</td></tr>
<tr><td><code>t, t1, t2</code></td>
<td>are scalar values</td></tr>
<tr><td><code>r, r1, r2</code></td>
<td>are <a href="range.htm">ranges</a>, e.g. <code>range(0, 3)</code></td></tr>
<tr><td><code>s, s1, s2</code></td>
<td>are <a href="range.htm#slice">slices</a>, e.g. <code>slice(0, 1, 3)</code></td></tr>
</table>
<h2 id="blas"><a name="blas">Basic Linear Algebra</a></h2>
<h3>standard operations: addition, subtraction, multiplication by a
scalar</h3>
<pre><code>
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;
</code></pre>
<h3>computed assignements</h3>
<pre><code>
C += A; C -= A;
w += u; w -= u;
C *= t; C /= t;
w *= t; w /= t;
</code></pre>
<h3>inner, outer and other products</h3>
<pre><code>
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);
</code></pre>
<h3>transformations</h3>
<pre><code>
w = conj(u); w = real(u); w = imag(u);
C = trans(A); C = conj(A); C = herm(A); C = real(A); C = imag(A);
</code></pre>
<h2 id="advanced"><a name="advanced">Advanced functions</a></h2>
<h3>norms</h3>
<pre><code>
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);
</code></pre>
<h3>products</h3>
<pre><code>
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
</code></pre>
<p><em>Note:</em> The last argument (<code>bool init</code>) of
<code>axpy_prod</code> is optional. Currently it defaults to
<code>true</code>, but this may change in the future. Set the
<code>init</code> to <code>true</code> is equivalent to call
<code>w.clear()</code> before <code>axpy_prod</code>. Up to now
there are some specialisation for compressed matrices that give a
large speed up compared to <code>prod</code>.</p>
<pre><code>
w = block_prod&lt;matrix_type, 64&gt; (A, u); // w = A * u
w = block_prod&lt;matrix_type, 64&gt; (u, A); // w = trans(A) * u
C = block_prod&lt;matrix_type, 64&gt; (A, B); // w = A * B
</code></pre>
<p><em>Note:</em> The blocksize can be any integer. However, the
total speed depends very strong on the combination of blocksize,
CPU and compiler. The function <code>block_prod</code> is designed
for large dense matrices.</p>
<h3>rank-k updates</h3>
<pre><code>
opb_prod(A, B, C, true); // C = A * B
opb_prod(A, B, C, false); // C += A * B
</code></pre>
<p><em>Note:</em> The last argument (<code>bool init</code>) of
<code>opb_prod</code> is optional. Currently it defaults to
<code>true</code>, but this may change in the future. This function
may give a speedup if <code>A</code> has less columns than rows,
because the product is computed as a sum of outer products.</p>
<h2 id="sub"><a name="sub">Submatrices, Subvectors</a></h2>
<p>Accessing submatrices and subvectors via <b>proxies</b> using <code>project</code> functions:</p>
<pre><code>
w = project(u, r); // the subvector of u specifed by the index range r
w = project(u, s); // the subvector of u specifed by the index slice s
C = project(A, r1, r2); // the submatrix of A specified by the two index ranges r1 and r2
C = project(A, s1, s2); // the submatrix of A specified by the two index slices s1 and s2
w = row(A, i); w = column(A, j); // a row or column of matrix as a vector
</code></pre>
<p>Assigning to submatrices and subvectors via <b>proxies</b> using <code>project</code> functions:</p>
<pre><code>
project(u, r) = w; // assign the subvector of u specifed by the index range r
project(u, s) = w; // assign the subvector of u specifed by the index slice s
project(A, r1, r2) = C; // assign the submatrix of A specified by the two index ranges r1 and r2
project(A, s1, s2) = C; // assign the submatrix of A specified by the two index slices s1 and s2
row(A, i) = w; column(A, j) = w; // a row or column of matrix as a vector
</code></pre>
<p><em>Note:</em> A range <code>r = range(start, stop)</code>
contains all indices <code>i</code> with <code>start &lt;= i &lt;
stop</code>. A slice is something more general. The slice
<code>s = slice(start, stride, size)</code> contains the indices
<code>start, start+stride, ..., start+(size-1)*stride</code>. The
stride can be 0 or negative! If <code>start >= stop</code> for a range
or <code>size == 0</code> for a slice then it contains no elements.</p>
<p>Sub-ranges and sub-slices of vectors and matrices can be created directly with the <code>subrange</code> and <code>sublice</code> functions:</p>
<pre><code>
w = subrange(u, 0, 2); // the 2 element subvector of u
w = subslice(u, 0, 1, 2); // the 2 element subvector of u
C = subrange(A, 0,2, 0,3); // the 2x3 element submatrix of A
C = subslice(A, 0,1,2, 0,1,3); // the 2x3 element submatrix of A
subrange(u, 0, 2) = w; // assign the 2 element subvector of u
subslice(u, 0, 1, 2) = w; // assign the 2 element subvector of u
subrange(A, 0,2, 0,3) = C; // assign the 2x3 element submatrix of A
subrange(A, 0,1,2, 0,1,3) = C; // assigne the 2x3 element submatrix of A
</code></pre>
<p>There are to more ways to access some matrix elements as a
vector:</p>
<pre><code>matrix_vector_range&lt;matrix_type&gt; (A, r1, r2);
matrix_vector_slice&lt;matrix_type&gt; (A, s1, s2);
</code></pre>
<p><em>Note:</em> These matrix proxies take a sequence of elements
of a matrix and allow you to access these as a vector. In
particular <code>matrix_vector_slice</code> can do this in a very
general way. <code>matrix_vector_range</code> is less useful as the
elements must lie along a diagonal.</p>
<p><em>Example:</em> 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:<br />
<code>matrix_vector_slice&lt;matrix_type&gt; (A, slice(0,1,2),
slice(0,0,2));
</code></p>
<h2 id="speed"><a name="speed">Speed improvements</a></h2>
<h3><a name='noalias'>Matrix / Vector assignment</a></h3>
<p>If you know for sure that the left hand expression and the right
hand expression have no common storage, then assignment has
no <em>aliasing</em>. A more efficient assignment can be specified
in this case:</p>
<pre><code>noalias(C) = prod(A, B);
</code></pre>
<p>This avoids the creation of a temporary matrix that is required in a normal assignment.
'noalias' assignment requires that the left and right hand side be size conformant.</p>
<h3>Sparse element access</h3>
<p>The matrix element access function <code>A(i1,i2)</code> or the equivalent vector
element access functions (<code>v(i) or v[i]</code>) usually create 'sparse element proxies'
when applied to a sparse matrix or vector. These <em>proxies</em> allow access to elements
without having to worry about nasty C++ issues where references are invalidated.</p>
<p>These 'sparse element proxies' can be implemented more efficiently when applied to <code>const</code>
objects.
Sadly in C++ there is no way to distinguish between an element access on the left and right hand side of
an assignment. Most often elements on the right hand side will not be changed and therefore it would
be better to use the <code>const</code> proxies. We can do this by making the matrix or vector
<code>const</code> before accessing it's elements. For example:</p>
<pre><code>value = const_cast&lt;const VEC&gt;(v)[i]; // VEC is the type of V
</code></pre>
<p>If more then one element needs to be accessed <code>const_iterator</code>'s should be used
in preference to <code>iterator</code>'s for the same reason. For the more daring 'sparse element proxies'
can be completely turned off in uBLAS by defining the configuration macro <code>BOOST_UBLAS_NO_ELEMENT_PROXIES</code>.
</p>
<h3>Controlling the complexity of nested products</h3>
<p>What is the complexity (the number of add and multiply operations) required to compute the following?
</p>
<pre>
R = prod(A, prod(B,C));
</pre>
<p>Firstly the complexity depends on matrix size. Also since prod is transitive (not commutative)
the bracket order affects the complexity.
</p>
<p>uBLAS evaluates expressions without matrix or vector temporaries and honours
the bracketing structure. However avoiding temporaries for nested product unnecessarly increases the complexity.
Conversly by explictly using temporary matrices the complexity of a nested product can be reduced.
</p>
<p>uBLAS provides 3 alternative syntaxes for this purpose:
</p>
<pre>
temp_type T = prod(B,C); R = prod(A,T); // Preferable if T is preallocated
</pre>
<pre>
prod(A, temp_type(prod(B,C));
</pre>
<pre>
prod(A, prod&lt;temp_type&gt;(B,C));
</pre>
<p>The 'temp_type' is important. Given A,B,C are all of the same type. Say
matrix&lt;float&gt;, the choice is easy. However if the value_type is mixed (int with float or double)
or the matrix type is mixed (sparse with symmetric) the best solution is not so obvious. It is up to you! It
depends on numerical properties of A and the result of the prod(B,C).
</p>
<hr />
<p>Copyright (&copy;) 2000-2007 Joerg Walter, Mathias Koch, Gunter
Winkler, Michael Stevens<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,247 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" >
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<!-- tidy options: -w 120 -asxhtml -clean - - vertical-space yes -f index.htm.err -m index.htm -->
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Boost Basic Linear Algebra - Configuration Options</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" alt="logo"/>Boost Basic Linear Algebra - Configuration Options</h1>
<div class="toc" id="toc"></div>
<div class="navigation">
<a href="index.htm">back to uBLAS home</a>
</div>
<h2>NDEBUG</h2>
<p><strong>Make sure you define NDEBUG</strong> The only way uBLAS
knows you want a release configuration is to check if you have defined
NDEBUG. If you don't it assumes you want a debug configuration and
adds a lot of very useful runtime check. However these are very slow!
</p>
<h2>BOOST_UBLAS_MOVE_SEMANTICS</h2>
<p class="credit">The patch and description was provided by Nasos Iliopoulos.</p>
<p>An immediate effect of this option is the elimination of the need
for noalias in types <tt>vector&lt;T&gt;</tt> and <tt>matrix&lt;T&gt;</tt>,
when assigned to the same type. This option doesn't have an effect on
bounded and c types. Although it is rare, not all compilers support copy
elision (that allows for move semantics), so a test must be performed to
make sure that there is a benefit when it is enabled. A small
demonstration and test can be found in
<a href="../test/manual/test_move_semantics.cpp"><tt>test_move_semantics.cpp</tt></a></p>
<p>
In the <a href="../test/manual/test_move_semantics.cpp">test
example</a> two tests are defined, one for vectors and one for
matrices. The aim of this example is to print the pointers of the
storage of each of the containers, before and after the assignment to
a temporary object. When move semantics are enabled, the
<tt>vector&lt;T&gt;</tt> and <tt>matrix&lt;T&gt;</tt> storage is moved
from the temporary and no copy is performed.
</p>
<p>
If move semantics are supported by your compiler you will get an output like the following:
</p>
<pre class="screen">
matrix&lt;double&gt; --------------------------------------------------------------------
Temporary pointer r: 0x94790c0
Pointer (must be equal to temp. pointer if move semantics are enabled) : 0x94790c0
</pre>
<p>Notes:</p>
<ul>
<li>It should be no surprise to see matrices and vectors been passed
by VALUE, the compiler takes care and either moves (if the underlying
code does not modify the object), or copies (if the underlying code
modifies the object).
</li>
<li>There might be some space for some improvements (like clearing the
data, before swaping)
</li>
<li>Move semantics don't eliminate temporaries. They rather move their
storage around so no copies are performed.
</li>
<li>MSVC does no implement Named Return Value Optimization in debug
mode. So if you build in debug with this compiler you might get <a
href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483229"
target="_blank">different behaviour</a> than a release build.
</li>
<li>Enabling move semantics is done via #define BOOST_UBLAS_MOVE_SEMANTICS.
</li>
<li>There is plenty of room for optimizations when c++0x standard is
out, taking advantage of rvalue references. (I have a sweet vector
implementation using that).
</li>
<li>If you enable move semantics and your compiler does not support
them, the operation will just be as passing by const reference.
</li>
</ul>
<p>Interesting links</p>
<ul>
<li> <a href="http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/" target="_blank">Want Speed? Pass by Value.</a>
</li>
<li> <a href="http://blogs.msdn.com/vcblog/archive/2009/02/03/rvalue-references-c-0x-features-in-vc10-part-2.aspx" target="_blank">Rvalue References: C++0x Features in VC10, Part 2</a>
</li>
<li> <a href="http://cpp-next.com/archive/2009/09/move-it-with-rvalue-references/" target="_blank">Move It With Rvalue References</a>
</li>
</ul>
<h2>BOOST_UBLAS_CHECK_ENABLE</h2>
<p>When BOOST_UBLAS_CHECK_ENABLE is defined then all index and
parameter checks are enabled. This is enabled in debug mode and
disabled in release mode.
</p>
<h2>BOOST_UBLAS_TYPE_CHECK</h2>
<p>When BOOST_UBLAS_TYPE_CHECK is enabled then all possibly expensive
structure checks are enabled. If this is not desireable then use
<tt>#define BOOST_UBLAS_TYPE_CHECK 0</tt> before including any uBLAS
header. The define BOOST_UBLAS_TYPE_CHECK_EPSILON can be used to
control the acceptable tolerance, see
<tt>detail/matrix_assign.hpp</tt> for implementation details of this
check.
</p>
<h2>BOOST_UBLAS_USE_LONG_DOUBLE</h2>
<p>Enable uBLAS expressions that involve containers of 'long double'</p>
<h2>BOOST_UBLAS_USE_INTERVAL</h2>
<p>Enable uBLAS expressions that involve containers of 'boost::numeric::interval' types</p>
<h2>Configuring uBLAS with Macros</h2>
<p>Many macro's appear in ublas/config.hpp and elsewhere. Hopefully in the future some of these will disappear!
They fall into 4 groups:
</p>
<ul>
<li> Automatically set by 'boost/numeric/ublas/config.hpp' based on
NDEBUG. Makes the distinction between debug (safe) and release (fast)
mode. Similar to STLport
<ul>
<li> <i>Release</i> mode (NDEBUG defined)
<ul>
<li> BOOST_UBLAS_INLINE <i>Compiler dependant definition to control
function inlining.</i> </li><li> BOOST_UBLAS_USE_FAST_SAME </li></ul>
</li><li> <i>Debug</i> mode
<ul>
<li> BOOST_UBLAS_CHECK_ENABLE <i>Enable checking of indexs, iterators
and parameters. Prevents out of bound access etc.</i> </li><li>
BOOST_UBLAS_TYPE_CHECK <i>Enable additional checks for the results of
expressions using non dense types. Picks up runtime error such as the
assignment of a numerically non-symmetric matrix to
symmertic_matrix. Use <tt>#define BOOST_UBLAS_TYPE_CHECK 0</tt> to
disable expensive numeric type checks.</i> (Note: "structure check"
would be a much better name.) </li><li>
BOOST_UBLAS_TYPE_CHECK_EPSILON <i>default: sqrt(epsilon), controls how
large the difference between the expected result and the computed
result may become. Increase this value if you are going to use near
singular or badly scaled matrices. Please, refer to
<tt>detail/matrix_assign.hpp</tt> for implementation of these type
checks.</i> </li></ul> </li></ul>
</li>
<li> Automatically set by 'boost/numeric/ublas/config.hpp' based on
compiler and boost/config.hpp macro's. Augments the compiler
deficiency workarounds already supplied by boost/config.hpp
<ul>
<li> BOOST_UBLAS_NO_NESTED_CLASS_RELATION <i>A particularly nasty
problem with VC7.1 Requires that uBLAS and the user use begin(it)
rather then it.begin()</i> </li><li> BOOST_UBLAS_NO_SMART_PROXIES
<i>Disable the automatic propagation of 'constantness' to
proxies. Smart proxies automatically determine if the underling
container they reference is constant or not. They adjust there
definition of iterators and container access to reflect this
constantness.</i> </li></ul>
</li>
<li> For use by uBLAS authors to test implementation methods. Preset
in config.hpp
<ul>
<li> BOOST_UBLAS_USE_INVARIANT_HOISTING </li><li>
BOOST_UBLAS_USE_INDEXING </li><li> BOOST_UBLAS_USE_INDEXED_ITERATOR
</li><li> BOOST_UBLAS_NON_CONFORMANT_PROXIES <i>Gappy containers may
be non-conformant, that is contain elements at different
indices. Assigning between proxies (vector ranges for example) of
these containers is difficult as the LHS may need insert new
elements. This is slow.</i> </li><li> BOOST_UBLAS_USE_DUFF_DEVICE
<i>Near useless on all platforms (see GCC's -funroll-loops)</i>
</li></ul>
</li>
<li> User options. Can be predefined by user before including any
uBLAS headers. They may also be automatically defined for some
compilers to work around compile bugs.
<ul>
<li> BOOST_UBLAS_USE_LONG_DOUBLE <i>Enable uBLAS expressions that
involve containers of 'long double'</i> </li><li>
BOOST_UBLAS_USE_INTERVAL <i>Enable uBLAS expressions that involve
containers of 'boost::numeric::interval' types</i> </li><li>
BOOST_UBLAS_SIMPLE_ET_DEBUG <i>In order to simplify debugging is is
possible to simplify expression templateso they are restricted to a
single operation</i>
</li><li> BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS <i> enable automatic
conversion from proxy class to matrix expression </i> </li><li>
BOOST_UBLAS_NO_ELEMENT_PROXIES <i>Disables the use of element proxies
for gappy types.</i> </li><li> <i>The Gappy types (sparse, coordinate,
compressed) store non-zero elements in their own containers. When new
non-zero elements are assigned they must rearrange these
containers. This invalidates references, iterators or pointers to
these elements. This can happen at some surprising times such as the
expression "a [1] = a [0] = 1;". Element proxies guarantee all such
expressions will work as expected. However they bring their own
restrictions and efficiency problems. For example as of Boost 1.30.0
they prevent the assignment of elements between different types.</i>
</li>
<li> BOOST_UBLAS_REFERENCE_CONST_MEMBER <i>Enable to allow refernces
to be returned to fixed (zero or one) elements of triangular or banded
matrices</i>
</li><li> BOOST_UBLAS_NO_EXCEPTIONS <i>Disable the use exceptions of
uBLAS internal checks and error conditions. BOOST_NO_EXCEPTIONS has
same effect.</i>
</li>
<li> BOOST_UBLAS_SINGULAR_CHECK <i>Check the for singularity in triangular solve() functions</i></li>
</ul>
</li>
</ul>
<hr />
<div id="copyright">
<p>Copyright (&copy;) 2000-2009 Joerg Walter, Mathias Koch, Gunter Winkler<br />
Use, modification and distribution are subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
</div>
<div id="revision">
<p>
<!-- Created: Wed Sep 16 21:19:20 CEST 2009 -->
<!-- hhmts start -->
Last modified: Wed Sep 16 23:16:45 CEST 2009
<!-- hhmts end -->
</p>
</div>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,965 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>uBLAS Overview</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" alt="logo"/>uBLAS Overview</h1>
<div class="toc" id="toc"></div>
<h2 id="rationale"><a name="rationale" id="rationale" />Rationale</h2>
<p><cite>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).</cite></p>
<p>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:</p>
<ul type="disc">
<li>mathematical notation</li>
<li>efficiency</li>
<li>functionality</li>
<li>compatibility</li>
</ul>
<p>Another intention was to evaluate, if the abstraction penalty
resulting from the use of such matrix and vector classes is
acceptable.</p>
<h2>Resources</h2>
<p>The development of this library was guided by a couple of
similar efforts:</p>
<ul type="disc">
<li><a href="http://www.netlib.org/blas/index.html">BLAS</a> by
Jack Dongarra et al.</li>
<li><a href="http://www.oonumerics.org/blitz/">Blitz++</a> by Todd
Veldhuizen</li>
<li><a href="http://acts.nersc.gov/pooma/">POOMA</a> by Scott
Haney et al.</li>
<li><a href="http://www.lsc.nd.edu/research/mtl/">MTL</a> by Jeremy
Siek et al.</li>
</ul>
<p>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
abstracted from simple linear algebra operations. Due to the fact
that is has been implemented using Fortran and its optimizations,
it also seems to be one of the fastest libraries available. As we
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.</p>
<p>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++
states, that the library achieves performance on par or better than
corresponding Fortran code due to his implementation technique
using expression templates and template metaprograms. However we
see some reasons, to develop an own design and implementation
approach. We do not know whether anybody tries to implement
traditional linear algebra and other numerical algorithms using
Blitz++. We also presume that even today Blitz++ needs the most
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.</p>
<p>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.</p>
<p>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
linear algebra library has to provide functionality comparable to
BLAS. On the other hand we think, that the concepts of the C++
standard library have not yet been proven to support numerical
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.</p>
<h2>Concepts</h2>
<h3>Mathematical Notation</h3>
<p>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.</p>
<p>We decided to use operator overloading for the following
primitives:</p>
<table border="1" summary="operators">
<tbody>
<tr>
<th align="left">Description</th>
<th align="left">Operator</th>
</tr>
<tr>
<td>Indexing of vectors and matrices</td>
<td><code>vector::operator(size_t i);<br />
matrix::operator(size_t i, size_t j);</code></td>
</tr>
<tr>
<td>Assignment of vectors and matrices</td>
<td><code>vector::operator = (const vector_expression &amp;);<br />
vector::operator += (const vector_expression &amp;);<br />
vector::operator -= (const vector_expression &amp;);<br />
vector::operator *= (const scalar_expression &amp;);<br />
matrix::operator = (const matrix_expression &amp;);<br />
matrix::operator += (const matrix_expression &amp;);<br />
matrix::operator -= (const matrix_expression &amp;);<br />
matrix::operator *= (const scalar_expression &amp;);</code></td>
</tr>
<tr>
<td>Unary operations on vectors and matrices</td>
<td><code>vector_expression operator - (const vector_expression
&amp;);<br />
matrix_expression operator - (const matrix_expression
&amp;);</code></td>
</tr>
<tr>
<td>Binary operations on vectors and matrices</td>
<td><code>vector_expression operator + (const vector_expression
&amp;, const vector_expression &amp;);<br />
vector_expression operator - (const vector_expression &amp;, const
vector_expression &amp;);<br />
matrix_expression operator + (const matrix_expression &amp;, const
matrix_expression &amp;);<br />
matrix_expression operator - (const matrix_expression &amp;, const
matrix_expression &amp;);</code></td>
</tr>
<tr>
<td>Multiplication of vectors and matrices with a scalar</td>
<td><code>vector_expression operator * (const scalar_expression
&amp;, const vector_expression &amp;);<br />
vector_expression operator * (const vector_expression &amp;, const
scalar_expression &amp;);<br />
matrix_expression operator * (const scalar_expression &amp;, const
matrix_expression &amp;);<br />
matrix_expression operator * (const matrix_expression &amp;, const
scalar_expression &amp;);</code></td>
</tr>
</tbody>
</table>
<p>We decided to use no operator overloading for the following
other primitives:</p>
<table border="1" summary="functions">
<tbody>
<tr>
<th align="left">Description</th>
<th align="left">Function</th>
</tr>
<tr>
<td>Left multiplication of vectors with a matrix</td>
<td><code>vector_expression
prod&lt;</code><code><em>vector_type</em></code> <code>&gt; (const
matrix_expression &amp;, const vector_expression &amp;);<br />
vector_expression prod (const matrix_expression &amp;, const
vector_expression &amp;);</code></td>
</tr>
<tr>
<td>Right multiplication of vectors with a matrix</td>
<td><code>vector_expression
prod&lt;</code><code><em>vector_type</em></code> <code>&gt; (const
vector_expression &amp;, const matrix_expression &amp;);<br />
vector_expression prod (const vector_expression &amp;, const
matrix_expression &amp;);<br /></code></td>
</tr>
<tr>
<td>Multiplication of matrices</td>
<td><code>matrix_expression
prod&lt;</code><code><em>matrix_type</em></code> <code>&gt; (const
matrix_expression &amp;, const matrix_expression &amp;);<br />
matrix_expression prod (const matrix_expression &amp;, const
matrix_expression &amp;);</code></td>
</tr>
<tr>
<td>Inner product of vectors</td>
<td><code>scalar_expression inner_prod (const vector_expression
&amp;, const vector_expression &amp;);</code></td>
</tr>
<tr>
<td>Outer product of vectors</td>
<td><code>matrix_expression outer_prod (const vector_expression
&amp;, const vector_expression &amp;);</code></td>
</tr>
<tr>
<td>Transpose of a matrix</td>
<td><code>matrix_expression trans (const matrix_expression
&amp;);</code></td>
</tr>
</tbody>
</table>
<h3>Efficiency</h3>
<p>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.</p>
<h4>Eliminating Temporaries</h4>
<p>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
of a composition into a temporary and next to evaluate the
composite resulting in another temporary. This method is expensive
in terms of time especially for small and space especially for
large vectors and matrices. The approach to solve this problem is
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.</p>
<p>Two interesting and dangerous facts result:</p>
<h4>Aliases</h4>
<p>One may get serious side effects using element wise
evaluation on vectors or matrices. Consider the matrix vector
product <em>x = A x</em>. Evaluation of
<em>A</em><sub><em>1</em></sub><em>x</em> and assignment to
<em>x</em><sub><em>1</em></sub> changes the right hand side, so
that the evaluation of <em>A</em><sub><em>2</em></sub><em>x</em>
returns a wrong result. In this case there are <strong>aliases</strong> of the elements
<em>x</em><sub><em>n</em></sub> on both the left and right hand side of the assignment.</p>
<p>Our solution for this problem is to
evaluate the right hand side of an assignment into a temporary and
then to assign this temporary to the left hand side. To allow
further optimizations, we provide a corresponding member function
for every assignment operator and also a
<a href="operations_overview.htm#noalias"> <code>noalias</code> syntax.</a>
By using this syntax 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.</p>
<h4>Complexity</h4>
<p>The computational complexity may be unexpectedly large under certain
cirumstances. Consider the chained matrix vector product <em>A (B
x)</em>. Conventional evaluation of <em>A (B x)</em> is quadratic.
Deferred evaluation of <em>B x</em><sub><em>i</em></sub> is linear.
As every element <em>B x</em><sub><em>i</em></sub> is needed
linearly depending of the size, a completely deferred evaluation of
the chained matrix vector product <em>A (B x)</em> is cubic. In
such cases one needs to reintroduce temporaries in the
expression.</p>
<h4>Eliminating Virtual Function Calls</h4>
<p>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,
which is also known to be expensive in terms of time. A solution
was found a couple of years ago independently by David Vandervoorde
and Todd Veldhuizen and is commonly called expression templates.
Expression templates contain lazy evaluation and replace dynamic
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.</p>
<p>Expression templates form the base of our implementation.</p>
<h4>Compilation times</h4>
<p>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.</p>
<p>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
development cycle. Switching from debug mode to release mode is
controlled by the <code>NDEBUG</code> preprocessor symbol of
<code>&lt;cassert&gt;</code>.</p>
<h2 id="functionality"><a name="functionality" id="functionality"/>Functionality</h2>
<p>Every C++ library supporting linear algebra will be measured
against the long-standing Fortran package BLAS. We now describe how
BLAS calls may be mapped onto our classes.</p>
<p>The page <a href="operations_overview.htm">Overview of Matrix and Vector Operations</a>
gives a short summary of the most used operations on vectors and
matrices.</p>
<h4>Blas Level 1</h4>
<table border="1" summary="level 1 blas">
<tbody>
<tr>
<th align="left">BLAS Call</th>
<th align="left">Mapped Library Expression</th>
<th align="left">Mathematical Description</th>
<th align="left">Comment</th>
</tr>
<tr>
<td><code>sasum</code> OR <code>dasum</code></td>
<td><code>norm_1 (x)</code></td>
<td><em>sum |x<sub>i</sub>|</em></td>
<td>Computes the <em>l<sub>1</sub></em> (sum) norm of a real vector.</td>
</tr>
<tr>
<td><code>scasum</code> OR <code>dzasum</code></td>
<td><em><code>real (sum (v)) + imag (sum (v))</code></em></td>
<td><em>sum re(x<sub>i</sub>) + sum im(x<sub>i</sub>)</em></td>
<td>Computes the sum of elements of a complex vector.</td>
</tr>
<tr>
<td><code>_nrm2</code></td>
<td><code>norm_2 (x)</code></td>
<td><em>sqrt (sum
|x</em><sub><em>i</em></sub>|<sup><em>2</em></sup> <em>)</em></td>
<td>Computes the <em>l<sub>2</sub></em> (euclidean) norm of a vector.</td>
</tr>
<tr>
<td><code>i_amax</code></td>
<td><code>norm_inf (x)<br />
index_norm_inf (x)</code></td>
<td><em>max |x</em><sub><em>i</em></sub><em>|</em></td>
<td>Computes the <em>l<sub>inf</sub></em> (maximum) norm of a vector.<br />
BLAS computes the index of the first element having this
value.</td>
</tr>
<tr>
<td><code>_dot<br />
_dotu<br />
_dotc</code></td>
<td><code>inner_prod (x, y)</code>or<code><br />
inner_prod (conj (x), y)</code></td>
<td><em>x</em><sup><em>T</em></sup> <em>y</em> or<br />
<em>x</em><sup><em>H</em></sup> <em>y</em></td>
<td>Computes the inner product of two vectors.<br />
BLAS implements certain loop unrollment.</td>
</tr>
<tr>
<td><code>dsdot<br />
sdsdot</code></td>
<td><code>a + prec_inner_prod (x, y)</code></td>
<td><em>a + x</em><sup><em>T</em></sup> <em>y</em></td>
<td>Computes the inner product in double precision.</td>
</tr>
<tr>
<td><code>_copy</code></td>
<td><code>x = y<br />
y.assign (x)</code></td>
<td><em>x &lt;- y</em></td>
<td>Copies one vector to another.<br />
BLAS implements certain loop unrollment.</td>
</tr>
<tr>
<td><code>_swap</code></td>
<td><code>swap (x, y)</code></td>
<td><em>x &lt;-&gt; y</em></td>
<td>Swaps two vectors.<br />
BLAS implements certain loop unrollment.</td>
</tr>
<tr>
<td><code>_scal<br />
csscal<br />
zdscal</code></td>
<td><code>x *= a</code></td>
<td><em>x &lt;- a x</em></td>
<td>Scales a vector.<br />
BLAS implements certain loop unrollment.</td>
</tr>
<tr>
<td><code>_axpy</code></td>
<td><code>y += a * x</code></td>
<td><em>y &lt;- a x + y</em></td>
<td>Adds a scaled vector.<br />
BLAS implements certain loop unrollment.</td>
</tr>
<tr>
<td><code>_rot<br />
_rotm<br />
csrot<br />
zdrot</code></td>
<td><code>t.assign (a * x + b * y),<br />
y.assign (- b * x + a * y),<br />
x.assign (t)</code></td>
<td><em>(x, y) &lt;- (a x + b y, -b x + a y)</em></td>
<td>Applies a plane rotation.</td>
</tr>
<tr>
<td><code>_rotg<br />
_rotmg</code></td>
<td>&nbsp;</td>
<td><em>(a, b) &lt;-<br />
&nbsp; (? a / sqrt (a</em><sup><em>2</em></sup> +
<em>b</em><sup><em>2</em></sup><em>),<br />
&nbsp; &nbsp; ? b / sqrt (a</em><sup><em>2</em></sup> +
<em>b</em><sup><em>2</em></sup><em>))</em> or<em><br />
(1, 0) &lt;- (0, 0)</em></td>
<td>Constructs a plane rotation.</td>
</tr>
</tbody>
</table>
<h4>Blas Level 2</h4>
<table border="1" summary="level 2 blas">
<tbody>
<tr>
<th align="left">BLAS Call</th>
<th align="left">Mapped Library Expression</th>
<th align="left">Mathematical Description</th>
<th align="left">Comment</th>
</tr>
<tr>
<td><code>_t_mv</code></td>
<td><code>x = prod (A, x)</code> or<code><br />
x = prod (trans (A), x)</code> or<code><br />
x = prod (herm (A), x)</code></td>
<td><em>x &lt;- A x</em> or<em><br />
x &lt;- A</em><sup><em>T</em></sup> <em>x</em> or<em><br />
x &lt;- A</em><sup><em>H</em></sup> <em>x</em></td>
<td>Computes the product of a matrix with a vector.</td>
</tr>
<tr>
<td><code>_t_sv</code></td>
<td><code>y = solve (A, x, tag)</code> or<br />
<code>inplace_solve (A, x, tag)</code> or<br />
<code>y = solve (trans (A), x, tag)</code> or<br />
<code>inplace_solve (trans (A), x, tag)</code> or<br />
<code>y = solve (herm (A), x, tag)</code>or<br />
<code>inplace_solve (herm (A), x, tag)</code></td>
<!-- TODO: replace nested sub/sup -->
<td><em>y &lt;- A</em><sup><em>-1</em></sup> <em>x</em>
or<em><br />
x &lt;- A</em><sup><em>-1</em></sup> <em>x</em> or<em><br />
y &lt;-
A</em><sup><em>T</em></sup><sup><sup><em>-1</em></sup></sup>
<em>x</em> or<em><br />
x &lt;-
A</em><sup><em>T</em></sup><sup><sup><em>-1</em></sup></sup>
<em>x</em> or<em><br />
y &lt;-
A</em><sup><em>H</em></sup><sup><sup><em>-1</em></sup></sup>
<em>x</em> or<em><br />
x &lt;-
A</em><sup><em>H</em></sup><sup><sup><em>-1</em></sup></sup>
<em>x</em></td>
<td>Solves a system of linear equations with triangular form, i.e.
<em>A</em> is triangular.</td>
</tr>
<tr>
<td><code>_g_mv<br />
_s_mv<br />
_h_mv</code></td>
<td><code>y = a * prod (A, x) + b * y</code> or<code><br />
y = a * prod (trans (A), x) + b * y</code> or<code><br />
y = a * prod (herm (A), x) + b * y</code></td>
<td><em>y &lt;- a A x + b y</em> or<em><br />
y &lt;- a A</em><sup><em>T</em></sup> <em>x + b y<br />
y &lt;- a A</em><sup><em>H</em></sup> <em>x + b y</em></td>
<td>Adds the scaled product of a matrix with a vector.</td>
</tr>
<tr>
<td><code>_g_r<br />
_g_ru<br />
_g_rc</code></td>
<td><code>A += a * outer_prod (x, y)</code> or<code><br />
A += a * outer_prod (x, conj (y))</code></td>
<td><em>A &lt;- a x y</em><sup><em>T</em></sup> <em>+ A</em>
or<em><br />
A &lt;- a x y</em><sup><em>H</em></sup> <em>+ A</em></td>
<td>Performs a rank <em>1</em> update.</td>
</tr>
<tr>
<td><code>_s_r<br />
_h_r</code></td>
<td><code>A += a * outer_prod (x, x)</code> or<code><br />
A += a * outer_prod (x, conj (x))</code></td>
<td><em>A &lt;- a x x</em><sup><em>T</em></sup> <em>+ A</em>
or<em><br />
A &lt;- a x x</em><sup><em>H</em></sup> <em>+ A</em></td>
<td>Performs a symmetric or hermitian rank <em>1</em> update.</td>
</tr>
<tr>
<td><code>_s_r2<br />
_h_r2</code></td>
<td><code>A += a * outer_prod (x, y) +<br />
&nbsp;a * outer_prod (y, x))</code> or<code><br />
A += a * outer_prod (x, conj (y)) +<br />
&nbsp;conj (a) * outer_prod (y, conj (x)))</code></td>
<td><em>A &lt;- a x y</em><sup><em>T</em></sup> <em>+ a y
x</em><sup><em>T</em></sup> <em>+ A</em> or<em><br />
A &lt;- a x y</em><sup><em>H</em></sup> <em>+
a</em><sup><em>-</em></sup> <em>y x</em><sup><em>H</em></sup> <em>+
A</em></td>
<td>Performs a symmetric or hermitian rank <em>2</em> update.</td>
</tr>
</tbody>
</table>
<h4>Blas Level 3</h4>
<table border="1" summary="level 3 blas">
<tbody>
<tr>
<th align="left">BLAS Call</th>
<th align="left">Mapped Library Expression</th>
<th align="left">Mathematical Description</th>
<th align="left">Comment</th>
</tr>
<tr>
<td><code>_t_mm</code></td>
<td><code>B = a * prod (A, B)</code> or<br />
<code>B = a * prod (trans (A), B)</code> or<br />
<code>B = a * prod (A, trans (B))</code> or<br />
<code>B = a * prod (trans (A), trans (B))</code> or<br />
<code>B = a * prod (herm (A), B)</code> or<br />
<code>B = a * prod (A, herm (B))</code> or<br />
<code>B = a * prod (herm (A), trans (B))</code> or<br />
<code>B = a * prod (trans (A), herm (B))</code> or<br />
<code>B = a * prod (herm (A), herm (B))</code></td>
<td><em>B &lt;- a op (A) op (B)</em> with<br />
&nbsp; <em>op (X) = X</em> or<br />
&nbsp; <em>op (X) = X</em><sup><em>T</em></sup> or<br />
&nbsp; <em>op (X) = X</em><sup><em>H</em></sup></td>
<td>Computes the scaled product of two matrices.</td>
</tr>
<tr>
<td><code>_t_sm</code></td>
<td><code>C = solve (A, B, tag)</code> or<br />
<code>inplace_solve (A, B, tag)</code> or<br />
<code>C = solve (trans (A), B, tag)</code> or<code><br />
inplace_solve (trans (A), B, tag)</code> or<code><br />
C = solve (herm (A), B, tag)</code> or<code><br />
inplace_solve (herm (A), B, tag)</code></td>
<td><em>C &lt;- A</em><sup><em>-1</em></sup> <em>B</em>
or<em><br />
B &lt;- A</em><sup><em>-1</em></sup> <em>B</em> or<em><br />
C &lt;-
A</em><sup><em>T</em></sup><sup><sup><em>-1</em></sup></sup>
<em>B</em> or<em><br />
B &lt;- A</em><sup><em>-1</em></sup> <em>B</em> or<em><br />
C &lt;-
A</em><sup><em>H</em></sup><sup><sup><em>-1</em></sup></sup>
<em>B</em> or<em><br />
B &lt;-
A</em><sup><em>H</em></sup><sup><sup><em>-1</em></sup></sup>
<em>B</em></td>
<td>Solves a system of linear equations with triangular form, i.e.
<em>A</em> is triangular.</td>
</tr>
<tr>
<td><code>_g_mm<br />
_s_mm<br />
_h_mm</code></td>
<td><code>C = a * prod (A, B) + b * C</code> or<br />
<code>C = a * prod (trans (A), B) + b * C</code> or<br />
<code>C = a * prod (A, trans (B)) + b * C</code> or<br />
<code>C = a * prod (trans (A), trans (B)) + b * C</code> or<br />
<code>C = a * prod (herm (A), B) + b * C</code> or<br />
<code>C = a * prod (A, herm (B)) + b * C</code> or<br />
<code>C = a * prod (herm (A), trans (B)) + b * C</code> or<br />
<code>C = a * prod (trans (A), herm (B)) + b * C</code> or<br />
<code>C = a * prod (herm (A), herm (B)) + b * C</code></td>
<td><em>C &lt;- a op (A) op (B) + b C</em> with<br />
&nbsp; <em>op (X) = X</em> or<br />
&nbsp; <em>op (X) = X</em><sup><em>T</em></sup> or<br />
&nbsp; <em>op (X) = X</em><sup><em>H</em></sup></td>
<td>Adds the scaled product of two matrices.</td>
</tr>
<tr>
<td><code>_s_rk<br />
_h_rk</code></td>
<td><code>B = a * prod (A, trans (A)) + b * B</code> or<br />
<code>B = a * prod (trans (A), A) + b * B</code> or<br />
<code>B = a * prod (A, herm (A)) + b * B</code> or<br />
<code>B = a * prod (herm (A), A) + b * B</code></td>
<td><em>B &lt;- a A A</em><sup><em>T</em></sup> <em>+ b B</em>
or<em><br />
B &lt;- a A</em><sup><em>T</em></sup> <em>A + b B</em> or<br />
<em>B &lt;- a A A</em><sup><em>H</em></sup> <em>+ b B</em>
or<em><br />
B &lt;- a A</em><sup><em>H</em></sup> <em>A + b B</em></td>
<td>Performs a symmetric or hermitian rank <em>k</em> update.</td>
</tr>
<tr>
<td><code>_s_r2k<br />
_h_r2k</code></td>
<td><code>C = a * prod (A, trans (B)) +<br />
&nbsp;a * prod (B, trans (A)) + b * C</code> or<br />
<code>C = a * prod (trans (A), B) +<br />
&nbsp;a * prod (trans (B), A) + b * C</code> or<br />
<code>C = a * prod (A, herm (B)) +<br />
&nbsp;conj (a) * prod (B, herm (A)) + b * C</code> or<br />
<code>C = a * prod (herm (A), B) +<br />
&nbsp;conj (a) * prod (herm (B), A) + b * C</code></td>
<td><em>C &lt;- a A B</em><sup><em>T</em></sup> <em>+ a B
A</em><sup><em>T</em></sup> <em>+ b C</em> or<em><br />
C &lt;- a A</em><sup><em>T</em></sup> <em>B + a
B</em><sup><em>T</em></sup> <em>A + b C</em> or<em><br />
C &lt;- a A B</em><sup><em>H</em></sup> <em>+
a</em><sup><em>-</em></sup> <em>B A</em><sup><em>H</em></sup> <em>+
b C</em> or<em><br />
C &lt;- a A</em><sup><em>H</em></sup> <em>B +
a</em><sup><em>-</em></sup> <em>B</em><sup><em>H</em></sup> <em>A +
b C</em></td>
<td>Performs a symmetric or hermitian rank <em>2 k</em>
update.</td>
</tr>
</tbody>
</table>
<h2>Storage Layout</h2>
<p>uBLAS supports many different storage layouts. The full details can be
found at the <a href="types_overview.htm">Overview of Types</a>. Most types like
<code>vector&lt;double&gt;</code> and <code>matrix&lt;double&gt;</code> are
by default compatible to C arrays, but can also be configured to contain
FORTAN compatible data.
</p>
<h2>Compatibility</h2>
<p>For compatibility reasons we provide array like indexing for vectors and matrices. For some types (hermitian, sparse etc) this can be expensive for matrices due to the needed temporary proxy objects.</p>
<p>uBLAS uses STL compatible allocators for the allocation of the storage required for it's containers.</p>
<h2>Benchmark Results</h2>
<p>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
library assume aliasing, the fast variants do not use temporaries
and are functionally equivalent to the native C implementation.
Besides the generic vector and matrix classes the benchmark
utilizes special classes <code>c_vector</code> and
<code>c_matrix</code>, which are intended to avoid every overhead
through genericity.</p>
<p>The benchmark program <strong>bench1</strong> was compiled with GCC 4.0 and run on an Athlon 64 3000+. Times are scales for reasonable precision by running <strong>bench1 100</strong>.</p>
<p>First we comment the results for double vectors and matrices of dimension 3 and 3 x 3, respectively.</p>
<table border="1" summary="1st benchmark">
<tbody>
<tr>
<th align="left">Comment</th>
</tr>
<tr>
<td rowspan="3">inner_prod</td>
<td>C array</td>
<td align="right">0.61</td>
<td align="right">782</td>
<td rowspan="3">Some abstraction penalty</td>
</tr>
<tr>
<td>c_vector</td>
<td align="right">0.86</td>
<td align="right">554</td>
</tr>
<tr>
<td>vector&lt;unbounded_array&gt;</td>
<td align="right">1.02</td>
<td align="right">467</td>
</tr>
<tr>
<td rowspan="5">vector + vector</td>
<td>C array</td>
<td align="right">0.51</td>
<td align="right">1122</td>
<td rowspan="5">Abstraction penalty: factor 2</td>
</tr>
<tr>
<td>c_vector fast</td>
<td align="right">1.17</td>
<td align="right">489</td>
</tr>
<tr>
<td>vector&lt;unbounded_array&gt; fast</td>
<td align="right">1.32</td>
<td align="right">433</td>
</tr>
<tr>
<td>c_vector safe</td>
<td align="right">2.02</td>
<td align="right">283</td>
</tr>
<tr>
<td>vector&lt;unbounded_array&gt; safe</td>
<td align="right">6.95</td>
<td align="right">82</td>
</tr>
<tr>
<td rowspan="5">outer_prod</td>
<td>C array</td>
<td align="right">0.59</td>
<td align="right">872</td>
<td rowspan="5">Some abstraction penalty</td>
</tr>
<tr>
<td>c_matrix, c_vector fast</td>
<td align="right">0.88</td>
<td align="right">585</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt; fast</td>
<td align="right">0.90</td>
<td align="right">572</td>
</tr>
<tr>
<td>c_matrix, c_vector safe</td>
<td align="right">1.66</td>
<td align="right">310</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt; safe</td>
<td align="right">2.95</td>
<td align="right">175</td>
</tr>
<tr>
<td rowspan="5">prod (matrix, vector)</td>
<td>C array</td>
<td align="right">0.64</td>
<td align="right">671</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix, c_vector fast</td>
<td align="right">0.70</td>
<td align="right">613</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt; fast</td>
<td align="right">0.79</td>
<td align="right">543</td>
</tr>
<tr>
<td>c_matrix, c_vector safe</td>
<td align="right">0.95</td>
<td align="right">452</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt; safe</td>
<td align="right">2.61</td>
<td align="right">164</td>
</tr>
<tr>
<td rowspan="5">matrix + matrix</td>
<td>C array</td>
<td align="right">0.75</td>
<td align="right">686</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix fast</td>
<td align="right">0.99</td>
<td align="right">520</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; fast</td>
<td align="right">1.29</td>
<td align="right">399</td>
</tr>
<tr>
<td>c_matrix safe</td>
<td align="right">1.7</td>
<td align="right">303</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; safe</td>
<td align="right">3.14</td>
<td align="right">164</td>
</tr>
<tr>
<td rowspan="5">prod (matrix, matrix)</td>
<td>C array</td>
<td align="right">0.94</td>
<td align="right">457</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix fast</td>
<td align="right">1.17</td>
<td align="right">367</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; fast</td>
<td align="right">1.34</td>
<td align="right">320</td>
</tr>
<tr>
<td>c_matrix safe</td>
<td align="right">1.56</td>
<td align="right">275</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; safe</td>
<td align="right">2.06</td>
<td align="right">208</td>
</tr>
</tbody>
</table>
<p>We notice a two fold 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.</p>
<p>Next we comment the results for double vectors and matrices of
dimension 100 and 100 x 100, respectively.</p>
<table border="1" summary="2nd benchmark">
<tbody>
<tr>
<th align="left">Operation</th>
<th align="left">Implementation</th>
<th align="left">Elapsed [s]</th>
<th align="left">MFLOP/s</th>
<th align="left">Comment</th>
</tr>
<tr>
<td rowspan="3">inner_prod</td>
<td>C array</td>
<td align="right">0.64</td>
<td align="right">889</td>
<td rowspan="3">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_vector</td>
<td align="right">0.66</td>
<td align="right">862</td>
</tr>
<tr>
<td>vector&lt;unbounded_array&gt;</td>
<td align="right">0.66</td>
<td align="right">862</td>
</tr>
<tr>
<td rowspan="5">vector + vector</td>
<td>C array</td>
<td align="right">0.64</td>
<td align="right">894</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_vector fast</td>
<td align="right">0.66</td>
<td align="right">867</td>
</tr>
<tr>
<td>vector&lt;unbounded_array&gt; fast</td>
<td align="right">0.66</td>
<td align="right">867</td>
</tr>
<tr>
<td>c_vector safe</td>
<td align="right">1.14</td>
<td align="right">501</td>
</tr>
<tr>
<td>vector&lt;unbounded_array&gt; safe</td>
<td align="right">1.23</td>
<td align="right">465</td>
</tr>
<tr>
<td rowspan="5">outer_prod</td>
<td>C array</td>
<td align="right">0.50</td>
<td align="right">1144</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix, c_vector fast</td>
<td align="right">0.71</td>
<td align="right">806</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt; fast</td>
<td align="right">0.57</td>
<td align="right">1004</td>
</tr>
<tr>
<td>c_matrix, c_vector safe</td>
<td align="right">1.91</td>
<td align="right">300</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt; safe</td>
<td align="right">0.89</td>
<td align="right">643</td>
</tr>
<tr>
<td rowspan="5">prod (matrix, vector)</td>
<td>C array</td>
<td align="right">0.65</td>
<td align="right">876</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix, c_vector fast</td>
<td align="right">0.65</td>
<td align="right">876</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt;
fast</td>
<td align="right">0.66</td>
<td align="right">863</td>
</tr>
<tr>
<td>c_matrix, c_vector safe</td>
<td align="right">0.66</td>
<td align="right">863</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt;, vector&lt;unbounded_array&gt;
safe</td>
<td align="right">0.66</td>
<td align="right">863</td>
</tr>
<tr>
<td rowspan="5">matrix + matrix</td>
<td>C array</td>
<td align="right">0.96</td>
<td align="right">596</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix fast</td>
<td align="right">1.21</td>
<td align="right">473</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; fast</td>
<td align="right">1.00</td>
<td align="right">572</td>
</tr>
<tr>
<td>c_matrix safe</td>
<td align="right">2.44</td>
<td align="right">235</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; safe</td>
<td align="right">1.30</td>
<td align="right">440</td>
</tr>
<tr>
<td rowspan="5">prod (matrix, matrix)</td>
<td>C array</td>
<td align="right">0.70</td>
<td align="right">813</td>
<td rowspan="5">No significant abstraction penalty</td>
</tr>
<tr>
<td>c_matrix fast</td>
<td align="right">0.73</td>
<td align="right">780</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; fast</td>
<td align="right">0.76</td>
<td align="right">749</td>
</tr>
<tr>
<td>c_matrix safe</td>
<td align="right">0.75</td>
<td align="right">759</td>
</tr>
<tr>
<td>matrix&lt;unbounded_array&gt; safe</td>
<td align="right">0.76</td>
<td align="right">749</td>
</tr>
</tbody>
</table>
<p>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.</p>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,319 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Special Products</title>
<meta name="GENERATOR" content="Quanta Plus" />
<meta name="AUTHOR" content="Gunter Winkler" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<link rel="stylesheet" type="text/css" href="doxygen.css" />
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Special Products </h1>
<div class="toc" id="toc"></div>
<h2>Functions</h2>
<table summary="" border=0 cellpadding=0 cellspacing=0>
<tr>
<td class="memItemLeft" nowrap align=right valign=top>template&lt;class V, class E1, class E2&gt; BOOST_UBLAS_INLINE V &amp;&nbsp;</td>
<td class="memItemRight" valign=bottom><a class="el" href="#ga8">axpy_prod</a> (const matrix_expression&lt; E1 &gt; &amp;e1, const vector_expression&lt; E2 &gt; &amp;e2, V &amp;v, bool init=true)</td></tr>
<tr>
<td class="mdescLeft">&nbsp;</td>
<td class="mdescRight">computes <code>v += A x</code> or <code>v = A x</code> in an optimized fashion. <a href="#ga8"></a><br /><br /></td></tr>
<tr>
<td class="memItemLeft" nowrap align=right valign=top>template&lt;class V, class E1, class E2&gt; BOOST_UBLAS_INLINE V &amp;&nbsp;</td>
<td class="memItemRight" valign=bottom><a class="el" href="#ga9">axpy_prod</a> (const vector_expression&lt; E1 &gt; &amp;e1, const matrix_expression&lt; E2 &gt; &amp;e2, V &amp;v, bool init=true)</td></tr>
<tr>
<td class="mdescLeft">&nbsp;</td>
<td class="mdescRight">computes <code>v += A<sup>T</sup> x</code> or <code>v = A<sup>T</sup> x</code> in an optimized fashion. <a href="#ga9"></a><br /><br /></td></tr>
<tr>
<td class="memItemLeft" nowrap align=right valign=top>template&lt;class M, class E1, class E2&gt; BOOST_UBLAS_INLINE M &amp;&nbsp;</td>
<td class="memItemRight" valign=bottom><a class="el" href="#ga7">axpy_prod</a> (const matrix_expression&lt; E1 &gt; &amp;e1, const matrix_expression&lt; E2 &gt; &amp;e2, M &amp;m, bool init=true)</td></tr>
<tr>
<td class="mdescLeft">&nbsp;</td>
<td class="mdescRight">computes <code>M += A X</code> or <code>M = A X</code> in an optimized fashion. <a href="#ga7"></a><br /><br /></td></tr>
<tr>
<td class="memItemLeft" nowrap align=right valign=top>template&lt;class M, class E1, class E2&gt; BOOST_UBLAS_INLINE M &amp;&nbsp;</td>
<td class="memItemRight" valign=bottom><a class="el" href="#ga6">opb_prod</a> (const matrix_expression&lt; E1 &gt; &amp;e1, const matrix_expression&lt; E2 &gt; &amp;e2, M &amp;m, bool init=true)</td></tr>
<tr>
<td class="mdescLeft">&nbsp;</td>
<td class="mdescRight">computes <code>M += A X</code> or <code>M = A X</code> in an optimized fashion. <a href="#ga6"></a><br /><br /></td></tr>
</table>
<hr />
<a class="anchor" name="ga8" doxytag="boost::numeric::ublas::axpy_prod" ></a>
<table summary="" class="mdTable" width="95%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> BOOST_UBLAS_INLINE V&amp; axpy_prod </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const matrix_expression&lt; E1 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const vector_expression&lt; E2 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>V &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>v</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>init</em> = <code>true</code></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
computes <code>v += A x</code> or <code>v = A x</code> in an optimized fashion.
</p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table summary="" border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>e1</em>&nbsp;</td><td>the matrix expression <code>A</code> </td></tr>
<tr><td></td><td valign=top><em>e2</em>&nbsp;</td><td>the vector expression <code>x</code> </td></tr>
<tr><td></td><td valign=top><em>v</em>&nbsp;</td><td>the result vector <code>v</code> </td></tr>
<tr><td></td><td valign=top><em>init</em>&nbsp;</td><td>a boolean parameter</td></tr>
</table>
</dl>
<code>axpy_prod(A, x, v, init)</code> implements the well known axpy-product. Setting <em>init</em> to <code>true</code> is equivalent to call <code>v.clear()</code> before <code>axpy_prod</code>. Currently <em>init</em> defaults to <code>true</code>, but this may change in the future.<p>
Up to now there are some specialisation for compressed matrices that give a large speed up compared to prod. </td>
</tr>
</table>
<a class="anchor" name="ga9" doxytag="boost::numeric::ublas::axpy_prod" ></a>
<table summary="" class="mdTable" width="95%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> BOOST_UBLAS_INLINE V&amp; axpy_prod </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const vector_expression&lt; E1 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const matrix_expression&lt; E2 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>V &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>v</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>init</em> = <code>true</code></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
computes <code>v += A<sup>T</sup> x</code> or <code>v = A<sup>T</sup> x</code> in an optimized fashion.
</p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table summary="" border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>e1</em>&nbsp;</td><td>the vector expression <code>x</code> </td></tr>
<tr><td></td><td valign=top><em>e2</em>&nbsp;</td><td>the matrix expression <code>A</code> </td></tr>
<tr><td></td><td valign=top><em>v</em>&nbsp;</td><td>the result vector <code>v</code> </td></tr>
<tr><td></td><td valign=top><em>init</em>&nbsp;</td><td>a boolean parameter</td></tr>
</table>
</dl>
<code>axpy_prod(x, A, v, init)</code> implements the well known axpy-product. Setting <em>init</em> to <code>true</code> is equivalent to call <code>v.clear()</code> before <code>axpy_prod</code>. Currently <em>init</em> defaults to <code>true</code>, but this may change in the future.<p>
Up to now there are some specialisation for compressed matrices that give a large speed up compared to prod. </td>
</tr>
</table>
<a class="anchor" name="ga7" doxytag="boost::numeric::ublas::axpy_prod" ></a>
<table summary="" class="mdTable" width="95%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> BOOST_UBLAS_INLINE M&amp; axpy_prod </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const matrix_expression&lt; E1 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const matrix_expression&lt; E2 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>M &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>init</em> = <code>true</code></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
computes <code>M += A X</code> or <code>M = A X</code> in an optimized fashion.
</p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table summary="" border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>e1</em>&nbsp;</td><td>the matrix expression <code>A</code> </td></tr>
<tr><td></td><td valign=top><em>e2</em>&nbsp;</td><td>the matrix expression <code>X</code> </td></tr>
<tr><td></td><td valign=top><em>m</em>&nbsp;</td><td>the result matrix <code>M</code> </td></tr>
<tr><td></td><td valign=top><em>init</em>&nbsp;</td><td>a boolean parameter</td></tr>
</table>
</dl>
<code>axpy_prod(A, X, M, init)</code> implements the well known axpy-product. Setting <em>init</em> to <code>true</code> is equivalent to call <code>M.clear()</code> before <code>axpy_prod</code>. Currently <em>init</em> defaults to <code>true</code>, but this may change in the future.<p>
Up to now there are no specialisations. </td>
</tr>
</table>
<a class="anchor" name="ga6" doxytag="boost::numeric::ublas::opb_prod" ></a>
<table summary="" class="mdTable" width="95%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table summary="" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> BOOST_UBLAS_INLINE M&amp; opb_prod </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const matrix_expression&lt; E1 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e1</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const matrix_expression&lt; E2 &gt; &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>e2</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>M &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>m</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>init</em> = <code>true</code></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table summary="" cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
computes <code>M += A X</code> or <code>M = A X</code> in an optimized fashion.
</p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table summary="" border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>e1</em>&nbsp;</td><td>the matrix expression <code>A</code> </td></tr>
<tr><td></td><td valign=top><em>e2</em>&nbsp;</td><td>the matrix expression <code>X</code> </td></tr>
<tr><td></td><td valign=top><em>m</em>&nbsp;</td><td>the result matrix <code>M</code> </td></tr>
<tr><td></td><td valign=top><em>init</em>&nbsp;</td><td>a boolean parameter</td></tr>
</table>
</dl>
<code>opb_prod(A, X, M, init)</code> implements the well known axpy-product. Setting <em>init</em> to <code>true</code> is equivalent to call <code>M.clear()</code> before <code>opb_prod</code>. Currently <em>init</em> defaults to <code>true</code>, but this may change in the future.<p>
This function may give a speedup if <code>A</code> has less columns than rows, because the product is computed as a sum of outer products. </td>
</tr>
</table>
<hr />
<p>Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
Joerg Walter, Gunter Winkler<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,229 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Range and slice</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />Range and Slice Storage</h1>
<div class="toc" id="toc"></div>
<h2 id="range"><a name="range" id="range"></a>Range&lt;SizeType,DistanceType&gt;</h2>
<h4>Description</h4>
<p>The class <code>range</code> specifies a range of indicies. The range is a sequence of indices
from a start value to stop value. The indices increase by one and exlude the stop value.
<code>range</code> can therefore be used to specify ranges of elements from vectors and matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
range r (0, 3);
for (unsigned i = 0; i &lt; r.size (); ++ i) {
std::cout &lt;&lt; r (i) &lt;&lt; std::endl;
}
}
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Model of</h4>
<p>Reversible Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Reversible
Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>range (size_type start, size_type stop)</code></td>
<td>Constructs a range of indicies from <code>start</code> to <code>stop (excluded)</code>
.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the beginning of the <code>range</code>.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value <code>start + i</code> of the <code>i</code>
-th element.</td>
</tr>
<tr>
<td><code>range compose (const range &amp;r) const</code></td>
<td>Returns the composite range from <code>start + r.start
()</code> to <code>start + r.start () + r.size ()</code>.</td>
</tr>
<tr>
<td><code>bool operator == (const range &amp;r) const</code></td>
<td>Tests two ranges for equality.</td>
</tr>
<tr>
<td><code>bool operator != (const range &amp;r) const</code></td>
<td>Tests two ranges for inequality.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>range</code>.</td>
</tr>
</tbody>
</table>
<h4>Preconditions</h4>
<ul>
<li><code>start () &lt;= stop ()</code></li>
</ul>
<h2 id="slice"><a name="slice" id="slice"></a>Slice&lt;SizeType,DistanceType&gt;</h2>
<h4>Description</h4>
<p>The class <code>slice</code> specifies a 'slice' of indicies. Slices are more general
then ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element.
<code>slice</code> can therefore be used to specify slices of element from vectors and matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;
int main () {
using namespace boost::numeric::ublas;
slice s (0, 1, 3);
for (unsigned i = 0; i &lt; s.size (); ++ i) {
std::cout &lt;&lt; s (i) &lt;&lt; std::endl;
}
}
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Model of</h4>
<p>Reversible Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Reversible
Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>slice (size_type start, size_type stride, size_type
size)</code></td>
<td>Constructs a slice <code>start,start+stride,start+2*stride...</code> with
<code>size</code> elements.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the beginning of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>size_type stride () const</code></td>
<td>Returns the stride of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value <code>start + i * stride</code> of the
<code>i</code>-th element.</td>
</tr>
<tr>
<td><code>slice compose (const range &amp;r) const</code></td>
<td>Returns the composite slice from <code>start + stride * r.start
()</code> to <code>start + stride * (r.start () + r.size ())</code>
with stride <code>stride</code>.</td>
</tr>
<tr>
<td><code>slice compose (const slice &amp;s) const</code></td>
<td>Returns the composite slice from <code>start + stride * s.start
()</code> to <code>start + stride * s.stride () * (s.start () +
s.size ())</code> with stride <code>stride * s.stride ()</code>
.</td>
</tr>
<tr>
<td><code>bool operator == (const slice &amp;s) const</code></td>
<td>Tests two slices for equality.</td>
</tr>
<tr>
<td><code>bool operator != (const slice &amp;s) const</code></td>
<td>Tests two slices for inequality.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>slice</code>.</td>
</tr>
</tbody>
</table>
<h4>Preconditions</h4>
<ul>
<li>None all strides are vaild. However when an index is returned or an iterator is dereferenced its
value must be representable as the size_type.</li>
</ul>
<hr/>
<p>
Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
Joerg Walter, Gunter Winkler<br />
Use, modification and distribution are subject to the
Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,84 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<!-- tidy options: -w 120 -asxhtml -clean - - vertical-space yes -f index.htm.err -m index.htm -->
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
<link rel="stylesheet" href="ublas.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
<title>Boost Basic Linear Algebra - Release Notes</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" alt="logo"/>Boost Basic Linear Algebra - Release Notes</h1>
<div class="navigation">
<a href="index.htm">back to uBLAS home</a>
</div>
<div class="toc" id="toc"></div>
<h2>Release 1.43.0</h2>
<h3>bug fixes</h3>
<ul>
<li><a href="https://svn.boost.org/trac/boost/ticket/3968">[3968]</a> fixed coordinate_matrix sort problem on MSVC10
</li>
<li><a href="https://svn.boost.org/trac/boost/ticket/3539">[3539]</a>
changed computation of <code>norm_inf</code> for complex types to match
mathematical definition. <br />
<b>Note:</b> This might cause a performance drop
because now <code>std::abs(z)</code> is called for each vector element.
The old implementation used <code>std::max(std::abs(real(z)),std::abs(imag(z))</code>.
Further <code>norm_inf</code> and <code>norm_1</code> will now return
the same values for complex vector.
</li>
<li><a href="https://svn.boost.org/trac/boost/ticket/3501">[3501]</a> Moved free functions in <code>concepts.hpp</code> into anonymous namespace.
</li>
</ul>
<h2>Release 1.41.1</h2>
<h3>new features</h3>
<ul>
<li>Move semantics of vector/matrix container assignments have been
implemented. They can be enabled by setting
BOOST_UBLAS_MOVE_SEMANTICS. More details are on the <a
href="options.htm">preprocessor options page</a>.
</li>
<li>Introduce new free functions. See <a href="https://svn.boost.org/trac/boost/ticket/3449" target="_blank">[3449]</a>,
the new tests in <tt>libs/numeric/ublas/test</tt> and the inline documentation of the files in <tt>boost/numeric/ublas/operation/</tt>.
</li>
</ul>
<h3>bug fixes</h3>
<ul>
<li><a href="https://svn.boost.org/trac/boost/ticket/3293">[3293]</a> Fix resizing problem in <code>identity_matrix</code>
</li>
<li><a href="https://svn.boost.org/trac/boost/ticket/3499">[3499]</a> Add DefaultConstructible to concept checks
</li>
</ul>
<h2>Release 1.40.0 and before</h2>
<ul>
<li>Release notes were not available in this form.</li>
</ul>
<hr />
<p>Copyright (&copy;) 2000-2009 Joerg Walter, Mathias Koch, Gunter Winkler<br />
Use, modification and distribution are subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt
</a>).
</p>
<!-- Created: Sun Sep 13 00:57:13 CEST 2009 -->
<script type="text/javascript">
(function($) {
$('#toc').toc();
})(jQuery);
</script>
</body>
</html>

View File

@@ -1,228 +0,0 @@
# Copyright Michael Stevens 2004
# Use, modification, and distribution is subject to the Boost Software
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# bring in rules for testing
# Boost uBLAS library documentation samples
# Project requirements
project samples
: requirements
<toolset>borland:<cxxflags>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092"
<toolset>kylix:<cxxflags>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092"
;
exe unbounded_array
: unbounded_array.cpp
;
exe bounded_array
: bounded_array.cpp
;
exe range
: range.cpp
;
exe slice
: slice.cpp
;
exe map_array
: map_array.cpp
;
exe vector
: vector.cpp
;
exe unit_vector
: unit_vector.cpp
;
exe zero_vector
: zero_vector.cpp
;
exe mapped_vector
: mapped_vector.cpp
;
exe compressed_vector
: compressed_vector.cpp
;
exe coordinate_vector
: coordinate_vector.cpp
;
exe vector_range
: vector_range.cpp
;
exe vector_range_project
: vector_range_project.cpp
;
exe vector_slice
: vector_slice.cpp
;
exe vector_slice_project
: vector_slice_project.cpp
;
exe vector_unary
: vector_unary.cpp
;
exe vector_binary
: vector_binary.cpp
;
exe vector_binary_outer
: vector_binary_outer.cpp
;
exe vector_binary_scalar
: vector_binary_scalar.cpp
;
exe vector_unary_redux
: vector_unary_redux.cpp
;
exe vector_binary_redux
: vector_binary_redux.cpp
;
exe matrix
: matrix.cpp
;
exe identity_matrix
: identity_matrix.cpp
;
exe zero_matrix
: zero_matrix.cpp
;
exe mapped_matrix
: mapped_matrix.cpp
;
exe compressed_matrix
: compressed_matrix.cpp
;
exe coordinate_matrix
: coordinate_matrix.cpp
;
exe matrix_row
: matrix_row.cpp
;
exe matrix_row_project
: matrix_row_project.cpp
;
exe matrix_column
: matrix_column.cpp
;
exe matrix_column_project
: matrix_column_project.cpp
;
exe matrix_vector_range
: matrix_vector_range.cpp
;
exe matrix_vector_slice
: matrix_vector_slice.cpp
;
exe matrix_range
: matrix_range.cpp
;
exe matrix_range_project
: matrix_range_project.cpp
;
exe matrix_slice
: matrix_slice.cpp
;
exe matrix_slice_project
: matrix_slice_project.cpp
;
exe matrix_unary
: matrix_unary.cpp
;
exe matrix_binary
: matrix_binary.cpp
: <include>$(BOOST_ROOT)
;
exe matrix_binary_scalar
: matrix_binary_scalar.cpp
;
exe matrix_vector_binary
: matrix_vector_binary.cpp
;
exe matrix_vector_solve
: matrix_vector_solve.cpp
;
exe matrix_matrix_binary
: matrix_matrix_binary.cpp
;
exe matrix_matrix_solve
: matrix_matrix_solve.cpp
;
exe banded_matrix
: banded_matrix.cpp
;
exe banded_adaptor
: banded_adaptor.cpp
;
exe hermitian_matrix
: hermitian_matrix.cpp
;
exe hermitian_adaptor
: hermitian_adaptor.cpp
;
exe symmetric_matrix
: symmetric_matrix.cpp
;
exe symmetric_adaptor
: symmetric_adaptor.cpp
;
exe triangular_matrix
: triangular_matrix.cpp
;
exe triangular_adaptor
: triangular_adaptor.cpp
;
exe ex_triangular
: ex_triangular.cpp
;

View File

@@ -1,25 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,24 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,23 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}
}

View File

@@ -1,24 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,23 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,24 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,23 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,58 +0,0 @@
// Copyright Gunter Winkler 2004 - 2009.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/io.hpp>
using std::cout;
using std::endl;
namespace ublas = boost::numeric::ublas;
int main(int argc, char * argv[] ) {
ublas::matrix<double> M (3, 3);
for (std::size_t i=0; i < M.data().size(); ++i) { M.data()[i] = 1+i ; }
std::cout << "full M = " << M << "\n" ;
ublas::triangular_matrix<double, ublas::lower> L;
ublas::triangular_matrix<double, ublas::unit_lower> UL;
ublas::triangular_matrix<double, ublas::strict_lower> SL;
L = ublas::triangular_adaptor<ublas::matrix<double>, ublas::lower> (M);
SL = ublas::triangular_adaptor<ublas::matrix<double>, ublas::strict_lower> (M);
UL = ublas::triangular_adaptor<ublas::matrix<double>, ublas::unit_lower> (M);
std::cout << "lower L = " << L << "\n"
<< "strict lower SL = " << SL << "\n"
<< "unit lower UL = " << UL << "\n" ;
ublas::triangular_matrix<double, ublas::upper> U;
ublas::triangular_matrix<double, ublas::unit_upper> UU;
ublas::triangular_matrix<double, ublas::strict_upper> SU;
U = ublas::triangular_adaptor<ublas::matrix<double>, ublas::upper> (M);
SU = ublas::triangular_adaptor<ublas::matrix<double>, ublas::strict_upper> (M);
UU = ublas::triangular_adaptor<ublas::matrix<double>, ublas::unit_upper> (M);
std::cout << "upper U = " << U << "\n"
<< "strict upper SU = " << SU << "\n"
<< "unit upper UU = " << UU << "\n" ;
std::cout << "M = L + SU ? " << ((norm_inf( M - (L + SU) ) == 0.0)?"ok":"failed") << "\n";
std::cout << "M = U + SL ? " << ((norm_inf( M - (U + SL) ) == 0.0)?"ok":"failed") << "\n";
}

View File

@@ -1,34 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,33 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,21 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,24 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/storage_sparse.hpp>
int main () {
using namespace boost::numeric::ublas;
map_array<int, double> a;
a.reserve (3);
for (unsigned i = 0; i < 3; ++ i) {
a [i] = i;
std::cout << a [i] << std::endl;
}
}

View File

@@ -1,24 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
mapped_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;
}

View File

@@ -1,23 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
mapped_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}

View File

@@ -1,24 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,26 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,26 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,27 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}
}

View File

@@ -1,26 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}
}

View File

@@ -1,25 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,25 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,26 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}

View File

@@ -1,25 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}

View File

@@ -1,27 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}
}

View File

@@ -1,26 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}
}

View File

@@ -1,26 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}

View File

@@ -1,25 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}

View File

@@ -1,30 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,29 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,27 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}

View File

@@ -1,27 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.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;
}

View File

@@ -1,29 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,22 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}
}

View File

@@ -1,22 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}
}

View File

@@ -1,30 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,29 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,30 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,29 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}

View File

@@ -1,23 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}
}

View File

@@ -1,23 +0,0 @@
//
// Copyright (c) 2000-2002
// Joerg Walter, Mathias Koch
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// GeNeSys mbH & Co. KG in producing this work.
//
#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;
}
}

Some files were not shown because too many files have changed in this diff Show More