-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
176 additions
and
176 deletions.
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
70 changes: 35 additions & 35 deletions
70
src/NetFabric.Numerics.Tensors.UnitTests/ProductOfAdditionsTuple3DTests.cs
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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
namespace NetFabric.Numerics.Tensors.UnitTests; | ||
|
||
public class ProductOfAdditionsTuple3DTests | ||
{ | ||
public static TheoryData<int> ProductOfAdditions3DData | ||
=> new() { | ||
{ 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 }, { 10 }, { 100 }, | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(ProductOfAdditions3DData))] | ||
static void ProductOfAdditions4D_Using_Tuple3D_Should_Succeed(int count) | ||
{ | ||
// arrange | ||
var x = new ValueTuple<int, int, int>[count]; | ||
var y = new ValueTuple<int, int, int>[count]; | ||
var expected = new ValueTuple<int, int, int, int>(1, 1, 1, 0); | ||
var random = new Random(42); | ||
for (var index = 0; index < x.Length; index++) | ||
{ | ||
var value = new ValueTuple<int, int, int>(random.Next(10), random.Next(10), random.Next(10)); | ||
var value2 = new ValueTuple<int, int, int>(random.Next(10), random.Next(10), random.Next(10)); | ||
x[index] = value; | ||
y[index] = value2; | ||
expected = new ((value.Item1 + value2.Item1) * expected.Item1, (value.Item2 + value2.Item2) * expected.Item2, (value.Item3 + value2.Item3) * expected.Item3, 0); | ||
} | ||
|
||
// act | ||
var result = TensorOperations.ProductOfAdditions4D<int>( | ||
MemoryMarshal.Cast<ValueTuple<int, int, int>, int>(x), | ||
MemoryMarshal.Cast<ValueTuple<int, int, int>, int>(y)); | ||
|
||
// assert | ||
Assert.Equal(expected, Assert.NotNull(result)); | ||
} | ||
namespace NetFabric.Numerics.Tensors.UnitTests; | ||
|
||
public class ProductOfAdditionsTuple3DTests | ||
{ | ||
public static TheoryData<int> ProductOfAdditions3DData | ||
=> new() { | ||
{ 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 }, { 10 }, { 100 }, | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(ProductOfAdditions3DData))] | ||
static void ProductOfAdditions4D_Using_Tuple3D_Should_Succeed(int count) | ||
{ | ||
// arrange | ||
var x = new ValueTuple<int, int, int>[count]; | ||
var y = new ValueTuple<int, int, int>[count]; | ||
var expected = new ValueTuple<int, int, int, int>(1, 1, 1, 0); | ||
var random = new Random(42); | ||
for (var index = 0; index < x.Length; index++) | ||
{ | ||
var value = new ValueTuple<int, int, int>(random.Next(10), random.Next(10), random.Next(10)); | ||
var value2 = new ValueTuple<int, int, int>(random.Next(10), random.Next(10), random.Next(10)); | ||
x[index] = value; | ||
y[index] = value2; | ||
expected = new ((value.Item1 + value2.Item1) * expected.Item1, (value.Item2 + value2.Item2) * expected.Item2, (value.Item3 + value2.Item3) * expected.Item3, 0); | ||
} | ||
|
||
// act | ||
var result = TensorOperations.ProductOfAdditions4D<int>( | ||
MemoryMarshal.Cast<ValueTuple<int, int, int>, int>(x), | ||
MemoryMarshal.Cast<ValueTuple<int, int, int>, int>(y)); | ||
|
||
// assert | ||
Assert.Equal(expected, Assert.NotNull(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
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
Oops, something went wrong.