MoCSI API Reference
Loading...
Searching...
No Matches
CoreEnums.h
Go to the documentation of this file.
1#ifndef CORE_ENUMS_H
2#define CORE_ENUMS_H
3
4#include <stdexcept>
5#include <string>
6
7enum class Dimension
8{
9 OneD,
10 TwoD,
11 ThreeD,
12};
13
14constexpr Dimension setDimension(const std::string& dimension)
15{
16 if (dimension == "1D")
17 {
18 return Dimension::OneD;
19 }
20 if (dimension == "2D")
21 {
22 return Dimension::TwoD;
23 }
24 if (dimension == "3D")
25 {
26 return Dimension::ThreeD;
27 }
28 std::cerr << "[CoreEnums]: Unrecognized dimension. Please select \"1D\", \"2D\" or \"3D\" as "
29 "dimension.\n";
30 throw std::runtime_error(static_cast<std::string>(
31 "[CoreEnums]: Unrecognized dimension. Please select \"1D\", \"2D\" or \"3D\" as "
32 "dimension."));
33}
34
35enum class MatrixType
36{
37 Dense,
38 Csr
39};
40
41constexpr MatrixType setMatrixType(const std::string& type)
42{
43 if (type == "dense" || type == "Dense")
44 {
45 return MatrixType::Dense;
46 }
47 if (type == "csr" || type == "Csr")
48 {
49 return MatrixType::Csr;
50 }
51 std::cerr << "[CoreEnums]: Unknown matrix type: " << type
52 << "Please select \"Dense\" or \"Csr\".\n";
53 throw std::runtime_error(static_cast<std::string>("[CoreEnums]: Unknown matrix type: ") + type
54 + static_cast<std::string>("Please select \"Dense\" or \"Csr\"."));
55}
56
57#endif
constexpr MatrixType setMatrixType(const std::string &type)
Definition CoreEnums.h:41
MatrixType
Definition CoreEnums.h:36
Dimension
Definition CoreEnums.h:8
constexpr Dimension setDimension(const std::string &dimension)
Definition CoreEnums.h:14
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37