NDArrayAdvanced =============== .. cpp:class:: numpy::NDArrayAdvanced numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use NDArrayAdvanced NDArrayAdvanced obj; // ... operations ... Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``NDArrayAdvanced(const NDArray&array)`` - NP_NDARRAY_ADVANCED.H:23 - * - ``NDArrayAdvanced(NDArray&&array)`` - NP_NDARRAY_ADVANCED.H:24 - Operators --------- .. list-table:: :widths: 40 25 15 20 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``T operator[](ssize_tindex)`` - T - NP_NDARRAY_ADVANCED.H:32 - * - ``IndexedArrayResult operator[](const IndexExpr &expr)`` - IndexedArrayResult - NP_NDARRAY_ADVANCED.H:45 - * - ``IndexedArrayResult operator[](const IndexExpr &expr)`` - IndexedArrayResult - NP_NDARRAY_ADVANCED.H:49 - * - ``IndexedArrayResult operator[](const Slice &slice)`` - IndexedArrayResult - NP_NDARRAY_ADVANCED.H:54 - * - ``NDArray operator[](const NDArray&mask)`` - NDArray - NP_NDARRAY_ADVANCED.H:61 - * - ``NDArray operator[](const NDArray&indices)`` - NDArray - NP_NDARRAY_ADVANCED.H:66 - * - ``NDArray operator[](const NDArray&indices)`` - NDArray - NP_NDARRAY_ADVANCED.H:77 - Indexing / Selection -------------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``auto getitem(Args...args)`` - auto - NP_NDARRAY_ADVANCED.H:95 - * - ``void put(const NDArray&indices, const NDArray&values)`` - void - NP_NDARRAY_ADVANCED.H:133 - :ref:`View ` Math Operations --------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void add_to_expr(IndexExpr &expr, ssize_tidx)`` - void - NP_NDARRAY_ADVANCED.H:187 - * - ``void add_to_expr(IndexExpr &expr, const Slice &slice)`` - void - NP_NDARRAY_ADVANCED.H:191 - * - ``void add_to_expr(IndexExpr &expr, const NDArray&array)`` - void - NP_NDARRAY_ADVANCED.H:195 - * - ``void add_to_expr(IndexExpr &expr, const NDArray&array)`` - void - NP_NDARRAY_ADVANCED.H:199 - * - ``void add_to_expr(IndexExpr &expr, const Ellipsis &e)`` - void - NP_NDARRAY_ADVANCED.H:203 - * - ``void add_to_expr(IndexExpr &expr, const NewAxis &n)`` - void - NP_NDARRAY_ADVANCED.H:207 - * - ``void add_to_expr(IndexExpr &expr, const Colon &c)`` - void - NP_NDARRAY_ADVANCED.H:211 - Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void assign_values(NDArray&target, const NDArray&source)`` - void - NP_NDARRAY_ADVANCED.H:216 - * - ``void build_index_expr(IndexExpr &expr, Firstfirst, Rest...rest)`` - void - NP_NDARRAY_ADVANCED.H:179 - * - ``void setitem(const NDArray&values, Args...args)`` - void - NP_NDARRAY_ADVANCED.H:103 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-ndarrayadvanced-put-0: .. dropdown:: put (np_test_5_all.cpp:4389) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 4379 :emphasize-lines: 11 numpy::NDArray indices({ 3 }); indices.setElementAt({ 0 }, 5); // Last position indices.setElementAt({ 1 }, 2); // Middle position indices.setElementAt({ 2 }, 0); // First position numpy::NDArray values({ 3 }); values.setElementAt({ 0 }, 100); values.setElementAt({ 1 }, 200); values.setElementAt({ 2 }, 300); numpy::put(arr, indices, values); // Check modified values if (arr.getElementAt({ 0 }) != 300 || arr.getElementAt({ 2 }) != 200 || arr.getElementAt({ 5 }) != 100) { std::cout << " [FAIL] : in np_test_put_basic() : Values not correctly placed"; throw std::runtime_error("Test failed"); } // Check unmodified values if (arr.getElementAt({ 1 }) != 10 || arr.getElementAt({ 3 }) != 30 || arr.getElementAt({ 4 }) != 40) { std::cout << " [FAIL] : in np_test_put_basic() : Unmodified values changed";