Parser ====== .. cpp:class:: numpy::Parser numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use Parser Parser obj; // ... operations ... Math Operations --------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void expect(TokenType type, const std::string& msg)`` - void - df_query.h:321 - * - ``expect(TokenType::RPAREN, "Expected ')' after expression")`` - - df_query.h:379 - Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void advance()`` - void - df_query.h:313 - * - ``Token& current()`` - Token& - df_query.h:304 - * - ``bool match(TokenType type)`` - bool - df_query.h:317 - :ref:`View ` * - ``Token& peek(size_t ahead = 1)`` - Token& - df_query.h:308 - * - ``explicit Parser(std::vector tokens) : tokens\_(std::move(tokens))`` - explicit Parser(std::vector tokens) : - df_query.h:422 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-parser-match-0: .. dropdown:: match (np_test_2_all.cpp:3450) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 3440 :emphasize-lines: 11 auto duration_naive = std::chrono::duration_cast(end_naive - start_naive); // std::cout << "MKL DGEMM time: " << duration_mkl.count() << " microseconds" << std::endl; // std::cout << "Naive multiplication time: " << duration_naive.count() << " microseconds" << std::endl; if (duration_mkl.count() > 0) { double speedup = (double)duration_naive.count() / duration_mkl.count(); // std::cout << "MKL speedup: " << std::fixed << std::setprecision(2) << speedup << "x" << std::endl; } // Verify results match (check a few elements) bool results_match = true; double tolerance = 1e-10; for (int i = 0; i < std::min(10, size); i++) { if (std::abs(C_mkl[i] - C_naive[i]) > tolerance) { results_match = false; break; } } if (results_match) {