Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ from sympy import symbols, solve, I, re, im, Poly, simplify, N, mpmath
|
|
17 |
# Set page config with wider layout
|
18 |
st.set_page_config(
|
19 |
page_title="Matrix Analysis Dashboard",
|
20 |
-
page_icon="
|
21 |
layout="wide",
|
22 |
initial_sidebar_state="expanded"
|
23 |
)
|
@@ -388,7 +388,7 @@ CubicRoots solveCubic(double a, double b, double c, double d) {
|
|
388 |
}
|
389 |
|
390 |
if (std::abs(delta0) < zero_threshold) {
|
391 |
-
// Delta0
|
392 |
double simple = std::cbrt(-delta1);
|
393 |
double doubleRoot = -simple/2 - shift;
|
394 |
double simpleRoot = simple - shift;
|
@@ -716,21 +716,21 @@ bool eigenvalueAnalysis(int n, int p, double a, double y, int fineness,
|
|
716 |
<< ", theory_tolerance = " << theory_tolerance << std::endl;
|
717 |
std::cout << "Output will be saved to: " << output_file << std::endl;
|
718 |
|
719 |
-
//
|
720 |
const int num_beta_points = fineness; // Controlled by fineness parameter
|
721 |
std::vector<double> beta_values(num_beta_points);
|
722 |
for (int i = 0; i < num_beta_points; ++i) {
|
723 |
beta_values[i] = static_cast<double>(i) / (num_beta_points - 1);
|
724 |
}
|
725 |
|
726 |
-
//
|
727 |
std::vector<double> max_eigenvalues(num_beta_points);
|
728 |
std::vector<double> min_eigenvalues(num_beta_points);
|
729 |
std::vector<double> theoretical_max_values(num_beta_points);
|
730 |
std::vector<double> theoretical_min_values(num_beta_points);
|
731 |
|
732 |
try {
|
733 |
-
//
|
734 |
std::random_device rd;
|
735 |
std::mt19937_64 rng{rd()};
|
736 |
std::normal_distribution<double> norm(0.0, 1.0);
|
@@ -740,7 +740,7 @@ bool eigenvalueAnalysis(int n, int p, double a, double y, int fineness,
|
|
740 |
for(int j = 0; j < n; ++j)
|
741 |
X.at<double>(i,j) = norm(rng);
|
742 |
|
743 |
-
//
|
744 |
for (int beta_idx = 0; beta_idx < num_beta_points; ++beta_idx) {
|
745 |
double beta = beta_values[beta_idx];
|
746 |
|
@@ -748,7 +748,7 @@ bool eigenvalueAnalysis(int n, int p, double a, double y, int fineness,
|
|
748 |
theoretical_max_values[beta_idx] = compute_theoretical_max(a, y, beta, theory_grid_points, theory_tolerance);
|
749 |
theoretical_min_values[beta_idx] = compute_theoretical_min(a, y, beta, theory_grid_points, theory_tolerance);
|
750 |
|
751 |
-
//
|
752 |
int k = static_cast<int>(std::floor(beta * p));
|
753 |
std::vector<double> diags(p, 1.0);
|
754 |
std::fill_n(diags.begin(), k, a);
|
@@ -759,10 +759,10 @@ bool eigenvalueAnalysis(int n, int p, double a, double y, int fineness,
|
|
759 |
T_n.at<double>(i,i) = diags[i];
|
760 |
}
|
761 |
|
762 |
-
//
|
763 |
cv::Mat B = (X.t() * T_n * X) / static_cast<double>(n);
|
764 |
|
765 |
-
//
|
766 |
cv::Mat eigVals;
|
767 |
cv::eigen(B, eigVals);
|
768 |
std::vector<double> eigs(n);
|
@@ -820,7 +820,7 @@ int main(int argc, char* argv[]) {
|
|
820 |
|
821 |
try {
|
822 |
if (mode == "eigenvalues") {
|
823 |
-
//
|
824 |
if (argc != 10) {
|
825 |
std::cerr << "Error: Incorrect number of arguments for eigenvalues mode." << std::endl;
|
826 |
std::cerr << "Usage: " << argv[0] << " eigenvalues <n> <p> <a> <y> <fineness> <theory_grid_points> <theory_tolerance> <output_file>" << std::endl;
|
@@ -857,7 +857,7 @@ int main(int argc, char* argv[]) {
|
|
857 |
|
858 |
# Compile the C++ code with the right OpenCV libraries
|
859 |
st.sidebar.title("Dashboard Settings")
|
860 |
-
need_compile = not os.path.exists(executable) or st.sidebar.button("
|
861 |
|
862 |
if need_compile:
|
863 |
with st.sidebar:
|
@@ -891,11 +891,11 @@ if need_compile:
|
|
891 |
|
892 |
if success:
|
893 |
compiled = True
|
894 |
-
st.success(f"
|
895 |
break
|
896 |
|
897 |
if not compiled:
|
898 |
-
st.error("
|
899 |
with st.expander("Compilation Details"):
|
900 |
st.code(compile_output)
|
901 |
st.stop()
|
@@ -904,7 +904,7 @@ if need_compile:
|
|
904 |
if platform.system() != "Windows":
|
905 |
os.chmod(executable, 0o755)
|
906 |
|
907 |
-
st.success("
|
908 |
|
909 |
# Set higher precision for mpmath
|
910 |
mpmath.mp.dps = 100 # 100 digits of precision
|
@@ -1042,7 +1042,7 @@ def compute_ImS_vs_Z(a, y, beta, num_points, z_min, z_max, progress_callback=Non
|
|
1042 |
progress_callback(i / num_points)
|
1043 |
|
1044 |
# Coefficients for the cubic equation:
|
1045 |
-
# zas
|
1046 |
coef_a = z * a
|
1047 |
coef_b = z * (a + 1) + a * (1 - y)
|
1048 |
coef_c = z + (a + 1) - y - y * beta * (a - 1)
|
@@ -1116,8 +1116,8 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1116 |
rows=2,
|
1117 |
cols=1,
|
1118 |
subplot_titles=(
|
1119 |
-
f"Imaginary Parts of Roots: a={cubic_a}, y={cubic_y},
|
1120 |
-
f"Real Parts of Roots: a={cubic_a}, y={cubic_y},
|
1121 |
),
|
1122 |
vertical_spacing=0.15,
|
1123 |
specs=[[{"type": "scatter"}], [{"type": "scatter"}]]
|
@@ -1129,9 +1129,9 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1129 |
x=z_values,
|
1130 |
y=ims_values1,
|
1131 |
mode='lines',
|
1132 |
-
name='Im(s
|
1133 |
line=dict(color='rgb(239, 85, 59)', width=2.5),
|
1134 |
-
hovertemplate='z: %{x:.4f}<br>Im(s
|
1135 |
),
|
1136 |
row=1, col=1
|
1137 |
)
|
@@ -1141,9 +1141,9 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1141 |
x=z_values,
|
1142 |
y=ims_values2,
|
1143 |
mode='lines',
|
1144 |
-
name='Im(s
|
1145 |
line=dict(color='rgb(0, 129, 201)', width=2.5),
|
1146 |
-
hovertemplate='z: %{x:.4f}<br>Im(s
|
1147 |
),
|
1148 |
row=1, col=1
|
1149 |
)
|
@@ -1153,9 +1153,9 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1153 |
x=z_values,
|
1154 |
y=ims_values3,
|
1155 |
mode='lines',
|
1156 |
-
name='Im(s
|
1157 |
line=dict(color='rgb(0, 176, 80)', width=2.5),
|
1158 |
-
hovertemplate='z: %{x:.4f}<br>Im(s
|
1159 |
),
|
1160 |
row=1, col=1
|
1161 |
)
|
@@ -1166,9 +1166,9 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1166 |
x=z_values,
|
1167 |
y=real_values1,
|
1168 |
mode='lines',
|
1169 |
-
name='Re(s
|
1170 |
line=dict(color='rgb(239, 85, 59)', width=2.5),
|
1171 |
-
hovertemplate='z: %{x:.4f}<br>Re(s
|
1172 |
),
|
1173 |
row=2, col=1
|
1174 |
)
|
@@ -1178,9 +1178,9 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1178 |
x=z_values,
|
1179 |
y=real_values2,
|
1180 |
mode='lines',
|
1181 |
-
name='Re(s
|
1182 |
line=dict(color='rgb(0, 129, 201)', width=2.5),
|
1183 |
-
hovertemplate='z: %{x:.4f}<br>Re(s
|
1184 |
),
|
1185 |
row=2, col=1
|
1186 |
)
|
@@ -1190,9 +1190,9 @@ def create_dash_style_visualization(result, cubic_a, cubic_y, cubic_beta):
|
|
1190 |
x=z_values,
|
1191 |
y=real_values3,
|
1192 |
mode='lines',
|
1193 |
-
name='Re(s
|
1194 |
line=dict(color='rgb(0, 176, 80)', width=2.5),
|
1195 |
-
hovertemplate='z: %{x:.4f}<br>Re(s
|
1196 |
),
|
1197 |
row=2, col=1
|
1198 |
)
|
@@ -1482,7 +1482,7 @@ def create_complex_plane_visualization(result, z_idx):
|
|
1482 |
symbol='circle',
|
1483 |
line=dict(width=1, color='black')
|
1484 |
),
|
1485 |
-
text=['s
|
1486 |
textposition="top center",
|
1487 |
name='Roots'
|
1488 |
))
|
@@ -1614,7 +1614,7 @@ with st.sidebar.expander("Theme & Appearance"):
|
|
1614 |
color_theory_min = 'rgb(180, 30, 180)'
|
1615 |
|
1616 |
# Create tabs for different analyses
|
1617 |
-
tab1, tab2 = st.tabs(["
|
1618 |
|
1619 |
# Tab 1: Eigenvalue Analysis (KEEP UNCHANGED from original)
|
1620 |
with tab1:
|
@@ -1648,7 +1648,7 @@ with tab1:
|
|
1648 |
max_value=500,
|
1649 |
value=100,
|
1650 |
step=10,
|
1651 |
-
help="Number of points to calculate along the
|
1652 |
key="eig_fineness"
|
1653 |
)
|
1654 |
st.markdown('</div>', unsafe_allow_html=True)
|
@@ -1831,7 +1831,7 @@ with tab1:
|
|
1831 |
color=color_max,
|
1832 |
line=dict(color='white', width=1)
|
1833 |
),
|
1834 |
-
hovertemplate='
|
1835 |
))
|
1836 |
|
1837 |
fig.add_trace(go.Scatter(
|
@@ -1846,7 +1846,7 @@ with tab1:
|
|
1846 |
color=color_min,
|
1847 |
line=dict(color='white', width=1)
|
1848 |
),
|
1849 |
-
hovertemplate='
|
1850 |
))
|
1851 |
|
1852 |
fig.add_trace(go.Scatter(
|
@@ -1861,7 +1861,7 @@ with tab1:
|
|
1861 |
color=color_theory_max,
|
1862 |
line=dict(color='white', width=1)
|
1863 |
),
|
1864 |
-
hovertemplate='
|
1865 |
))
|
1866 |
|
1867 |
fig.add_trace(go.Scatter(
|
@@ -1876,7 +1876,7 @@ with tab1:
|
|
1876 |
color=color_theory_min,
|
1877 |
line=dict(color='white', width=1)
|
1878 |
),
|
1879 |
-
hovertemplate='
|
1880 |
))
|
1881 |
|
1882 |
# Configure layout for better appearance
|
@@ -1890,7 +1890,7 @@ with tab1:
|
|
1890 |
'yanchor': 'top'
|
1891 |
},
|
1892 |
xaxis={
|
1893 |
-
'title': {'text': '
|
1894 |
'tickfont': {'size': 14},
|
1895 |
'gridcolor': 'rgba(220, 220, 220, 0.5)',
|
1896 |
'showgrid': True
|
@@ -1986,7 +1986,7 @@ with tab1:
|
|
1986 |
color=color_max,
|
1987 |
line=dict(color='white', width=1)
|
1988 |
),
|
1989 |
-
hovertemplate='
|
1990 |
))
|
1991 |
|
1992 |
fig.add_trace(go.Scatter(
|
@@ -2001,7 +2001,7 @@ with tab1:
|
|
2001 |
color=color_min,
|
2002 |
line=dict(color='white', width=1)
|
2003 |
),
|
2004 |
-
hovertemplate='
|
2005 |
))
|
2006 |
|
2007 |
fig.add_trace(go.Scatter(
|
@@ -2016,7 +2016,7 @@ with tab1:
|
|
2016 |
color=color_theory_max,
|
2017 |
line=dict(color='white', width=1)
|
2018 |
),
|
2019 |
-
hovertemplate='
|
2020 |
))
|
2021 |
|
2022 |
fig.add_trace(go.Scatter(
|
@@ -2031,7 +2031,7 @@ with tab1:
|
|
2031 |
color=color_theory_min,
|
2032 |
line=dict(color='white', width=1)
|
2033 |
),
|
2034 |
-
hovertemplate='
|
2035 |
))
|
2036 |
|
2037 |
# Configure layout for better appearance
|
@@ -2045,7 +2045,7 @@ with tab1:
|
|
2045 |
'yanchor': 'top'
|
2046 |
},
|
2047 |
xaxis={
|
2048 |
-
'title': {'text': '
|
2049 |
'tickfont': {'size': 14},
|
2050 |
'gridcolor': 'rgba(220, 220, 220, 0.5)',
|
2051 |
'showgrid': True
|
@@ -2074,10 +2074,10 @@ with tab1:
|
|
2074 |
st.info("This is the previous analysis result. Adjust parameters and click 'Generate Analysis' to create a new visualization.")
|
2075 |
|
2076 |
except Exception as e:
|
2077 |
-
st.info("
|
2078 |
else:
|
2079 |
# Show placeholder
|
2080 |
-
st.info("
|
2081 |
|
2082 |
st.markdown('</div>', unsafe_allow_html=True)
|
2083 |
|
@@ -2097,7 +2097,7 @@ with tab2:
|
|
2097 |
help="Parameter a > 1", key="cubic_a")
|
2098 |
cubic_y = st.number_input("Value for y", min_value=0.1, max_value=10.0, value=1.0, step=0.1,
|
2099 |
help="Parameter y > 0", key="cubic_y")
|
2100 |
-
cubic_beta = st.number_input("Value for
|
2101 |
help="Value between 0 and 1", key="cubic_beta")
|
2102 |
st.markdown('</div>', unsafe_allow_html=True)
|
2103 |
|
@@ -2307,11 +2307,11 @@ with tab2:
|
|
2307 |
st.plotly_chart(complex_fig, use_container_width=True)
|
2308 |
|
2309 |
except Exception as e:
|
2310 |
-
st.info("
|
2311 |
st.error(f"Error loading previous data: {str(e)}")
|
2312 |
else:
|
2313 |
# Show placeholder
|
2314 |
-
st.info("
|
2315 |
|
2316 |
st.markdown('</div>', unsafe_allow_html=True)
|
2317 |
|
|
|
17 |
# Set page config with wider layout
|
18 |
st.set_page_config(
|
19 |
page_title="Matrix Analysis Dashboard",
|
20 |
+
page_icon="Γ°ΒΒΒ",
|
21 |
layout="wide",
|
22 |
initial_sidebar_state="expanded"
|
23 |
)
|
|
|
388 |
}
|
389 |
|
390 |
if (std::abs(delta0) < zero_threshold) {
|
391 |
+
// Delta0 Γ’ΒΒ 0: One double root and one simple root
|
392 |
double simple = std::cbrt(-delta1);
|
393 |
double doubleRoot = -simple/2 - shift;
|
394 |
double simpleRoot = simple - shift;
|
|
|
716 |
<< ", theory_tolerance = " << theory_tolerance << std::endl;
|
717 |
std::cout << "Output will be saved to: " << output_file << std::endl;
|
718 |
|
719 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Beta range parameters Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
720 |
const int num_beta_points = fineness; // Controlled by fineness parameter
|
721 |
std::vector<double> beta_values(num_beta_points);
|
722 |
for (int i = 0; i < num_beta_points; ++i) {
|
723 |
beta_values[i] = static_cast<double>(i) / (num_beta_points - 1);
|
724 |
}
|
725 |
|
726 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Storage for results Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
727 |
std::vector<double> max_eigenvalues(num_beta_points);
|
728 |
std::vector<double> min_eigenvalues(num_beta_points);
|
729 |
std::vector<double> theoretical_max_values(num_beta_points);
|
730 |
std::vector<double> theoretical_min_values(num_beta_points);
|
731 |
|
732 |
try {
|
733 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ RandomΓ’ΒΒGaussian X and S_n Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
734 |
std::random_device rd;
|
735 |
std::mt19937_64 rng{rd()};
|
736 |
std::normal_distribution<double> norm(0.0, 1.0);
|
|
|
740 |
for(int j = 0; j < n; ++j)
|
741 |
X.at<double>(i,j) = norm(rng);
|
742 |
|
743 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Process each beta value Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
744 |
for (int beta_idx = 0; beta_idx < num_beta_points; ++beta_idx) {
|
745 |
double beta = beta_values[beta_idx];
|
746 |
|
|
|
748 |
theoretical_max_values[beta_idx] = compute_theoretical_max(a, y, beta, theory_grid_points, theory_tolerance);
|
749 |
theoretical_min_values[beta_idx] = compute_theoretical_min(a, y, beta, theory_grid_points, theory_tolerance);
|
750 |
|
751 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Build T_n matrix Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
752 |
int k = static_cast<int>(std::floor(beta * p));
|
753 |
std::vector<double> diags(p, 1.0);
|
754 |
std::fill_n(diags.begin(), k, a);
|
|
|
759 |
T_n.at<double>(i,i) = diags[i];
|
760 |
}
|
761 |
|
762 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Form B_n = (1/n) * X * T_n * X^T Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
763 |
cv::Mat B = (X.t() * T_n * X) / static_cast<double>(n);
|
764 |
|
765 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Compute eigenvalues of B Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
766 |
cv::Mat eigVals;
|
767 |
cv::eigen(B, eigVals);
|
768 |
std::vector<double> eigs(n);
|
|
|
820 |
|
821 |
try {
|
822 |
if (mode == "eigenvalues") {
|
823 |
+
// Γ’ΒΒΓ’ΒΒΓ’ΒΒ Eigenvalue analysis mode Γ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒΓ’ΒΒ
|
824 |
if (argc != 10) {
|
825 |
std::cerr << "Error: Incorrect number of arguments for eigenvalues mode." << std::endl;
|
826 |
std::cerr << "Usage: " << argv[0] << " eigenvalues <n> <p> <a> <y> <fineness> <theory_grid_points> <theory_tolerance> <output_file>" << std::endl;
|
|
|
857 |
|
858 |
# Compile the C++ code with the right OpenCV libraries
|
859 |
st.sidebar.title("Dashboard Settings")
|
860 |
+
need_compile = not os.path.exists(executable) or st.sidebar.button("Γ°ΒΒΒ Recompile C++ Code")
|
861 |
|
862 |
if need_compile:
|
863 |
with st.sidebar:
|
|
|
891 |
|
892 |
if success:
|
893 |
compiled = True
|
894 |
+
st.success(f"Γ’ΒΒ
Successfully compiled with: {cmd}")
|
895 |
break
|
896 |
|
897 |
if not compiled:
|
898 |
+
st.error("Γ’ΒΒ All compilation attempts failed.")
|
899 |
with st.expander("Compilation Details"):
|
900 |
st.code(compile_output)
|
901 |
st.stop()
|
|
|
904 |
if platform.system() != "Windows":
|
905 |
os.chmod(executable, 0o755)
|
906 |
|
907 |
+
st.success("Γ’ΒΒ
C++ code compiled successfully!")
|
908 |
|
909 |
# Set higher precision for mpmath
|
910 |
mpmath.mp.dps = 100 # 100 digits of precision
|
|
|
1042 |
progress_callback(i / num_points)
|
1043 |
|
1044 |
# Coefficients for the cubic equation:
|
1045 |
+
# zasΓΒ³ + [z(a+1)+a(1-y)]sΓΒ² + [z+(a+1)-y-yΓΒ²(a-1)]s + 1 = 0
|
1046 |
coef_a = z * a
|
1047 |
coef_b = z * (a + 1) + a * (1 - y)
|
1048 |
coef_c = z + (a + 1) - y - y * beta * (a - 1)
|
|
|
1116 |
rows=2,
|
1117 |
cols=1,
|
1118 |
subplot_titles=(
|
1119 |
+
f"Imaginary Parts of Roots: a={cubic_a}, y={cubic_y}, ΓΒ²={cubic_beta}",
|
1120 |
+
f"Real Parts of Roots: a={cubic_a}, y={cubic_y}, ΓΒ²={cubic_beta}"
|
1121 |
),
|
1122 |
vertical_spacing=0.15,
|
1123 |
specs=[[{"type": "scatter"}], [{"type": "scatter"}]]
|
|
|
1129 |
x=z_values,
|
1130 |
y=ims_values1,
|
1131 |
mode='lines',
|
1132 |
+
name='Im(sΓ’ΒΒ)',
|
1133 |
line=dict(color='rgb(239, 85, 59)', width=2.5),
|
1134 |
+
hovertemplate='z: %{x:.4f}<br>Im(sΓ’ΒΒ): %{y:.6f}<extra>Root 1</extra>'
|
1135 |
),
|
1136 |
row=1, col=1
|
1137 |
)
|
|
|
1141 |
x=z_values,
|
1142 |
y=ims_values2,
|
1143 |
mode='lines',
|
1144 |
+
name='Im(sΓ’ΒΒ)',
|
1145 |
line=dict(color='rgb(0, 129, 201)', width=2.5),
|
1146 |
+
hovertemplate='z: %{x:.4f}<br>Im(sΓ’ΒΒ): %{y:.6f}<extra>Root 2</extra>'
|
1147 |
),
|
1148 |
row=1, col=1
|
1149 |
)
|
|
|
1153 |
x=z_values,
|
1154 |
y=ims_values3,
|
1155 |
mode='lines',
|
1156 |
+
name='Im(sΓ’ΒΒ)',
|
1157 |
line=dict(color='rgb(0, 176, 80)', width=2.5),
|
1158 |
+
hovertemplate='z: %{x:.4f}<br>Im(sΓ’ΒΒ): %{y:.6f}<extra>Root 3</extra>'
|
1159 |
),
|
1160 |
row=1, col=1
|
1161 |
)
|
|
|
1166 |
x=z_values,
|
1167 |
y=real_values1,
|
1168 |
mode='lines',
|
1169 |
+
name='Re(sΓ’ΒΒ)',
|
1170 |
line=dict(color='rgb(239, 85, 59)', width=2.5),
|
1171 |
+
hovertemplate='z: %{x:.4f}<br>Re(sΓ’ΒΒ): %{y:.6f}<extra>Root 1</extra>'
|
1172 |
),
|
1173 |
row=2, col=1
|
1174 |
)
|
|
|
1178 |
x=z_values,
|
1179 |
y=real_values2,
|
1180 |
mode='lines',
|
1181 |
+
name='Re(sΓ’ΒΒ)',
|
1182 |
line=dict(color='rgb(0, 129, 201)', width=2.5),
|
1183 |
+
hovertemplate='z: %{x:.4f}<br>Re(sΓ’ΒΒ): %{y:.6f}<extra>Root 2</extra>'
|
1184 |
),
|
1185 |
row=2, col=1
|
1186 |
)
|
|
|
1190 |
x=z_values,
|
1191 |
y=real_values3,
|
1192 |
mode='lines',
|
1193 |
+
name='Re(sΓ’ΒΒ)',
|
1194 |
line=dict(color='rgb(0, 176, 80)', width=2.5),
|
1195 |
+
hovertemplate='z: %{x:.4f}<br>Re(sΓ’ΒΒ): %{y:.6f}<extra>Root 3</extra>'
|
1196 |
),
|
1197 |
row=2, col=1
|
1198 |
)
|
|
|
1482 |
symbol='circle',
|
1483 |
line=dict(width=1, color='black')
|
1484 |
),
|
1485 |
+
text=['sΓ’ΒΒ', 'sΓ’ΒΒ', 'sΓ’ΒΒ'],
|
1486 |
textposition="top center",
|
1487 |
name='Roots'
|
1488 |
))
|
|
|
1614 |
color_theory_min = 'rgb(180, 30, 180)'
|
1615 |
|
1616 |
# Create tabs for different analyses
|
1617 |
+
tab1, tab2 = st.tabs(["Γ°ΒΒΒ Eigenvalue Analysis (C++)", "Γ°ΒΒΒ Im(s) vs z Analysis (SymPy)"])
|
1618 |
|
1619 |
# Tab 1: Eigenvalue Analysis (KEEP UNCHANGED from original)
|
1620 |
with tab1:
|
|
|
1648 |
max_value=500,
|
1649 |
value=100,
|
1650 |
step=10,
|
1651 |
+
help="Number of points to calculate along the ΓΒ² axis (0 to 1)",
|
1652 |
key="eig_fineness"
|
1653 |
)
|
1654 |
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
1831 |
color=color_max,
|
1832 |
line=dict(color='white', width=1)
|
1833 |
),
|
1834 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Empirical Max</extra>'
|
1835 |
))
|
1836 |
|
1837 |
fig.add_trace(go.Scatter(
|
|
|
1846 |
color=color_min,
|
1847 |
line=dict(color='white', width=1)
|
1848 |
),
|
1849 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Empirical Min</extra>'
|
1850 |
))
|
1851 |
|
1852 |
fig.add_trace(go.Scatter(
|
|
|
1861 |
color=color_theory_max,
|
1862 |
line=dict(color='white', width=1)
|
1863 |
),
|
1864 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Theoretical Max</extra>'
|
1865 |
))
|
1866 |
|
1867 |
fig.add_trace(go.Scatter(
|
|
|
1876 |
color=color_theory_min,
|
1877 |
line=dict(color='white', width=1)
|
1878 |
),
|
1879 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Theoretical Min</extra>'
|
1880 |
))
|
1881 |
|
1882 |
# Configure layout for better appearance
|
|
|
1890 |
'yanchor': 'top'
|
1891 |
},
|
1892 |
xaxis={
|
1893 |
+
'title': {'text': 'ΓΒ² Parameter', 'font': {'size': 18, 'color': '#424242'}},
|
1894 |
'tickfont': {'size': 14},
|
1895 |
'gridcolor': 'rgba(220, 220, 220, 0.5)',
|
1896 |
'showgrid': True
|
|
|
1986 |
color=color_max,
|
1987 |
line=dict(color='white', width=1)
|
1988 |
),
|
1989 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Empirical Max</extra>'
|
1990 |
))
|
1991 |
|
1992 |
fig.add_trace(go.Scatter(
|
|
|
2001 |
color=color_min,
|
2002 |
line=dict(color='white', width=1)
|
2003 |
),
|
2004 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Empirical Min</extra>'
|
2005 |
))
|
2006 |
|
2007 |
fig.add_trace(go.Scatter(
|
|
|
2016 |
color=color_theory_max,
|
2017 |
line=dict(color='white', width=1)
|
2018 |
),
|
2019 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Theoretical Max</extra>'
|
2020 |
))
|
2021 |
|
2022 |
fig.add_trace(go.Scatter(
|
|
|
2031 |
color=color_theory_min,
|
2032 |
line=dict(color='white', width=1)
|
2033 |
),
|
2034 |
+
hovertemplate='ΓΒ²: %{x:.3f}<br>Value: %{y:.6f}<extra>Theoretical Min</extra>'
|
2035 |
))
|
2036 |
|
2037 |
# Configure layout for better appearance
|
|
|
2045 |
'yanchor': 'top'
|
2046 |
},
|
2047 |
xaxis={
|
2048 |
+
'title': {'text': 'ΓΒ² Parameter', 'font': {'size': 18, 'color': '#424242'}},
|
2049 |
'tickfont': {'size': 14},
|
2050 |
'gridcolor': 'rgba(220, 220, 220, 0.5)',
|
2051 |
'showgrid': True
|
|
|
2074 |
st.info("This is the previous analysis result. Adjust parameters and click 'Generate Analysis' to create a new visualization.")
|
2075 |
|
2076 |
except Exception as e:
|
2077 |
+
st.info("Γ°ΒΒΒ Set parameters and click 'Generate Eigenvalue Analysis' to create a visualization.")
|
2078 |
else:
|
2079 |
# Show placeholder
|
2080 |
+
st.info("Γ°ΒΒΒ Set parameters and click 'Generate Eigenvalue Analysis' to create a visualization.")
|
2081 |
|
2082 |
st.markdown('</div>', unsafe_allow_html=True)
|
2083 |
|
|
|
2097 |
help="Parameter a > 1", key="cubic_a")
|
2098 |
cubic_y = st.number_input("Value for y", min_value=0.1, max_value=10.0, value=1.0, step=0.1,
|
2099 |
help="Parameter y > 0", key="cubic_y")
|
2100 |
+
cubic_beta = st.number_input("Value for ΓΒ²", min_value=0.0, max_value=1.0, value=0.5, step=0.05,
|
2101 |
help="Value between 0 and 1", key="cubic_beta")
|
2102 |
st.markdown('</div>', unsafe_allow_html=True)
|
2103 |
|
|
|
2307 |
st.plotly_chart(complex_fig, use_container_width=True)
|
2308 |
|
2309 |
except Exception as e:
|
2310 |
+
st.info("Γ°ΒΒΒ Set parameters and click 'Generate Im(s) vs z Analysis' to create a visualization.")
|
2311 |
st.error(f"Error loading previous data: {str(e)}")
|
2312 |
else:
|
2313 |
# Show placeholder
|
2314 |
+
st.info("Γ°ΒΒΒ Set parameters and click 'Generate Im(s) vs z Analysis' to create a visualization.")
|
2315 |
|
2316 |
st.markdown('</div>', unsafe_allow_html=True)
|
2317 |
|