使用自制CtlPointsCurve.dll组件实现样条曲线拟合

对于现在数据采集重绘处理,很多情况下都用到了曲线重绘,而曲线生成的方法也有多种 

最简单的一种就是两点一线法,简单来说就是对每个采集点做直线连接,使到其趋向一曲线,这种方法的好处是保证数据的真实性,但同时也引申出很多问题.首先,采集点必须要足够多,否则的话就成了线段组,而并非曲线了,这样对于一些无法多点采集的技术领域,或者采集成本很高的技术领域来说,便无法满足其分析需求了.因此,产生了样条曲线的计算方法.

样条曲线的计算法则中,最复杂的可以算是B样条多次曲线拟合,其思路是在当前采样点的前提下,根据其计算公式,推算出对于采样点符合条件的曲线目标点,然后再在目标点间连线.这样就可以在采样点少的情况下,画出趋向曲线的点了.

 

理论的东西就说那么多,至于计算法则,我相信数学书上比我写的要详细很多,接下来就介绍在程序里面的实现,特别是VB里面的实现.

 

关于曲线拟合的VC代码,网络上面已经可以找到很多,推荐大家可以到codeguru里面找找,有位Tom Chan的控制点曲线计算(Control Point Curve)的类已经封装得很好了,特别对于不关心具体算法的用户可以放心使用,而至于VB上面实现的代码,到目前为止在下还没有找到.于是引申自己编写的念头.

在实现过程中,发觉VB对数的处理能力,特别是数组的处理能力实在不敢恭维(是因为VB里面的数组都为SALFARRAY的原因吧).

于是想到可以借助Tom Chan的计算类来实现.首先使用ATL编写ACTIVEX COM DLL,DLL里封装了Tom Chan的计算方法,然后给予VB接口的调用,这样不但可以加快运算的速度,也可以减低VB做算法的负担.(要知道,如果用VB里面的安全数组来做算法的话,对CPU实在是一种浪费)

下图为在下的程序演示:

 

 

至于该组件--CtlPointsCurve.dll ,可以Email给在下(Xeden3@hotmail.com).

 

现在,我们具体看看如何使用这个CtlPointsCurve.dll.

 

首先,我们必须要给一个画线的空间给他,当然,PICTUREBOX是最好的选择。

然后我们定义两个按键,一个用于绘出曲线,一个清空,以便重新绘制。


 

Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long

Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long



定义两个
API Ellipse()用于在PICTUREBOX绘制鼠标点击的采样点,Polyline()用于画出最后目标点连线。



Dim ctlPointCurveMathMaker As New CTLPOINTSCURVELib.CtlPointsCurveMath

Dim posSrc(5000) As CTLPOINTSCURVELib.Point

Private Type POINTAPI

X As Long

Y As Long

End Type



ctlPointCurveMathMaker
对象,作为计算样条曲线用。

posSrc定义最大的采样点,内部结构与POINTAPI相同,现在设定的最大采样值是5000点。POINTAPI 结构,用于表示2D坐标。

m_Count当前采样点数。



由于样条计算是在
CTLPOINTSCURVELib.CtlPointsCurveMath内部进行,所以必须把API2D坐标结构POINTAPI转化到CTLPOINTSCURVELib.Point内,同样,生成目标点的坐标也要转换到API2D坐标结构POINTAPI以便绘制。

 


Private Sub cmdClear_Click()

Picture1.Cls
m_Count = 0

End Sub



清空



Private Sub Picture1_MouseDown(Buton As Integer, Shift As Integer, X As Single, Y As Single)

Picture1.ForeColor = vbBlue
posSrc(m_Count).pixX = X
posSrc(m_Count).pixY = Y
m_Count = m_Count + 1
Ellipse Picture1.hdc, X, Y, X + 5, Y + 5
Picture1.Refresh

End Sub



