|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
#include <triqs/det_manip/det_manip_basic.hpp>
Simple reference implementation of determinant manipulation for CTQMC solvers.
This class manipulates the determinant \( \det(F^{(n)}) \) of a matrix whose elements are given by a callable \( F^{(n)}_{ij} = f(x_i, y_j) \) (see Determinant manipulation for the general setup).
It exposes the same API as triqs::det_manip::det_manip (the same try/complete operations, accessors and HDF5 support), but uses a straightforward implementation: instead of the fast rank-update algorithm, it rebuilds the matrix and recomputes the determinant (and, on demand, the inverse) from scratch on every operation. It does not track row/column permutations or a sign, so the matrix is stored in the user's order, i.e. the internal order equals the user order.
This makes it simpler and easier to verify, but asymptotically slower than triqs::det_manip::det_manip; it is primarily useful as a reference/testing implementation.
| FunctionType | Callable object \( f \) that takes two arguments and returns a real or complex value. It determines the elements of the matrix via \( F^{(n)}_{ij} = f(x_i, y_j) \). |
Definition at line 65 of file det_manip_basic.hpp.
Public Types | |
| enum | RollDirection |
| Direction of the roll_matrix() operation. More... | |
Public Member Functions | |
| template<typename ArgumentContainer1, typename ArgumentContainer2> | |
| det_manip_basic (FunctionType F, ArgumentContainer1 const &X, ArgumentContainer2 const &Y) | |
| Construct a det_manip_basic object with a callable FunctionType and two containers holding the arguments for the matrix builder. | |
| det_manip_basic (FunctionType F, long init_size) | |
| Construct a det_manip_basic object with a callable FunctionType and an initial capacity for the data storages. | |
| matrix_type | build_matrix_scratch () |
| Build the matrix \( F^{(n)} \) from scratch from the stored arguments. | |
| value_type | change_col (long j, y_type const &y) |
| Change one column. | |
| value_type | change_one_row_and_one_col (long i, long j, x_type const &x, y_type const &y) |
| Change one row and one column. | |
| value_type | change_row (long i, x_type const &x) |
| Change one row. | |
| void | clear () |
| Clear the data storages and reset the matrix to size zero. | |
| void | complete_operation () |
| Complete the last try-operation. | |
| auto | determinant () |
| Get the determinant of the matrix \( F^{(n)} \). | |
| FunctionType const & | get_function () const |
| Get the callable FunctionType object \( f \) used as the matrix builder. | |
| auto | get_x () const |
| Get a vector with all matrix builder arguments \( \mathbf{x} \). | |
| x_type const & | get_x (long i) const |
| Get the matrix builder argument \( x_i \) that determines the elements of the ith row. | |
| auto const & | get_x_internal_order () const |
| Get the matrix builder arguments \( \mathbf{x} \) in internal storage order. | |
| auto | get_y () const |
| Get a vector with all matrix builder arguments \( \mathbf{y} \). | |
| y_type const & | get_y (long j) const |
| Get the matrix builder argument \( y_j \) that determines the elements of the jth column. | |
| auto const & | get_y_internal_order () const |
| Get the matrix builder arguments \( \mathbf{y} \) in internal storage order. | |
| value_type | insert (long i, long j, x_type const &x, y_type const &y) |
| Insert one row and column. | |
| value_type | insert2 (long i0, long i1, long j0, long j1, x_type const &x0, x_type const &x1, y_type const &y0, y_type const &y1) |
| Insert two rows and columns. | |
| value_type | insert2_at_end (x_type const &x0, x_type const &x1, y_type const &y0, y_type const &y1) |
| Insert two rows and columns at the end of the matrix. | |
| value_type | insert_at_end (x_type const &x, y_type const &y) |
| Insert one row and column at the end of the matrix. | |
| template<nda::Array X, nda::Array Y> requires (nda::get_rank<X> == nda::get_rank<Y>) | |
| auto | insert_ratios (long i, long j, X const &xs, Y const &ys) const -> nda::array< value_type, nda::get_rank< X > > |
| Compute independent single-insertion determinant ratios at position \( (i, j) \) for paired elements of xs and ys. | |
| nda::matrix_const_view< value_type > | inverse_matrix () const |
| Get the full inverse matrix \( [F^{(n)}]^{-1} \). | |
| value_type | inverse_matrix (int i, int j) const |
| Get an element of the inverse matrix \( [F^{(n)}]^{-1} \). | |
| nda::matrix_const_view< value_type > | inverse_matrix_internal_order () const |
| Get the full inverse matrix in internal storage order. | |
| value_type | inverse_matrix_internal_order (int i, int j) const |
| Get an element of the inverse matrix in internal storage order. | |
| matrix_type | matrix () const |
| Get the matrix \( F^{(n)} \). | |
| value_type | matrix (int i, int j) const |
| Get an element of the matrix \( F^{(n)} \). | |
| void | reject_last_try () |
| Reject the last try-operation. | |
| value_type | remove (long i, long j) |
| Remove one row and column. | |
| value_type | remove2 (long i0, long i1, long j0, long j1) |
| Remove two rows and columns. | |
| value_type | remove2_at_end () |
| Remove the last two rows and columns of the matrix. | |
| value_type | remove_at_end () |
| Remove the last row and column of the matrix. | |
| void | reserve (long new_size, long new_k=1) |
| Reserve memory to increase the capacity of the data storages. | |
| int | roll_matrix (RollDirection roll) |
| Perform a circular shift permutation on the rows or columns of the matrix \( F^{(n)} \). | |
| auto | size () const |
| Get the current size of the matrix. | |
| value_type | try_change_col (long j, y_type const &y) |
| Try to change one column in the matrix \( F^{(n)} \). | |
| value_type | try_change_col_row (long i, long j, x_type const &x, y_type const &y) |
| Try to change one column and one row in the matrix \( F^{(n)} \). | |
| value_type | try_change_row (long i, x_type const &x) |
| Try to change one row in the matrix \( F^{(n)} \). | |
| value_type | try_insert (long i, long j, x_type const &x, y_type const &y) |
| Try to insert one row and column. | |
| value_type | try_insert2 (long i0, long i1, long j0, long j1, x_type const &x0_, x_type const &x1_, y_type const &y0_, y_type const &y1_) |
| Try to insert two rows and columns. | |
| value_type | try_insert_k (std::vector< long > i, std::vector< long > j, std::vector< x_type > x, std::vector< y_type > y) |
| Try to insert \( k \) rows and columns. | |
| template<typename ArgumentContainer1, typename ArgumentContainer2> | |
| value_type | try_refill (ArgumentContainer1 const &X, ArgumentContainer2 const &Y) |
| Try to fill the matrix \( F^{(n)} \) with new elements. | |
| value_type | try_remove (long i, long j) |
| Try to remove one row and column. | |
| value_type | try_remove2 (long i0, long i1, long j0, long j1) |
| Try to remove two rows and two columns. | |
| value_type | try_remove_k (std::vector< long > i, std::vector< long > j) |
| Try to remove \( k \) rows and columns. | |
Friends | |
| template<typename LambdaType> | |
| void | foreach (det_manip_basic const &d, LambdaType const &func) |
| For-each implementation for triqs::det_manip::det_manip_basic objects. | |
| void | h5_read (h5::group fg, std::string subgroup_name, det_manip_basic &g) |
| Read a triqs::det_manip::det_manip_basic object from HDF5. | |
| void | h5_write (h5::group fg, std::string subgroup_name, det_manip_basic const &g) |
| Write a triqs::det_manip::det_manip_basic object to HDF5. | |
| enum triqs::det_manip::det_manip_basic::RollDirection |
Direction of the roll_matrix() operation.
It specifies the direction of the circular shift performed on either the rows or columns of the matrix \( F^{(n)} \). The following directions are supported:
Definition at line 1503 of file det_manip_basic.hpp.
|
inline |
Construct a det_manip_basic object with a callable FunctionType and an initial capacity for the data storages.
Like for std::vector, the capacity grows automatically (by a factor of 2) when needed, but this can yield a performance penalty if it happens too often.
| F | Callable FunctionType object (a copy is stored in the class). |
| init_size | Initial capacity for the size of the matrix, i.e. the maximum number of rows and columns. |
Definition at line 245 of file det_manip_basic.hpp.
|
inline |
Construct a det_manip_basic object with a callable FunctionType and two containers holding the arguments for the matrix builder.
| ArgumentContainer1 | Container type holding the first arguments. |
| ArgumentContainer2 | Container type holding the second arguments. |
| F | Callable FunctionType object (a copy is stored in the class). |
| X | Container holding the first arguments \( \mathbf{x} \). |
| Y | Container holding the second arguments \( \mathbf{y} \). |
Definition at line 261 of file det_manip_basic.hpp.
|
inline |
Build the matrix \( F^{(n)} \) from scratch from the stored arguments.
Evaluates \( f(x_i, y_j) \) for all \( i, j \) and returns a freshly allocated matrix.
Definition at line 299 of file det_manip_basic.hpp.
|
inline |
Change one column.
Wrapper for try_change_col() followed by a complete_operation() call. See try_change_col() for details.
| j | Position of the column to be changed in the matrix \( F^{(n)} \). |
| y | Argument to the matrix builder that determines the new elements of the column. |
Definition at line 1456 of file det_manip_basic.hpp.
|
inline |
Change one row and one column.
Wrapper for try_change_col_row() followed by a complete_operation() call. See try_change_col_row() for details.
| i | Position of the row to be changed in the matrix \( F^{(n)} \). |
| j | Position of the column to be changed in the matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the new elements of the row. |
| y | Argument to the matrix builder that determines the new elements of the column. |
Definition at line 1485 of file det_manip_basic.hpp.
|
inline |
Change one row.
Wrapper for try_change_row() followed by a complete_operation() call. See try_change_row() for details.
| i | Position of the row to be changed in the matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the new elements of the row. |
Definition at line 1469 of file det_manip_basic.hpp.
|
inline |
Complete the last try-operation.
It completes the last try-operation by applying the candidate matrix and determinant that were prepared by the corresponding try_* call, depending on the tag set in the last try function call.
Definition at line 1327 of file det_manip_basic.hpp.
|
inline |
Get the determinant of the matrix \( F^{(n)} \).
Definition at line 402 of file det_manip_basic.hpp.
|
inline |
Get the callable FunctionType object \( f \) used as the matrix builder.
Definition at line 396 of file det_manip_basic.hpp.
|
inline |
Get a vector with all matrix builder arguments \( \mathbf{x} \).
Definition at line 354 of file det_manip_basic.hpp.
|
inline |
Get the matrix builder argument \( x_i \) that determines the elements of the ith row.
| i | Argument index. |
Definition at line 367 of file det_manip_basic.hpp.
|
inline |
Get the matrix builder arguments \( \mathbf{x} \) in internal storage order.
For this class the internal order equals the user order (there is no permutation), so this returns the same as get_x().
Definition at line 382 of file det_manip_basic.hpp.
|
inline |
Get a vector with all matrix builder arguments \( \mathbf{y} \).
Definition at line 360 of file det_manip_basic.hpp.
|
inline |
Get the matrix builder argument \( y_j \) that determines the elements of the jth column.
| j | Argument index. |
Definition at line 374 of file det_manip_basic.hpp.
|
inline |
Get the matrix builder arguments \( \mathbf{y} \) in internal storage order.
For this class the internal order equals the user order (there is no permutation), so this returns the same as get_y().
Definition at line 390 of file det_manip_basic.hpp.
|
inline |
Insert one row and column.
Wrapper for try_insert() followed by a complete_operation() call. See try_insert() for details.
| i | Position of the row to be inserted in the matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the elements of the new row. |
| y | Argument to the matrix builder that determines the elements of the new column. |
Definition at line 1368 of file det_manip_basic.hpp.
|
inline |
Insert two rows and columns.
Wrapper for try_insert2() followed by a complete_operation() call. See try_insert2() for details.
| i0,i1 | Positions of the rows to be inserted in the matrix \( F^{(n)} \). |
| j0,j1 | Positions of the columns to be inserted in the matrix \( F^{(n)} \). |
| x0,x1 | Arguments to the matrix builder that determine the elements of the new rows. |
| y0,y1 | Arguments to the matrix builder that determine the elements of the new columns. |
Definition at line 1392 of file det_manip_basic.hpp.
|
inline |
Insert two rows and columns at the end of the matrix.
Same as insert2() but with i0 and j0 set to size() and i1 and j1 set to size() + 1.
| x0,x1 | Arguments to the matrix builder that determine the elements of the new rows. |
| y0,y1 | Arguments to the matrix builder that determine the elements of the new columns. |
Definition at line 1405 of file det_manip_basic.hpp.
|
inline |
Insert one row and column at the end of the matrix.
Same as insert() but with i and j set to size().
| x | Argument to the matrix builder that determines the elements of the new row. |
| y | Argument to the matrix builder that determines the elements of the new column. |
Definition at line 1381 of file det_manip_basic.hpp.
|
inline |
Compute independent single-insertion determinant ratios at position \( (i, j) \) for paired elements of xs and ys.
For each pair (xs[m], ys[m]) it computes the determinant ratio that a single try_insert() at position \( (i, j) \) would produce, without modifying the internal state. The inputs must be nda::Array objects with the same rank and shape, and the result has the same shape.
| X | nda::Array type of the first arguments. |
| Y | nda::Array type of the second arguments. |
| i | Position of the row to be inserted in the matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the matrix \( F^{(n)} \). |
| xs | Array of first arguments to the matrix builder. |
| ys | Array of second arguments to the matrix builder. |
Definition at line 718 of file det_manip_basic.hpp.
|
inline |
Get the full inverse matrix \( [F^{(n)}]^{-1} \).
The inverse is recomputed from scratch on demand and cached until the next operation.
Definition at line 409 of file det_manip_basic.hpp.
|
inline |
Get an element of the inverse matrix \( [F^{(n)}]^{-1} \).
| i | Row index. |
| j | Column index. |
Definition at line 421 of file det_manip_basic.hpp.
|
inline |
Get the full inverse matrix in internal storage order.
For this class the internal order equals the user order, so this returns the same as inverse_matrix().
Definition at line 432 of file det_manip_basic.hpp.
|
inline |
Get an element of the inverse matrix in internal storage order.
For this class the internal order equals the user order, so this returns the same as inverse_matrix(int, int).
| i | Row index. |
| j | Column index. |
Definition at line 442 of file det_manip_basic.hpp.
|
inline |
Get the matrix \( F^{(n)} \).
Definition at line 448 of file det_manip_basic.hpp.
|
inline |
Get an element of the matrix \( F^{(n)} \).
| i | Row index. |
| j | Column index. |
Definition at line 459 of file det_manip_basic.hpp.
|
inline |
Reject the last try-operation.
All try_* operations have to be either accepted (via complete_operation()) or rejected.
Definition at line 1354 of file det_manip_basic.hpp.
|
inline |
Remove one row and column.
Wrapper for try_remove() followed by a complete_operation() call. See try_remove() for details.
| i | Position of the row to be removed in the matrix \( F^{(n)} \). |
| j | Position of the column to be removed in the matrix \( F^{(n)} \). |
Definition at line 1416 of file det_manip_basic.hpp.
|
inline |
Remove two rows and columns.
Wrapper for try_remove2() followed by a complete_operation() call. See try_remove2() for details.
| i0,i1 | Positions of the rows to be removed in the matrix \( F^{(n)} \). |
| j0,j1 | Positions of the columns to be removed in the matrix \( F^{(n)} \). |
Definition at line 1436 of file det_manip_basic.hpp.
|
inline |
Remove the last two rows and columns of the matrix.
Same as remove2() but with i0 and j0 set to size() - 1 and i1 and j1 set to size() - 2.
Definition at line 1447 of file det_manip_basic.hpp.
|
inline |
Remove the last row and column of the matrix.
Same as remove() but with i and j set to size() - 1.
Definition at line 1427 of file det_manip_basic.hpp.
|
inline |
Reserve memory to increase the capacity of the data storages.
Like for std::vector, this reserves memory for a bigger matrix size. It only reserves/resizes if the requested capacity is larger than the current one. It preserves the matrix but not the temporary working data, so it must NOT be called between a try_* function and the corresponding complete_operation().
| new_size | New capacity for the size of the matrix, i.e. the maximum number of rows and columns. |
| new_k | Unused, kept for API compatibility with triqs::det_manip::det_manip. |
Definition at line 220 of file det_manip_basic.hpp.
|
inline |
Perform a circular shift permutation on the rows or columns of the matrix \( F^{(n)} \).
See RollDirection for the supported directions. This routine is not a try_* operation: it does make the modification (it rebuilds the matrix and updates the determinant directly) and does not need to be completed.
A circular shift permutation of a finite set is equivalent to \( N \) transpositions, where \( N \) is the size of the set. The sign of the permutation is therefore given by \( (-1)^{N-1} \).
| roll | Direction of the roll operation. |
Definition at line 1518 of file det_manip_basic.hpp.
|
inline |
Get the current size of the matrix.
Definition at line 348 of file det_manip_basic.hpp.
|
inline |
Try to change one column in the matrix \( F^{(n)} \).
The column at position \( j \) is replaced; its new elements are determined by the given matrix builder argument \( y \). It builds the candidate matrix and recomputes its determinant from scratch.
| j | Position of the column to be changed in the matrix \( F^{(n)} \). |
| y | Argument to the matrix builder that determines the new elements of the column. |
Definition at line 1140 of file det_manip_basic.hpp.
|
inline |
Try to change one column and one row in the matrix \( F^{(n)} \).
The row at position \( i \) and the column at position \( j \) are replaced; their new elements are determined by the given matrix builder arguments \( x \) and \( y \). It builds the candidate matrix and recomputes its determinant from scratch.
| i | Position of the row to be changed in the matrix \( F^{(n)} \). |
| j | Position of the column to be changed in the matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the new elements of the row. |
| y | Argument to the matrix builder that determines the new elements of the column. |
Definition at line 1220 of file det_manip_basic.hpp.
|
inline |
Try to change one row in the matrix \( F^{(n)} \).
The row at position \( i \) is replaced; its new elements are determined by the given matrix builder argument \( x \). It builds the candidate matrix and recomputes its determinant from scratch.
| i | Position of the row to be changed in the matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the new elements of the row. |
Definition at line 1179 of file det_manip_basic.hpp.
|
inline |
Try to insert one row and column.
The row is inserted at position \( i \) and the column at position \( j \) in the matrix \( F^{(n)} \), with elements determined by the given matrix builder arguments \( x \) and \( y \). The current column \( j \) (resp. row \( i \)) becomes column \( j + 1 \) (resp. row \( i + 1 \)); inserting at \( n \) simply appends at the end ( \( 0 \leq i, j \leq n \)).
It builds the candidate matrix and recomputes its determinant from scratch.
| i | Position of the row to be inserted in the matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the elements of the new row. |
| y | Argument to the matrix builder that determines the elements of the new column. |
Definition at line 497 of file det_manip_basic.hpp.
|
inline |
Try to insert two rows and columns.
The rows are inserted at positions \( i_0 \) and \( i_1 \) and the columns at positions \( j_0 \) and \( j_1 \) in the matrix \( F^{(n)} \), with elements determined by the given matrix builder arguments \( x_0, x_1, y_0, y_1 \) ( \( 0 \leq i_0,i_1,j_0,j_1 \leq n+1 \)).
It builds the candidate matrix and recomputes its determinant from scratch.
| i0 | Position of the first row to be inserted in the matrix \( F^{(n)} \). |
| i1 | Position of the second row to be inserted in the matrix \( F^{(n)} \). |
| j0 | Position of the first column to be inserted in the matrix \( F^{(n)} \). |
| j1 | Position of the second column to be inserted in the matrix \( F^{(n)} \). |
| x0_ | Argument to the matrix builder that determines the elements of the first new row. |
| x1_ | Argument to the matrix builder that determines the elements of the second new row. |
| y0_ | Argument to the matrix builder that determines the elements of the first new column. |
| y1_ | Argument to the matrix builder that determines the elements of the second new column. |
Definition at line 574 of file det_manip_basic.hpp.
|
inline |
Try to insert \( k \) rows and columns.
The new rows and columns are inserted at the positions given by the tuples \( \mathbf{i} \) and \( \mathbf{j} \), with elements determined by the matrix builder arguments \( \mathbf{x} \) and \( \mathbf{y} \) (each position \( i_l, j_l \) valid up to \( n + l \)).
It builds the candidate matrix and recomputes its determinant from scratch.
| i | Positions of the rows to be inserted in the matrix \( F^{(n)} \). |
| j | Positions of the columns to be inserted in the matrix \( F^{(n)} \). |
| x | Arguments to the matrix builder that determine the elements of the new rows. |
| y | Arguments to the matrix builder that determine the elements of the new columns. |
Definition at line 763 of file det_manip_basic.hpp.
|
inline |
Try to fill the matrix \( F^{(n)} \) with new elements.
Builds a completely new matrix \( \widetilde{F}^{(\widetilde{n})} \) from the given matrix builder arguments \( \mathbf{x} \) and \( \mathbf{y} \) (with \( \widetilde{F}_{ij} = f(x_i, y_j) \)) and recomputes its determinant from scratch.
| ArgumentContainer1 | Container type holding the first arguments. |
| ArgumentContainer2 | Container type holding the second arguments. |
| X | Container holding the first matrix builder arguments. |
| Y | Container holding the second matrix builder arguments. |
Definition at line 1274 of file det_manip_basic.hpp.
|
inline |
Try to remove one row and column.
The row at position \( i \) and the column at position \( j \) are removed from the matrix \( F^{(n)} \). It builds the candidate matrix and recomputes its determinant from scratch.
| i | Position of the row to be removed in the matrix \( F^{(n)} \). |
| j | Position of the column to be removed in the matrix \( F^{(n)} \). |
Definition at line 885 of file det_manip_basic.hpp.
|
inline |
Try to remove two rows and two columns.
The rows at positions \( i_0, i_1 \) and the columns at positions \( j_0, j_1 \) are removed from the matrix \( F^{(n)} \). It builds the candidate matrix and recomputes its determinant from scratch.
| i0 | Position of the first row to be removed in the matrix \( F^{(n)} \). |
| i1 | Position of the second row to be removed in the matrix \( F^{(n)} \). |
| j0 | Position of the first column to be removed in the matrix \( F^{(n)} \). |
| j1 | Position of the second column to be removed in the matrix \( F^{(n)} \). |
Definition at line 946 of file det_manip_basic.hpp.
|
inline |
Try to remove \( k \) rows and columns.
The rows and columns at the positions given by the tuples \( \mathbf{i} \) and \( \mathbf{j} \) are removed from the matrix \( F^{(n)} \). It builds the candidate matrix and recomputes its determinant from scratch.
| i | Positions of the rows to be removed in the matrix \( F^{(n)} \). |
| j | Positions of the columns to be removed in the matrix \( F^{(n)} \). |
Definition at line 1038 of file det_manip_basic.hpp.
|
friend |
For-each implementation for triqs::det_manip::det_manip_basic objects.
It loops over all elements of the inverse matrix and calls the given callable object for each element together with the corresponding arguments \( x_i \) and \( y_j \). The order of iteration is not fixed; it is optimised for memory traversal.
| LambdaType | Callable type. |
| d | triqs::det_manip::det_manip_basic object. |
| func | Callable object that takes three arguments: \( x_i \), \( y_j \), and \( [F^{(n)}]^{-1}_{ji} \). |
Definition at line 472 of file det_manip_basic.hpp.
|
friend |
Read a triqs::det_manip::det_manip_basic object from HDF5.
| fg | h5::group containing the subgroup to be read from. |
| subgroup_name | Name of the subgroup. |
| g | Manipulator object to be read into. |
Definition at line 197 of file det_manip_basic.hpp.
|
friend |
Write a triqs::det_manip::det_manip_basic object to HDF5.
| fg | h5::group containing the subgroup to be written to. |
| subgroup_name | Name of the subgroup. |
| g | Manipulator object to be written. |
Definition at line 180 of file det_manip_basic.hpp.