redesign matrix design
This commit is contained in:
@@ -25,59 +25,74 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using hlsfAllocator = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
|
||||
// using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
public static class Matrix
|
||||
public unsafe partial class Matrix<T> where T : unmanaged, INumber<T>
|
||||
{
|
||||
|
||||
public static hlsfAllocator? DefaultAllocator
|
||||
private protected static readonly int t_count = 16 / sizeof(T);
|
||||
|
||||
private protected static readonly int t_size = sizeof(T);
|
||||
private MatrixMetadata _enumeration;
|
||||
|
||||
private MatrixStorage<T> _buffer;
|
||||
|
||||
private protected Matrix() { }
|
||||
|
||||
public ref T this[int column, int row]
|
||||
{
|
||||
get
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(field, nameof(DefaultAllocator));
|
||||
return null;
|
||||
get => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public unsafe Matrix<T> this[
|
||||
ReadOnlySpan<MatrixIndex> column,
|
||||
ReadOnlySpan<MatrixIndex> row]
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Length of the matrix in columns.
|
||||
/// </summary>
|
||||
public int ColumnLength { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Length of the matrix in rows.
|
||||
/// </summary>
|
||||
public int RowLength { get; init; }
|
||||
|
||||
public MatrixLayout Layout { get; init; }
|
||||
|
||||
internal MatrixKernel<T>* Buffer { get; }
|
||||
|
||||
protected internal int KernelColumnLength { get; init; }
|
||||
|
||||
protected internal int KernelRowLength { get; init; }
|
||||
|
||||
public ref MatrixKernel<T> GetMatrixKernel(int column, int row)
|
||||
{
|
||||
if (_enumeration.GetCurrentKernelIndex) { } else { }
|
||||
}
|
||||
|
||||
private protected void AssertIndex(int column, int row)
|
||||
{
|
||||
if (column < 0 || column >= ColumnLength) {
|
||||
throw new ArgumentOutOfRangeException(nameof(column));
|
||||
}
|
||||
set;
|
||||
} = null;
|
||||
|
||||
public static MatrixAllocation DefaultAllocation { get; set; } = MatrixAllocation.GC;
|
||||
|
||||
public static Matrix<T> FromDefault<T>(int columnLength, int rowLength)
|
||||
where T : unmanaged, INumber<T>
|
||||
{
|
||||
return DefaultAllocation switch
|
||||
{
|
||||
MatrixAllocation.GC => FromGC<T>(columnLength, rowLength),
|
||||
MatrixAllocation.HLSF => FromHlsf<T>(columnLength, rowLength, DefaultAllocator!),
|
||||
_ => throw new NotSupportedException("This allocation is not supported."),
|
||||
};
|
||||
}
|
||||
|
||||
public static Matrix<T> FromGC<T>(int columnLength, int rowLength)
|
||||
where T : unmanaged, INumber<T>
|
||||
{
|
||||
return new GCMatrix<T>(columnLength, rowLength);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix<T> FromHlsf<T>(
|
||||
int columnLength,
|
||||
int rowLength,
|
||||
hlsfAllocator allocator)
|
||||
where T : unmanaged, INumber<T>
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(allocator, nameof(allocator));
|
||||
return new HlsfMatrix<T>(columnLength, rowLength, allocator);
|
||||
if (row < 0 || row >= RowLength) {
|
||||
throw new ArgumentOutOfRangeException(nameof(row));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user