90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
// -----------------------------------------------------------------------------
|
|
// file="MatrixTest"
|
|
// Project: StgSharp
|
|
// Copyright (c) Nitload.
|
|
// SPDX-License-Identifier: MIT
|
|
// -----------------------------------------------------------------------------
|
|
|
|
using StgSharp.HighPerformance.Memory;
|
|
using StgSharp.Mathematics.Numeric;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using T = float;
|
|
|
|
namespace StgSharp
|
|
{
|
|
internal static partial class Program
|
|
{
|
|
|
|
private static int sideLength = 1000;
|
|
|
|
private static readonly nuint size = (nuint)(1024UL * 1024UL * 1024UL * 4UL);
|
|
|
|
internal static unsafe void TestMatrix(
|
|
)
|
|
{
|
|
// TestRender();
|
|
/**/
|
|
TwoLayerSegregatedFitAllocator hlsf;
|
|
unchecked {
|
|
hlsf = new(size, 32, size);
|
|
}
|
|
Matrix<float> m = Matrix<float>.Create(sideLength, sideLength,
|
|
MatrixLayout.DenseRectangle, hlsf);
|
|
|
|
// MatrixCompute.Fill(m, 1.0f);
|
|
Matrix<float> n = Matrix<float>.Create(sideLength, sideLength,
|
|
MatrixLayout.DenseRectangle, hlsf);
|
|
|
|
// MatrixCompute.Fill(n, 1.0f);
|
|
Matrix<float> p = Matrix<float>.Create(sideLength, sideLength,
|
|
MatrixLayout.DenseRectangle, hlsf);
|
|
|
|
// MatrixCompute.Fill(p, 0.0f);
|
|
|
|
/*
|
|
for (int j = 0; j < 20; j++)
|
|
{
|
|
for (int k = 0; k < 10; k++) {
|
|
Console.Write($"{m[j, k]:0.0E+00}\t");
|
|
}
|
|
Console.WriteLine();
|
|
}
|
|
|
|
/**/
|
|
Console.WriteLine("===================================================");
|
|
|
|
// MatrixCompute.Mul(n, m, p);
|
|
/**/
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
if (i % 4 == 0) {
|
|
Console.WriteLine();
|
|
}
|
|
for (int j = 0; j < 20; j++)
|
|
{
|
|
string extra = j % 4 == 3 ? " " : ",";
|
|
float value = p[j, i];
|
|
|
|
// value = T.Abs(value) < 1e-6 ? 0 : value;
|
|
|
|
// Console.Write($"{p.GetElementOffset(j,i)}{extra}");
|
|
|
|
Console.Write($"{value:000}{extra}");
|
|
}
|
|
Console.WriteLine();
|
|
}
|
|
Console.WriteLine("===================================================");
|
|
|
|
/**/
|
|
hlsf.Dispose();
|
|
}
|
|
|
|
}
|
|
}
|