24#if defined(_DEBUG) || defined(DEBUG) || !defined(NDEBUG)
26#define SUANPAN_EXTRA_DEBUG
31#ifdef SUANPAN_SUPERLUMT
32#define ARMA_DONT_USE_SUPERLU
34#define ARMA_USE_SUPERLU
38#define MKL_DIRECT_CALL
47#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__)
54#if defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(__WIN64__)
67#if defined(unix) || defined(__unix__) || defined(__linux__) || defined(linux)
76#ifdef SUANPAN_COMPILER
77#undef SUANPAN_COMPILER
86#define SUANPAN_VERSION __VERSION__
87#ifdef SUANPAN_COMPILER
88#undef SUANPAN_COMPILER
90#define SUANPAN_COMPILER "CLANG"
92#elif defined(__GNUG__)
94#define SUANPAN_VERSION __VERSION__
95#define SUANPAN_COMPILER "GCC"
97#elif defined(_MSC_BUILD)
99#define SUANPAN_VERSION _MSC_FULL_VER
100#define SUANPAN_COMPILER "MSVC"
103#pragma warning(disable : 4505)
106#define SUANPAN_VERSION __ICC
107#define SUANPAN_COMPILER "INTEL"
117#define SUANPAN_VERSION __ICL
118#define SUANPAN_COMPILER "INTEL"
137#define SUANPAN_IMPORT extern "C" __declspec(dllimport)
139#define SUANPAN_EXPORT extern "C" __declspec(dllexport)
140#elif defined(SUANPAN_UNIX)
142#define SUANPAN_IMPORT extern "C"
144#define SUANPAN_EXPORT extern "C"
147#define SUANPAN_IMPORT extern "C"
148#define SUANPAN_EXPORT extern "C"
167#define _strcmpi strcasecmp
171#include <tbb/parallel_for_each.h>
172#include <tbb/parallel_sort.h>
173#define suanpan_sort tbb::parallel_sort
174#define suanpan_for_each tbb::parallel_for_each
176#define suanpan_sort std::sort
177#define suanpan_for_each std::for_each
186#define ARMA_COUT_STREAM SUANPAN_COUT
187#define ARMA_CERR_STREAM SUANPAN_COUT
189#include <armadillo/armadillo>
193namespace fs = std::filesystem;
195#include <fmt/color.h>
201 inline std::string
pattern(
const std::string_view header,
const std::string_view& file_name,
const std::string_view&
format) {
203 pattern += fs::path(file_name).filename().string();
209 template<
typename...
T>
void debug(
const std::string_view file_name,
const int line,
const std::string_view format_str,
const T&... args) {
213 else SUANPAN_COUT << fmt::vformat(
pattern(
"[DEBUG] ", file_name, format_str), fmt::make_format_args(line, args...));
216 template<
typename...
T>
void warning(
const std::string_view file_name,
const int line,
const std::string_view format_str,
const T&... args) {
219 if(
SUANPAN_COLOR)
SUANPAN_CWRN << fmt::vformat(fg(fmt::color::slate_blue),
pattern(
"[WARNING] ", file_name, format_str), fmt::make_format_args(line, args...));
220 else SUANPAN_CWRN << fmt::vformat(
pattern(
"[WARNING] ", file_name, format_str), fmt::make_format_args(line, args...));
223 template<
typename...
T>
void error(
const std::string_view file_name,
const int line,
const std::string_view format_str,
const T&... args) {
227 else SUANPAN_CERR << fmt::vformat(
pattern(
"[ERROR] ", file_name, format_str), fmt::make_format_args(line, args...));
230 template<
typename...
T>
void fatal(
const std::string_view file_name,
const int line,
const std::string_view format_str,
const T&... args) {
234 else SUANPAN_CFTL << fmt::vformat(
pattern(
"[FATAL] ", file_name, format_str), fmt::make_format_args(line, args...));
237 template<
typename...
T>
void info(
const std::string_view format_str,
const T&... args) {
240 if(
SUANPAN_COLOR)
SUANPAN_COUT << fmt::vformat(fg(fmt::color::green_yellow), format_str, fmt::make_format_args(args...));
241 else SUANPAN_COUT << fmt::vformat(format_str, fmt::make_format_args(args...));
244 template<
typename...
T> std::string
format(
const std::string_view format_str,
const T&... args) {
return fmt::vformat(format_str, fmt::make_format_args(args...)); }
246 template<
typename T> std::string
format(
const Col<T>& in_vec) {
248 if(std::is_floating_point_v<T>)
for(
const auto I : in_vec) output +=
format(
" {: 1.4e}", I);
249 else for(
const auto I : in_vec) output +=
format(
" {:6d}", I);
254 template<
typename T>
void info(
const Col<T>& in_vec) {
261 template<
typename T>
void info(
const std::string_view format_str,
const Col<T>& in_vec) {
263 std::string output =
format(format_str);
264 if(format_str.back() !=
'\t' && format_str.back() !=
'\n') output +=
'\n';
271 template<
typename...
T>
void highlight(
const std::string_view format_str,
const T&... args) {
275 else SUANPAN_COUT << fmt::vformat(format_str, fmt::make_format_args(args...));
280#pragma warning(disable : 4100)
290#pragma warning(default : 4100)
293#define suanpan_info suanpan::info
294#define suanpan_highlight suanpan::highlight
295#define suanpan_debug(...) suanpan::debug(__FILE__, __LINE__, ##__VA_ARGS__)
296#define suanpan_warning(...) suanpan::warning(__FILE__, __LINE__, ##__VA_ARGS__)
297#define suanpan_error(...) suanpan::error(__FILE__, __LINE__, ##__VA_ARGS__)
298#define suanpan_fatal(...) suanpan::fatal(__FILE__, __LINE__, ##__VA_ARGS__)
302using std::shared_ptr;
303using std::unique_ptr;
306using std::make_shared;
307using std::make_unique;
310using std::invalid_argument;
311using std::logic_error;
312using std::out_of_range;
314using std::istringstream;
315using std::ostringstream;
318template<
class T>
concept sp_d = std::is_floating_point_v<T>;
319template<
class T>
concept sp_i = std::is_integral_v<T>;
322 template<
class IN,
class FN>
void for_all(IN& from, FN&& func) {
327#if defined(SUANPAN_CLANG) && !defined(__cpp_lib_ranges)
329namespace std::ranges {
330 template<
class IN,
class OUT,
class FN> OUT
transform(IN& from, OUT to, FN&& func) {
return std::transform(from.begin(), from.end(), to, std::forward<FN>(func)); }
332 template<
class IN,
class FN> FN for_each(IN& from, FN&& func) {
return std::for_each(from.begin(), from.end(), std::forward<FN>(func)); }
334 template<
class IN,
class OUT> OUT copy(IN& from, OUT to) {
return std::copy(from.begin(), from.end(), to); }
Definition: suanPan.h:318
Definition: suanPan.h:319
Definition: MatrixModifier.hpp:36
std::string pattern(const std::string_view header, const std::string_view &file_name, const std::string_view &format)
Definition: suanPan.h:201
void error(const std::string_view file_name, const int line, const std::string_view format_str, const T &... args)
Definition: suanPan.h:223
void debug(const std::string_view file_name, const int line, const std::string_view format_str, const T &... args)
Definition: suanPan.h:209
std::string format(const std::string_view format_str, const T &... args)
Definition: suanPan.h:244
void info(const std::string_view format_str, const T &... args)
Definition: suanPan.h:237
void warning(const std::string_view file_name, const int line, const std::string_view format_str, const T &... args)
Definition: suanPan.h:216
void highlight(const std::string_view format_str, const T &... args)
Definition: suanPan.h:271
std::mutex print_mutex
Definition: suanPan.h:199
void for_all(IN &from, FN &&func)
Definition: suanPan.h:322
void fatal(const std::string_view file_name, const int line, const std::string_view format_str, const T &... args)
Definition: suanPan.h:230
constexpr auto SUANPAN_SUCCESS
Definition: suanPan.h:162
auto & SUANPAN_COUT
Definition: suanPan.h:181
#define suanpan_for_each
Definition: suanPan.h:177
SUANPAN_EXPORT bool SUANPAN_COLOR
Definition: suanPan.h:158
#define SUANPAN_EXPORT
Definition: suanPan.h:148
constexpr auto SUANPAN_EXIT
Definition: suanPan.h:161
auto & SUANPAN_CWRN
Definition: suanPan.h:182
auto & SUANPAN_CFTL
Definition: suanPan.h:184
void suanpan_assert(const std::function< void()> &F)
Definition: suanPan.h:284
SUANPAN_EXPORT bool SUANPAN_PRINT
Definition: suanPan.h:156
constexpr auto SUANPAN_FAIL
Definition: suanPan.h:163
#define SUANPAN_IMPORT
Definition: suanPan.h:147
SUANPAN_EXPORT bool SUANPAN_VERBOSE
Definition: suanPan.h:157
auto & SUANPAN_CERR
Definition: suanPan.h:183