move random gen to Math, working on VL4

This commit is contained in:
Nitload
2026-03-02 23:56:21 +08:00
parent 7e3ed8b0fd
commit ae1a49d6fb
63 changed files with 6463 additions and 6970 deletions
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixCompute.Float"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -26,8 +26,8 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.HighPerformance;
using StgSharp.Internal;
using StgSharp.Mathematics;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
@@ -42,11 +42,7 @@ namespace StgSharp.Mathematics.Numeric
public static partial class MatrixCompute
{
public static unsafe void Add(
Matrix<float> left,
Matrix<float> right,
Matrix<float> ans
)
public static unsafe void Add(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
{
int f32 = (int)MatrixElementType.F32;
if (left.ColumnLength != right.ColumnLength ||
@@ -92,10 +88,7 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Fill(
Matrix<float> ans,
float value
)
public static unsafe void Fill(Matrix<float> ans, float value)
{
int f32 = (int)MatrixElementType.F32;
long count = (long)ans.KernelColumnLength * ans.KernelRowLength;
@@ -126,11 +119,7 @@ namespace StgSharp.Mathematics.Numeric
taskGroup.Dispose();
}
public static unsafe void Mul(
Matrix<float> left,
Matrix<float> right,
Matrix<float> ans
)
public static unsafe void Mul(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
{
int f32 = (int)MatrixElementType.F32;
@@ -168,8 +157,7 @@ namespace StgSharp.Mathematics.Numeric
NativeIntrinsic.Context
.mat[f32].kernel_tile_fma((MatrixKernel*)left.Buffer,
(MatrixKernel*)right.Buffer,
(MatrixKernel*)ans.Buffer,
enumeration);
(MatrixKernel*)ans.Buffer, enumeration);
}
}
@@ -196,18 +184,13 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Mul(
Matrix<float> left,
float right,
Matrix<float> ans
)
public static unsafe void Mul(Matrix<float> left, float right, Matrix<float> ans)
{
int f32 = (int)MatrixElementType.F32;
if (left.ColumnLength != ans.ColumnLength || left.RowLength != ans.RowLength) {
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
}
if (left.Layout != MatrixLayout.DenseRectangle ||
ans.Layout != MatrixLayout.DenseRectangle) {
if (left.Layout != MatrixLayout.DenseRectangle || ans.Layout != MatrixLayout.DenseRectangle) {
throw new NotSupportedException("Only dense rectangle matrices are supported.");
}
long count = (long)left.KernelColumnLength * left.KernelRowLength;
@@ -248,11 +231,7 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Sub(
Matrix<float> left,
Matrix<float> right,
Matrix<float> ans
)
public static unsafe void Sub(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
{
int f32 = (int)MatrixElementType.F32;
if (left.ColumnLength != right.ColumnLength ||