-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tested some fun stuff, sadly ToSpan, while fast is not faster than wo…
…rking with pointers.
- Loading branch information
1 parent
ea00b05
commit f14f6a0
Showing
5 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using ExtendedSystemObjects; | ||
using Mathematics; | ||
|
||
namespace CommonLibraryTests | ||
{ | ||
internal static class MathSpeedTests | ||
{ | ||
/// <summary> | ||
/// Tests one. Matrix Multiplication | ||
/// </summary> | ||
/// <param name="mOne">The m one.</param> | ||
/// <param name="mTwo">The m two.</param> | ||
/// <returns></returns> | ||
internal static BaseMatrix TestOne(BaseMatrix mOne, BaseMatrix mTwo) | ||
{ | ||
var h = mOne.Height; | ||
var w = mTwo.Width; | ||
var l = mOne.Width; | ||
var result = new BaseMatrix(h, w); | ||
var spanOne = mOne.Matrix.ToSpan(); | ||
var spanTwo = mTwo.Matrix.ToSpan(); | ||
var spanResult = result.Matrix.ToSpan(); | ||
|
||
for (var i = 0; i < h; i++) | ||
{ | ||
var iOne = i * l; | ||
|
||
for (var j = 0; j < w; j++) | ||
{ | ||
var iTwo = j; | ||
|
||
double res = 0; | ||
|
||
for (var k = 0; k < l; k++, iTwo += w) | ||
{ | ||
res += spanOne[iOne + k] * spanTwo[iTwo]; | ||
} | ||
|
||
spanResult[(i * w) + j] = res; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters