using System; using CeresSharp.Native; using CeresSharp.Native.SafeHandles; namespace CeresSharp.Advanced; /// /// Options for gradient checking. /// public sealed class GradientCheckerOptions : IDisposable { private readonly GradientCheckerOptionsHandle _handle; private bool _disposed; /// /// Creates a new GradientCheckerOptions instance with default settings. /// public GradientCheckerOptions() { _handle = GradientCheckerOptionsHandle.Create(); } /// /// Gets the native handle. /// internal GradientCheckerOptionsHandle Handle => _handle; /// /// Gets or sets the gradient check relative precision. /// public double GradientCheckRelativePrecision { get => CeresNative.ceres_wrapper_gradient_checker_options_get_gradient_check_relative_precision(_handle.DangerousGetHandle()); set => CeresNative.ceres_wrapper_gradient_checker_options_set_gradient_check_relative_precision(_handle.DangerousGetHandle(), value); } /// /// Gets or sets the numeric derivative relative step size. /// public double NumericDerivativeRelativeStepSize { get => CeresNative.ceres_wrapper_gradient_checker_options_get_gradient_check_numeric_derivative_relative_step_size(_handle.DangerousGetHandle()); set => CeresNative.ceres_wrapper_gradient_checker_options_set_gradient_check_numeric_derivative_relative_step_size(_handle.DangerousGetHandle(), value); } public void Dispose() { if (!_disposed) { _handle?.Dispose(); _disposed = true; } } }