Skip to content

Commit 5a0898d

Browse files
committed
Created directory named Logic
1 parent ddcfdd5 commit 5a0898d

5 files changed

Lines changed: 418 additions & 50 deletions

File tree

src/NumSharp.Core/Logic/np.all.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NumSharp.Backends;
2+
using NumSharp.Generic;
3+
4+
namespace NumSharp {
5+
public static partial class np
6+
{
7+
/// <summary>
8+
/// Test whether all array elements evaluate to True.
9+
/// </summary>
10+
/// <param name="nd"></param>
11+
/// <returns></returns>
12+
public static bool all(NDArray nd)
13+
=> BackendFactory.GetEngine().All(nd);
14+
15+
/// <summary>
16+
/// Test whether all array elements along a given axis evaluate to True.
17+
/// </summary>
18+
/// <param name="nd"></param>
19+
/// <param name="axis"></param>
20+
/// <returns>Returns an array of bools</returns>
21+
public static NDArray<bool> all(NDArray nd, int axis)
22+
=> BackendFactory.GetEngine().All(nd, axis);
23+
}
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using NumSharp.Backends;
2+
3+
namespace NumSharp {
4+
public static partial class np
5+
{
6+
/// <summary>
7+
/// Returns True if two arrays are element-wise equal within a tolerance.
8+
/// The tolerance values are positive, typically very small numbers.The
9+
///
10+
/// relative difference (`rtol` * abs(`b`)) and the absolute difference
11+
/// `atol` are added together to compare against the absolute difference
12+
/// between `a` and `b`.
13+
/// If either array contains one or more NaNs, False is returned.
14+
/// Infs are treated as equal if they are in the same place and of the same
15+
/// sign in both arrays.
16+
/// </summary>
17+
/// <param name="a">Input array to compare with b</param>
18+
/// <param name="b">Input array to compare with a.</param>
19+
/// <param name="rtol">The relative tolerance parameter(see Notes)</param>
20+
/// <param name="atol">The absolute tolerance parameter(see Notes)</param>
21+
/// <param name="equal_nan">Whether to compare NaN's as equal. If True, NaN's in `a` will be
22+
///considered equal to NaN's in `b` in the output array.</param>
23+
public static bool allclose(NDArray a, NDArray b, double rtol = 1.0E-5, double atol = 1.0E-8,
24+
bool equal_nan = false)
25+
=> BackendFactory.GetEngine().AllClose(a, b, rtol, atol, equal_nan);
26+
}
27+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace NumSharp {
2+
public static partial class np
3+
{
4+
/// <summary>
5+
/// True if two arrays have the same shape and elements, False otherwise.
6+
/// </summary>
7+
/// <param name="a">Input array.</param>
8+
/// <param name="b">Input array.</param>
9+
/// <returns>Returns True if the arrays are equal.</returns>
10+
/// <remarks>https://docs.scipy.org/doc/numpy-1.16.0/reference/generated/numpy.array_equal.html</remarks>
11+
public static bool array_equal(NDArray a, NDArray b)
12+
{
13+
return a.array_equal(b);
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)