This commit is contained in:
h z
2024-06-21 21:48:07 +08:00
commit 42ba33d229
129 changed files with 10711 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
using Skeleton.Algebra.Extensions;
namespace Skeleton.Utils.Helpers;
/// <summary>
/// </summary>
public static class Decorators
{
/// <summary>
/// </summary>
/// <param name="tol"></param>
/// <param name="f"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T WithTol<T>(double tol, Func<T> f)
{
GeneralExt.SetTol(tol);
T res = f();
GeneralExt.ResetTol();
return res;
}
/// <summary>
/// </summary>
/// <param name="tol"></param>
/// <param name="a"></param>
public static void WithTol(double tol, Action a)
{
GeneralExt.SetTol(tol);
a();
GeneralExt.ResetTol();
}
/*public static M WithRealFix<D, V, M>(Func<M> f)
where D : IDimension
where V : class, IRealVector<D, V>
where M : class, IRealMatrix<D, V, M>
{
M res = f();
res.Fix();
return res;
}
public static M WithComplexFix<D, V, M>(Func<M> f)
where D : IDimension
where V : class, IComplexVector<D, V>
where M : class, IComplexMatrix<D, V, M>
{
M res = f();
res.Fix();
return res;
}*/
}