void Interpolate(int n) { FreeMem(); GetMem(n); GetMaxMin(); GetNodesAndValues(n); GetWeights(n); }
void Scale(vector<double>& a_Values, const double a_tr_min, const double a_tr_max) { double t_max = std::numeric_limits<double>::min(), t_min = std::numeric_limits<double>::max(); GetMaxMin(a_Values, t_min, t_max); vector<double> t_ValuesScaled; for(vector<double>::const_iterator t_It = a_Values.begin(); t_It != a_Values.end(); ++t_It) { double t_ValueToBeScaled = (*t_It); Scale(t_ValueToBeScaled, t_min, t_max, 0, 1); // !!!!!!!!!!!!!!!!?????????? t_ValuesScaled.push_back(t_ValueToBeScaled); } a_Values = t_ValuesScaled; }
void ByjDrawRightRect::CalcSonFiguer(CDC* pDC,CRect &rt) { m_rectDrawLine = rt; { m_dataFormular .numLine = 0; CFormularContent* pIndex; pIndex=(CFormularContent*)pDoc->LookUpArray (pDoc->m_formuar_index,m_nameIndex); if(pIndex!=NULL) if(!pIndex->IsValid()) return; if(pIndex==NULL || pView->m_nCountKline<=0) { return; } m_nValidIndicator = CTaiScreenParent::IsPeriodValid(pView->m_nKlineKind2 ,pIndex); CString s ; CString str = " "; CFormularCompute* m_formuCompute = NULL; INPUT_PARAM input; input.pmax =pView->m_nCountKline-1; input.pp = pView->m_pkline; input.symbol = pView->m_sharesSymbol ; input.nKindKline = pView->m_nKlineKind2 ; input.pBuySellList =&( pView->m_hs) ; input.pIndex = pIndex; input.bAddBuySell = false; input.m_stkKind = pView->m_stkKind; float fMax, fMin; fMax = pView->m_pkline[0].high ; fMin = pView->m_pkline[0].low ; for(int j=1; j<pView->m_nCountKline; j++) { if(pView->m_pkline[j].high>fMax) fMax = pView->m_pkline[j].high; if(pView->m_pkline[j].low<fMin) fMin = pView->m_pkline[j].low; } ARRAY_Right_Box::SetTime (CTime(pView->m_pkline [pView->pKlineDrawing ->m_footCurrent].day )) ; TRACE("pView->pKlineDrawing ->m_footCurrent: %d ; \n",pView->pKlineDrawing ->m_footCurrent); ARRAY_Right_Box::GetRuler(fMax, fMin); CTaiKlineShowKline *pDoK = pView->pKlineDrawing ; pDoK->m_nSon=0; pDoK->SetRectCurrent(0); if(ComputeFormu2(m_formuCompute,input)==0) { int rtnLine=0; m_dataFormular .numLine =m_formuCompute->GetRlineNum (); if(m_dataFormular .numLine>18) m_dataFormular .numLine = 18; for(int i=0 ; i<m_dataFormular .numLine ; i++) { CString namePer; int nIn = i ; rtnLine = m_formuCompute->GetLine (nIn,m_dataFormular .line [i].m_arrBE,namePer); if(rtnLine==1) m_dataFormular .line [i].m_arrBE.b = -1; m_dataFormular .line [i].type = m_formuCompute->m_RlineType[i] ; if(namePer.GetLength()>18) m_lineName [i]="δ֪"; else m_lineName [i]=namePer; GetMaxMin(i,i==0); } for(int i=0 ; i<m_dataFormular .numLine ; i++) { DrawSonFiguer( pDC,i); } DrawCaption(pDC, pIndex); } else ; delete m_formuCompute; ARRAY_Right_Box::Reset (); } }
void Interpolate(int n) { FreeMem(); GetMem(n); GetMaxMin(); GetNodesAndValues(n); MakeMatrix(n); double *ss = new double[n - 2]; SolveSystem(n - 2, aa, bb, ss); for (int i = 2; i < n; i++) D(i) = ss[i - 2 - 1]; delete ss; EM(1, 1) = X(1) * X(1) * X(1); EM(1, 2) = X(1) * X(1); EM(1, 3) = X(1); EM(1, 4) = 1.0; EM(2, 1) = X(2) * X(2) * X(2); EM(2, 2) = X(2) * X(2); EM(2, 3) = X(2); EM(2, 4) = 1.0; EM(3, 1) = X(3) * X(3) * X(3); EM(3, 2) = X(3) * X(3); EM(3, 3) = X(3); EM(3, 4) = 1.0; EM(4, 1) = 3.0 * X(3) * X(3); EM(4, 2) = 2.0 * X(3); EM(4, 3) = X(3); EM(4, 4) = 0.0; eb[0] = F(1); eb[1] = F(2); eb[2] = F(3); eb[3] = D(3); SolveSystem(4, em, eb, exs); EM(1, 1) = X(n - 2) * X(n - 2) * X(n - 2); EM(1, 2) = X(n - 2) * X(n - 2); EM(1, 3) = X(n - 2); EM(1, 4) = 1.0; EM(2, 1) = X(n - 1) * X(n - 1) * X(n - 1); EM(2, 2) = X(n - 1) * X(n - 1); EM(2, 3) = X(n - 1); EM(2, 4) = 1.0; EM(3, 1) = X(n) * X(n) * X(n); EM(3, 2) = X(n) * X(n); EM(3, 3) = X(n); EM(3, 4) = 1.0; EM(4, 1) = 3.0 * X(n - 2) * X(n - 2); EM(4, 2) = 2.0 * X(n - 2); EM(4, 3) = X(n - 2); EM(4, 4) = 0.0; eb[0] = F(n - 2); eb[1] = F(n - 1); eb[2] = F(n); eb[3] = D(n - 2); SolveSystem(4, em, eb, exe); }