3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-31 11:13:46 +01:00

Work on doc

This commit is contained in:
Olivier Parcollet 2013-09-09 15:46:58 +02:00
parent d86c0df332
commit 1a85f5a16c
4 changed files with 18 additions and 28 deletions

View File

@ -2,23 +2,19 @@
.. _Lazy: .. _Lazy:
Interaction with clef expressions Interaction with CLEF expressions
============================================ ============================================
* The Value and View classes (array, matrix and vector and algebraic expression of them) * The containers and their view classes can be used with the :doc:`../clef/contents` library :
are ready to use with the triqs::clef library :
* They can be called on lazy expressions made of placeholders. * They can be called with CLEF expressions.
* :doc:`Automatic assignment<../clef/assign>` has been set up.
* Automatic assignment has been set up. Cf clef lib doc ... * Using the CLEF library offers a quick and efficient way to fill an array with multiple advantages :
* Using the clef library offers a quick and efficient way to fill an array with multiple advantages :
* It is simpler and more readeable than a series of for loops. * It is simpler and more readeable than a series of for loops.
* It is usually more optimal since the for loops are automatically written in the TraversalOrder of the * It is usually more optimal since the for loops are automatically written in the TraversalOrder of the array.
array.
* NB : the expression can be (and are) inlined by the compilers...
* **Example** : * **Example** :
@ -26,13 +22,11 @@ Interaction with clef expressions
#include <triqs/arrays.hpp> #include <triqs/arrays.hpp>
using triqs::arrays::array; using triqs::clef::placeholder; using triqs::arrays::array; using triqs::clef::placeholder;
int main(){ int main(){
placeholder<0> i_; placeholder<1> j_; placeholder<0> i_; placeholder<1> j_;
array<double,2> A(2,2), B(2,2); array<double,2> A(2,2), B(2,2);
A(i_,j_) << i_ + 2*j_ ; A(i_,j_) << i_ + 2*j_ ;
B(i_,j_) << A(j_,i_)/2; B(i_,j_) << A(j_,i_)/2;
std::cout << "A = "<<A << std::endl; std::cout << "A = "<<A << std::endl;

View File

@ -7,7 +7,7 @@ Functional constructs : map & fold
Two standard functional constructs are provided : Two standard functional constructs are provided :
* *map* that promotes a function of the array element to a function of the array, * *map* that promotes a function acting on the array element to an array function, acting
element by element. element by element.
* *fold* is the reduction of a function on the array. * *fold* is the reduction of a function on the array.
@ -26,39 +26,32 @@ map
If `f` is a function, or a function object :: If `f` is a function, or a function object ::
ValueType2 f(ValueType1) T2 f(T1)
Then map(f) is a function:: Then map(f) is a function::
template<ImmutableCuboidArray A> auto map(f) (A const &) template<ImmutableCuboidArray A> auto map(f) (A const &)
with : with :
* A::value_type == ValueType1 * A::value_type == T1
* The returned type of map(f) models the :ref:`ImmutableCuboidArray` concept * The returned type of map(f) models the :ref:`ImmutableCuboidArray` concept
* with the same domain as A * with the same domain as A
* with value_type == ValueType2 * with value_type == T2
* N.B. : Some cases require explicit cast, e.g. for the standard abs function (already defined in arrays/mapped_function.hpp) ,
or the compiler does not know which std::abs you are talking about ::
auto Abs = map( std::function<double(double)>(static_cast< double (*)(double)> (std::abs)) );
* TO DO : clarify the F f or F const & : check code and put an example with std::ref.
* **Example** : * **Example** :
.. compileblock:: .. compileblock::
#include <triqs/arrays.hpp> #include <triqs/arrays.hpp>
using triqs::arrays::matrix; using triqs::arrays::make_matrix; using triqs::clef::placeholder; using namespace triqs;
int main() { int main() {
// declare and init a matrix // declare and init a matrix
placeholder<0> i_; placeholder<1> j_; clef::placeholder<0> i_; clef::placeholder<1> j_;
matrix<int> A (2,2); A(i_,j_) << i_ + j_ ; arrays::matrix<int> A (2,2); A(i_,j_) << i_ + j_ ;
// the mapped function // the mapped function
auto F = triqs::arrays::map([](int i) { return i*2.5;}); auto F = arrays::map([](int i) { return i*2.5;});
std::cout<< "A = " << A << std::endl; std::cout<< "A = " << A << std::endl;
std::cout<< "F(A) = " << F(A) << std::endl; // oops no computation done std::cout<< "F(A) = " << F(A) << std::endl; // oops no computation done

View File

@ -1,5 +1,7 @@
.. highlight:: c .. highlight:: c
.. _clef_auto_assign:
Automatic assignment of containers Automatic assignment of containers
=================================== ===================================

View File

@ -5,7 +5,8 @@ Manipulations of determinants
.. warning:: .. warning::
This library is stable, but documentation is still a bit spartan ... This library is stable, but documentation is currently being written
and needs a serious rereading and cleaning
The purpose of this little class is to regroup standard block manipulations on determinant, used in several algorithms. The purpose of this little class is to regroup standard block manipulations on determinant, used in several algorithms.