92 lines
3.2 KiB
C#
92 lines
3.2 KiB
C#
using System;
|
|
using CeresSharp.Enums;
|
|
using CeresSharp.Native;
|
|
using CeresSharp.Native.SafeHandles;
|
|
|
|
namespace CeresSharp.Advanced;
|
|
|
|
/// <summary>
|
|
/// Options for covariance estimation.
|
|
/// </summary>
|
|
public sealed class CovarianceOptions : IDisposable
|
|
{
|
|
private readonly CovarianceOptionsHandle _handle;
|
|
private bool _disposed;
|
|
|
|
/// <summary>
|
|
/// Creates a new CovarianceOptions instance with default settings.
|
|
/// </summary>
|
|
public CovarianceOptions()
|
|
{
|
|
_handle = CovarianceOptionsHandle.Create();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the native handle.
|
|
/// </summary>
|
|
internal CovarianceOptionsHandle Handle => _handle;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the number of threads to use.
|
|
/// </summary>
|
|
public int NumThreads
|
|
{
|
|
get => CeresNative.ceres_wrapper_covariance_options_get_num_threads(_handle.DangerousGetHandle());
|
|
set => CeresNative.ceres_wrapper_covariance_options_set_num_threads(_handle.DangerousGetHandle(), value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the sparse linear algebra library type.
|
|
/// </summary>
|
|
public SparseLinearAlgebraLibraryType SparseLinearAlgebraLibraryType
|
|
{
|
|
get => (SparseLinearAlgebraLibraryType)CeresNative.ceres_wrapper_covariance_options_get_sparse_linear_algebra_library_type(_handle.DangerousGetHandle());
|
|
set => CeresNative.ceres_wrapper_covariance_options_set_sparse_linear_algebra_library_type(_handle.DangerousGetHandle(), (int)value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the algorithm type.
|
|
/// </summary>
|
|
public CovarianceAlgorithmType AlgorithmType
|
|
{
|
|
get => (CovarianceAlgorithmType)CeresNative.ceres_wrapper_covariance_options_get_algorithm_type(_handle.DangerousGetHandle());
|
|
set => CeresNative.ceres_wrapper_covariance_options_set_algorithm_type(_handle.DangerousGetHandle(), (int)value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the minimum reciprocal condition number.
|
|
/// </summary>
|
|
public double MinReciprocalConditionNumber
|
|
{
|
|
get => CeresNative.ceres_wrapper_covariance_options_get_min_reciprocal_condition_number(_handle.DangerousGetHandle());
|
|
set => CeresNative.ceres_wrapper_covariance_options_set_min_reciprocal_condition_number(_handle.DangerousGetHandle(), value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the null space rank.
|
|
/// </summary>
|
|
public int NullSpaceRank
|
|
{
|
|
get => CeresNative.ceres_wrapper_covariance_options_get_null_space_rank(_handle.DangerousGetHandle());
|
|
set => CeresNative.ceres_wrapper_covariance_options_set_null_space_rank(_handle.DangerousGetHandle(), value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether to apply loss function.
|
|
/// </summary>
|
|
public bool ApplyLossFunction
|
|
{
|
|
get => CeresNative.ceres_wrapper_covariance_options_get_apply_loss_function(_handle.DangerousGetHandle()) != 0;
|
|
set => CeresNative.ceres_wrapper_covariance_options_set_apply_loss_function(_handle.DangerousGetHandle(), value ? 1 : 0);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (!_disposed)
|
|
{
|
|
_handle?.Dispose();
|
|
_disposed = true;
|
|
}
|
|
}
|
|
}
|