Parser#

class numpy::Parser#

numpy C++ class.

Example#

#include <numpy/np_ndarray.h>
using namespace numpy;

// Use Parser
Parser obj;
// ... operations ...

Math Operations#

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#

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

View

Token& peek(size_t ahead = 1)

Token&

df_query.h:308

explicit Parser(std::vector<Token> tokens) : tokens\_(std::move(tokens))

explicit Parser(std::vector<Token> tokens) :

df_query.h:422

Code Examples#

The following examples are extracted from the test suite.

match (np_test_2_all.cpp:3450)
3440      auto duration_naive = std::chrono::duration_cast<std::chrono::microseconds>(end_naive - start_naive);
3441
3442      // std::cout << "MKL DGEMM time: " << duration_mkl.count() << " microseconds" << std::endl;
3443      // std::cout << "Naive multiplication time: " << duration_naive.count() << " microseconds" << std::endl;
3444
3445      if (duration_mkl.count() > 0) {
3446        double speedup = (double)duration_naive.count() / duration_mkl.count();
3447        // std::cout << "MKL speedup: " << std::fixed << std::setprecision(2) << speedup << "x" << std::endl;
3448      }
3449
3450      // Verify results match (check a few elements)
3451      bool results_match = true;
3452      double tolerance = 1e-10;
3453      for (int i = 0; i < std::min(10, size); i++) {
3454        if (std::abs(C_mkl[i] - C_naive[i]) > tolerance) {
3455          results_match = false;
3456          break;
3457        }
3458      }
3459
3460      if (results_match) {