@@ -25,10 +25,10 @@ spir_kernel* spir_logistic_kernel_new(double lambda, int* status)
25
25
try {
26
26
auto kernel_ptr = std::make_shared<sparseir::LogisticKernel>(lambda);
27
27
std::shared_ptr<sparseir::AbstractKernel> abstract_kernel = _safe_static_pointer_cast<sparseir::AbstractKernel>(kernel_ptr);
28
-
28
+
29
29
// Check if dynamic_cast works at this point
30
30
auto check_logistic = _safe_dynamic_pointer_cast<sparseir::LogisticKernel>(abstract_kernel);
31
-
31
+
32
32
*status = SPIR_COMPUTATION_SUCCESS;
33
33
return create_kernel (abstract_kernel);
34
34
} catch (const std::exception &e) {
@@ -118,9 +118,9 @@ spir_sve_result* spir_sve_result_new(const spir_kernel *k, double epsilon, int*
118
118
*status = SPIR_GET_IMPL_FAILED;
119
119
return nullptr ;
120
120
}
121
-
121
+
122
122
std::shared_ptr<sparseir::SVEResult> sve_result;
123
-
123
+
124
124
if (auto logistic = std::dynamic_pointer_cast<sparseir::LogisticKernel>(impl)) {
125
125
sve_result = std::make_shared<sparseir::SVEResult>(sparseir::compute_sve (*logistic, epsilon));
126
126
} else if (auto bose = std::dynamic_pointer_cast<sparseir::RegularizedBoseKernel>(impl)) {
@@ -235,7 +235,7 @@ spir_sampling* spir_tau_sampling_new_with_matrix(int order, int statistics, int
235
235
DEBUG_LOG (" Error: Invalid statistics" );
236
236
return nullptr ;
237
237
}
238
-
238
+
239
239
// check order
240
240
if (order != SPIR_ORDER_ROW_MAJOR && order != SPIR_ORDER_COLUMN_MAJOR) {
241
241
*status = SPIR_INVALID_ARGUMENT;
@@ -334,14 +334,14 @@ spir_sampling* spir_matsu_sampling_new_with_matrix(
334
334
*status = SPIR_INVALID_ARGUMENT;
335
335
return nullptr ;
336
336
}
337
-
337
+
338
338
// check statistics
339
339
if (statistics != SPIR_STATISTICS_FERMIONIC && statistics != SPIR_STATISTICS_BOSONIC) {
340
340
*status = SPIR_INVALID_ARGUMENT;
341
341
DEBUG_LOG (" Error: Invalid statistics" );
342
342
return nullptr ;
343
343
}
344
-
344
+
345
345
// check order
346
346
if (order != SPIR_ORDER_ROW_MAJOR && order != SPIR_ORDER_COLUMN_MAJOR) {
347
347
*status = SPIR_INVALID_ARGUMENT;
@@ -476,7 +476,7 @@ int spir_dlr2ir_dd(const spir_basis *dlr, int order, int ndim,
476
476
auto impl = get_impl_basis (dlr);
477
477
if (!impl)
478
478
return SPIR_GET_IMPL_FAILED;
479
-
479
+
480
480
if (!is_dlr_basis (dlr)) {
481
481
DEBUG_LOG (" Error: The basis is not a DLR basis" );
482
482
return SPIR_INVALID_ARGUMENT;
@@ -523,7 +523,7 @@ int spir_ir2dlr_dd(const spir_basis *dlr, int order,
523
523
auto impl = get_impl_basis (dlr);
524
524
if (!impl)
525
525
return SPIR_GET_IMPL_FAILED;
526
-
526
+
527
527
if (!is_dlr_basis (dlr)) {
528
528
DEBUG_LOG (" Error: The basis is not a DLR basis" );
529
529
return SPIR_INVALID_ARGUMENT;
@@ -545,7 +545,7 @@ int spir_ir2dlr_zz(const spir_basis *dlr, int order,
545
545
auto impl = get_impl_basis (dlr);
546
546
if (!impl)
547
547
return SPIR_GET_IMPL_FAILED;
548
-
548
+
549
549
if (!is_dlr_basis (dlr)) {
550
550
DEBUG_LOG (" Error: The basis is not a DLR basis" );
551
551
return SPIR_INVALID_ARGUMENT;
@@ -1016,6 +1016,74 @@ int spir_basis_get_default_matsus(const spir_basis *b, bool positive_only, int64
1016
1016
}
1017
1017
}
1018
1018
1019
+ int spir_basis_get_n_default_matsus_ext (const spir_basis *b, bool positive_only, int L, int *num_points_returned)
1020
+ {
1021
+ if (!b || !num_points_returned) {
1022
+ return SPIR_INVALID_ARGUMENT;
1023
+ }
1024
+
1025
+ auto impl = get_impl_basis (b);
1026
+ if (!impl) {
1027
+ return SPIR_GET_IMPL_FAILED;
1028
+ }
1029
+
1030
+ if (!is_ir_basis (b)) {
1031
+ DEBUG_LOG (" Error: The basis is not an IR basis" );
1032
+ return SPIR_INVALID_ARGUMENT;
1033
+ }
1034
+
1035
+ try {
1036
+ if (impl->get_statistics () == SPIR_STATISTICS_FERMIONIC) {
1037
+ auto ir_basis = _safe_static_pointer_cast<_IRBasis<sparseir::Fermionic>>(impl);
1038
+ auto points = ir_basis->default_matsubara_sampling_points_ext (L, positive_only);
1039
+ *num_points_returned = points.size ();
1040
+ return SPIR_COMPUTATION_SUCCESS;
1041
+ } else {
1042
+ auto ir_basis = _safe_static_pointer_cast<_IRBasis<sparseir::Bosonic>>(impl);
1043
+ auto points = ir_basis->default_matsubara_sampling_points_ext (L, positive_only);
1044
+ *num_points_returned = points.size ();
1045
+ return SPIR_COMPUTATION_SUCCESS;
1046
+ }
1047
+ } catch (const std::exception &e) {
1048
+ return SPIR_GET_IMPL_FAILED;
1049
+ }
1050
+ }
1051
+
1052
+ int spir_basis_get_default_matsus_ext (const spir_basis *b, bool positive_only, int L, int64_t *points, int *n_points_returned)
1053
+ {
1054
+ if (!b || !points) {
1055
+ return SPIR_INVALID_ARGUMENT;
1056
+ }
1057
+
1058
+ auto impl = get_impl_basis (b);
1059
+ if (!impl) {
1060
+ return SPIR_GET_IMPL_FAILED;
1061
+ }
1062
+
1063
+ if (!is_ir_basis (b)) {
1064
+ DEBUG_LOG (" Error: The basis is not an IR basis" );
1065
+ return SPIR_INVALID_ARGUMENT;
1066
+ }
1067
+
1068
+ try {
1069
+ if (impl->get_statistics () == SPIR_STATISTICS_FERMIONIC) {
1070
+ auto ir_basis = _safe_static_pointer_cast<_IRBasis<sparseir::Fermionic>>(impl);
1071
+ auto matsubara_points = ir_basis->default_matsubara_sampling_points_ext (L, positive_only);
1072
+ *n_points_returned = matsubara_points.size ();
1073
+ std::copy (matsubara_points.begin (), matsubara_points.end (), points);
1074
+ return SPIR_COMPUTATION_SUCCESS;
1075
+ } else {
1076
+ auto ir_basis = _safe_static_pointer_cast<_IRBasis<sparseir::Bosonic>>(impl);
1077
+ auto matsubara_points = ir_basis->default_matsubara_sampling_points_ext (L, positive_only);
1078
+ *n_points_returned = matsubara_points.size ();
1079
+ std::copy (matsubara_points.begin (), matsubara_points.end (), points);
1080
+ return SPIR_COMPUTATION_SUCCESS;
1081
+ }
1082
+ } catch (const std::exception &e) {
1083
+ return SPIR_GET_IMPL_FAILED;
1084
+ }
1085
+ }
1086
+
1019
1087
int spir_basis_get_stats (const spir_basis *b,
1020
1088
int *statistics)
1021
1089
{
@@ -1093,7 +1161,7 @@ int spir_funcs_batch_eval(const spir_funcs *funcs,
1093
1161
// result is a matrix of size n_funcs x num_points in column-major order
1094
1162
Eigen::MatrixXd result = std::dynamic_pointer_cast<AbstractContinuousFunctions>(impl)->operator ()(Eigen::Map<const Eigen::VectorXd>(xs, num_points));
1095
1163
1096
- // out is a matrix of size num_points x n_funcs
1164
+ // out is a matrix of size num_points x n_funcs
1097
1165
if (order == SPIR_ORDER_ROW_MAJOR) {
1098
1166
// Copy the results to the output array
1099
1167
for (int i = 0 ; i < num_points; ++i) {
@@ -1475,7 +1543,7 @@ int spir_funcs_get_roots(const spir_funcs *funcs, double *roots)
1475
1543
1476
1544
// Get the roots from the implementation
1477
1545
Eigen::VectorXd roots_vec = continuous_impl->roots ();
1478
-
1546
+
1479
1547
// Copy the roots to the output array
1480
1548
std::memcpy (roots, roots_vec.data (), roots_vec.size () * sizeof (double ));
1481
1549
0 commit comments