当鼠标点击Picture1后,把鼠标当前坐标作为采样点赋值到posSrc(m_Count)内,并且绘制一个半径为5pixel的圆。



Private Sub cmdRun_Click()

Dim posDest() As CTLPOINTSCURVELib.Point
Dim ptAPI() As POINTAPI

Dim ptCount As Long
ctlPointCurveMathMaker.InputCtlPoints m_Count, posSrc(0)
ctlPointCurveMathMaker.Generate
ptCount = ctlPointCurveMathMaker.GetCurveCount
ReDim posDest(ptCount - 1)
ReDim ptAPI(ptCount - 1)
ctlPointCurveMathMaker.GetCurve ptCount, posDest(0)
For i = 0 To ptCount - 1
   ptAPI(i).X = posDest(i).pixX
   ptAPI(i).Y = posDest(i).pixY
Next i
Picture1.ForeColor = vbRed
Polyline Picture1.hdc, ptAPI(0), ptCount
Picture1.Refresh

 End Sub



Dim posDest() As CTLPOINTSCURVELib.Point
定义生成的目标点的坐标。

Dim ptAPI() As POINTAPI 当然,这个就是把posDest转化过来,用于绘制曲线用的。ctlPointCurveMathMaker.InputCtlPoints m_Count, posSrc(0) 入采样点,m_Count为采样数。posSrc(0)为采样点。

 

ctlPointCurveMathMaker.Generate 开始计算样条曲线。

ptCount = ctlPointCurveMathMaker.GetCurveCount 获取目标点数目。

ReDim posDest(ptCount - 1)

ReDim ptAPI(ptCount - 1)

 

好了,我们现在根据得到的ptCount,重新定义posDestptAPI的大小。

ctlPointCurveMathMaker.GetCurve ptCount, posDest(0) 读取目标点。

 

For i = 0 To ptCount - 1

    ptAPI(i).X = posDest(i).pixX
    ptAPI(i).Y = posDest(i).pixY
Next i

把目标点转化到ptAPI里面,然后调用Polyline Picture1.hdc, ptAPI(0), ptCount绘制出来。

 

