keep working on matrix. key is to remove old matrix types
Signed-off-by: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com>
This commit is contained in:
@@ -29,10 +29,13 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance;
|
||||
|
||||
using StgSharp.HighPerformance.Memory;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
using hlsfAllocator = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
|
||||
using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
|
||||
|
||||
namespace StgSharp.Mathematics
|
||||
{
|
||||
public abstract unsafe partial class Matrix<T> where T: unmanaged, INumber<T>
|
||||
@@ -42,6 +45,8 @@ namespace StgSharp.Mathematics
|
||||
|
||||
private protected readonly int t_size = sizeof(T);
|
||||
|
||||
private protected Matrix() { }
|
||||
|
||||
public abstract ref T this[int column, int row]
|
||||
{
|
||||
get;
|
||||
@@ -53,6 +58,14 @@ namespace StgSharp.Mathematics
|
||||
set;
|
||||
}
|
||||
|
||||
public int ColumnCount { get; init; }
|
||||
|
||||
public int RowCount { get; init; }
|
||||
|
||||
protected int KernelColumnCount { get; init; }
|
||||
|
||||
protected int KernelRowCount { get; init; }
|
||||
|
||||
public abstract MatrixKernel* GetMatrixKernel(int column, int row);
|
||||
|
||||
[Obsolete("This method does not contain boarder check, so be careful on size or use indexer instead.", false)]
|
||||
@@ -67,9 +80,9 @@ namespace StgSharp.Mathematics
|
||||
|
||||
public GCMatrix(int column, int row)
|
||||
{
|
||||
int columnSet = (column + 3) / 4;
|
||||
int rowSet = (row + 3) / 4;
|
||||
buffer = new MatrixKernel[columnSet, rowSet];
|
||||
KernelColumnCount = (column + 3) / 4;
|
||||
KernelRowCount = (row + 3) / t_count;
|
||||
buffer = new MatrixKernel[KernelColumnCount, KernelRowCount];
|
||||
}
|
||||
|
||||
public override ref T this[int column, int row]
|
||||
@@ -77,7 +90,7 @@ namespace StgSharp.Mathematics
|
||||
get
|
||||
{
|
||||
int kernelColumn = column / 4, c = column % 4;
|
||||
int kernelRow = row / t_count,r = row % t_count;
|
||||
int kernelRow = row / t_count, r = row % t_count;
|
||||
ref MatrixKernel kernel = ref buffer[kernelColumn, kernelRow];
|
||||
return ref kernel.UnsafeIndex<T>(c, r);
|
||||
}
|
||||
@@ -104,6 +117,15 @@ namespace StgSharp.Mathematics
|
||||
internal unsafe class HlsfMatrix<T> : Matrix<T> where T: unmanaged, INumber<T>
|
||||
{
|
||||
|
||||
private hlsfHandle handle;
|
||||
|
||||
internal HlsfMatrix(int column, int row, hlsfAllocator allocator)
|
||||
{
|
||||
KernelColumnCount = (column + 3) / 4;
|
||||
KernelRowCount = (row + 3) / t_count;
|
||||
this.handle = allocator.Alloc((uint)(KernelColumnCount * KernelRowCount * sizeof(MatrixKernel)));
|
||||
}
|
||||
|
||||
public override ref T this[int column, int row] => throw new NotImplementedException();
|
||||
|
||||
public override Matrix<T> this[ReadOnlySpan<MatrixIndex> column, ReadOnlySpan<MatrixIndex> row]
|
||||
|
||||
Reference in New Issue
Block a user