M2
This commit is contained in:
54
src/Utils/Helpers/Decorators.cs
Normal file
54
src/Utils/Helpers/Decorators.cs
Normal 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;
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user