Skip to content

Commit

Permalink
expose type and order
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcseacave committed Jul 26, 2019
1 parent 0c79541 commit 721a498
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 14 additions & 0 deletions TinyNPY.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ class TINYNPY_LIB NpyArray {
return shape;
}

char Type() const {
return type;
}
char& Type() {
return type;
}

bool ColMajor() const {
return fortranOrder;
}
bool& ColMajor() {
return fortranOrder;
}

template<typename T=uint8_t>
const T* Data() const {
return reinterpret_cast<const T*>(data);
Expand Down
9 changes: 5 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ int main(int argc, const char** argv)
}

// print array metadata
std::cout << "Number of values " << arr.NumValue() << "\n";
std::cout << "Size in bytes " << arr.SizeBytes() << "\n";
std::cout << "Number of values: " << arr.NumValue() << "\n";
std::cout << "Size in bytes: " << arr.SizeBytes() << "\n";
if (typeid(int) == arr.ValueType())
std::cout << "Value type float\n";
std::cout << "Value type: int\n";
if (typeid(float) == arr.ValueType())
std::cout << "Value type float\n";
std::cout << "Value type: float\n";
std::cout << "Values order: " << (arr.ColMajor() ? "col-major\n" : "row-major\n");
return EXIT_SUCCESS;
}

0 comments on commit 721a498

Please sign in to comment.