Spaces:
Sleeping
Sleeping
Update app.cpp
Browse files
app.cpp
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
// app.cpp - Modified version
|
| 2 |
#include <opencv2/opencv.hpp>
|
| 3 |
#include <algorithm>
|
| 4 |
#include <cmath>
|
|
@@ -9,12 +9,13 @@
|
|
| 9 |
#include <vector>
|
| 10 |
#include <limits>
|
| 11 |
#include <sstream>
|
|
|
|
| 12 |
|
| 13 |
// Function to compute the theoretical max value
|
| 14 |
double compute_theoretical_max(double a, double y, double beta) {
|
| 15 |
auto f = [a, y, beta](double k) -> double {
|
| 16 |
return (y * beta * (a - 1) * k + (a * k + 1) * ((y - 1) * k - 1)) /
|
| 17 |
-
((a * k + 1) * (k * k + k));
|
| 18 |
};
|
| 19 |
|
| 20 |
// Use numerical optimization to find the maximum
|
|
@@ -62,7 +63,7 @@ double compute_theoretical_max(double a, double y, double beta) {
|
|
| 62 |
double compute_theoretical_min(double a, double y, double beta) {
|
| 63 |
auto f = [a, y, beta](double t) -> double {
|
| 64 |
return (y * beta * (a - 1) * t + (a * t + 1) * ((y - 1) * t - 1)) /
|
| 65 |
-
((a * t + 1) * (t * t + t) * y);
|
| 66 |
};
|
| 67 |
|
| 68 |
// Use numerical optimization to find the minimum
|
|
@@ -111,8 +112,8 @@ double compute_theoretical_min(double a, double y, double beta) {
|
|
| 111 |
|
| 112 |
int main(int argc, char* argv[]) {
|
| 113 |
// βββ Inputs from command line βββββββββββββββββββββββββββββββββββββββββββ
|
| 114 |
-
if (argc !=
|
| 115 |
-
std::cerr << "Usage: " << argv[0] << " <n> <p> <a> <y>" << std::endl;
|
| 116 |
return 1;
|
| 117 |
}
|
| 118 |
|
|
@@ -120,10 +121,12 @@ int main(int argc, char* argv[]) {
|
|
| 120 |
int p = std::stoi(argv[2]);
|
| 121 |
double a = std::stod(argv[3]);
|
| 122 |
double y = std::stod(argv[4]);
|
|
|
|
| 123 |
const double b = 1.0;
|
| 124 |
|
| 125 |
std::cout << "Running with parameters: n = " << n << ", p = " << p
|
| 126 |
<< ", a = " << a << ", y = " << y << std::endl;
|
|
|
|
| 127 |
|
| 128 |
// βββ Beta range parameters ββββββββββββββββββββββββββββββββββββββββ
|
| 129 |
const int num_beta_points = 100; // More points for smoother curves
|
|
@@ -453,9 +456,8 @@ int main(int argc, char* argv[]) {
|
|
| 453 |
cv::FONT_HERSHEY_COMPLEX, 0.8, cv::Scalar(0, 0, 0), 1);
|
| 454 |
|
| 455 |
// βββ Save the image to the output directory βββββββββββββββββββββββββββ
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
std::cout << "Plot saved as " << output_path << std::endl;
|
| 459 |
|
| 460 |
return 0;
|
| 461 |
}
|
|
|
|
| 1 |
+
// app.cpp - Modified version for Hugging Face Spaces
|
| 2 |
#include <opencv2/opencv.hpp>
|
| 3 |
#include <algorithm>
|
| 4 |
#include <cmath>
|
|
|
|
| 9 |
#include <vector>
|
| 10 |
#include <limits>
|
| 11 |
#include <sstream>
|
| 12 |
+
#include <string>
|
| 13 |
|
| 14 |
// Function to compute the theoretical max value
|
| 15 |
double compute_theoretical_max(double a, double y, double beta) {
|
| 16 |
auto f = [a, y, beta](double k) -> double {
|
| 17 |
return (y * beta * (a - 1) * k + (a * k + 1) * ((y - 1) * k - 1)) /
|
| 18 |
+
((a * k + 1) * (k * k + k));
|
| 19 |
};
|
| 20 |
|
| 21 |
// Use numerical optimization to find the maximum
|
|
|
|
| 63 |
double compute_theoretical_min(double a, double y, double beta) {
|
| 64 |
auto f = [a, y, beta](double t) -> double {
|
| 65 |
return (y * beta * (a - 1) * t + (a * t + 1) * ((y - 1) * t - 1)) /
|
| 66 |
+
((a * t + 1) * (t * t + t) * y);
|
| 67 |
};
|
| 68 |
|
| 69 |
// Use numerical optimization to find the minimum
|
|
|
|
| 112 |
|
| 113 |
int main(int argc, char* argv[]) {
|
| 114 |
// βββ Inputs from command line βββββββββββββββββββββββββββββββββββββββββββ
|
| 115 |
+
if (argc != 6) {
|
| 116 |
+
std::cerr << "Usage: " << argv[0] << " <n> <p> <a> <y> <output_file>" << std::endl;
|
| 117 |
return 1;
|
| 118 |
}
|
| 119 |
|
|
|
|
| 121 |
int p = std::stoi(argv[2]);
|
| 122 |
double a = std::stod(argv[3]);
|
| 123 |
double y = std::stod(argv[4]);
|
| 124 |
+
std::string output_file = argv[5];
|
| 125 |
const double b = 1.0;
|
| 126 |
|
| 127 |
std::cout << "Running with parameters: n = " << n << ", p = " << p
|
| 128 |
<< ", a = " << a << ", y = " << y << std::endl;
|
| 129 |
+
std::cout << "Output will be saved to: " << output_file << std::endl;
|
| 130 |
|
| 131 |
// βββ Beta range parameters ββββββββββββββββββββββββββββββββββββββββ
|
| 132 |
const int num_beta_points = 100; // More points for smoother curves
|
|
|
|
| 456 |
cv::FONT_HERSHEY_COMPLEX, 0.8, cv::Scalar(0, 0, 0), 1);
|
| 457 |
|
| 458 |
// βββ Save the image to the output directory βββββββββββββββββββββββββββ
|
| 459 |
+
cv::imwrite(output_file, canvas);
|
| 460 |
+
std::cout << "Plot saved as " << output_file << std::endl;
|
|
|
|
| 461 |
|
| 462 |
return 0;
|
| 463 |
}
|