/// <summary> /// Checks if two NdArrays have the same (within machine precision) values in all elements. /// </summary> /// <param name="lhs">The NdArray on the left side of this binary operation.</param> /// <param name="rhs">The NdArray on the right side of this binary operation.</param> /// <param name="absoluteTolerence">The absolute tolerance. (default 1e-8)</param> /// <param name="relativeTolerence">The relative tolerance. (default 1e-5)</param> /// <returns>true if two NdArrays have same (within specified precision) values in all elements, otherwise false.</returns> public static bool AlmostEqual(NdArray <float> lhs, NdArray <float> rhs, float absoluteTolerence = 1e-8f, float relativeTolerence = 1e-5f) { if (Enumerable.SequenceEqual(lhs.Shape, rhs.Shape)) { return(NdArray <float> .All(IsClose(lhs, rhs, absoluteTolerence, relativeTolerence))); } return(false); }
/// <summary> /// Checks if two NdArrays have the same (within machine precision) values in all elements. /// </summary> /// <param name="lhs">The NdArray on the left side of this binary operation.</param> /// <param name="rhs">The NdArray on the right side of this binary operation.</param> /// <param name="absoluteTolerence">The absolute tolerance. (default 1e-8)</param> /// <param name="relativeTolerence">The relative tolerance. (default 1e-5)</param> /// <returns>true if two NdArrays have same (within specified precision) values in all elements, otherwise false.</returns> public static bool AlmostEqual(NdArray <double> lhs, NdArray <double> rhs, double absoluteTolerence = 1e-8, double relativeTolerence = 1e-5) { if (Enumerable.SequenceEqual(lhs.Shape, rhs.Shape)) { return(NdArray <double> .All(IsClose(lhs, rhs, absoluteTolerence, relativeTolerence))); } return(false); }
/// <summary> /// Checks if two NdArrays have the same (within machine precision) values in all elements. /// The default absolute tolerance is 1e-8. /// The default relative tolerance is 1e-5. /// </summary> /// <param name="lhs">The NdArray on the left side of this binary operation.</param> /// <param name="rhs">The NdArray on the right side of this binary operation.</param> /// <returns>true if two NdArrays have same (within specified precision) values in all elements, otherwise false.</returns> public static bool AlmostEqual(NdArray <T> lhs, NdArray <T> rhs) { if (Enumerable.SequenceEqual(lhs.Shape, rhs.Shape)) { return(NdArray <T> .All(IsClose(lhs, rhs))); } return(false); }
public void Negate() { // arrange var input = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 10 }); // action var output = LogicalFunction <bool> .Negate(input); // assert Assert.IsTrue(NdArray <bool> .All(output)); }
public void IsFinite() { // arrange var device = HostDevice.Instance; var source = NdArray <int> .Zeros(device, new[] { 2, 3, 4 }); // action var result = ComparisonFunction <int> .IsFinite(source); // assert Assert.IsTrue(NdArray <int> .All(result)); }
public void Or() { // arrange var input1 = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 4 }); var input2 = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 4 }); // action var output = LogicalFunction <bool> .Or(input1, input2); // assert var expected = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 4 }); var result = expected == output; Assert.IsTrue(NdArray <bool> .All(result)); }