51 const Metric& metric = Metric{},
52 const double max_memory = 1)
54 using namespace detail;
56 const std::size_t n_colors = colors.size();
59 throw std::invalid_argument(
"At least one color is required to compute "
60 "a color difference matrix.");
63 if (!checkMatrixSize(n_colors, max_memory)) {
64 throw std::runtime_error(
65 "Color difference matrix would require " +
66 std::to_string(estimateMatrixMemory(n_colors) /
67 (1024.0 * 1024.0 * 1024.0)) +
68 " GB, which exceeds the limit of " + std::to_string(max_memory) +
69 " GB. Reduce the number of colors or increase the memory limit.");
72 Matrix<double> result(n_colors, n_colors);
75#pragma omp parallel for num_threads(Threads::get())
77 for (std::size_t i = 0; i < n_colors; ++i) {
82 for (std::size_t j = i + 1; j < n_colors; ++j) {
83 double d = metric(colors[i], colors[j]);