91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 11KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-05
  • 語言: C/C++
  • 標(biāo)簽: C++??矩陣類??

資源簡介

這個(gè)一個(gè)老外寫的矩陣類,用C++實(shí)現(xiàn),注釋詳細(xì),把線性代數(shù)里用到的加減乘除和轉(zhuǎn)置、求逆等矩陣運(yùn)算都實(shí)現(xiàn)了,小可查到并修改了幾個(gè)小錯(cuò)誤,幾近完美了。

資源截圖

代碼片段和文件信息

//?Matrix.cpp:?implementation?of?the?CMatrix?class.
//
//////////////////////////////////////////////////////////////////////

#include?“stdafx.h“
#include?“Matrix.h“

#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
//?Construction/Destruction?CMatrix
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CMatrix?Cobject?1)?;

#ifdef?_DEBUG
int?CMatrix::m_NextobjectNumber?=?1?;
#endif

CMatrix::CMatrix()
{
#ifdef?_DEBUG
//?so?we?can?regonise?each?individual?object
m_objectNumber?=?m_NextobjectNumber++?;
TRACE(“Creating?CMatrix?object?%1d?-?default?constructor\n“?m_objectNumber)?;
#endif
//?default?constructor?create?a?1?*?1?array
m_NumColumns?=?1?;
m_NumRows?=?1?;
m_pData?=?NULL?;
m_pData?=?AllocateMemory(m_NumColumns?m_NumRows)?;
IncrementReferenceCount()?; //?count?the?reference?to?this?memory
}

CMatrix::CMatrix(const?CMatrix?&other)
{
#ifdef?_DEBUG
//?so?we?can?regonise?each?individual?object
m_objectNumber?=?m_NextobjectNumber++?;
TRACE(“Creating?CMatrix?object?%1d?-?copy?constructor?other?=?%1d\n“?m_objectNumber?other.m_objectNumber)?;
#endif
//?copy?constructor
m_pData?=?NULL?;
//?use?the?other?objects?data?pointer
m_NumColumns?=?other.m_NumColumns?;
m_NumRows?=?other.m_NumRows?;
m_pData?=?other.m_pData?; //?copy?the?pointer
IncrementReferenceCount()?; //?this?thread?can?get?the?mutex?multiple?times?without?blocking
}

CMatrix::CMatrix(int?nCols?int?nRows)
{
#ifdef?_DEBUG
//?so?we?can?regonise?each?individual?object
m_objectNumber?=?m_NextobjectNumber++?;
TRACE(“Creating?CMatrix?object?%1d?-?size?constructor\n“?m_objectNumber)?;
#endif
//?size?constructor
ASSERT(nCols?>?0)?; //?matrix?size?error
ASSERT(nRows?>?0)?; //?matrix?size?error
m_pData?=?NULL?;
m_NumColumns?=?nCols?;
m_NumRows?=?nRows?;
m_pData?=?AllocateMemory(m_NumColumns?m_NumRows)?;
IncrementReferenceCount()?; //?count?the?reference?to?this?memory
}

CMatrix::CMatrix(int?size?bool?set_diagonal)
{
//?construct?a?square?matrix?with?1.0‘s?on?the?diagonal?if?required
#ifdef?_DEBUG
//?so?we?can?regonise?each?individual?object
m_objectNumber?=?m_NextobjectNumber++?;
TRACE(“Creating?CMatrix?object?%1d?-?square?size?constructor\n“?m_objectNumber)?;
#endif
//?size?constructor
ASSERT(size?>?0)?; //?matrix?size?error
m_pData?=?NULL?;
m_NumColumns?=?size?;
m_NumRows?=?size?;
m_pData?=?AllocateMemory(m_NumColumns?m_NumRows)?;
IncrementReferenceCount()?; //?count?the?reference?to?this?memory
//?set?the?dialognal?if?required
if?(set_diagonal)
{
for?(int?i?=?0?;?i? SetElement(i?i?1.0)?;
}
}

//?creates?a?CMatrix?object?from?a?SafeArray?that?contains?a?2D?matrix
//?Note?that?you?will?probably?have?to?call?“VariantClear“?to?correctly?de-allocate
//?

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????35902??2011-10-21?11:45??Matrix.cpp
?????文件????????8674??2011-10-19?14:20??Matrix.h

評論

共有 條評論