IndexedArray ============ .. cpp:class:: numpy::IndexedArray numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use IndexedArray IndexedArray obj; // ... operations ... Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``IndexedArray(const NDArray\*source, const IndexExpr &expr)`` - NP_ADVANCED_INDEXING.H:59 - Linear Algebra -------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``size_t normalize_array_index(IndexTypeidx, size_tdim_size)`` - size_t - NP_ADVANCED_INDEXING.H:223 - Type Handling ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void copy_with_slices(NDArray&result, const std::vector&slices, const std::vector&fixed_indices, const std::vector&fixed_dims, const std::vector&newaxis_positions)`` - void - NP_ADVANCED_INDEXING.H:149 - Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void apply_boolean_indexing(NDArray&result, const std::vector\*>&bool_masks)`` - void - NP_ADVANCED_INDEXING.H:197 - * - ``void apply_fancy_indexing(NDArray&result, const std::vector,NDArray,NDArray>>&indices)`` - void - NP_ADVANCED_INDEXING.H:233 - * - ``void apply_mixed_basic_indexing(NDArray&result, const std::vector,NDArray,NDArray>>&indices)`` - void - NP_ADVANCED_INDEXING.H:324 - * - ``void materialize_advanced(NDArray&result)`` - void - NP_ADVANCED_INDEXING.H:117 - * - ``void materialize_basic(NDArray&result)`` - void - NP_ADVANCED_INDEXING.H:81 - * - ``const std::vector& shape()`` - const std::vector& - NP_ADVANCED_INDEXING.H:64 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-indexedarray-shape-0: .. dropdown:: shape (np_test_1_all.cpp:3751) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 3741 :emphasize-lines: 11 } for (size_t j = 0; j < 3; ++j) { arr3.setElementAt({0, j}, static_cast((j + 1) * 100)); // [100, 200, 300] } // Broadcast all arrays together std::vector> arrays = {arr1, arr2, arr3}; auto broadcasted = broadcast_arrays(arrays); // All should have shape (2, 3) for (const auto& arr : broadcasted) { if (!((arr.getShape() == std::vector{2, 3}))) { std::string description = std::string("test_broadcast_arrays():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !((arr.getShape() == std::vector{2, 3}))"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } } // Check values if (!(broadcasted[0].getElementAt({0, 1}) == 2.0)) {