diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index ff1f80e1..363644b1 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -19,49 +19,9 @@ else (Sphinx_Math_Generator_MathJax)
endif (Sphinx_Math_Generator_MathJax)
# the local extensions....
-file(COPY ../foreignlibs/breathe ../foreignlibs/doxylink ../foreignlibs/mpl ../foreignlibs/autocompile DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY ../foreignlibs/breathe ../foreignlibs/doxylink ../foreignlibs/mpl ../foreignlibs/autorun ../foreignlibs/triqs_example DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-# The compiler flags for autocompile
-set(TRIQS_LIBRARY_ALL ${TRIQS_LIBRARY_BOOST} ${TRIQS_LIBRARY_PYTHON} ${TRIQS_LIBRARY_MPI} ${TRIQS_LIBRARY_HDF5} ${TRIQS_LIBRARY_LAPACK} ${TRIQS_LIBRARY_FFTW} ${TRIQS_LIBRARY_GMP} ${TRIQS_LIBRARY_GSL} )
-set(TRIQS_INCLUDE_ALL ${TRIQS_INCLUDE_BOOST} ${TRIQS_INCLUDE_PYTHON} ${TRIQS_INCLUDE_MPI} ${TRIQS_INCLUDE_HDF5} ${TRIQS_INCLUDE_LAPACK} ${TRIQS_INCLUDE_FFTW} ${TRIQS_INCLUDE_GMP} ${TRIQS_INCLUDE_GSL} )
-
-set( link_libs " ${TRIQS_LIBRARY_ALL}")
-if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- list (REMOVE_DUPLICATES link_libs)
-endif( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-string(REPLACE "debug" " " TMP "${link_libs}")
-string(REPLACE "optimized" " " TMP "${TMP}")
-
-set(DOC_AUTOCOMPILE_INCLUDE ${CMAKE_SOURCE_DIR} ${TRIQS_INCLUDE_ALL})
-if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- set(DOC_AUTOCOMPILE_LINK "${TRIQS_LIBRARY_BOOST} -L ${CMAKE_BINARY_DIR}/triqs -ltriqs ${TMP}")
- set(DOC_AUTOCOMPILE_DEFINITIONS -std=c++0x -DBOOST_PP_VARIADICS=1 -stdlib=libc++ -I/System/Library/Frameworks/vecLib.framework/Versions/A/Headers)
-else()
- set(DOC_AUTOCOMPILE_LINK "${TRIQS_LIBRARY_BOOST} -L ${CMAKE_BINARY_DIR}/triqs -ltriqs ${TMP} -Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR} ")
- set(DOC_AUTOCOMPILE_DEFINITIONS -std=c++0x -DBOOST_PP_VARIADICS=1 )
-endif()
-set(DOC_AUTOCOMPILE_LD_LIBRARY_PATH "${CMAKE_BINARY_DIR}/triqs")
-set(DOC_AUTOCOMPILE_DEFINITIONS ${DOC_AUTOCOMPILE_DEFINITIONS} -DTRIQS_BUILDING_LIBRARY -I ${CMAKE_BINARY_DIR}/Config )
-
-# debug
-#message( " Link libs ${DOC_AUTOCOMPILE_LINK}")
-
-EXECUTE_PROCESS(COMMAND sh -c "ln -sf ${CMAKE_BINARY_DIR}/triqs/libtriqs.so ${CMAKE_CURRENT_BINARY_DIR}")
-
-# Dive and find the doxygen sources
-add_subdirectory(reference/c++)
-
-# Build the doxygen
-set(DOXYGEN_HTML_OUTPUT ./html/doxy_triqs)
-find_package(Doxygen REQUIRED)
-
-# debug
-get_property(DOXYGEN_SOURCES GLOBAL PROPERTY DOXYGEN_SOURCES)
-string(REPLACE ";" " " DOXYGEN_SOURCES_LIST "${DOXYGEN_SOURCES}")
-#message(STATUS "Doxygen sources are ${DOXYGEN_SOURCES}")
-
-# Prepare the Doxyfile
-configure_file(${TRIQS_SOURCE_DIR}/cmake/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+#EXECUTE_PROCESS(COMMAND sh -c "ln -sf ${CMAKE_BINARY_DIR}/triqs/libtriqs.so ${CMAKE_CURRENT_BINARY_DIR}")
# Generate the conf.py
FILE(GLOB_RECURSE SOURCES *.rst)
@@ -70,6 +30,41 @@ EXECUTE_PROCESS(COMMAND sh -c "mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/html")
set(DOC_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
include(${TRIQS_SOURCE_DIR}/cmake/BuildSphinx.cmake)
+# for the C++ compilation of tests
+include_directories( ${CMAKE_SOURCE_DIR} )
+
+#set( link_libs " ${TRIQS_LIBRARY_ALL}")
+SET( link_libs ${LAPACK_LIBS} ${BOOST_LIBRARY} )
+IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ list (REMOVE_DUPLICATES link_libs)
+ENDIF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+link_libraries( ${link_libs} triqs)
+
+macro(all_tests )
+FILE(GLOB ExampleList RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
+FOREACH(example ${ExampleList})
+ STRING(REPLACE ".cpp" "" example_short ${example})
+ add_executable( doc_${example_short} ${CMAKE_CURRENT_SOURCE_DIR}/${example})
+ add_dependencies(docs_sphinx doc_${example_short}) ## so that all code examples are compiled before the doc
+ add_test_C_simple( doc_${example_short} )
+ #add_test ( ${example_short} ${example_short})
+ENDFOREACH()
+endmacro()
+
+# Dive and find the doxygen sources
+add_subdirectory(reference/c++)
+add_subdirectory(tutorials/c++)
+
+# Build the doxygen
+set(DOXYGEN_HTML_OUTPUT ./html/doxy_triqs)
+find_package(Doxygen REQUIRED)
+get_property(DOXYGEN_SOURCES GLOBAL PROPERTY DOXYGEN_SOURCES)
+string(REPLACE ";" " " DOXYGEN_SOURCES_LIST "${DOXYGEN_SOURCES}")
+#message(STATUS "Doxygen sources are ${DOXYGEN_SOURCES}")
+
+# Prepare the Doxyfile
+configure_file(${TRIQS_SOURCE_DIR}/cmake/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+
# Set dependencies
GET_PROPERTY(PYTHON_DYNAMIC_MODULES_LIST GLOBAL PROPERTY PYTHON_DYNAMIC_MODULES_LIST)
foreach (mod ${PYTHON_DYNAMIC_MODULES_LIST})
diff --git a/doc/_tools/split_code.py b/doc/_tools/split_code.py
new file mode 100644
index 00000000..c1236646
--- /dev/null
+++ b/doc/_tools/split_code.py
@@ -0,0 +1,49 @@
+import glob,re,os
+
+def work(arg, dirname, names):
+
+ for fil in glob.glob(dirname+ "/*.rst") :
+
+ fi = fil[:-4]
+ lines = open(fil).readlines()
+ out = open(fi + ".rst", 'w')
+ def get_decal(line) : return len(line) - len(line.lstrip())
+
+ reading = False
+ ex_list = []
+ for line in lines :
+
+ if re.match("\s*.. compileblock\s*::.*",line) :
+ assert not reading
+ decal = get_decal(line)
+ reading = True
+ current_ex = []
+ out.write(decal*' ' + ".. triqs_example:: ./" + fi.rsplit('/',1)[-1] + "_%s"%len(ex_list) + ".cpp\n")
+ continue
+
+ if reading :
+ if line.strip()=='' or get_decal(line) > decal :
+ current_ex.append(line)
+ continue
+ else :
+ reading = False
+ ex_list.append(current_ex)
+
+ out.write(line)
+
+ if reading : ex_list.append(current_ex)
+
+ for n,ex in enumerate(ex_list) :
+ filename = fi + "_%s.cpp"%n
+ out = open(filename,'w')
+ print filename
+ for l in ex :
+ out.write(l)
+ #os.system("vim -c '%
+
+os.path.walk('./', work, None)
+
+# then
+#find . -name "*_?.cpp" | xargs mvim
+#macro ggVG Ctrl K
+# :bufdo execute "normal! @a" | w:bufdo execute "normal! @a" | w
diff --git a/doc/conf.py.in b/doc/conf.py.in
index d8644264..4e376935 100644
--- a/doc/conf.py.in
+++ b/doc/conf.py.in
@@ -22,7 +22,7 @@ import sys, os
# ---------------------
sys.path +=[ #"@CMAKE_BINARY_DIR@/doc/breathe",
-"@CMAKE_BINARY_DIR@/doc/mpl","@CMAKE_BINARY_DIR@/doc/autocompile",
+"@CMAKE_BINARY_DIR@/doc/mpl", "@CMAKE_BINARY_DIR@/doc/autorun", "@CMAKE_BINARY_DIR@/doc/triqs_example",
"@CMAKE_BINARY_DIR@/doc/sandbox","@CMAKE_BINARY_DIR@/doc"]
# Add any Sphinx extension module names here, as strings. They can be extensions
@@ -40,15 +40,7 @@ extensions += [
# 'inheritance_diagram',
'numpydoc']
-extensions += ['autocompile','autorun']
-
-##options for autocompile module: c++ execution
-autocompile_opts = dict(compiler = "@CMAKE_CXX_COMPILER@",
- link = "@DOC_AUTOCOMPILE_LINK@".replace(';',' '),
- ld_library_path = "@DOC_AUTOCOMPILE_LD_LIBRARY_PATH@".replace(';',' '),
- include =''.join([ " -I%s"%arg for arg in "@DOC_AUTOCOMPILE_INCLUDE@".split(';')] ),
- definitions =''.join([ " %s"%arg for arg in "@DOC_AUTOCOMPILE_DEFINITIONS@".split(';')] )
- )
+extensions += ['autorun', 'triqs_example']
##options for autorun module: python execution
autorun_languages = {}
diff --git a/doc/overview.rst b/doc/overview.rst
deleted file mode 100644
index 517acd81..00000000
--- a/doc/overview.rst
+++ /dev/null
@@ -1,209 +0,0 @@
-TRIQS in a nutshell
-===================
-
-TRIQS is a toolbox containing **ready-to-use applications**, **python modules** as well as **C++ libraries** aimed at physicists in the field of quantum interacting systems.
-
-Applications
-------------
-
-Interface to Wien2k for LDA+DMFT calculation
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-TRIQS allows you to turn band-structure calculations obtained from the Wien2k package to inputs to full-fledged LDA+DMFT calculations in a few lines!
-
-
-
-[example here]
-
-To learn more, see
-
-Solvers for impurity models
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-TRIQS comes with powerful numerical solvers for quantum impurity models.
-
-
-[example here]
-
-To learn more, see
-
-Python modules
---------------
-
-Green's functions
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-With TRIQS, the manipulation of Green's functions is made easy: construction of Green's functions in frequency and time domains (imaginary and real), Fourier transforms, visualization, tail computation...
-
-
-
-.. runblock:: python
-
- # Import the Green's functions
- from pytriqs.gf.local import GfImFreq, iOmega_n, inverse
-
- # Create the Matsubara-frequency Green's function and initialize it
- gw = GfImFreq(indices = [1], beta = 50, n_points = 1000, name = "imp")
- gw <<= inverse( iOmega_n + 0.5 )
-
-
- # Create an imaginary-time Green's function and plot it
- gt = GFBloc_ImTime(Indices = [1], Beta = 50)
- gt <<= InverseFourier(gw)
-
- #from pytriqs.plot.mpl_interface import oplot
- #oplot(g, '-o', x_window = (0,10))
-
- print gt(0.5)
-
-
-To learn more, see
-
-Lattice tools
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-With TRIQS, build a tight-binding model on any lattice in a few lines, and extract its density of states, dispersion...
-
-
-[example here]
-
-.. runblock:: python
-
- print 2+2 # this will give output
-
-
-To learn more, see
-
-C++ libraries
--------------
-
-
-Monte-Carlo library
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Set up a Monte-Carlo simulation in a few lines: you write the configuration, moves and measures, while TRIQS takes care of the Metropolis algorithm and parallelization of the code.
-
-
-.. compileblock::
-
- #include
- #include
- #include
-
- // the configuration: a spin, the inverse temperature, the external field
- struct configuration {
- int spin; double beta, h;
- configuration(double beta_, double h_) : spin(-1), beta(beta_), h(h_) {}
- };
-
- // a move: flip the spin
- struct flip {
- configuration & config;
-
- flip(configuration & config_) : config(config_) {}
-
- double attempt() { return std::exp(-2*config.spin*config.h*config.beta); }
- double accept() { config.spin*= -1; return 1.0; }
- void reject() {}
- };
-
- // a measurement: the magnetization
- struct compute_m {
- configuration & config;
- double Z, M;
-
- compute_m(configuration & config_) : config(config_), Z(0), M(0) {}
-
- void accumulate(double sign) { Z += sign; M += sign * config.spin; }
-
- void collect_results(boost::mpi::communicator const &c) {
- double sum_Z, sum_M;
- boost::mpi::reduce(c, Z, sum_Z, std::plus(), 0);
- boost::mpi::reduce(c, M, sum_M, std::plus(), 0);
-
- if (c.rank() == 0) {
- std::cout << "Magnetization: " << sum_M / sum_Z << std::endl << std::endl;
- }
- }
- };
-
- int main(int argc, char* argv[]) {
-
- // initialize mpi
- boost::mpi::environment env(argc, argv);
- boost::mpi::communicator world;
-
- // greeting
- if (world.rank() == 0) std::cout << "Isolated spin" << std::endl;
-
- // prepare the MC parameters
- int N_Cycles = 500000;
- int Length_Cycle = 10;
- int N_Warmup_Cycles = 1000;
- std::string Random_Name = "";
- int Random_Seed = 374982 + world.rank() * 273894;
- int Verbosity = (world.rank() == 0 ? 2 : 0);
-
- // construct a Monte Carlo loop
- triqs::mc_tools::mc_generic SpinMC(N_Cycles, Length_Cycle, N_Warmup_Cycles,
- Random_Name, Random_Seed, Verbosity);
-
- // parameters of the model
- double beta = 0.3;
- double field = 0.5;
-
- // construct configuration
- configuration config(beta, field);
-
- // add moves and measures
- SpinMC.add_move(flip(config), "flip move");
- SpinMC.add_measure(compute_m(config), "magnetization measure");
-
- // Run and collect results
- SpinMC.start(1.0, triqs::utility::clock_callback(600));
- SpinMC.collect_results(world);
-
- return 0;
- }
-
-To learn more, see
-
-Array library
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Create, manipulate and store powerful multi-dimensional arrays:
-
-
-.. highlight:: c
-
-
-.. compileblock::
-
- #include
- using triqs::arrays::array;
- int main(){
- array A(20);
- }
-
-To learn more, see
-
-Expression library: CLEF
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Write mathematical expressions in a seamless and computationally efficient way:
-
-
- .. compileblock::
-
- #include
- int main () {
- triqs::clef::placeholder <1> x_;
-
- auto e1 = cos(2*x_+1);
- auto e2 = abs(2*x_-1);
- auto e3 = floor(2*x_-1);
- auto e4 = pow(2*x_+1,2);
- }
-
-
-To learn more, see
diff --git a/doc/reference/c++/CMakeLists.txt b/doc/reference/c++/CMakeLists.txt
index e2bc51d3..a0f81c22 100644
--- a/doc/reference/c++/CMakeLists.txt
+++ b/doc/reference/c++/CMakeLists.txt
@@ -1,3 +1,4 @@
+
add_all_subdirectories_with_cmakelist()
diff --git a/doc/reference/c++/arrays/CMakeLists.txt b/doc/reference/c++/arrays/CMakeLists.txt
index 12643128..7dd9c19b 100644
--- a/doc/reference/c++/arrays/CMakeLists.txt
+++ b/doc/reference/c++/arrays/CMakeLists.txt
@@ -8,3 +8,7 @@ set_property(GLOBAL APPEND PROPERTY DOXYGEN_SOURCES
#${TRIQS_SOURCE_DIR}/triqs/arrays/vector.hpp
)
+all_tests()
+add_subdirectory(containers)
+
+
diff --git a/doc/reference/c++/arrays/IO.rst b/doc/reference/c++/arrays/IO.rst
index 2332206d..361aa047 100644
--- a/doc/reference/c++/arrays/IO.rst
+++ b/doc/reference/c++/arrays/IO.rst
@@ -14,26 +14,4 @@ MPI
The `value classes` (array, matrix, vector) can be bcasted, reduced,
with the boost.mpi library, e.g. :
-.. compileblock::
-
- #include
- #include
- using triqs::arrays::array;using triqs::clef::placeholder;
-
- int main() {
- boost::mpi::environment env;//argc, argv);
- boost::mpi::communicator world;
-
- array A (2,2), B(2,2),C(2,2);
- placeholder<0> i_; placeholder<1> j_;
- A(i_,j_) << (1+world.rank())*(10*i_+ j_);
-
- if (world.rank() ==0) std::cout<<" A = "< >(),0);
-
- int s= world.size();
- if (world.rank() ==0) std::cout<<" C = "<( (s*(s+1)/2) * A) <
+#include
+using triqs::arrays::array;
+using triqs::clef::placeholder;
+
+int main() {
+ boost::mpi::environment env; // argc, argv);
+ boost::mpi::communicator world;
+
+ array A(2, 2), B(2, 2), C(2, 2);
+ placeholder<0> i_;
+ placeholder<1> j_;
+ A(i_, j_) << (1 + world.rank()) * (10 * i_ + j_);
+
+ if (world.rank() == 0) std::cout << " A = " << A << std::endl;
+
+ boost::mpi::reduce(world, A, C, std::plus>(), 0);
+
+ int s = world.size();
+ if (world.rank() == 0) std::cout << " C = " << C << " should be " << array((s * (s + 1) / 2) * A) << std::endl;
+}
+
diff --git a/doc/reference/c++/arrays/algebras.rst b/doc/reference/c++/arrays/algebras.rst
index dabaaeb0..d8086bad 100644
--- a/doc/reference/c++/arrays/algebras.rst
+++ b/doc/reference/c++/arrays/algebras.rst
@@ -10,26 +10,7 @@ Arrays and matrices can be combined in formal algebraic expressions, which model
This algebraic expressions can therefore be used in assignment array/matrix contructors.
For example:
-.. compileblock::
-
- #include
- using triqs::arrays::array; using triqs::clef::placeholder;
- int main() {
- // init
- placeholder<0> i_; placeholder<1> j_;
- array A (2,2), B(2,2);
- A(i_,j_) << i_ + j_ ;
- B(i_,j_) << i_ - j_ ;
-
- // use expressions
- array C = A+ 2*B;
- array D = 0.5 * A; // Type promotion is automatic
- std::cout<< "A= "<< A<< std::endl;
- std::cout<< "B= "<< B<< std::endl;
- std::cout<< "C= "<< C<< std::endl;
- std::cout<< "D= "<< D<< std::endl;
- }
-
+.. triqs_example:: ./algebras_0.cpp
Arrays vs matrices
----------------------
@@ -37,16 +18,7 @@ Because their multiplication is not the same, arrays and matrices algebras can n
Mixing them in expression would therefore be meaningless and it is therefore not allowed.
However, you can always use e.g. `matrix_view` from a array of rank 2 :
-.. compileblock::
-
- #include
- using namespace triqs::arrays;
- int main() {
- array A(2,2); matrix M(2,2);
- //M + A; // --> ERROR. Rejected by the compiler.
- M + make_matrix_view(A); //--> OK.
- }
-
+.. triqs_example:: ./algebras_1.cpp
.. note::
Making such a view is very cheap, it only copies the index systems. Nevertheless
diff --git a/doc/reference/c++/arrays/algebras_0.cpp b/doc/reference/c++/arrays/algebras_0.cpp
new file mode 100644
index 00000000..5b02d4a8
--- /dev/null
+++ b/doc/reference/c++/arrays/algebras_0.cpp
@@ -0,0 +1,20 @@
+#include
+using triqs::arrays::array;
+using triqs::clef::placeholder;
+int main() {
+ // init
+ placeholder<0> i_;
+ placeholder<1> j_;
+ array A(2, 2), B(2, 2);
+ A(i_, j_) << i_ + j_;
+ B(i_, j_) << i_ - j_;
+
+ // use expressions
+ array C = A + 2 * B;
+ array D = 0.5 * A; // Type promotion is automatic
+ std::cout << "A= " << A << std::endl;
+ std::cout << "B= " << B << std::endl;
+ std::cout << "C= " << C << std::endl;
+ std::cout << "D= " << D << std::endl;
+}
+
diff --git a/doc/reference/c++/arrays/algebras_1.cpp b/doc/reference/c++/arrays/algebras_1.cpp
new file mode 100644
index 00000000..20ed6d3b
--- /dev/null
+++ b/doc/reference/c++/arrays/algebras_1.cpp
@@ -0,0 +1,9 @@
+#include
+using namespace triqs::arrays;
+int main() {
+ array A(2, 2);
+ matrix M(2, 2);
+ // M + A; // --> ERROR. Rejected by the compiler.
+ M + make_matrix_view(A); //--> OK.
+}
+
diff --git a/doc/reference/c++/arrays/blas_lapack.rst b/doc/reference/c++/arrays/blas_lapack.rst
index 77ad21c2..588a834a 100644
--- a/doc/reference/c++/arrays/blas_lapack.rst
+++ b/doc/reference/c++/arrays/blas_lapack.rst
@@ -25,19 +25,7 @@ The * operator map the matrix x matrix and matrix x vector product.
Example : matrix * matrix and * vector ...
-..
- compileblock::
- #include
- using triqs::arrays::matrix; using triqs::clef::placeholder;
- int main() {
- // declare an init 2 matrices
- placeholder<0> i_; placeholder<1> j_;
- matrix A (2,2), B(2,2), C;
- A(i_,j_) << i_ + j_ ; B(i_,j_) << 2*i_ + j_ ;
- C= A*B;
- std::cout<< " C = " << C<< std::endl;
- }
-
+.. triqs_example:: ./blas_lapack_0.cpp
For types that lapack do not use, a generic version of the matrix product is provided.
(same syntax, the dispatch is made at compile time depending of the type of the matrices).
diff --git a/doc/reference/c++/arrays/blas_lapack_0.cpp b/doc/reference/c++/arrays/blas_lapack_0.cpp
new file mode 100644
index 00000000..835c8e4b
--- /dev/null
+++ b/doc/reference/c++/arrays/blas_lapack_0.cpp
@@ -0,0 +1,14 @@
+#include
+using triqs::arrays::matrix;
+using triqs::clef::placeholder;
+int main() {
+ // declare an init 2 matrices
+ placeholder<0> i_;
+ placeholder<1> j_;
+ matrix A(2, 2), B(2, 2), C;
+ A(i_, j_) << i_ + j_;
+ B(i_, j_) << 2 * i_ + j_;
+ C = A * B;
+ std::cout << " C = " << C << std::endl;
+}
+
diff --git a/doc/reference/c++/arrays/concepts.rst b/doc/reference/c++/arrays/concepts.rst
index 307672dd..ed767da9 100644
--- a/doc/reference/c++/arrays/concepts.rst
+++ b/doc/reference/c++/arrays/concepts.rst
@@ -186,46 +186,7 @@ For example:
* A simple solution :
- .. compileblock ::
-
- #include
- #include
- namespace triqs { namespace arrays { // better to put it in this namespace for ADL...
-
- template class immutable_diagonal_matrix_view {
-
- array_view data; // the diagonal stored as a 1d array
-
- public:
-
- immutable_diagonal_matrix_view(array_view v) : data (v) {} // constructor
-
- // the ImmutableMatrix concept
- typedef indexmaps::cuboid::domain_t<2> domain_type;
- domain_type domain() const { auto s = data.shape()[0]; return {s,s}; }
- typedef T value_type;
- T operator()(size_t i, size_t j) const { return (i==j ? data(i) : 0);} // just kronecker...
-
- friend std::ostream & operator<<(std::ostream & out, immutable_diagonal_matrix_view const & d)
- {return out<<"diagonal_matrix "< struct ImmutableMatrix> : std::true_type{};
- }}
-
- /// TESTING
- using namespace triqs::arrays;
- int main(int argc, char **argv) {
- auto a = array {1,2,3,4};
- auto d = immutable_diagonal_matrix_view{a};
- std::cout << "domain = " << d.domain()<< std::endl;
- std::cout << "d = "<< d << std::endl;
- std::cout << "2*d = "<< make_matrix(2*d) << std::endl;
- std::cout << "d*d = "<< matrix(d*d) << std::endl;
- }
-
-
+ .. triqs_example:: ./concepts_0.cpp
* Discussion
* Of course, this solution is not perfect. Several algorithms could be optimised if we know that a matrix is diagonal.
diff --git a/doc/reference/c++/arrays/concepts_0.cpp b/doc/reference/c++/arrays/concepts_0.cpp
new file mode 100644
index 00000000..07333aad
--- /dev/null
+++ b/doc/reference/c++/arrays/concepts_0.cpp
@@ -0,0 +1,42 @@
+#include
+#include
+namespace triqs {
+namespace arrays { // better to put it in this namespace for ADL...
+
+ template class immutable_diagonal_matrix_view {
+
+ array_view data; // the diagonal stored as a 1d array
+
+ public:
+ immutable_diagonal_matrix_view(array_view v) : data(v) {} // constructor
+
+ // the ImmutableMatrix concept
+ typedef indexmaps::cuboid::domain_t<2> domain_type;
+ domain_type domain() const {
+ auto s = data.shape()[0];
+ return {s, s};
+ }
+ typedef T value_type;
+ T operator()(size_t i, size_t j) const { return (i == j ? data(i) : 0); } // just kronecker...
+
+ friend std::ostream &operator<<(std::ostream &out, immutable_diagonal_matrix_view const &d) {
+ return out << "diagonal_matrix " << d.data;
+ }
+ };
+
+ // Marking this class as belonging to the Matrix & Vector algebra.
+ template struct ImmutableMatrix> : std::true_type {};
+}
+}
+
+/// TESTING
+using namespace triqs::arrays;
+int main(int argc, char **argv) {
+ auto a = array{1, 2, 3, 4};
+ auto d = immutable_diagonal_matrix_view{a};
+ std::cout << "domain = " << d.domain() << std::endl;
+ std::cout << "d = " << d << std::endl;
+ std::cout << "2*d = " << make_matrix(2 * d) << std::endl;
+ std::cout << "d*d = " << matrix(d * d) << std::endl;
+}
+
diff --git a/doc/reference/c++/arrays/containers/CMakeLists.txt b/doc/reference/c++/arrays/containers/CMakeLists.txt
new file mode 100644
index 00000000..1e301193
--- /dev/null
+++ b/doc/reference/c++/arrays/containers/CMakeLists.txt
@@ -0,0 +1,3 @@
+all_tests()
+
+
diff --git a/doc/reference/c++/arrays/containers/STL.rst b/doc/reference/c++/arrays/containers/STL.rst
index bd2af59a..b0a8b9ae 100644
--- a/doc/reference/c++/arrays/containers/STL.rst
+++ b/doc/reference/c++/arrays/containers/STL.rst
@@ -22,46 +22,4 @@ Examples::
Some examples of usage :
-.. compileblock::
-
- #include
- #include
- #include