mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-05 15:34:39 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
# 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
|
||||
;
|
||||
@@ -0,0 +1,319 @@
|
||||
//
|
||||
// Copyright (c) 2010 Athanasios Iliopoulos
|
||||
//
|
||||
// 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 <boost/numeric/ublas/assignment.hpp>
|
||||
#include <boost/numeric/ublas/vector.hpp>
|
||||
#include <boost/numeric/ublas/vector_proxy.hpp>
|
||||
#include <boost/numeric/ublas/matrix_proxy.hpp>
|
||||
#include <boost/numeric/ublas/vector_sparse.hpp>
|
||||
#include <boost/numeric/ublas/matrix_sparse.hpp>
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
#include <boost/numeric/ublas/matrix.hpp>
|
||||
|
||||
using namespace boost::numeric::ublas;
|
||||
|
||||
int main() {
|
||||
// Simple vector fill
|
||||
vector<double> a(3);
|
||||
a <<= 0, 1, 2;
|
||||
std::cout << a << std::endl;
|
||||
// [ 0 1 2]
|
||||
|
||||
// Vector from vector
|
||||
vector<double> b(7);
|
||||
b <<= a, 10, a;
|
||||
std::cout << b << std::endl;
|
||||
// [ 0 1 2 10 0 1 2]
|
||||
|
||||
// Simple matrix fill
|
||||
matrix<double> A(3,3);
|
||||
A <<= 0, 1, 2,
|
||||
3, 4, 5,
|
||||
6, 7, 8;
|
||||
std::cout << A << std::endl;
|
||||
// [ 0 1 2 ]
|
||||
// [ 3 4 5 ]
|
||||
// [ 6 7 8 ]
|
||||
|
||||
// Matrix from vector
|
||||
A <<= 0, 1, 2,
|
||||
3, 4, 5,
|
||||
a;
|
||||
std::cout << A << std::endl;
|
||||
// [ 0 1 2 ]
|
||||
// [ 3 4 5 ]
|
||||
// [ 0 1 2 ]
|
||||
|
||||
// Matrix from vector - column assignment
|
||||
A <<= move(0,2), traverse_policy::by_column(),
|
||||
a;
|
||||
std::cout << A << std::endl;
|
||||
// [ 0 1 0 ]
|
||||
// [ 3 4 1 ]
|
||||
// [ 0 1 2 ]
|
||||
|
||||
// Another matrix from vector example (watch the wraping);
|
||||
vector<double> c(9); c <<= 1, 2, 3, 4, 5, 6, 7, 8, 9;
|
||||
A <<= c;
|
||||
std::cout << A << std::endl;
|
||||
// [ 1 2 3 ]
|
||||
// [ 4 5 6 ]
|
||||
// [ 7 8 9 ]
|
||||
|
||||
// If for performance(Benchmarks are not definite about that) or consistency reasons you need to disable wraping:
|
||||
static next_row_manip endr; //This can be defined globally
|
||||
A <<= traverse_policy::by_row_no_wrap(),
|
||||
1, 2, 3, endr,
|
||||
4, 5, 6, endr,
|
||||
7, 8, 9, endr;
|
||||
// [ 1 2 3 ]
|
||||
// [ 4 5 6 ]
|
||||
// [ 7 8 9 ]
|
||||
// If by default you need to disable wraping define
|
||||
// BOOST_UBLAS_DEFAULT_NO_WRAP_POLICY, in the compilation options,
|
||||
// so that you avoid typing the "traverse_policy::by_row_no_wrap()".
|
||||
|
||||
// Plus and minus assign:
|
||||
A <<= fill_policy::index_plus_assign(),
|
||||
3,2,1;
|
||||
std::cout << A << std::endl;
|
||||
// [ 4 4 4 ]
|
||||
// [ 4 5 6 ]
|
||||
// [ 7 8 9 ]
|
||||
|
||||
// Matrix from proxy
|
||||
A <<= 0, 1, 2,
|
||||
project(b, range(3,6)),
|
||||
a;
|
||||
std::cout << A << std::endl;
|
||||
// [ 0 1 2 ]
|
||||
// [10 0 1 ]
|
||||
// [ 6 7 8 ]
|
||||
|
||||
// Matrix from matrix
|
||||
matrix<double> B(6,6);
|
||||
B <<= A, A,
|
||||
A, A;
|
||||
std::cout << B << std::endl;
|
||||
// [ A A ]
|
||||
// [ A A ]
|
||||
|
||||
// Matrix range (vector is similar)
|
||||
B = zero_matrix<double>(6,6);
|
||||
matrix_range<matrix<double> > mrB (B, range (1, 4), range (1, 4));
|
||||
mrB <<= 1,2,3,4,5,6,7,8,9;
|
||||
std::cout << B << std::endl;
|
||||
// [ 0 0 0 0 0 0]
|
||||
// [ 0 1 2 3 0 0]
|
||||
// [ 0 4 5 6 0 0]
|
||||
// [ 0 0 0 0 0 0]
|
||||
// [ 0 0 0 0 0 0]
|
||||
// [ 0 0 0 0 0 0]
|
||||
|
||||
// Horizontal concatenation can be achieved using this trick:
|
||||
matrix<double> BH(3,9);
|
||||
BH <<= A, A, A;
|
||||
std::cout << BH << std::endl;
|
||||
// [ A A A]
|
||||
|
||||
// Vertical concatenation can be achieved using this trick:
|
||||
matrix<double> BV(9,3);
|
||||
BV <<= A,
|
||||
A,
|
||||
A;
|
||||
std::cout << BV << std::endl;
|
||||
// [ A ]
|
||||
// [ A ]
|
||||
// [ A ]
|
||||
|
||||
// Watch the difference when assigning matrices for different traverse policies:
|
||||
matrix<double> BR(9,9, 0);
|
||||
BR <<= traverse_policy::by_row(), // This is the default, so this might as well be omitted.
|
||||
A, A, A;
|
||||
std::cout << BR << std::endl;
|
||||
// [ A A A]
|
||||
// [ 0 0 0]
|
||||
// [ 0 0 0]
|
||||
|
||||
matrix<double> BC(9,9, 0);
|
||||
BC <<= traverse_policy::by_column(),
|
||||
A, A, A;
|
||||
std::cout << BC << std::endl;
|
||||
// [ A 0 0]
|
||||
// [ A 0 0]
|
||||
// [ A 0 0]
|
||||
|
||||
// The following will throw a run-time exception in debug mode (matrix mid-assignment wrap is not allowed) :
|
||||
// matrix<double> C(7,7);
|
||||
// C <<= A, A, A;
|
||||
|
||||
// Matrix from matrix with index manipulators
|
||||
matrix<double> C(6,6,0);
|
||||
C <<= A, move(3,0), A;
|
||||
// [ A 0 ]
|
||||
// [ 0 A ]
|
||||
|
||||
// A faster way for to construct this dense matrix.
|
||||
matrix<double> D(6,6);
|
||||
D <<= A, zero_matrix<double>(3,3),
|
||||
zero_matrix<double>(3,3), A;
|
||||
// [ A 0 ]
|
||||
// [ 0 A ]
|
||||
|
||||
// The next_row and next_column index manipulators:
|
||||
// note: next_row and next_column functions return
|
||||
// a next_row_manip and and next_column_manip object.
|
||||
// This is the manipulator we used earlier when we disabled
|
||||
// wrapping.
|
||||
matrix<double> E(2,4,0);
|
||||
E <<= 1, 2, next_row(),
|
||||
3, 4, next_column(),5;
|
||||
std::cout << E << std::endl;
|
||||
// [ 1 2 0 5 ]
|
||||
// [ 3 4 0 0 ]
|
||||
|
||||
// The begin1 (moves to the begining of the column) index manipulator, begin2 does the same for the row:
|
||||
matrix<double> F(2,4,0);
|
||||
F <<= 1, 2, next_row(),
|
||||
3, 4, begin1(),5;
|
||||
std::cout << F << std::endl;
|
||||
// [ 1 2 5 0 ]
|
||||
// [ 3 4 0 0 ]
|
||||
|
||||
// The move (relative) and move_to(absolute) index manipulators (probably the most useful manipulators):
|
||||
matrix<double> G(2,4,0);
|
||||
G <<= 1, 2, move(0,1), 3,
|
||||
move_to(1,3), 4;
|
||||
std::cout << G << std::endl;
|
||||
// [ 1 2 0 3 ]
|
||||
// [ 0 0 0 4 ]
|
||||
|
||||
// Static equivallents (faster) when sizes are known at compile time:
|
||||
matrix<double> Gs(2,4,0);
|
||||
Gs <<= 1, 2, move<0,1>(), 3,
|
||||
move_to<1,3>(), 4;
|
||||
std::cout << Gs << std::endl;
|
||||
// [ 1 2 0 3 ]
|
||||
// [ 0 0 0 4 ]
|
||||
|
||||
// Choice of traverse policy (default is "row by row" traverse):
|
||||
|
||||
matrix<double> H(2,4,0);
|
||||
H <<= 1, 2, 3, 4,
|
||||
5, 6, 7, 8;
|
||||
std::cout << H << std::endl;
|
||||
// [ 1 2 3 4 ]
|
||||
// [ 5 6 7 8 ]
|
||||
|
||||
H <<= traverse_policy::by_column(),
|
||||
1, 2, 3, 4,
|
||||
5, 6, 7, 8;
|
||||
std::cout << H << std::endl;
|
||||
// [ 1 3 5 7 ]
|
||||
// [ 2 4 6 8 ]
|
||||
|
||||
// traverse policy can be changed mid assignment if desired.
|
||||
matrix<double> H1(4,4,0);
|
||||
H1 <<= 1, 2, 3, traverse_policy::by_column(), 1, 2, 3;
|
||||
|
||||
std::cout << H << std::endl;
|
||||
// [1 2 3 1]
|
||||
// [0 0 0 2]
|
||||
// [0 0 0 3]
|
||||
// [0 0 0 0]
|
||||
|
||||
// note: fill_policy and traverse_policy are namespaces, so you can use them
|
||||
// by a using statement.
|
||||
|
||||
// For compressed and coordinate matrix types a push_back or insert fill policy can be chosen for faster assginment:
|
||||
compressed_matrix<double> I(2, 2);
|
||||
I <<= fill_policy::sparse_push_back(),
|
||||
0, 1, 2, 3;
|
||||
std::cout << I << std::endl;
|
||||
// [ 0 1 ]
|
||||
// [ 2 3 ]
|
||||
|
||||
coordinate_matrix<double> J(2,2);
|
||||
J<<=fill_policy::sparse_insert(),
|
||||
1, 2, 3, 4;
|
||||
std::cout << J << std::endl;
|
||||
// [ 1 2 ]
|
||||
// [ 3 4 ]
|
||||
|
||||
// A sparse matrix from another matrix works as with other types.
|
||||
coordinate_matrix<double> K(3,3);
|
||||
K<<=fill_policy::sparse_insert(),
|
||||
J;
|
||||
std::cout << K << std::endl;
|
||||
// [ 1 2 0 ]
|
||||
// [ 3 4 0 ]
|
||||
// [ 0 0 0 ]
|
||||
|
||||
// Be careful this will not work:
|
||||
//compressed_matrix<double> J2(4,4);
|
||||
//J2<<=fill_policy::sparse_push_back(),
|
||||
// J,J;
|
||||
// That's because the second J2's elements
|
||||
// are attempted to be assigned at positions
|
||||
// that come before the elements already pushed.
|
||||
// Unfortunatelly that's the only thing you can do in this case
|
||||
// (or of course make a custom agorithm):
|
||||
compressed_matrix<double> J2(4,4);
|
||||
J2<<=fill_policy::sparse_push_back(),
|
||||
J, fill_policy::sparse_insert(),
|
||||
J;
|
||||
|
||||
std::cout << J2 << std::endl;
|
||||
// [ J J ]
|
||||
// [ 0 0 0 0 ]
|
||||
// [ 0 0 0 0 ]
|
||||
|
||||
// A different traverse policy doesn't change the result, only they order it is been assigned.
|
||||
coordinate_matrix<double> L(3,3);
|
||||
L<<=fill_policy::sparse_insert(), traverse_policy::by_column(),
|
||||
J;
|
||||
std::cout << L << std::endl;
|
||||
// (same as previous)
|
||||
// [ 1 2 0 ]
|
||||
// [ 3 4 0 ]
|
||||
// [ 0 0 0 ]
|
||||
|
||||
typedef coordinate_matrix<double>::size_type cmst;
|
||||
const cmst size = 30;
|
||||
//typedef fill_policy::sparse_push_back spb;
|
||||
// Although the above could have been used the following is may be faster if
|
||||
// you use the policy often and for relatively small containers.
|
||||
static fill_policy::sparse_push_back spb;
|
||||
|
||||
// A block diagonal sparse using a loop:
|
||||
compressed_matrix<double> M(size, size, 4*15);
|
||||
for (cmst i=0; i!=size; i+=J.size1())
|
||||
M <<= spb, move_to(i,i), J;
|
||||
|
||||
|
||||
// If typedef was used above the last expression should start
|
||||
// with M <<= spb()...
|
||||
|
||||
// Displaying so that blocks can be easily seen:
|
||||
for (unsigned int i=0; i!=M.size1(); i++) {
|
||||
std::cout << M(i,0);
|
||||
for (unsigned int j=1; j!=M.size2(); j++) std::cout << ", " << M(i,j);
|
||||
std::cout << "\n";
|
||||
}
|
||||
// [ J 0 0 0 ... 0]
|
||||
// [ 0 J 0 0 ... 0]
|
||||
// [ 0 . . . ... 0]
|
||||
// [ 0 0 ... 0 0 J]
|
||||
|
||||
|
||||
// A "repeat" trasverser may by provided so that this becomes faster and an on-liner like:
|
||||
// M <<= spb, repeat(0, size, J.size1(), 0, size, J.size1()), J;
|
||||
// An alternate would be to create a :repeater" matrix and vector expression that can be used in other places as well. The latter is probably better,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// 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";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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;
|
||||
vector<double> v (3);
|
||||
for (unsigned i = 0; i < v.size (); ++ i)
|
||||
v (i) = i;
|
||||
std::cout << v << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
vector<double> v1 (3), v2 (3);
|
||||
for (unsigned i = 0; i < (std::min) (v1.size (), v2.size ()); ++ i)
|
||||
v1 (i) = v2 (i) = i;
|
||||
|
||||
std::cout << v1 + v2 << std::endl;
|
||||
std::cout << v1 - v2 << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
vector<double> v1 (3), v2 (3);
|
||||
for (unsigned i = 0; i < (std::min) (v1.size (), v2.size ()); ++ i)
|
||||
v1 (i) = v2 (i) = i;
|
||||
|
||||
std::cout << outer_prod (v1, v2) << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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>
|
||||
|
||||
int main () {
|
||||
using namespace boost::numeric::ublas;
|
||||
vector<double> v1 (3), v2 (3);
|
||||
for (unsigned i = 0; i < (std::min) (v1.size (), v2.size ()); ++ i)
|
||||
v1 (i) = v2 (i) = i;
|
||||
|
||||
std::cout << inner_prod (v1, v2) << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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;
|
||||
vector<double> v (3);
|
||||
for (unsigned i = 0; i < v.size (); ++ i)
|
||||
v (i) = i;
|
||||
|
||||
std::cout << 2.0 * v << std::endl;
|
||||
std::cout << v * 2.0 << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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/vector_proxy.hpp>
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
|
||||
int main () {
|
||||
using namespace boost::numeric::ublas;
|
||||
vector<double> v (3);
|
||||
vector_range<vector<double> > vr (v, range (0, 3));
|
||||
for (unsigned i = 0; i < vr.size (); ++ i)
|
||||
vr (i) = i;
|
||||
std::cout << vr << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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/vector_proxy.hpp>
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
|
||||
int main () {
|
||||
using namespace boost::numeric::ublas;
|
||||
vector<double> v (3);
|
||||
for (int i = 0; i < 3; ++ i)
|
||||
project (v, range (0, 3)) (i) = i;
|
||||
std::cout << project (v, range (0, 3)) << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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/vector_proxy.hpp>
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
|
||||
int main () {
|
||||
using namespace boost::numeric::ublas;
|
||||
vector<double> v (3);
|
||||
vector_slice<vector<double> > vs (v, slice (0, 1, 3));
|
||||
for (unsigned i = 0; i < vs.size (); ++ i)
|
||||
vs (i) = i;
|
||||
std::cout << vs << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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/vector_proxy.hpp>
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
|
||||
int main () {
|
||||
using namespace boost::numeric::ublas;
|
||||
vector<double> v (3);
|
||||
for (int i = 0; i < 3; ++ i)
|
||||
project (v, slice (0, 1, 3)) (i) = i;
|
||||
std::cout << project (v, slice (0, 1, 3)) << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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;
|
||||
vector<std::complex<double> > v (3);
|
||||
for (unsigned i = 0; i < v.size (); ++ i)
|
||||
v (i) = std::complex<double> (i, i);
|
||||
|
||||
std::cout << - v << std::endl;
|
||||
std::cout << conj (v) << std::endl;
|
||||
std::cout << real (v) << std::endl;
|
||||
std::cout << imag (v) << std::endl;
|
||||
std::cout << trans (v) << std::endl;
|
||||
std::cout << herm (v) << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// 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>
|
||||
|
||||
int main () {
|
||||
using namespace boost::numeric::ublas;
|
||||
vector<double> v (3);
|
||||
for (unsigned i = 0; i < v.size (); ++ i)
|
||||
v (i) = i;
|
||||
|
||||
std::cout << sum (v) << std::endl;
|
||||
std::cout << norm_1 (v) << std::endl;
|
||||
std::cout << norm_2 (v) << std::endl;
|
||||
std::cout << norm_inf (v) << std::endl;
|
||||
std::cout << index_norm_inf (v) << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// 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;
|
||||
zero_matrix<double> m (3, 3);
|
||||
std::cout << m << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// 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;
|
||||
zero_vector<double> v (3);
|
||||
std::cout << v << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user