|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
#include <triqs/det_manip/det_manip.hpp>
Manipulate determinants and ratios of determinants for CTQMC solvers.
The code and the following documentation uses the notation introduced in Determinant manipulation.
The determinant \( \det(F^{(n)}) \) or the underlying matrix \( F^{(n)} \) is manipulated by performing operations. Most of those operations are split into a try and a complete function. While the try functions only produce intermediate results that are necessary to calculate the ratio of the new to the old determinant, the complete functions actually perform the operation and update the matrix and the determinant.
The following operations are supported:
| 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 166 of file det_manip.hpp.
Public Types | |
| enum | RollDirection |
| Direction of the roll_matrix() operation. More... | |
Public Member Functions | |
| template<typename ArgumentContainer1, typename ArgumentContainer2> | |
| det_manip (FunctionType F, ArgumentContainer1 const &X, ArgumentContainer2 const &Y) | |
| Construct a det_manip object with a callable FunctionType and two containers holding the arguments for the matrix builder. | |
| det_manip (FunctionType F, long init_size) | |
| Construct a det_manip object with a callable FunctionType and an initial capacity for the data storages. | |
| 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. | |
| det_type | determinant () |
| Get the determinant of the original matrix \( F^{(n)} \). | |
| FunctionType const & | get_function () const |
| Get the callable FunctionType object \( f \) used as the matrix builder. | |
| double | get_n_operations_before_check () const |
| Get the number of operations before a consistency check is performed. | |
| double | get_precision_error () const |
| Get the precision threshold that determines when to throw an exception. | |
| double | get_precision_warning () const |
| Get the precision threshold that determines when to print a warning. | |
| double | get_singular_threshold () const |
| Get the threshold being used when testing for a singular matrix. | |
| std::vector< x_type > | 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 in the original matrix \( F^{(n)} \). | |
| std::vector< x_type > const & | get_x_internal_order () const |
| Get the matrix builder arguments \( \mathbf{x} \) in the order of the matrix \( G^{(n)} \). | |
| std::vector< y_type > | 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 in the original matrix \( F^{(n)} \). | |
| std::vector< y_type > const & | get_y_internal_order () const |
| Get the matrix builder arguments \( \mathbf{y} \) in the order of the matrix \( G^{(n)} \). | |
| 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. | |
| matrix_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. | |
| nda::matrix_const_view< value_type > | inverse_matrix_internal_order () const |
| Get the full inverse matrix \( M^{(n)} = [G^{(n)}]^{-1} \). | |
| value_type | inverse_matrix_internal_order (int i, int j) const |
| Get an element of the matrix \( M^{(n)} = [G^{(n)}]^{-1} \). | |
| matrix_type | matrix () const |
| Get the original matrix \( F^{(n)} \). | |
| void | regenerate () |
| Regenerate the inverse matrix \( M^{(n)} \), the determinant \( \det(G^{(n)}) \) and the sign \( s^{(n)} \) from scratch using the matrix builder. | |
| 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_N, long new_k=1) |
| Reserve memory and resize the data storages. | |
| int | roll_matrix (RollDirection roll) |
| Perform a circular shift permutation on the rows or columns of the matrix \( F^{(n)} \). | |
| void | set_n_operations_before_check (uint64_t n) |
| Set the number of operations before a consistency check is performed (default: 100). | |
| void | set_precision_error (double threshold) |
| Set the precision threshold that determines when to throw an exception (default: 1e-5). | |
| void | set_precision_warning (double threshold) |
| Set the precision threshold that determines when to print a warning (default: 1e-8). | |
| void | set_singular_threshold (double threshold) |
| Set the threshold being used when testing for a singular matrix (default: -1). | |
| long | size () const |
| Get the current size of the matrix. | |
| void | swap_col (long i, long j) |
| Swap two columns. | |
| void | swap_row (long i, long j) |
| Swap two rows. | |
| value_type | try_change_col (long j, y_type const &y) |
| Try to change one column in the original 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 original matrix \( F^{(n)} \). | |
| value_type | try_change_row (long i, x_type const &x) |
| Try to change one row in the original 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. | |
| template<typename Fx, typename Fy> | |
| value_type | try_insert_from_function (long i, long j, Fx fx, Fy fy, value_type const ksi) |
| Try to insert one row and column, providing the new elements through callables instead of the matrix builder. | |
| 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 original 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 const &d, LambdaType const &fn) |
| For-each implementation for triqs::det_manip::det_manip objects. | |
| void | h5_read (h5::group fg, std::string subgroup_name, det_manip &g) |
| Read a triqs::det_manip::det_manip object from HDF5. | |
| void | h5_write (h5::group fg, std::string subgroup_name, det_manip const &g) |
| Write a triqs::det_manip::det_manip object to HDF5. | |
| enum triqs::det_manip::det_manip::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 1950 of file det_manip.hpp.
|
inline |
Construct a det_manip 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 403 of file det_manip.hpp.
|
inline |
Construct a det_manip 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 419 of file det_manip.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 original matrix \( F^{(n)} \). |
| y | Argument to the matrix builder that determines the new elements of the column. |
Definition at line 1903 of file det_manip.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 original matrix \( F^{(n)} \). |
| j | Position of the column to be changed in the original 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 1932 of file det_manip.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 original matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the new elements of the row. |
Definition at line 1916 of file det_manip.hpp.
|
inline |
Complete the last try-operation.
It completes the last try-operation by calling the correct completion function depending on the try tag set in the last try function call.
If the number of operations exceeds a certain threshold (see set_n_operations_before_check()), the inverse matrix \( M^{(n)} \), the determinant \( \det(G^{(n)}) \) and the sign \( s^{(n)} \) are regenerated using the matrix builder and checked against the stored values.
A possible warning is emitted or an exception is thrown if the current objects are not consistent with the regenerated ones (see set_precision_warning() and set_precision_error()).
Definition at line 1776 of file det_manip.hpp.
|
inline |
Get the determinant of the original matrix \( F^{(n)} \).
Definition at line 544 of file det_manip.hpp.
|
inline |
Get the callable FunctionType object \( f \) used as the matrix builder.
Definition at line 538 of file det_manip.hpp.
|
inlinenodiscard |
Get the number of operations before a consistency check is performed.
See set_n_operations_before_check() for details.
Definition at line 350 of file det_manip.hpp.
|
inlinenodiscard |
Get the precision threshold that determines when to throw an exception.
See set_precision_warning() for details.
Definition at line 385 of file det_manip.hpp.
|
inlinenodiscard |
Get the precision threshold that determines when to print a warning.
See set_precision_warning() for details.
Definition at line 364 of file det_manip.hpp.
|
inlinenodiscard |
Get the threshold being used when testing for a singular matrix.
See set_singular_threshold() for details.
Definition at line 331 of file det_manip.hpp.
|
inline |
Get a vector with all matrix builder arguments \( \mathbf{x} \).
Warning: this is slow, since it creates a new copy and reorders the rows.
Definition at line 497 of file det_manip.hpp.
|
inline |
Get the matrix builder argument \( x_i \) that determines the elements of the ith row in the original matrix \( F^{(n)} \).
| i | Argument index. |
Definition at line 482 of file det_manip.hpp.
|
inline |
Get the matrix builder arguments \( \mathbf{x} \) in the order of the matrix \( G^{(n)} \).
Advanced: this is the internal storage order, which differs by some permutation from the order given by the user. Useful for some performance-critical loops, to be used together with the other *_internal_order functions.
Definition at line 525 of file det_manip.hpp.
|
inline |
Get a vector with all matrix builder arguments \( \mathbf{y} \).
Warning: this is slow, since it creates a new copy and reorders the columns.
Definition at line 509 of file det_manip.hpp.
|
inline |
Get the matrix builder argument \( y_j \) that determines the elements of the jth column in the original matrix \( F^{(n)} \).
| j | Argument index. |
Definition at line 490 of file det_manip.hpp.
|
inline |
Get the matrix builder arguments \( \mathbf{y} \) in the order of the matrix \( G^{(n)} \).
See get_x_internal_order() for details.
Definition at line 532 of file det_manip.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 original matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the original 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 1815 of file det_manip.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 original matrix \( F^{(n)} \). |
| j0,j1 | Positions of the columns to be inserted in the original 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 1839 of file det_manip.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 1852 of file det_manip.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 1828 of file det_manip.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 original matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the original matrix \( F^{(n)} \). |
| xs | Array of first arguments to the matrix builder. |
| ys | Array of second arguments to the matrix builder. |
Definition at line 975 of file det_manip.hpp.
|
inline |
Get the full inverse matrix \( [F^{(n)}]^{-1} \).
See inverse_matrix(int, int) for details. Warning: this is slow, since it creates a new copy and reorders the rows/columns.
Definition at line 570 of file det_manip.hpp.
|
inline |
Get an element of the inverse matrix.
The inverse matrix is given by
\[ [F^{(n)}]^{-1} = (P^{(n)}_r G^{(n)} P^{(n)}_c)^{-1} = [P^{(n)}_c]^T [G^{(n)}]^{-1} [P^{(n)}_r]^T \; . \]
| i | Row index. |
| j | Column index. |
Definition at line 562 of file det_manip.hpp.
|
inline |
Get the full inverse matrix \( M^{(n)} = [G^{(n)}]^{-1} \).
Advanced: uses the internal storage order, see get_x_internal_order().
Definition at line 591 of file det_manip.hpp.
|
inline |
Get an element of the matrix \( M^{(n)} = [G^{(n)}]^{-1} \).
Advanced: uses the internal storage order, see get_x_internal_order().
| i | Row index. |
| j | Column index. |
Definition at line 584 of file det_manip.hpp.
|
inline |
Get the original matrix \( F^{(n)} \).
Warning: this is slow, since it creates a new matrix and re-evaluates the matrix builder.
Definition at line 598 of file det_manip.hpp.
|
inline |
Regenerate the inverse matrix \( M^{(n)} \), the determinant \( \det(G^{(n)}) \) and the sign \( s^{(n)} \) from scratch using the matrix builder.
It uses the matrix builder to rebuild the matrix \( G^{(n)} \), then computes its inverse \( M^{(n)} \) and its determinant \( \det(G^{(n)}) \), and recomputes the sign \( s^{(n)} \) associated with the permutation matrices. This is used to counteract the accumulation of numerical errors after many try/complete operations.
The consistency check against the stored values (see set_precision_warning(), set_precision_error() and set_singular_threshold()) is performed automatically in complete_operation() after a configurable number of operations (see set_n_operations_before_check()); this function itself does not perform that check.
Definition at line 1760 of file det_manip.hpp.
|
inline |
Reject the last try-operation.
All try_* operations have to be either accepted (via complete_operation()) or rejected.
Definition at line 1801 of file det_manip.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 original matrix \( F^{(n)} \). |
| j | Position of the column to be removed in the original matrix \( F^{(n)} \). |
Definition at line 1863 of file det_manip.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 original matrix \( F^{(n)} \). |
| j0,j1 | Positions of the columns to be removed in the original matrix \( F^{(n)} \). |
Definition at line 1883 of file det_manip.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 1894 of file det_manip.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 1874 of file det_manip.hpp.
|
inline |
Reserve memory and resize 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 \( M^{(n)} \) but not the temporary working data, so it must NOT be called between a try_* function and the corresponding complete_operation().
| new_N | New capacity for the size of the matrix, i.e. the maximum number of rows and columns. |
| new_k | Maximum number of rows and columns inserted or removed in a single operation. It sizes the working data used by the try_*_k functions. |
Definition at line 303 of file det_manip.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 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 1964 of file det_manip.hpp.
|
inline |
Set the number of operations before a consistency check is performed (default: 100).
See complete_operation(), which triggers the check once the counter exceeds this number.
| n | Number of operations. |
Definition at line 357 of file det_manip.hpp.
|
inline |
Set the precision threshold that determines when to throw an exception (default: 1e-5).
See set_precision_warning() for details.
| threshold | Threshold value. |
Definition at line 392 of file det_manip.hpp.
|
inline |
Set the precision threshold that determines when to print a warning (default: 1e-8).
In case we compare two matrices \( A \) and \( B \), a warning is printed when \( 2 \lVert A - B \rVert >= \epsilon \left( \lVert A \rVert + \lVert B \rVert \right) \), where \( \lVert \cdot \rVert \) is the max norm.
In case we compare two scalar values \( a \) and \( b \), a warning is printed when \( 2 |a - b| >= \epsilon (|a| + |b|) \).
| threshold | Threshold value. |
Definition at line 378 of file det_manip.hpp.
|
inline |
Set the threshold being used when testing for a singular matrix (default: -1).
The threshold \( \epsilon \) determines when a matrix \( M \) is considered singular. A matrix is considered to be singular if \( |\det(M)| < \epsilon \).
If \( \epsilon \) is negative, it simply checks if the determinant is not std::isnormal.
| threshold | Threshold value. |
Definition at line 343 of file det_manip.hpp.
|
inlinenodiscard |
Get the current size of the matrix.
Definition at line 474 of file det_manip.hpp.
|
inline |
Swap two columns.
It simply performs the transposition in the column permutation vector and changes the sign \( s^{(n)} \) associated with the permutation matrices. It is very quick: we just change the permutation table internally, and this operation is so simple that it has no try/complete step.
Since we are only changing the matrix \( P^{(n)}_c \), the matrix \( G^{(n)} \) and its determinant remain unchanged.
| i | Index of the first column to swap. |
| j | Index of the second column to swap. |
Definition at line 655 of file det_manip.hpp.
|
inline |
Swap two rows.
It simply performs the transposition in the row permutation vector and changes the sign \( s^{(n)} \) associated with the permutation matrices. It is very quick: we just change the permutation table internally, and this operation is so simple that it has no try/complete step.
Since we are only changing the matrix \( P^{(n)}_r \), the matrix \( G^{(n)} \) and its determinant remain unchanged.
| i | Index of the first row to swap. |
| j | Index of the second row to swap. |
Definition at line 635 of file det_manip.hpp.
|
inline |
Try to change one column in the original matrix \( F^{(n)} \).
The column to be changed is at position \( j \) in the original matrix \( F^{(n)} \). The new elements of the columns are determined by the given matrix builder argument \( y \).
Let \( j_p \) be the position of the column in the matrix \( G^{(n)} \). We can write the new matrix as
\[ \widetilde{G}^{(n)} = G^{(n)} + \mathbf{u} \mathbf{v}^T \; , \]
where \( u_i = f(x_i, y) - f(x_i, y_{j_p}) \) and \( \mathbf{v} = \mathbf{e}_{j_p} \) is a cartesian basis vector.
The new inverse matrix \( \widetilde{M}^{(n)} \) is then given by the Sherman-Morrison formula
\[ \widetilde{M}^{(n)} = M^{(n)} - \frac{M^{(n)} \mathbf{u} \mathbf{v}^T M^{(n)}}{1 + \mathbf{v}^T M^{(n)} \mathbf{u}} \; , \]
and the new determinant by the matrix determinant lemma
\[ \det(\widetilde{G}^{(n)}) = \det(G^{(n)}) \left( 1 + \mathbf{v}^T M^{(n)} \mathbf{u} \right) = \det(G^{(n)}) \xi \; . \]
The function returns the ratio
\[ R = \frac{\det(\widetilde{F}^{(n)})}{\det(F^{(n)})} = \left( 1 + \mathbf{v}^T M^{(n)} \mathbf{u} \right) \; . \]
| j | Position of the column to be changed in the original matrix \( F^{(n)} \). |
| y | Argument to the matrix builder that determines the new elements of the column. |
Definition at line 1375 of file det_manip.hpp.
|
inline |
Try to change one column and one row in the original matrix \( F^{(n)} \).
The row and column to be changed are at positions \( i \) and \( j \) in the original matrix \( F^{(n)} \), respectively. The new elements of the row and column are determined by the given matrix builder arguments \( x \) and \( y \).
Let \( i_p \) and \( j_p \) be the positions of the row and the column in the matrix \( G^{(n)} \). We can write the new matrix as
\[ \widetilde{G}^{(n)} = G^{(n)} + \mathbf{r} \mathbf{s}^T + \mathbf{u} \mathbf{v}^T \; , \]
where
By using the matrix determinant lemma twice and once the Sherman-Morrison formula, we find for the new determinant
\[ \det(\widetilde{G}^{(n)}) = \det(G^{(n)}) \left[ (1 + \mathbf{s}^T M^{(n)} \mathbf{r}) (1 + \mathbf{v}^T M^{(n)} \mathbf{u}) - M^{(n)}_{j_p i_p} \mathbf{s}^T M^{(n)} \mathbf{u} \right] = \det(G^{(n)}) \left[ (1 + \alpha)(1 + \beta) - M^{(n)}_{j_p i_p} \gamma \right] = \det(G^{(n)}) \xi \; . \]
The new inverse matrix \( \widetilde{M}^{(n)} \) can be obtained by applying the Sherman-Morrison formula twice:
\[ \widetilde{M}^{(n)} = H^{-1} - \frac{H^{-1} \mathbf{u} \mathbf{v}^T H^{-1}}{1 + \mathbf{v}^T H^{-1} \mathbf{u}} \; , \]
where
\[ H^{-1} = M^{(n)} - \frac{M^{(n)} \mathbf{r} \mathbf{s}^T M^{(n)}}{1 + \mathbf{s}^T M^{(n)} \mathbf{r}} \; . \]
After some algebra, we find for its elements
\[ \widetilde{M}^{(n)}_{ab} = M^{(n)}_{ab} - \frac{(1 + \alpha) (M^{(n)} \mathbf{u})_a M^{(n)}_{j_p b}}{\xi} + \frac{M^{(n)}_{j_p i_p} (M^{(n)} \mathbf{u})_a (\mathbf{s}^T M^{(n)})_b}{\xi} + \frac{\gamma M^{(n)}_{a i_p} M^{(n)}_{j_p b}}{\xi} - \frac{(1 + \beta) (\mathbf{s}^T M^{(n)})_b M^{(n)}_{a i_p}}{\xi} \; . \]
The function returns the ratio
\[ R = \frac{\det(\widetilde{F}^{(n)})}{\det(F^{(n)})} = \xi \; . \]
| i | Position of the row to be changed in the original matrix \( F^{(n)} \). |
| j | Position of the column to be changed in the original 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 1531 of file det_manip.hpp.
|
inline |
Try to change one row in the original matrix \( F^{(n)} \).
The row to be changed is at position \( i \) in the original matrix \( F^{(n)} \). The new elements of the row are determined by the given matrix builder argument \( x \).
We follow the same procedure as in try_change_col(), except that we use \( v_i = f(x, y_j) - f(x_{i_p}, y_j) \) and \( \mathbf{u} = \mathbf{e}_{i_p} \) is a cartesian basis vector.
| i | Position of the row to be changed in the original matrix \( F^{(n)} \). |
| x | Argument to the matrix builder that determines the new elements of the row. |
Definition at line 1432 of file det_manip.hpp.
|
inline |
Try to insert one row and column.
The row is inserted at position \( i \) and the column at position \( j \) in the original matrix \( F^{(n)} \). Their elements are determined by the given matrix builder arguments \( x \) and \( y \).
The new column/row will be at column \( j \), row \( i \), with \( 0 \leq i, j \leq n \). The current column \( j \) (resp. row \( i \)) becomes column \( j + 1 \) (resp. row \( i + 1 \)). Inserting at \( n \) simply adds the new row/column at the end.
This is a special case of try_insert_k() with \( k = 1 \).
| i | Position of the row to be inserted in the original matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the original 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 681 of file det_manip.hpp.
|
inline |
Try to insert two rows and columns.
The rows are inserted at the positions \( i_0 \) and \( i_1 \) and the columns at the positions \( j_0 \) and \( j_1 \) in the original matrix \( F^{(n)} \). Their elements are determined by the given matrix builder arguments \( x_0 \), \( x_1 \), \( y_0 \) and \( y_1 \).
It simply calls the more general try_insert_k().
| i0 | Position of the first row to be inserted in the original matrix \( F^{(n)} \). |
| i1 | Position of the second row to be inserted in the original matrix \( F^{(n)} \). |
| j0 | Position of the first column to be inserted in the original matrix \( F^{(n)} \). |
| j1 | Position of the second column to be inserted in the original 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 943 of file det_manip.hpp.
|
inline |
Try to insert one row and column, providing the new elements through callables instead of the matrix builder.
Like try_insert(), but the elements of the new row and column are supplied directly: fx gives the new row coefficients \( f(x_l, y) \), fy gives the new column coefficients \( f(x, y_l) \), and ksi is the corner element \( f(x, y) \) at the intersection of the new row and column.
| Fx | Callable type for the new row coefficients. |
| Fy | Callable type for the new column coefficients. |
| i | Position of the row to be inserted in the original matrix \( F^{(n)} \). |
| j | Position of the column to be inserted in the original matrix \( F^{(n)} \). |
| fx | Callable returning the new row coefficient for a given argument \( x_l \). |
| fy | Callable returning the new column coefficient for a given argument \( y_l \). |
| ksi | Corner element at the intersection of the new row and column. |
Definition at line 735 of file det_manip.hpp.
|
inline |
Try to insert \( k \) rows and columns.
The positions of the new rows and columns in the original matrix \( F^{(n+k)} \) are specified in the tuples \( \mathbf{i} \) and \( \mathbf{j} \), respectively. Their elements are determined by the given matrix builder arguments \( \mathbf{x} \) and \( \mathbf{y} \).
Since we are working with \( G^{(n)} \), we are free to insert the rows and columns at the bottom and right of the matrix and use the update formulas presented in Determinant manipulation.
We use the following order for the rows and columns to be inserted:
The expression for the new determinant \( \det(G^{(n+k)}) \) can be found at Determinant manipulation and the new sign associated with the permutation matrices can be written as
\[ s^{(n+k)} = \det(P^{(n)}_r) \det(P^{(n)}_c) \det(P1) \det(P2) = s^{(n)} \det(P1) \det(P2) \; , \]
where \( P1 \) and \( P2 \) are permutation matrices that move the inserted rows and columns to their respective positions in the original matrix \( F^{(n)} \).
The function returns the ratio
\[ R = \frac{\det(F^{(n+k)})}{\det(F^{(n)})} = \frac{\det(G^{(n+k)}) s^{(n+k)}}{\det(G^{(n)}) s^{(n)}} = \det(D - C M^{(n)} B) s^{(n+k)} s^{(n)} = \det(S^{-1}) s^{(n+k)} s^{(n)} \; , \]
where we used the fact that \( s^{(n)} = 1 / s^{(n)} \).
| i | Positions of the rows to be inserted in the original matrix \( F^{(n)} \). |
| j | Positions of the columns to be inserted in the original 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 857 of file det_manip.hpp.
|
inline |
Try to fill the original matrix \( F^{(n)} \) with new elements.
This function tries to build a completely new matrix \( \widetilde{F}^{(\widetilde{n})} \) using the given matrix builder arguments \( \mathbf{x} \) and \( \mathbf{y} \). The new elements are calculated as \( \widetilde{F}_{ij} = f(x_i, y_j) \).
The function returns the ratio
\[ R = \frac{\det(\widetilde{F}^{(\widetilde{n})})}{\det(F^{(n)})} \; . \]
| 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 1625 of file det_manip.hpp.
|
inline |
Try to remove one row and column.
The row to be removed is at position \( i \) and the column at position \( j \) in the original matrix \( F^{(n)} \).
This is a special case of try_remove_k() with \( k = 1 \).
| i | Position of the row to be removed in the original matrix \( F^{(n)} \). |
| j | Position of the column to be removed in the original matrix \( F^{(n)} \). |
Definition at line 1088 of file det_manip.hpp.
|
inline |
Try to remove two rows and two columns.
The rows to be removed are specified by the indices \( i_0 \) and \( i_1 \), and the columns by the indices \( j_0 \) and \( j_1 \). The positions are given w.r.t. the original matrix \( F^{(n)} \).
It simply calls the more general try_remove_k().
| i0 | Position of the first row to be removed in the original matrix \( F^{(n)} \). |
| i1 | Position of the second row to be removed in the original matrix \( F^{(n)} \). |
| j0 | Position of the first column to be removed in the original matrix \( F^{(n)} \). |
| j1 | Position of the second column to be removed in the original matrix \( F^{(n)} \). |
Definition at line 1277 of file det_manip.hpp.
|
inline |
Try to remove \( k \) rows and columns.
The rows to be removed are specified in the tuple \( \mathbf{i} \) and the columns in the tuple \( \mathbf{j} \). The positions are given w.r.t. the original matrix \( F^{(n)} \). The corresponding positions in the matrix \( G^{(n)} \) are denoted by \( \mathbf{i}_p \) and \( \mathbf{j}_p \), respectively.
Since we are working with \( G^{(n)} \), we are free to first move the rows and columns to the bottom and to the right of the matrix and use the update formulas presented in Determinant manipulation.
More specifically, we introduce the matrix
\[ \widetilde{G}^{(n)} = P_1 G^{(n)} P_2 = \begin{bmatrix} \widetilde{G}^{(n-k)} & B \\ C & D \end{bmatrix} \; , \]
where \( P_1 \) and \( P_2 \) are permutation matrices that swap the rows and columns to be removed (contained in the matrices \( B \), \( C \) and \( D \)) with the bottom rows and the right most columns of the matrix. \( \widetilde{G}^{(n-k)} \) is the resulting matrix after the remove operation.
We use the following order for the rows and columns to be removed:
The original matrix can be written as
\[ \begin{split} F^{(n)} &= P^{(n)}_r G^{(n)} P^{(n)}_c = P^{(n)}_r P_1^{-1} [P_1 G^{(n)} P_2] P_2^{-1} P^{(n)}_c = \widetilde{P}^{(n)}_r \widetilde{G}^{(n)} \widetilde{P}^{(n)}_c \\ &= P_3 \begin{bmatrix} P^{(n-k)}_r & 0 \\ 0 & I \end{bmatrix} \begin{bmatrix} \widetilde{G}^{(n-k)} & B \\ C & D \end{bmatrix} \begin{bmatrix} P^{(n-k)}_c & 0 \\ 0 & I \end{bmatrix} P_4 \; , \end{split} \]
where \( P_3 \) and \( P_4 \) are permutation matrices that move the rows and columns in \( B \), \( C \) and \( D \) back to their original positions in the matrix \( F^{(n)} \).
We can therefore write the determinant of the resulting matrix \( \widetilde{G}^{(n-k)} \) in terms of the determinant of the current matrix \( G^{(n)} \)
\[ \det(\widetilde{G}^{(n-k)}) = \det(\widetilde{G}^{(n)}) \det(S) = \det(P_1) \det(G^{(n)}) \det(P_2) \det(S) \; , \]
and the new sign \( \widetilde{s}^{(n-k)} \) in terms of the current sign \( s^{(n)} \):
\[ \begin{split} \widetilde{s}^{(n-k)} &= \det(\widetilde{P}^{(n-k)}_r) \det(\widetilde{P}^{(n-k)}_c) = \det(P_3) \det(\widetilde{P}^{(n)}_r) \det(\widetilde{P}^{(n)}_c) \det(P_4) \\ &= \det(P_3) \det(P^{(n)}_r) \det(P_1) \det(P_2) \det(P^{(n)}_c) \det(P_4) = s^{(n)} \det(P_1) \det(P_2) \det(P_3) \det(P_4) \; . \end{split} \]
Here, we used the fact that \( \det(P) = \det(P^{-1}) \) for a permutation matrix \( P \).
The function returns the ratio
\[ R = \frac{\det(F^{(n-k)})}{\det(F^{(n)})} = \frac{\det(\widetilde{G}^{(n-k)}) \widetilde{s}^{(n-k)}}{ \det(G^{(n)}) s^{(n)}} = \det(S) \det(P_3) \det(P_4) \; . \]
| i | Positions of the rows to be removed in the original matrix \( F^{(n)} \). |
| j | Positions of the columns to be removed in the original matrix \( F^{(n)} \). |
Definition at line 1223 of file det_manip.hpp.
|
friend |
For-each implementation for triqs::det_manip::det_manip objects.
It loops over all elements of the matrix \( M^{(n)} \) 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 object. |
| fn | Callable object that takes three arguments: \( x_i \), \( y_j \), and \( M_{ji} \). |
Definition at line 616 of file det_manip.hpp.
|
friend |
Read a triqs::det_manip::det_manip 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 238 of file det_manip.hpp.
|
friend |
Write a triqs::det_manip::det_manip 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 216 of file det_manip.hpp.