This repository has been archived on 2020-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
php-armadillo/src/constants.hh

166 lines
4.7 KiB
C++
Raw Normal View History

2019-03-22 08:30:44 +00:00
//
// php-armadillo/constants.hh
//
// @Author CismonX
//
#ifndef PHP_ARMA_CONSTANTS_HH
#define PHP_ARMA_CONSTANTS_HH
2019-04-16 11:00:50 +00:00
#include "php_arma.hh"
2019-03-22 08:30:44 +00:00
2019-05-27 08:51:46 +00:00
#include <armadillo>
2019-03-22 08:30:44 +00:00
namespace php_arma
{
struct fill
{
static constexpr auto none = 0;
static constexpr auto zeros = 1;
static constexpr auto ones = 2;
static constexpr auto eye = 3;
static constexpr auto randu = 4;
static constexpr auto randn = 5;
2019-05-29 15:45:04 +00:00
template <typename T>
zend_always_inline
static void invoke(T *obj, zend_long val)
{
switch (val) {
2019-06-12 03:11:27 +00:00
case none:
2019-05-29 15:45:04 +00:00
break;
2019-06-12 03:11:27 +00:00
case zeros:
2019-05-29 15:45:04 +00:00
obj->zeros();
break;
2019-06-12 03:11:27 +00:00
case ones:
2019-05-29 15:45:04 +00:00
obj->ones();
break;
2019-06-12 03:11:27 +00:00
case eye:
2019-05-29 15:45:04 +00:00
obj->eye();
break;
2019-06-12 03:11:27 +00:00
case randu:
2019-05-29 15:45:04 +00:00
obj->randu();
break;
2019-06-12 03:11:27 +00:00
case randn:
2019-05-29 15:45:04 +00:00
obj->randn();
break;
default:
2019-06-11 10:18:40 +00:00
throw_error("bad fill type");
2019-05-29 15:45:04 +00:00
}
}
2019-03-22 08:30:44 +00:00
};
2019-05-27 08:51:46 +00:00
constexpr const char fill_php_name[] = "Fill";
inline zend_class_entry *fill_ce;
2019-03-22 08:30:44 +00:00
struct file_type
{
static constexpr auto auto_detect = 0;
static constexpr auto arma_binary = 1;
static constexpr auto arma_ascii = 2;
static constexpr auto raw_binary = 3;
static constexpr auto raw_ascii = 4;
static constexpr auto csv_ascii = 5;
static constexpr auto coord_ascii = 6;
static constexpr auto pgm_binary = 7;
2019-04-04 08:07:37 +00:00
static constexpr auto hdf5_binary = 8;
2019-05-27 08:51:46 +00:00
2019-05-29 15:45:04 +00:00
zend_always_inline
static arma::file_type native(zend_long val)
{
switch (val) {
2019-06-12 03:11:27 +00:00
case auto_detect:
2019-05-29 15:45:04 +00:00
return arma::file_type::auto_detect;
2019-06-12 03:11:27 +00:00
case arma_binary:
2019-05-29 15:45:04 +00:00
return arma::file_type::arma_binary;
2019-06-12 03:11:27 +00:00
case arma_ascii:
2019-05-29 15:45:04 +00:00
return arma::file_type::arma_ascii;
2019-06-12 03:11:27 +00:00
case raw_binary:
2019-05-29 15:45:04 +00:00
return arma::file_type::raw_binary;
2019-06-12 03:11:27 +00:00
case csv_ascii:
2019-05-29 15:45:04 +00:00
return arma::file_type::csv_ascii;
2019-06-12 03:11:27 +00:00
case coord_ascii:
2019-05-29 15:45:04 +00:00
return arma::file_type::coord_ascii;
2019-06-12 03:11:27 +00:00
case pgm_binary:
2019-05-29 15:45:04 +00:00
return arma::file_type::pgm_binary;
#ifdef ARMA_USE_HDF5
2019-06-12 03:11:27 +00:00
case hdf5_binary:
2019-05-29 15:45:04 +00:00
return arma::file_type::hdf5_binary;
#endif // ARMA_USE_HDF5
default:
return arma::file_type::file_type_unknown;
}
}
2019-03-22 08:30:44 +00:00
};
2019-05-27 08:51:46 +00:00
constexpr const char file_type_php_name[] = "FileType";
inline zend_class_entry *file_type_ce;
2019-03-22 08:30:44 +00:00
struct sort_direction
{
static constexpr auto ascend = 0;
static constexpr auto descend = 1;
static constexpr auto strict_ascend = 2;
static constexpr auto strict_descend = 3;
2019-06-12 03:11:27 +00:00
zend_always_inline
static const char *native(zend_long val)
{
switch (val) {
case ascend:
return "ascend";
case descend:
return "decend";
case strict_ascend:
return "strictascend";
case strict_descend:
return "strictdescend";
default:
return nullptr;
}
}
2019-03-22 08:30:44 +00:00
};
2019-05-27 08:51:46 +00:00
constexpr const char sort_direction_php_name[] = "SortDirection";
inline zend_class_entry *sort_direction_ce;
#ifdef ARMA_USE_HDF5
2019-04-04 08:07:37 +00:00
struct hdf5_opts
{
2019-05-27 08:51:46 +00:00
static constexpr auto none = 0u;
2019-04-04 08:07:37 +00:00
static constexpr auto trans = 1u << 0;
static constexpr auto append = 1u << 1;
static constexpr auto replace = 1u << 2;
};
2019-07-12 17:50:16 +00:00
constexpr const char hdf5_opts_php_name[] = "Hdf5Opts";
2019-05-27 08:51:46 +00:00
inline zend_class_entry *hdf5_opts_ce;
#endif // ARMA_USE_HDF5
2019-04-16 11:00:50 +00:00
struct features
{
#ifdef PHP_ARMA_OPERATORS
static constexpr auto operators = true;
#else
static constexpr auto operators = false;
#endif // PHP_ARMA_OPERATORS
2019-05-27 08:51:46 +00:00
#ifdef ARMA_USE_HDF5
static constexpr auto hdf5 = true;
#else
static constexpr auto hdf5 = false;
#endif // ARMA_USE_HDF5
2019-07-16 14:16:01 +00:00
#ifdef __GLIBCXX__
2019-07-12 17:50:16 +00:00
static constexpr auto stream_res = true;
#else
static constexpr auto stream_res = false;
2019-07-16 14:16:01 +00:00
#endif // __GLIBCXX__
2019-04-16 11:00:50 +00:00
};
2019-05-27 08:51:46 +00:00
constexpr const char features_php_name[] = "Features";
2019-04-16 11:00:50 +00:00
inline zend_class_entry *features_ce;
2019-05-27 08:51:46 +00:00
void constants_init();
2019-03-22 08:30:44 +00:00
}
#endif //!PHP_ARMA_CONSTANTS_HH