Skip to content

Commit 8ea1eb4

Browse files
Expose array-scalar binary operators and some array and reduction functions (#30)
* Generate array and scalar binary operators +, -, *, / for all types * Expose Moddims (af_moddims), Flat (af_flat), and Flip (af_flip) * Expose MinAll and MaxAll for all supported types * Simplify MinAll and MaxAll
1 parent bce0bfa commit 8ea1eb4

File tree

3 files changed

+931
-0
lines changed

3 files changed

+931
-0
lines changed

src/Wrapper/Algorithm.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,31 @@ public static Complex SumAll(Array arr)
4747
return new Complex(r, i);
4848
}
4949

50+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
51+
public static object MinAll<T>(Array arr)
52+
{
53+
af_dtype dtype = Internal.toDType<T>();
54+
double r, i;
55+
Internal.VERIFY(AFAlgorithm.af_min_all(out r, out i, arr._ptr));
56+
if (dtype == af_dtype.c32 || dtype == af_dtype.c64) {
57+
return new Complex(r, i);
58+
} else {
59+
return Convert.ChangeType(r, Internal.toClrType(dtype));
60+
}
61+
}
62+
63+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
64+
public static object MaxAll<T>(Array arr)
65+
{
66+
af_dtype dtype = Internal.toDType<T>();
67+
double r, i;
68+
Internal.VERIFY(AFAlgorithm.af_max_all(out r, out i, arr._ptr));
69+
if (dtype == af_dtype.c32 || dtype == af_dtype.c64) {
70+
return new Complex(r, i);
71+
} else {
72+
return Convert.ChangeType(r, Internal.toClrType(dtype));
73+
}
74+
}
5075
// TODO: Add the other algorithms
5176
}
5277
}

0 commit comments

Comments
 (0)