54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
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;
|
|
}*/
|
|
} |