Commit Graph

13 Commits

Author SHA1 Message Date
lyken fc51bc63e2 core/ndstrides: implement broadcasting & np_broadcast_to() 2024-10-17 14:38:06 +08:00
lyken f8c0e2c4dd core/ndstrides: implement np_reshape() 2024-10-17 14:35:17 +08:00
lyken de732ba68e core/ndstrides: implement np_array()
It also checks for inconsistent dimensions if the input is a list.
e.g., rejecting `[[1.0, 2.0], [3.0]]`.

However, currently only `np_array(<input>, copy=False)` and `np_array(<input>, copy=True)` are supported. In NumPy, copy could be false, true, or None. Right now, NAC3's `np_array(<input>, copy=False)` behaves like NumPy's `np.array(<input>, copy=None)`.
2024-10-17 14:27:04 +08:00
lyken 5da67b4268 core/irrt: add List
Needed for implementing np_array()
2024-10-17 14:27:04 +08:00
lyken 0206c3989a core/ndstrides: implement ndarray indexing
The functionality for `...` and `np.newaxis` is there in IRRT, but there
is no implementation of them for @kernel Python expressions because of
#486.
2024-10-17 13:56:35 +08:00
lyken f07fe3b88e core/irrt: add Slice and Range
Needed for implementing general ndarray indexing.

Currently IRRT slice and range have nothing to do with NAC3's slice
and range. The IRRT slice and range are currently there to implement
ndarray specific features. However, in the future their definitions may
be used to replace that of NAC3's. (NAC3's range is a [i32 x 3], IRRT's
range is a proper struct. NAC3 does not have a slice struct).
2024-10-17 13:52:27 +08:00
lyken 9d8358c0e7 core/ndstrides: implement ndarray iterator NDIter
A necessary utility to iterate through all elements in a possibly strided ndarray.
2024-10-17 13:44:43 +08:00
lyken 9d87975c01 core/ndstrides: introduce NDArray
NDArray with strides.
2024-10-17 13:44:43 +08:00
David Mak 15ac00708a [core] Use quoted include paths instead of angled brackets
This is preferred for user-defined headers.
2024-08-28 16:37:03 +08:00
lyken 9848795dcc core/irrt: add exceptions and debug utils 2024-08-27 22:55:22 +08:00
lyken 58222feed4 core/irrt: split into headers 2024-08-27 22:55:22 +08:00
lyken c6dade1394 core/irrt: reformat 2024-08-27 22:55:22 +08:00
lyken d3b4c60d7f core/irrt: comment build.rs & move irrt to nac3core/irrt 2024-08-27 22:55:22 +08:00