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:
parent
d86c0df332
commit
1a85f5a16c
@ -2,23 +2,19 @@
|
||||
|
||||
.. _Lazy:
|
||||
|
||||
Interaction with clef expressions
|
||||
Interaction with CLEF expressions
|
||||
============================================
|
||||
|
||||
* The Value and View classes (array, matrix and vector and algebraic expression of them)
|
||||
are ready to use with the triqs::clef library :
|
||||
* The containers and their view classes can be used with the :doc:`../clef/contents` 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 usually more optimal since the for loops are automatically written in the TraversalOrder of the
|
||||
array.
|
||||
* It is usually more optimal since the for loops are automatically written in the TraversalOrder of the array.
|
||||
|
||||
* NB : the expression can be (and are) inlined by the compilers...
|
||||
|
||||
* **Example** :
|
||||
|
||||
@ -26,13 +22,11 @@ Interaction with clef expressions
|
||||
|
||||
#include <triqs/arrays.hpp>
|
||||
using triqs::arrays::array; using triqs::clef::placeholder;
|
||||
|
||||
int main(){
|
||||
placeholder<0> i_; placeholder<1> j_;
|
||||
array<double,2> A(2,2), B(2,2);
|
||||
|
||||
A(i_,j_) << i_ + 2*j_ ;
|
||||
|
||||
B(i_,j_) << A(j_,i_)/2;
|
||||
|
||||
std::cout << "A = "<<A << std::endl;
|
||||
|
@ -7,7 +7,7 @@ Functional constructs : map & fold
|
||||
|
||||
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.
|
||||
|
||||
* *fold* is the reduction of a function on the array.
|
||||
@ -26,39 +26,32 @@ map
|
||||
|
||||
If `f` is a function, or a function object ::
|
||||
|
||||
ValueType2 f(ValueType1)
|
||||
T2 f(T1)
|
||||
|
||||
Then map(f) is a function::
|
||||
|
||||
template<ImmutableCuboidArray A> auto map(f) (A const &)
|
||||
|
||||
with :
|
||||
* A::value_type == ValueType1
|
||||
* A::value_type == T1
|
||||
* The returned type of map(f) models the :ref:`ImmutableCuboidArray` concept
|
||||
|
||||
* with the same domain as A
|
||||
* with value_type == ValueType2
|
||||
|
||||
* 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.
|
||||
* with value_type == T2
|
||||
|
||||
* **Example** :
|
||||
|
||||
.. compileblock::
|
||||
|
||||
#include <triqs/arrays.hpp>
|
||||
using triqs::arrays::matrix; using triqs::arrays::make_matrix; using triqs::clef::placeholder;
|
||||
using namespace triqs;
|
||||
int main() {
|
||||
// declare and init a matrix
|
||||
placeholder<0> i_; placeholder<1> j_;
|
||||
matrix<int> A (2,2); A(i_,j_) << i_ + j_ ;
|
||||
clef::placeholder<0> i_; clef::placeholder<1> j_;
|
||||
arrays::matrix<int> A (2,2); A(i_,j_) << i_ + j_ ;
|
||||
|
||||
// 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<< "F(A) = " << F(A) << std::endl; // oops no computation done
|
||||
|
@ -1,5 +1,7 @@
|
||||
.. highlight:: c
|
||||
|
||||
.. _clef_auto_assign:
|
||||
|
||||
Automatic assignment of containers
|
||||
===================================
|
||||
|
||||
|
@ -5,7 +5,8 @@ Manipulations of determinants
|
||||
|
||||
.. 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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user