資源簡(jiǎn)介
C語(yǔ)言編寫LM迭代算法+文檔說明,是非線性優(yōu)化處理很好的方法

代碼片段和文件信息
#include?“growmat.h“
grow_mat::grow_mat()
{
clear_all();
}
//
grow_mat::grow_mat(int?r?int?c?int?type?void*?data?int?step)
{
clear_all();
if?(data)
{
CvMat?temp_mat;
cvInitMatHeader(&temp_mat?r?c?type?data?step?);
_mat?=?cvCreateMat(r?c?type);
cvCopy(&temp_mat_mat);
cvGetSubRect(_mat?this?cvRect(00cr));
return;
}
init(rctype00);
}
grow_mat::~grow_mat()
{
if(_mat)?
cvReleaseMat(&_mat);
}
void?grow_mat::clear_all(void)
{
memset(this0sizeof(CvMat));
_mat?=?0;
_expand_factor?=?1.6;
_copy_flag?=?1;
_zero_flag?=?1;
}
int?grow_mat::init(int?r?int?c?int?type?int?maxrows?int?maxcols)
{
int?no_max?=?0;
if?(maxrows==0)?{maxrows=r*_expand_factor;no_max=1;}
if?(maxcols==0)?{maxcols=c*_expand_factor;no_max=1;}
if?(type==0)?type=CV_64FC1;
if?(r<=0?||?c<=0?||?maxrows<0?||?maxcols<0?||?r>maxrows?||?c>maxcols)
return?0;
//?為了和mini_solver的set_solver一致,允許再次初始化!
if?(_mat)
{
//?若矩陣_mat存在,且類型相同,表示客戶想改變大小。
int?mat_type?=?CV_MAT_TYPE(_mat->type);
if?(CV_MAT_TYPE(type)==mat_type)
{
return?resize(rc);
}
}
if(_mat)?cvReleaseMat(&_mat);
if?(no_max)
_mat?=?cvCreateMat(r?c?type);
else
_mat?=?cvCreateMat(maxrows?maxcols?type);
if?(_mat==0)?return?0;
if?(_zero_flag)?cvSetZero(_mat);
cvGetSubRect(_mat?this?cvRect(00cr));
return?1;
}
int?grow_mat::resize(int?r?int?c)
{
if?(_mat==0?||?r<0?||?c<0)
return?0;
if?(r?<=?_mat->rows?&&?c?<=?_mat->cols)?
{
cvGetSubRect(_mat?this?cvRect(00cr));
}
else?
{
//?新擴(kuò)展矩陣為原來(lái)需要的矩陣大小的_expand_factor倍
int?maxrows?=?(r?>?_mat->rows???r*_expand_factor?:?_mat->rows);
int?maxcols?=?(c?>?_mat->cols???c*_expand_factor?:?_mat->cols);
reserve(maxrowsmaxcols);
cvGetSubRect(_mat?this?cvRect(00cr));
}
return?1;
}
int?grow_mat::reserve(int?maxrows?int?maxcols)
{
if?(_mat==0?||?maxrows<0?||?maxcols<0)
return?0;
//?只要申請(qǐng)的矩陣的行或列大于當(dāng)前矩陣就分配內(nèi)存
if?(maxrows?>?_mat->rows?||?maxcols?>?_mat->cols)?
{
//?新矩陣
CvMat?*?nm?=?cvCreateMat(maxrows?maxcols?_mat->type);
if?(nm==0)
return?0;
if?(_zero_flag)?cvSetZero(nm);
if?(this->rows?&&?this->cols?&&?_copy_flag)
{
//?若當(dāng)前矩陣大小不為0,且需要復(fù)制數(shù)據(jù),則將當(dāng)前矩陣this的數(shù)據(jù)復(fù)制到nm
CvMat?sub;
cvGetSubRect(nm?&sub?cvRect(00this->cols?this->rows));
cvCopy(this?&sub);
}
cvReleaseMat(&_mat);
_mat?=?nm;
}
return?1;
}
void?grow_mat::free()
{
if(_mat)?
cvReleaseMat(&_mat);
_mat=0;
memset(this0sizeof(CvMat));
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????194048??2010-05-04?21:47??lm\08Levenberg.doc
?????文件??????11953??2010-05-04?21:42??lm\lm\Debug\growmat.obj
?????文件??????????0??2010-05-04?21:42??lm\lm\Debug\growmat.sbr
?????文件?????705536??2010-05-04?21:42??lm\lm\Debug\lm.bsc
?????文件?????594008??2010-05-04?21:42??lm\lm\Debug\lm.exe
?????文件?????839716??2010-05-04?21:42??lm\lm\Debug\lm.ilk
?????文件?????807924??2010-05-04?21:42??lm\lm\Debug\lm.pch
?????文件????1377280??2010-05-04?21:42??lm\lm\Debug\lm.pdb
?????文件?????160182??2010-05-04?21:35??lm\lm\Debug\LM_DEMO.obj
?????文件??????????0??2010-05-04?21:35??lm\lm\Debug\LM_DEMO.sbr
?????文件??????37654??2010-05-04?21:35??lm\lm\Debug\ls_minimizer.obj
?????文件??????????0??2010-05-04?21:35??lm\lm\Debug\ls_minimizer.sbr
?????文件??????48433??2010-05-04?21:35??lm\lm\Debug\ls_observation.obj
?????文件??????????0??2010-05-04?21:35??lm\lm\Debug\ls_observation.sbr
?????文件?????123904??2010-05-04?21:42??lm\lm\Debug\vc60.idb
?????文件?????167936??2010-05-04?21:42??lm\lm\Debug\vc60.pdb
?????文件???????2660??2010-05-04?21:42??lm\lm\growmat.cpp
?????文件????????997??2008-08-30?11:27??lm\lm\growmat.h
?????文件?????????78??2010-05-04?21:30??lm\lm\lm.dep
?????文件???????4686??2010-05-04?23:01??lm\lm\lm.dsp
?????文件????????529??2010-05-04?21:30??lm\lm\lm.dsw
?????文件???????5889??2010-05-04?23:01??lm\lm\lm.mak
?????文件??????50176??2010-05-04?23:01??lm\lm\lm.ncb
?????文件??????49664??2010-05-04?23:01??lm\lm\lm.opt
?????文件???????1178??2010-05-04?21:42??lm\lm\lm.plg
?????文件???????1399??2009-09-23?10:53??lm\lm\LM_DEMO.cpp
?????文件???????7756??2009-09-23?11:06??lm\lm\ls_minimizer.cpp
?????文件???????3033??2010-05-04?21:32??lm\lm\ls_minimizer.h
?????文件???????7885??2009-09-23?10:28??lm\lm\ls_observation.cpp
?????文件???????5244??2009-06-28?18:31??lm\lm\ls_observation.h
............此處省略8個(gè)文件信息
評(píng)論
共有 條評(píng)論