-
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
56 changed files
with
1,878 additions
and
1,499 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
2 changes: 1 addition & 1 deletion
2
src/NetFabric.Numerics.Angle.UnitTests/NetFabric.Numerics.Angle.UnitTests.csproj
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,108 @@ | ||
namespace NetFabric.Numerics.UnitTests; | ||
|
||
public class SpanAddTests | ||
{ | ||
public static TheoryData<Angle<Degrees, double>[], Angle<Degrees, double>, Angle<Degrees, double>[]> AddValueData | ||
=> new() | ||
{ | ||
{ | ||
Array.Empty<Angle<Degrees, double>>(), | ||
new Angle<Degrees, double>(1), | ||
Array.Empty<Angle<Degrees, double>>() | ||
}, | ||
{ | ||
new Angle<Degrees, double>[] { new(1.0) }, | ||
new Angle<Degrees, double>(2.0), | ||
new Angle<Degrees, double>[] { new(3.0) } | ||
}, | ||
{ | ||
new Angle<Degrees, double>[] { new(1.0), new(11.0) }, | ||
new Angle<Degrees, double>(12.0), | ||
new Angle<Degrees, double>[] { new(13.0), new(23.0) } | ||
}, | ||
{ | ||
Enumerable.Range(0, 97).Select(value => new Angle<Degrees, double>(value)).ToArray(), | ||
new Angle<Degrees, double>(3.0), | ||
Enumerable.Range(0, 97).Select(value => new Angle<Degrees, double>(value + 3.0)).ToArray() | ||
}, | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(AddValueData))] | ||
public void Add_Value_Should_Succeed(Angle<Degrees, double>[] source, Angle<Degrees, double> value, Angle<Degrees, double>[] expected) | ||
{ | ||
// arrange | ||
var result = new Angle<Degrees, double>[source.Length]; | ||
|
||
// act | ||
Angle.Add(source, value, result); | ||
|
||
// assert | ||
result.Should().Equal(expected); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(AddValueData))] | ||
public void Add_Value_Inplace_Should_Succeed(Angle<Degrees, double>[] source, Angle<Degrees, double> value, Angle<Degrees, double>[] expected) | ||
{ | ||
// arrange | ||
|
||
// act | ||
Angle.Add(source, value, source); | ||
|
||
// assert | ||
source.Should().Equal(expected); | ||
} | ||
|
||
public static TheoryData<Angle<Degrees, double>[], Angle<Degrees, double>[], Angle<Degrees, double>[]> AddData | ||
=> new() | ||
{ | ||
{ | ||
Array.Empty<Angle<Degrees, double>>(), | ||
Array.Empty<Angle<Degrees, double>>(), | ||
Array.Empty<Angle<Degrees, double>>() | ||
}, | ||
{ | ||
new Angle<Degrees, double>[] { new(1.0) }, | ||
new Angle<Degrees, double>[] { new(3.0) }, | ||
new Angle<Degrees, double>[] { new(4.0) } | ||
}, | ||
{ | ||
new Angle<Degrees, double>[] { new(1.0), new(11.0) }, | ||
new Angle<Degrees, double>[] { new(12.0), new(13.0) }, | ||
new Angle<Degrees, double>[] { new(13.0), new(24.0) } | ||
}, | ||
{ | ||
Enumerable.Range(0, 97).Select(value => new Angle<Degrees, double>(value)).ToArray(), | ||
Enumerable.Range(0, 97).Select(value => new Angle<Degrees, double>(value + 1.0)).ToArray(), | ||
Enumerable.Range(0, 97).Select(value => new Angle<Degrees, double>(value * 2.0 + 1.0)).ToArray() | ||
}, | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(AddData))] | ||
public void Add_Should_Succeed(Angle<Degrees, double>[] left, Angle<Degrees, double>[] right, Angle<Degrees, double>[] expected) | ||
{ | ||
// arrange | ||
var result = new Angle<Degrees, double>[left.Length]; | ||
|
||
// act | ||
Angle.Add<Degrees, double>(left, right, result); | ||
|
||
// assert | ||
result.Should().Equal(expected); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(AddData))] | ||
public void Add_Inplace_Should_Succeed(Angle<Degrees, double>[] left, Angle<Degrees, double>[] right, Angle<Degrees, double>[] expected) | ||
{ | ||
// arrange | ||
|
||
// act | ||
Angle.Add<Degrees, double>(left, right, left); | ||
|
||
// assert | ||
left.Should().Equal(expected); | ||
} | ||
} |
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,37 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace NetFabric.Numerics; | ||
|
||
public static partial class Angle | ||
{ | ||
public static void Add<TUnits, T>(ReadOnlySpan<Angle<TUnits, T>> angles, Angle<TUnits, T> value, Span<Angle<TUnits, T>> result) | ||
where TUnits : IAngleUnits | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
=> Tensor.Add(MemoryMarshal.Cast<Angle<TUnits, T>, T>(angles), value.Value, MemoryMarshal.Cast<Angle<TUnits, T>, T>(result)); | ||
|
||
public static void Add<TUnits, T>(ReadOnlySpan<Angle<TUnits, T>> left, ReadOnlySpan<Angle<TUnits, T>> right, Span<Angle<TUnits, T>> result) | ||
where TUnits : IAngleUnits | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
=> Tensor.Add(MemoryMarshal.Cast<Angle<TUnits, T>, T>(left), MemoryMarshal.Cast<Angle<TUnits, T>, T>(right), MemoryMarshal.Cast<Angle<TUnits, T>, T>(result)); | ||
|
||
public static void Subtract<TUnits, T>(ReadOnlySpan<Angle<TUnits, T>> angles, Angle<TUnits, T> value, Span<Angle<TUnits, T>> result) | ||
where TUnits : IAngleUnits | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
=> Tensor.Subtract(MemoryMarshal.Cast<Angle<TUnits, T>, T>(angles), value.Value, MemoryMarshal.Cast<Angle<TUnits, T>, T>(result)); | ||
|
||
public static void Subtract<TUnits, T>(ReadOnlySpan<Angle<TUnits, T>> left, ReadOnlySpan<Angle<TUnits, T>> right, Span<Angle<TUnits, T>> result) | ||
where TUnits : IAngleUnits | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
=> Tensor.Subtract(MemoryMarshal.Cast<Angle<TUnits, T>, T>(left), MemoryMarshal.Cast<Angle<TUnits, T>, T>(right), MemoryMarshal.Cast<Angle<TUnits, T>, T>(result)); | ||
|
||
public static void Multiply<TUnits, T>(ReadOnlySpan<Angle<TUnits, T>> angles, Angle<TUnits, T> value, Span<Angle<TUnits, T>> result) | ||
where TUnits : IAngleUnits | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
=> Tensor.Multiply(MemoryMarshal.Cast<Angle<TUnits, T>, T>(angles), value.Value, MemoryMarshal.Cast<Angle<TUnits, T>, T>(result)); | ||
|
||
public static void Divide<TUnits, T>(ReadOnlySpan<Angle<TUnits, T>> angles, Angle<TUnits, T> value, Span<Angle<TUnits, T>> result) | ||
where TUnits : IAngleUnits | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
=> Tensor.Divide(MemoryMarshal.Cast<Angle<TUnits, T>, T>(angles), value.Value, MemoryMarshal.Cast<Angle<TUnits, T>, T>(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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
src/NetFabric.Numerics.Benchmarks/AdditionVectorDoubleBenchmark.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.