@@ -853,8 +853,8 @@ namespace cytnx {
853853 // Rsvd:
854854 // ==================================================
855855 /* *
856- * @brief Perform a truncated Singular-Value decomposition of a UniTensor.
857- @details This function will perform a truncated Singular-Value decomposition
856+ * @brief Perform a randomized truncated Singular-Value decomposition of a UniTensor.
857+ @details This function will perform a randomized truncated Singular-Value decomposition
858858 of a UniTensor. It uses the ?gesvd method for the SVD. It will perform the randomized
859859 SVD first, and then truncate the singular values to the given cutoff \p err. That means, given a
860860 UniTensor \p Tin as \f$ M \f$, then the result will be: \f[ M = U S V^\dagger, \f] where \f$ S
@@ -908,6 +908,41 @@ namespace cytnx {
908908 cytnx_uint64 power_iteration = 0 ,
909909 unsigned int seed = random::__static_random_device());
910910
911+ /* *
912+ * @brief Perform a truncated Singular-Value decomposition of a UniTensor and keep at most
913+ * \p min_blockdim singular values in each block.
914+ * @details For each block, the minimum dimension can be chosen for the truncation. This can be
915+ * helpful to avoid loosing symmetry sectors in the truncated SVD. For more details, please
916+ * refer to the documentation of the function \ref Rsvd(const cytnx::UniTensor &Tin,
917+ * cytnx_uint64 keepdim, double err = 0., bool is_U = true, bool is_vT = true, unsigned int
918+ * return_err = 0, cytnx_uint64 mindim = 1, cytnx_uint64 oversampling_summand = 10, double
919+ * oversampling_factor = 1., cytnx_uint64 power_iteration = 0, unsigned int seed =
920+ * random::__static_random_device()).
921+ *
922+ * The truncation order is as following (later constraints might be violated by previous
923+ * ones):<br> 1) Keep the largest \p min_blockdim singular values in each block; reduce \p
924+ * keepdim and \p mindim by the number of already kept singular values<br> 2) Keep at most \p
925+ * keepdim singular values; there might be an exception in case of exact degeneracies where more
926+ * singular values are kept<br> 3) Keep at least \p mindim singular values;<br> 4) Drop all
927+ * singular values smaller than \p err (no normalization applied to the singular values)
928+ *
929+ * @param[in] min_blockdim a vector containing the minimum dimension of each block;
930+ * alternatively, a vector with only one element can be given to have the same min_blockdim for
931+ * each block
932+ * @see Rsvd(const cytnx::UniTensor &Tin, cytnx_uint64 keepdim, double err = 0., bool is_U =
933+ * true, bool is_vT = true, unsigned int return_err = 0, cytnx_uint64 mindim = 1, cytnx_uint64
934+ * oversampling_summand = 10, double oversampling_factor = 1., cytnx_uint64 power_iteration = 0,
935+ * unsigned int seed = random::__static_random_device())
936+ */
937+ std::vector<cytnx::UniTensor> Rsvd (const cytnx::UniTensor &Tin, cytnx_uint64 keepdim,
938+ const std::vector<cytnx_uint64> min_blockdim,
939+ double err = 0 ., bool is_U = true , bool is_vT = true ,
940+ unsigned int return_err = 0 , cytnx_uint64 mindim = 1 ,
941+ cytnx_uint64 oversampling_summand = 10 ,
942+ double oversampling_factor = 1 .,
943+ cytnx_uint64 power_iteration = 0 ,
944+ unsigned int seed = random::__static_random_device());
945+
911946 std::vector<cytnx::UniTensor> Hosvd (
912947 const cytnx::UniTensor &Tin, const std::vector<cytnx_uint64> &mode,
913948 const bool &is_core = true , const bool &is_Ls = false ,
0 commit comments