Initial commit

This commit is contained in:
2026-07-03 16:37:12 +07:00
commit 63b8c1ea8b
1931 changed files with 640587 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System;
using CeresSharp.Native;
namespace CeresSharp.Native.SafeHandles;
/// <summary>
/// Safe handle for Ceres Covariance.
/// </summary>
internal sealed class CovarianceHandle : BaseSafeHandle
{
private CovarianceHandle() : base()
{
}
private CovarianceHandle(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle)
{
}
public static CovarianceHandle Create()
{
var handle = CeresNative.ceres_wrapper_create_covariance();
if (handle == IntPtr.Zero)
{
throw new Exceptions.CeresException(Exceptions.CeresErrorCode.OutOfMemory, "Failed to create covariance");
}
return new CovarianceHandle(handle, true);
}
public static CovarianceHandle CreateWithOptions(IntPtr options)
{
var handle = CeresNative.ceres_wrapper_create_covariance_with_options(options);
if (handle == IntPtr.Zero)
{
throw new Exceptions.CeresException(Exceptions.CeresErrorCode.OutOfMemory, "Failed to create covariance with options");
}
return new CovarianceHandle(handle, true);
}
protected override void ReleaseNativeHandle(IntPtr handle)
{
CeresNative.ceres_wrapper_free_covariance(handle);
}
}