fix: range auto
This commit is contained in:
parent
eafef1fd61
commit
f0df27ef9b
BIN
Figure_1.png
Normal file
BIN
Figure_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -368,8 +368,9 @@ void CMainFrame::OnOptOpen() {
|
|||||||
|
|
||||||
// 其他设置
|
// 其他设置
|
||||||
m_bClearFlag = TRUE;
|
m_bClearFlag = TRUE;
|
||||||
pView->m_sRangeMode = "Auto";
|
OnRangeAuto();
|
||||||
pView->m_sSmoothType = "Origin";
|
pView->m_sSmoothType = "Origin";
|
||||||
|
|
||||||
UpdateValue();
|
UpdateValue();
|
||||||
pDoc->UpdateAllViews(NULL);
|
pDoc->UpdateAllViews(NULL);
|
||||||
}
|
}
|
||||||
@ -519,8 +520,8 @@ void CMainFrame::OnAxisLog() {
|
|||||||
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
||||||
|
|
||||||
pView->m_sAxisMode = (CString)"Log";
|
pView->m_sAxisMode = (CString)"Log";
|
||||||
pView->m_sRangeMode = "Auto";
|
|
||||||
pView->m_ComboAxis.SetCurSel(1);
|
pView->m_ComboAxis.SetCurSel(1);
|
||||||
|
OnRangeAuto();
|
||||||
m_bAutoFlag = FALSE;
|
m_bAutoFlag = FALSE;
|
||||||
m_bLinearFlag = TRUE;
|
m_bLinearFlag = TRUE;
|
||||||
m_bLogFlag = FALSE;
|
m_bLogFlag = FALSE;
|
||||||
@ -538,6 +539,7 @@ void CMainFrame::OnRangeAuto() {
|
|||||||
pView->m_sRangeMode = (CString)"Auto";
|
pView->m_sRangeMode = (CString)"Auto";
|
||||||
m_bAutoFlag = FALSE;
|
m_bAutoFlag = FALSE;
|
||||||
pView->m_nLC = max(1, RoundupPowerof2(pView->m_nMaxCount));
|
pView->m_nLC = max(1, RoundupPowerof2(pView->m_nMaxCount));
|
||||||
|
pView->UpdateData(FALSE);
|
||||||
pDoc->UpdateAllViews(NULL);
|
pDoc->UpdateAllViews(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +552,7 @@ void CMainFrame::OnRangeD4() {
|
|||||||
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
||||||
|
|
||||||
pView->m_sRangeMode = (CString)"Manual";
|
pView->m_sRangeMode = (CString)"Manual";
|
||||||
pView->m_nLC /= 4;
|
pView->m_nLC = pView->m_nLC > 1 ? pView->m_nLC / 4 : 1;
|
||||||
m_bAutoFlag = TRUE;
|
m_bAutoFlag = TRUE;
|
||||||
pView->UpdateData(FALSE);
|
pView->UpdateData(FALSE);
|
||||||
pDoc->UpdateAllViews(NULL);
|
pDoc->UpdateAllViews(NULL);
|
||||||
@ -561,7 +563,7 @@ void CMainFrame::OnRangeD2() {
|
|||||||
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
if (pView == nullptr) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
||||||
|
|
||||||
pView->m_sRangeMode = (CString)"Manual";
|
pView->m_sRangeMode = (CString)"Manual";
|
||||||
pView->m_nLC /= 2;
|
pView->m_nLC = pView->m_nLC > 1 ? pView->m_nLC / 2: 1;
|
||||||
m_bAutoFlag = TRUE;
|
m_bAutoFlag = TRUE;
|
||||||
pView->UpdateData(FALSE);
|
pView->UpdateData(FALSE);
|
||||||
pDoc->UpdateAllViews(NULL);
|
pDoc->UpdateAllViews(NULL);
|
||||||
|
44
MCA/Matrix.h
44
MCA/Matrix.h
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef DESCSS_Matrix_h
|
#ifndef Matrix_h
|
||||||
#define DESCSS_Matrix_h
|
#define Matrix_h
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define swap2(x, y) ((x) = (x) ^ (y), (y) = (x) ^ (y), (x) = (x) ^ (y))
|
#define swap2(x, y) ((x) = (x) ^ (y), (y) = (x) ^ (y), (x) = (x) ^ (y))
|
||||||
@ -71,15 +71,9 @@ void matrix::Input(double* p) {
|
|||||||
for (int j = 0; j < m; j++) this->element[i][j] = *(p++);
|
for (int j = 0; j < m; j++) this->element[i][j] = *(p++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix::Output() {
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
for (int j = 0; j < m; j++) std::cout << element[i][j] << " ";
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double& matrix::operator()(int i, int j) const {
|
double& matrix::operator()(int i, int j) const {
|
||||||
if (i < 0 || i > n - 1 || j < 0 || j > m - 1) std::cout << "Matrix Index Out Of Bounds " << std::endl;
|
if (i < 0 || i > n - 1 || j < 0 || j > m - 1)
|
||||||
|
std::cout << "Matrix Index Out Of Bounds " << std::endl;
|
||||||
return element[i][j];
|
return element[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +117,15 @@ matrix matrix::operator/(const double& C) const {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LUPDescomposition(matrix mA, matrix& mL, matrix& mU, int* P)
|
std::ostream& operator<<(std::ostream& cout, matrix& mA) {
|
||||||
{
|
for (int i = 0; i < mA.rows(); i++) {
|
||||||
|
for (int j = 0; j < mA.cols(); j++) cout << mA(i, j) << " ";
|
||||||
|
if (i < mA.rows() - 1) cout << std::endl;
|
||||||
|
}
|
||||||
|
return cout;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LUPDescomposition(matrix mA, matrix& mL, matrix& mU, int* P) {
|
||||||
int n = mA.rows();
|
int n = mA.rows();
|
||||||
int row = 0, tmp;
|
int row = 0, tmp;
|
||||||
double L, U, tmp2;
|
double L, U, tmp2;
|
||||||
@ -144,15 +145,13 @@ BOOL LUPDescomposition(matrix mA, matrix& mL, matrix& mU, int* P)
|
|||||||
|
|
||||||
tmp = P[i], P[i] = P[row], P[row] = tmp;
|
tmp = P[i], P[i] = P[row], P[row] = tmp;
|
||||||
|
|
||||||
for (int j = 0; j < n; j++)
|
for (int j = 0; j < n; j++) tmp2 = mA(i, j), mA(i, j) = mA(row, j), mA(row, j) = tmp2;
|
||||||
tmp2 = mA(i, j), mA(i, j) = mA(row, j), mA(row, j) = tmp2;
|
|
||||||
|
|
||||||
U = mA(i, i), L = 0;
|
U = mA(i, i), L = 0;
|
||||||
for (int j = i + 1; j < n; j++) {
|
for (int j = i + 1; j < n; j++) {
|
||||||
L = mA(j, i) / U;
|
L = mA(j, i) / U;
|
||||||
mA(j, i) = L;
|
mA(j, i) = L;
|
||||||
for (int k = i + 1; k < n; k++)
|
for (int k = i + 1; k < n; k++) mA(j, k) = mA(j, k) - mA(i, k) * L;
|
||||||
mA(j, k) = mA(j, k) - mA(i, k) * L;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
@ -160,7 +159,7 @@ BOOL LUPDescomposition(matrix mA, matrix& mL, matrix& mU, int* P)
|
|||||||
for (int j = 0; j < i; j++) mL(i, j) = mA(i, j);
|
for (int j = 0; j < i; j++) mL(i, j) = mA(i, j);
|
||||||
for (int j = i; j < n; j++) mU(i, j) = mA(i, j);
|
for (int j = i; j < n; j++) mU(i, j) = mA(i, j);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix LUPSolve(matrix& mL, matrix& mU, int* P, double* b) {
|
matrix LUPSolve(matrix& mL, matrix& mU, int* P, double* b) {
|
||||||
@ -219,16 +218,17 @@ matrix matrix::T() {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Gaussian(double x, double A, double mean, double sigma) {
|
double Gaussian_(double x, double A, double mean, double sigma) {
|
||||||
return A * exp(-(x - mean) * (x - mean) / (2 * sigma * sigma));
|
return A * exp(-(x - mean) * (x - mean) / (2 * sigma * sigma));
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix Jacobian(int n, double* X, double A, double mean, double sigma) {
|
matrix GaussianJacobian_(int n, double* X, double A, double mean, double sigma) {
|
||||||
matrix J(n, 3);
|
matrix J(n, 3);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
J(i, 0) = -Gaussian(X[i], A, mean, sigma) / A;
|
J(i, 0) = -Gaussian_(X[i], A, mean, sigma) / A;
|
||||||
J(i, 1) = -(X[i] - mean) * Gaussian(X[i], A, mean, sigma) / (sigma * sigma);
|
J(i, 1) = -(X[i] - mean) * Gaussian_(X[i], A, mean, sigma) / (sigma * sigma);
|
||||||
J(i, 2) = -(X[i] - mean) * (X[i] - mean) * Gaussian(X[i], A, mean, sigma) / (sigma * sigma * sigma);
|
J(i, 2) = -(X[i] - mean) * (X[i] - mean) * Gaussian_(X[i], A, mean, sigma) /
|
||||||
|
(sigma * sigma * sigma);
|
||||||
}
|
}
|
||||||
return J;
|
return J;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user