Picture1内容,也把当前采样点数m_Count0
ct. 18, 1995 v. 1.00 =========================================================================== + First release of CurveExpert 1.0. Oct. 26, 1995, v. 1.01 =========================================================================== New Features: + More attractive help file, with more keywords for searching + new help search facility available directly from CurveExpert Bug Fixes: + If a polynomial was already calculated, selecting another polynomial of a differing degree incorrectly pulled results from the cache instead of recalculating the curve fit. Fixed. + running two versions of CurveExpert is prevented, since two simultaneous instances cause stack faults. + if the data set is sorted, all interpolations are now marked invalid as they should be. + "Apply to All" did not necessarily force the current attributes of a graph to the current graph (only if the user clicks OK). Fixed. + The scrollbar did not get reset to the top when the user read in a new data file. Fixed. + The structure of the code has been undergone some major changes to ease porting to Windows 95 and Windows NT. I was exceedingly careful, but I hope this didn't introduce new bugs! :-) + For some reason, the help file didn't have any single or double quotes in it. This has been corrected, so it is now easier to read. + The help file was not terminated when CurveExpert was. Fixed. + The Window and Help menus were moved to more conventional positions on the menu bar. Nov. 4, 1995, v. 1.10: =========================================================================== New Features: + Previously undocumented logical functions can be used in the user-defined models. See the help documentation. + Current filename now appears in the title bar. + QuickCalc has been expanded to find the x-value, given the y-value. + Optimizations have been applied to many routines, making the user interface more responsive and the algorithms quicker. Changes: + File reading system has been revamped. + the color scheme on all windows now conforms strictly to the user defined system colors. + Dialogs were expunged of all Borland controls (except for buttons) since they conflicted with user defined color schemes. + The QuickCalc dialog now automatically shifts focus back to the edit control and selects all text after the OK button is pushed. This makes it easier to calculate many points at a time. Bug Fixes: + pressing the tab key to force the built-in spreadsheet sometimes added points onto the end of the data set. Fixed. + If a graph window was closed and then reopened (except after a CurveFinder operation), the comments in the Graph Info dialog were not correct. Fixed. + The Cut Last Row/Undo pair now functions properly. + The the graph of a polynomial fit would be reset if the data was changed in the data window. Fixed. + The scaling procedure did not grab the latest data out of the data window's edit control if it was active, resulting in one point not being scaled or translated. Fixed. + A constant starting with a decimal (eg, .25) caused CurveExpert to bomb (when defining a user model). This has been fixed so that these constants are accepted. + A comma-delimited data file was not read correctly. A new file reading system was implemented to read files with any type of (unspecified) delimiter between the data columns + if a data file was not read correctly, the filename in the status bar showed the unreadable file instead of the previous file. Fixed. + the common dialogs (file open/save, print) did not accept keystokes until after they were clicked with the mouse, which makes it terribly hard for non-mouse users. Fixed. + If the current path was changed from CurveExpert, the help file was not found. Fixed. Nov. 9, 1995, v. 1.11 =========================================================================== New Features: + the data point markers on graphs can now be changed to filled or unfilled circles, squares, triangles, pluses, or crosses. Changes: + Small optimizations made to the speed of the user interface + The main window is now fully resizable + The position and size of the main window is saved on exit and restored the next time CurveExpert runs Bug Fixes: + Whoops! The new file reading procedure masked out all minus and minus signs in the data, so that numbers like -10 and 10e-3 were not read correctly. Fixed. + the exception reporting dialog box did not properly draw the exclamation point's background, which should match the dialog color. Fixed. + the single-precision version still read files incorrectly sometimes. Fixed. + the initial guess dialog sometimes opened unconditionally on the next fit performed after a CurveFinder evaluation. Fixed. Nov. 13, 1995, v. 1.12 =========================================================================== New Features: + Differentiation and integration of a calculated curve fit is now supported, similar to the implementation of QuickCalc. Changes: + If background processing is enabled, during iteration the cursor is a combined arrow/hourglass to inform the user that he/she can still perform operations. + editing points in the spreadsheet is now prohibited while any iteration is taking place. + Drawing of data points on a graph is internally clipped if it is outside of the graphing window. This allows for faster graph drawing if many points are outside of the graph pane. + A separate set of application-wide defaults are maintained for the single-precision and double-precision versions (registered version only) Bug Fixes: + Periods by themselves in the user models were parsed as the value zero instead generating a syntax error. Fixed. + A plot that was copied to the clipboard failed to "clip" data points that were outside of the graphing pane, resulting in points being drawn outside of the intended area. Fixed. + The information button on a graph window would sometimes disappear if a window was sized smaller. Fixed. + After copying a plot to the clipboard, the current graph resolution was incorrectly reset to 1. Fixed. + Extremely small parameter guesses were not allowed in the parameter guess dialog, since its precision was limited to six places. Fixed. Nov. 25, 1995, v. 1.13 =========================================================================== Changes: + The data manipulation tools have now been merged into one organized, tabbed dialog. + The model analytical tools have now been merged into one organized, tabbed dialog. + Cascading a large number of windows would sometimes result in some windows being moved off of the screen. Now, the cascade restarts at the top left if a window might be moved off-screen. + The built-in models have been reordered so that operations such as calculations and window manipulations naturally fall into a grouped arrangement. + the graph autoscaling algorithm has been rewritten to be more reliable + The info button on the graphing window has been changed and moved to be less obtrusive. + sizing restrictions on the graphing windows have been removed. Bug Fixes: + Whoops! Another problem with the file reading engine caused columns starting with a negative number to be discarded. Fixed. + Entering a user model with no parameters was allowed when it shouldn't have been. Now, a syntax error is generated. + the Window|Tile command sometimes worked strangely if graphing windows had been closed prior to invoking it. Fixed. + the Window|Cascade command did not properly cascade windows that were minimized. Fixed. + the last tick and label sometimes wasn't shown on the x/y axes of plots. Fixed. + the implementation of filled points didn't produce a filled entity for the circle or triangle when printed. Fixed. + The user was still asked whether to save a file or not upon exiting, even if the file had just been saved. Fixed. + CurveExpert will now run even if ctl3dv2.dll is not found. Dec. 2, 1995, v. 1.14 (Shareware Only) =========================================================================== Bug Fixes: + Graph Attributes/Graph Scaling Dialogs were not initialized properly in the Shareware version. Fixed. Dec. 31, 1995, v. 1.15 (Not Released) =========================================================================== Changes: + Sometimes, resizing a graph would result in the line width being drawn incorrectly (not the user-specified line width, screen only). Fixed. + delayed rendering of plots is now supported, to greatly increase drawing performance with user model plots and/or plots with a large number of data points + (registered only) the single precision package has now been optimized for single-precision arithmetic + the directions on the graph window are now removed if they will be collide with the error information. This leads to cleaner plots, especially with small graphing windows. Bug Fixes: + if one minor tick was selected (on either axis), there was a chance that one too many tick labels would be printed. Fixed. + some stray (and inappropriate) directions were left on the differentiate and integrate dialogs. Removed. Jan. 14, 1996, v. 1.20 =========================================================================== New Features: + many new graphing features and easier-to-use graphing properties interface has been added + the covariance matrix and residual plot are now available in the revamped information dialog + much faster nonlinear regression performance over version 1.1 (between 17% to 45% improvement in speed, depending on the number of parameters) Changes: + each graphing window no longer appears in the Win31 tasklist; and each window no longer shows up in the Win95 taskbar. + weighting values by 1/y^2 during nonlinear regression is now implemented Jan. 25, 1996, v. 1.21 =========================================================================== Bug Fixes: + the equation bitmaps in the initial guess and/or information dialog did not update properly at times. Fixed. + if the ctl3dv2 module could not be loaded, the info dialog GPF'ed when opened. Fixed. March 5, 1996, v. 1.22 =========================================================================== New Features: + the Preferences dialog has been revamped, with many new user- defineable options added for printing, regression/math options, and application options. + added right-click menus to all main window regions Changes: + The limitation of two-line titles in metafiles has been removed. + new and improved debugging console with a nicer appearance and more information. Necessary because of the ongoing port to Win32. + a button that coordinates the foreground (frame) color and the text colors was added to the graph properties dialog + the ability to draw grid lines at each minor tick mark was added + drag-and-drop from the file manager to CurveExpert is now supported + data information dialog box was widened to accommodate large numbers. + a new and much faster data clipping algorithm is now used + clipping and sorting operations now take place in the background, instead of hogging the CPU + two new symbols added to the graphing properties dialog Bug Fixes: + if the "Weight by Y^2" option was turned on, the results of nonlinear regression were likely to be a local minima or not converge at all. Fixed. + It was not possible to put a single percent sign in an axis label without typing '%%' in the axis label edit field. Fixed. + if the graph extents were set just right on the x or y axis, then one grid line would not draw. Fixed. + if the main window was minimized when CurveExpert was exited, the window was not restored to the correct position the next time CurveExpert was run. Fixed. + a GPF occurred if a data set with over 8192 data points was sorted. Fixed. + corrected an erroneous reading of the allocated memory (in bytes) that occurred if the quadratic fit was ever used. + if a residual table of an extremely large data set was copied to the clipboard in the info dialog, a GPF occurred. Fixed. + if a large data file with very large numbers was read, the first examination of that file would cause a program abort due to an overflow. Fixed. May 20, 1996, v. 1.23 =========================================================================== New Features: + 32 BIT VERSION FOR WINDOWS 95 AND WINDOWS NT RELEASED! + added x/y averages, minima, maxima, and standard deviations to the variables available for custom regressions + added the capability to swap the x and y data + (32 bit only) new tooltips feature gives quick access to a toolbar button's function Changes: + All BWCC controls have been removed, and as a result, several dialogs were redesigned. This gives a more consistent feel to the application, eases the port to Win32, and frees CurveExpert from having the BWCC.DLL library distributed with it. + (16 bit only) draws the missing line between the toolbar and menus if running under Windows 95. + added code to properly shut down CurveExpert if the user logs off while it is running. + fit type has been added to the caption of a residual plot window to make it clear where the window originated. + even if no changes were made to the graph from the Graph Properties dialog, the plot was re-rendered. Now, a check is made to see if any changes were made to determine if the graph should be redrawn. + the help file has undergone some formatting changes and additions + support for multiple-copy printouts was added Bug Fixes: + the table-generation and export-file mechanisms printed all zeros if a number was too small. Fixed. Now, the numbers are printed properly in exponential format. + the Preferences dialog would cause a program abort if no printer was installed. Fixed. + the function that draws the graph title had a potential memory leak. This would manifest itself also in the Residual page from the information dialog. Fixed. + the path field in the application preferences dialog would not allow horizontal scrolling, so the user was limited to a short data file path name. Fixed. + the ranking chart would sometimes get corrupted during a CurveFinder operation on a small data set (at unpredictable times). Fixed. + the underline style was ignored if it was specified for a font that would appear on a graph. Fixed. + a memory leak that caused a "floating point error" in the lagrangian interpolation routine was fixed + if a x or y axis label contained more than 50 characters, a subsequent display of the plot would cause a crash. Fixed. June 2, 1996, v. 1.24 =========================================================================== Changes: + when the 32-bit version opened a help file under Win32s, it went straight to the help file contents. Now, it opens the help file contents dialog box. + while reading a file, the progress is reported in the status bar Bug Fixes: + under Windows NT, all of the tabbed dialog boxes (preferences, graph properties, graph analyze, graph information) were blank. Fixed. + the history (dump) file did not have the last iteration written to it if the iteration converged. Fixed. + CurveExpert might not detect that it is running under Win32s correctly. Fixed. + if a line in a data file started with a +, it was not recognized as a number. Fixed. November 7, 1996, v. 1.30 =========================================================================== New Features: + uncertainties (standard deviations) in each data point can now be used + built-in spreadsheet facility has been enhanced -- now looks and behaves *much* more like a spreadsheet + spreadsheet facility has multilevel undo/redo capability + cut/copy/paste of ranges in the built-in spreadsheet and between other spreadsheets (Excel, Quattro Pro, etc.) is now implemented + enhanced file import facility gives more flexibility for reading data files + a most-recently-used file list is maintained in the File menu + [32-bit, '95 interface only] Internet-aware links in the Help menu directly access the CurveExpert home page(s) Changes: + the splash screen is now drawn in the correct user-defined color, instead of being hard-coded to light gray. + the graphs now comply with the user-defined color scheme unless set explicitly by the user. + there is no longer any limit on the number of data points that can be entered manually (previously 100) + the main window now responds appropriately when certain system settings change, such as the scroll bar width + more info was added to the debugging facility + the status bar now shows what degree of polynomial is being computed + some menu items have been rearranged to form a more consistent user interface + if the file is modified, an asterisk appears beside the filename in the title bar; when the file is saved, the asterisk is removed + typing a title in the "Graph Properties" dialog now automatically deselects the "Show Header" checkbox. Bug Fixes: + certain curve fits were turned off when they shouldn't have been if zeros or negatives existed in the x data. Fixed. + strange "NAN"s would occasionally appear in the released 32-bit version. This was due to a Microsoft optimizer bug; a workaround has been implemented. + On Windows NT, if a table file was to overwrite an already existing file, CurveExpert would terminate. Fixed. + if a two-column data file had a one-column entry later in the data file, CurveExpert would crash. Fixed. + an internal error that might cause a termination while using the CurveFinder was fixed + CurveExpert would crash soon after invoking the preferences dialog, if the polynomial window was open and the degree in it did not match the selected degree in the preferences dialog + the CurveFinder tool now correctly handles polynomial calculations when the Polynomial family is selected + if a data set line began with spaces or tabs, it could be misinterpreted as having one more column than it did. Fixed. + the help button for the ArcLength page in the "Analyze Graph" dialog did not work. Fixed. + the new-style help is now used unter Windows NT 3.51 by default + if a malformed file was attempted to be read, the toolbar was (mistakenly) reenabled anyway. Fixed. + various and sundry misspellings, typos, and formatting errors have been corrected in the on-line documentation. November 18, 1996, v. 1.31 =========================================================================== Changes: + [32-bit only] Bessel functions of first and second kind added to available user model functions + ceil and floor functions added to available user model functions Bug Fixes: + [32-bit only] When installing to a WinNT 3.51 platform. no Program Manager group and icons would be created unless the user was the administrator. Fixed. + [16-bit only] If a math error occurred and was handled in CurveExpert and 3d dialogs were being used, dialogs became transparent and unusable until CurveExpert was restarted. Fixed. February 24, 1997, v. 1.32 =========================================================================== New Features: + A history page has been added to the Graphing Information dialog to give the chi-square and parameter histories for each regression. + a preview plot gives quick access to visualization of various regressions on the ranking chart Changes: + if the y column is scaled and STD data is also present, the STD data is scaled by the same factor as the y column + the ranking chart interface has been changed to mesh smoothly with the preview plot + comments in the information dialog were not available after running CurveFinder or closing/reopening a window. This data is now stored with the fit coefficients, so the comments are available at any time for a valid curve fit result + various speedups implemented in the nonlinear regression routine Bug Fixes: + when sorting data and the standard deviation column is active, the STD data would not be carried with the data point. Fixed. + if pasting more than 25 points, CurveExpert would freeze. Fixed. + Several memory and resource leaks fixed. + if an exception occurred when plotting a graph, the message stating so would be misplaced on the window/metafile/printout. Fixed. + the keyboard interface on the File Import Dialog was nonexistant. Added. + After clipping the data set, if the user tried to undo a previous action, CurveExpert would crash. Now, the undo is disabled in this situation. + When dragging and dropping a file on CurveExpert, the title of the file became "TITLE.ERR". Fixed. + when a file was opened off of the MRU menu or dropped on CurveExpert, it could not be saved to the same file. Fixed. February 26, 1997, v. 1.33 =========================================================================== Bug Fixes: + For users with an international version of Windows where the comma is used for the decimal point, CurveExpert would not read files properly. Fixed. + In help file, correlation coefficient was documented incorrectly. Corrected. March 19, 1997, v. 1.34 =========================================================================== Bug Fixes: + [16 bit only] plots with a log x axis were not plotting correctly. Fixed. + Corrections made to keyboard interface in File Import Dialog. March 1, 1998, v. 1.36 =========================================================================== New Features: + a facility to transform a column of data at a time by selected functions was added Changes: + the initial viewable state of the CurveExpert window now reacts correctly to external control of the process spawning it + a switch was added to toggle the solid line at X=0 and Y=0 on the graph + some additions and changes to the help documentation Bug Fixes: + a 19th order polynomial fit caused a crash; fixed. Jan 1, 2001, v. 1.37 ============================================================================ Changes: + updates to address and payment information June 13, 2003, v. 1.38 ============================================================================ New Features: + added setting to curves.ini file to allow international users to set the decimal point appropriately based on their locale Changes: + Updated contact information and order form
做了一个dll,具有多项式拟合和表达式计算的功能,导出接口如下: /////////////////////////////////// /* 获取帮助信息 strOut:保存帮助文本信息 len:表示strOut的缓存长度 返回值:strOut==NULL或len==0时,strOut不写入内容,返回所需缓冲区长度(包括'\0'结尾符); 否则直接返回len */ EXPORT size_t Help(char* strOut, size_t len); /* 计算不含未知数表达式的值 strIn:预计算的表达式 ret:返回计算结果 IsRad:表达式中含有sin之类的三角函数时,表明是按弧度制还是角度制,TRUE表示弧度制 返回值:表示错误码,0代表计算成功,错误码代表的意思可通过调用ErrorStr函数取得 */ EXPORT int Calculate(const char* strIn, double* ret, BOOL IsRad); /* 计算含有一个未知数表达式(必须以字母x表示)当x等于value时的值 strIn:预计算的表达式 value:x等于value时 ret:返回计算结果 IsRad:表达式中含有sin之类的三角函数时,表明是按弧度制还是角度制,TRUE表示弧度制 返回值:表示错误码,0代表计算成功,错误码代表的意思可通过调用ErrorStr函数取得 */ EXPORT int Function(const char* strIn, double value, double* ret, BOOL IsRad); /* 计算含有一个未知数表达式(必须以字母x表示)当x在区间[low,high)内平均等分为cnt段时各点的值 strIn:预计算的表达式 low:左区间 high:右区间,内部会检查high<low时的情况(会做Swap处理) cnt:等分的段数(同时也表示xOut和yOut数组的长度) xOut:返回计算结果的横坐标值 yOut:返回计算结果的纵坐标值 IsRad:表达式中含有sin之类的三角函数时,表明是按弧度制还是角度制,TRUE表示弧度制 返回值:表示错误码,0代表计算成功,错误码代表的意思可通过调用ErrorStr函数取得 */ EXPORT int Function_Interval(const char* strIn, double low, double high, size_t cnt, double* xOut, double* yOut, BOOL IsRad); /* 根据错误码返回其文本描述信息 errNo:错误码,取值范围为[0-9],超过范围时,strOut写入"错误码超过取值范围" strOut:保存错误码的文本信息 len:表示strOut的缓存长度 返回值:strOut==NULL或len==0时,strOut不写入内容,返回所需缓冲区长度(包括'\0'结尾符); 否则直接返回len */ EXPORT size_t ErrorStr(size_t errNo, char* strOut, size_t len); /* 多项式拟合 xIn:输入采样数据横坐标的集合 yIn:输入采样数据纵坐标的集合 cnt:输入采样数据的对数,即xIn或yIn数组内数据个数,函数假设xIn、yIn数组内数据个数一样多 sztCiShu:sztCiShu代表最高次为sztCiShu-1,即待求未知系数个数为sztCiShu个,sztCiShu须不大于cnt aOut:保存未知系数的拟合结果,数组长度为sztCiShu 返回值:表示拟合成功与否 */ EXPORT BOOL Fitting_Double(double* xIn, double* yIn, size_t cnt, size_t sztCiShu, double* aOut); /* 也是多项式拟合,只是拟合结果直接表示成了表达式的字符串形式,写入到strOut中 xIn:输入采样数据横坐标的集合 yIn:输入采样数据纵坐标的集合 cnt:输入采样数据的对数,即xIn或yIn数组内数据个数,函数假设xIn、yIn数组内数据个数一样多 sztCiShu:sztCiShu代表最高次为sztCiShu-1,即待求未知系数个数为sztCiShu个,sztCiShu须不大于cnt strOut:保存未知系数的拟合结果 len:strOut缓冲区的长度 返回值:0表示不能拟合,非零表示能拟合,当: strOut==NULL或len==0时,strOut不写入内容,返回所需缓冲区长度(包括'\0'结尾符,其实内部已计算过一遍); 否则直接返回len(若len不够长,拟合结果
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值