示例#1
0
//----------------------------------------------------------------------
void svec(GeneralMatrix& M, double s, GeneralVector& dres)
{
  Clear(dres.dvec);
  Clear(dres.svec);
  
  int size = 0;
  int NonZeroCount = 0;
  for (int j=0; j<M.nBlock; j++) 
  {
    int bs = abs(M.blockStruct[j]);
    size += (bs*(bs+1))/2;
    if (M.isSparse) NonZeroCount += (bs+M.smat[j].colStarts[ColDimension(M.smat[j])])/2;
  }
  dres.n = size;
  if (M.isSparse)
  {
    dres.isSparse = true;
    Resize(dres.svec, size, 1, NonZeroCount);
    int blockShift = 0;
    for (int k=0; k<M.nBlock; k++)
    {
      int bs = abs(M.blockStruct[k]);
      int vectorBlockSize = (bs*(bs+1))/2;
      int vecPosition;
      int rowNumber;
      for (int j=0; j<bs; j++)
        for (int i=M.smat[k].colStarts[j]; i<M.smat[k].colStarts[j+1]; i++)
        {
	  rowNumber = M.smat[k].rowIndices[i];
	  if (rowNumber>=j)
	  {
	    vecPosition = blockShift+(bs+1)*j-(j*(j+3))/2+M.smat[k].rowIndices[i];
	    if (rowNumber==j) SetElement(dres.svec, vecPosition+1, 1, M.smat[k](rowNumber+1, j+1));
	      else SetElement(dres.svec, vecPosition+1, 1, M.smat[k](rowNumber+1, j+1)*s);
	  }
	}
      blockShift += vectorBlockSize;
    } 
  }
  else
  {
    dres.isSparse = false;
    Resize(dres.dvec, size);
    int pos = 1;
    for (int k=0; k<M.nBlock; k++)
    {
      int bs = abs(M.blockStruct[k]);
      for (int j=1; j<=bs; j++)
        for (int i=j; i<=bs; i++)
        {
          INTERVAL buf;
          if (i==j) buf = M.mat[k](i,j);
            else buf = s*M.mat[k](i,j);
          dres.dvec(pos) = buf;
	  pos++;
        }
    }
  }
  return;
}
void
CLDisplayClassTable::SetAlphabeticDisplay(
	Boolean		inAlphaSort)
{
	
	// Validate pointers.
	
	ValidateThis_();
	
	// Make sure we aren't changing the display.
	
	if (inAlphaSort == mAlphabeticSort)
		return;
	
	// Okay. Tear down the current display.
	
	DMElement* element = mElement;
	SetElement(nil);
	
	mAlphabeticSort = inAlphaSort;
	
	if (inAlphaSort)
		mFirstLevelIndent = 12;
	else
		mFirstLevelIndent = 24;
	
	SetElement(element);
	
}
示例#3
0
CComplexArray::CComplexArray (CDatum dSrc)

//	ComplexArray constructor

	{
	int i;

	if (dSrc.GetBasicType() == CDatum::typeStruct)
		{
		InsertEmpty(1);
		SetElement(0, dSrc);
		}
	else
		{
		int iCount = dSrc.GetCount();

		//	Clone from another complex array

		if (iCount > 0)
			{
			InsertEmpty(iCount);

			for (i = 0; i < iCount; i++)
				SetElement(i, dSrc.GetElement(i));
			}
		}
	}
示例#4
0
void mitk::pa::Vector::Rotate(double thetaChange, double phiChange)
{
  MITK_DEBUG << "Vector before rotation: (" << GetElement(0) << "|" << GetElement(1) << "|" << GetElement(2) << ")";
  if (thetaChange == 0 && phiChange == 0)
    return;

  double x = GetElement(0);
  double y = GetElement(1);
  double z = GetElement(2);

  double r = sqrt(x*x + y*y + z*z);
  if (r == 0)
    return;

  double theta = acos(z / r);
  double phi = atan2(y, x);

  theta += thetaChange;
  phi += phiChange;

  SetElement(0, r * sin(theta) * cos(phi));
  SetElement(1, r * sin(theta) * sin(phi));
  SetElement(2, r * cos(theta));

  MITK_DEBUG << "Vector after rotation: (" << GetElement(0) << "|" << GetElement(1) << "|" << GetElement(2) << ")";
}
示例#5
0
	//--------------------------------------------------------------------------------
	bool Serializer::NextNode()
	{
		//if(!CurrentNode) return false;

		//std::cout<<CurrentElement->Name()<<" "<<"from next node"<<std::endl;
		//if(CurrentElement == CurrentNode->Parent()->LastChildElement())
		//	CurrentNode = CurrentNode->Parent();

		//CurrentNode = CurrentNode->NextSibling();
		//if(!CurrentNode) return false;
		//SetElement();

		//return true;
		tinyxml2::XMLNode * NextNode = CurrentNode->NextSibling();
		if(!NextNode)
		{
			CurrentNode = CurrentNode->Parent();
			SetElement();
			return false;
		}

		CurrentNode = NextNode;
		SetElement();
		return true;
	}
示例#6
0
void
PIInspectorTable::SetElementFromSelection()
{

	// Validate pointers.

	ValidateThis_();

	// See if selection is empty.
	
	Boolean emptySelection = false;
	if (mFollowSelection == nil) {
	
		// No selection object... it must be empty. :-)
	
		SetElement(nil);
		return;
		
	}
	else {

		// We have a selection, check its item count.

		ValidateObject_(mFollowSelection.GetObject());
		if (mFollowSelection->GetSelectedElements().GetCount() < 1)
			emptySelection = true;

	}
	
 	// If selection is empty, just leave the previous element's data in the table.
	  
	if (emptySelection)
		return;
	
	// Okay, we have a selection, open PI for first selected item ONLY.

	DMElement* element = nil;
	mFollowSelection->GetSelectedElements().FetchItemAt(1, &element);
	ValidateObject_(element);
	
	DMObject* object = (dynamic_cast<DMObject*>(element));
	if (object != nil)
		ValidateObject_(object);

	SetElement(object);
	
	// Look for hidden preference resource.
	
	StApplicationContext appContext;
	Handle piPref = ::Get1Resource('INSP', 21000);
	if (piPref != nil) {
		ValidateHandle_(piPref);
		if (::GetHandleSize(piPref) >= 1) {
			Boolean detach = ** ((Boolean**) piPref);
			if (detach)
				DetachFromSelection();
		}
	}
}
示例#7
0
mitk::pa::Vector::Pointer mitk::pa::Vector::Clone()
{
  auto returnVector = Vector::New();
  returnVector->SetElement(0, this->GetElement(0));
  returnVector->SetElement(1, this->GetElement(1));
  returnVector->SetElement(2, this->GetElement(2));
  return returnVector;
}
示例#8
0
Matrix::Matrix() {
	//Initialize the data pointer using the rank
	data = new double[16];

	//Set all the diagonal elements to 1
	for (int i = 1; i <= 4; i++)
		for (int j = 1; j <= 4; j++)
			(i == j) ? SetElement(i, j, (double) 1.0) : SetElement(i, j,
					(double) 0.0);
}
示例#9
0
void ChSparseMatrix::DiagPivotSymmetric(int rowA, int rowB)
{
	int elcol, elrow;
	double temp;
	for (elrow=0; elrow<rowA; elrow++)
	{
		temp = GetElement(elrow, rowA);
		SetElement(elrow,rowA, GetElement(elrow, rowB));
		SetElement(elrow,rowB, temp);
	}
	for (elcol=rowB+1; elcol<columns; elcol++)
	{
		temp = GetElement(rowA, elcol);
		SetElement(rowA, elcol, GetElement(rowB, elcol));
		SetElement(rowB, elcol, temp);
	}
	for (elcol=rowA+1; elcol<rowB; elcol++)
	{
		temp = GetElement(rowA, elcol);
		SetElement(rowA, elcol, GetElement(elcol,rowB));
		SetElement(elcol, rowB, temp);
	}
	temp = GetElement(rowA, rowA);
	SetElement (rowA,rowA, GetElement(rowB,rowB));
	SetElement (rowB,rowB, temp);
}
示例#10
0
void ChSparseMatrix::SwapColumns (int a, int b)
{
	ChMelement* guessA;
	ChMelement* guessB;
	double valA, valB;

	for (int i=0; i<rows; i++)
	{
		guessA =GetElement (i, a, &valA, *(elarray+i));
		guessB =GetElement (i, b, &valB, *(elarray+i));

		SetElement (i,a, valB, guessA);
		SetElement (i,b, valA, guessB);
	}
}
示例#11
0
void ChSparseMatrix::PasteSumClippedMatrix (ChMatrix<>* matra, int cliprow, int clipcol, int nrows, int ncolumns, int insrow, int inscol)
{
	int i, j;
	int maxrows = matra->GetRows();
	int maxcol = matra->GetColumns();
	ChMelement* eguess;
	ChMelement* eguessread;
	double val, aval, sum;

	for (i=0;i < nrows;i++)
	{
		eguess = *(elarray+i+insrow);
		eguessread= eguess;

		for (j=0;j < ncolumns;j++)
		{
			val = (matra->GetElement (i+cliprow,j+clipcol));
			if (val)
			{
				eguessread= GetElement (i+insrow, j+inscol, &aval, eguessread);
				sum = val+aval;
				eguess = SetElement (i+insrow,
						j+inscol,
						sum,
						eguess);
			}
		}
	}
}
示例#12
0
const T * CHashTable<T>::SetElement(const CString& Key, const T& Value, bool * pAdded) {
  
    if (m_pKeys && m_pElements) {
        
        if (pAdded)
            * pAdded = false;
        
        if (!Key.GetLength())
            return NULL;
        
        int Counter = 0;
        while(Counter < (int) m_pKeys->GetSize()) {
            int HashValue = Hash(Key, Counter);    
            if (!((* m_pKeys)[HashValue].GetLength())) {      
                (* m_pKeys)[HashValue] = Key;
                (* m_pElements)[HashValue] = Value;
                m_Size++;
                if (* pAdded)
                    * pAdded = true;
                return & (* m_pElements)[HashValue];
            } else if ((* m_pKeys)[HashValue] == Key) {
                (* m_pElements)[HashValue] = Value;            
                return & (* m_pElements)[HashValue];
            }
            Counter++;
        }
    }

    Grow();
    return SetElement(Key, Value, pAdded);  
}
/*
Move using raw data
*/
void CalibrationWindow::On_Timer_Raw()
{
	NEW2DARR(double, matrix);

	if (ui->ATC_Radio->isChecked())
	{
		m_ATC->GetTransform(0, matrix);
	}
	else
	{
		m_Polaris->GetTransform(0,matrix);
	}
	
	// Capture and convert to vtkMatrix4X4
	auto matrixx = vtkSmartPointer<vtkMatrix4x4>::New();
	for (size_t i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4;j++)
			matrixx->SetElement(i,j,matrix[i][j]);
	}

	m_Actor->SetUserMatrix(matrixx);
	//m_Actor->SetUserMatrix(m_Tracking3D->GetRegisteredTransformMatrix());
	
	m_View->Render();

	DEL2DARR(double,matrix);
}
示例#14
0
DCM_ATTRIBUTE_CLASS::DCM_ATTRIBUTE_CLASS(UINT16 group, UINT16 element, ATTR_VR_ENUM vr)

//  DESCRIPTION     : Constructor.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// constructor activities
	SetGroup(group);	
	SetElement(element);
	SetType(ATTR_TYPE_3);
	SetVR(vr);
	mappedGroupM = group; 	
	mappedElementM = element;
	receivedLengthM = 0;
	transferVrM = TRANSFER_ATTR_VR_IMPLICIT;
	nestingDepthM = 0;
	definedLengthM = false;
	unVrDefinitionLookUpM = true;
	ensureEvenAttributeValueLengthM = true;
	loggerM_ptr = NULL;
	parentM_ptr = NULL;
	pahM_ptr = NULL;
}
示例#15
0
DCM_ATTRIBUTE_CLASS::DCM_ATTRIBUTE_CLASS()

//  DESCRIPTION     : Constructor.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// constructor activities
	SetGroup(TAG_UNDEFINED_GROUP);
	SetElement(TAG_UNDEFINED_ELEMENT);
	SetType(ATTR_TYPE_3);
	SetVR(ATTR_VR_UN);
	mappedGroupM = TAG_UNDEFINED_GROUP; 	
	mappedElementM = TAG_UNDEFINED_ELEMENT;
	receivedLengthM = 0;
	transferVrM = TRANSFER_ATTR_VR_IMPLICIT;
	nestingDepthM = 0;
	definedLengthM = false;
	unVrDefinitionLookUpM = true;
	ensureEvenAttributeValueLengthM = true;
	loggerM_ptr = NULL;
	parentM_ptr = NULL;
	pahM_ptr = NULL;
}
示例#16
0
void ChSparseMatrix::PasteSumTranspMatrix (ChMatrix<>* matra, int insrow, int inscol)
{
	int i, j;
	int maxrows = matra->GetRows();
	int maxcol = matra->GetColumns();
	ChMelement* eguess;
	ChMelement* eguessread;
	double val, aval, sum;

	for (j=0;j < maxcol; j++)
	{
		eguess= *(elarray+j+insrow);
		eguessread = eguess;

		for (i=0;i < maxrows; i++)
		{
			val = (matra->GetElement (i,j));
			if (val)
			{
				eguessread= GetElement (j+insrow, i+inscol, &aval, eguessread);
				sum = val + aval;
				eguess= SetElement (j+insrow,
						i+inscol,
						sum,
						eguess);
			}
		}
	}
}
void
JDiagBandMatrix::AddRowToRow
	(
	const JIndex	sourceIndex,
	const JFloat	scaleFactor,
	const JIndex	destIndex
	)
{
	JIndex minSrcCol = 1;
	if (sourceIndex > itsLowerBandCount)
		{
		minSrcCol = sourceIndex - itsLowerBandCount;
		}

	const JIndex maxSrcCol = JMin(sourceIndex + itsUpperBandCount, itsSize);

	JIndex minDestCol = 1;
	if (destIndex > itsLowerBandCount)
		{
		minDestCol = destIndex - itsLowerBandCount;
		}

	const JIndex maxDestCol = JMin(destIndex + itsUpperBandCount, itsSize);

	const JIndex minCol = JMax(minSrcCol, minDestCol);
	const JIndex maxCol = JMin(maxSrcCol, maxDestCol);

	for (JIndex i=minCol; i<=maxCol; i++)
		{
		SetElement(destIndex,i, GetElement(destIndex,i) +
				   scaleFactor * GetElement(sourceIndex,i));
		}
}
示例#18
0
	//--------------------------------------------------------------------------------
	void Serializer::LoadFirstItem()
	{
		//the name of the object/level/whatever
		GetFirstChild();
		SetElement();

		PutFirstChildOnElement();
	}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAString & aActorURI)
{
  nsresult rc = SetElement(nsnull);
  if (NS_FAILED(rc))
    return rc;
  mActorURI.Assign(aActorURI);
  return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetMustUnderstand(PRBool aMustUnderstand)
{
  nsresult rc = SetElement(nsnull);
  if (NS_FAILED(rc))
    return rc;
  mMustUnderstand = aMustUnderstand;
  return NS_OK;
}
示例#21
0
void
JStringManager::MergeFile
	(
	istream&		input,
	const JBoolean	debug
	)
{
	JUInt format;
	input >> format;
	if (format != kASCIIFormat)
		{
		return;
		}

	JString id;
	while (1)
		{
		input >> ws;
		while (!input.eof() && input.peek() == '#')		// peek() at eof sets fail()
			{
			JIgnoreLine(input);
			input >> ws;
			}
		if (input.eof() || input.fail())
			{
			break;
			}

		id = JReadUntilws(input);
		if (debug)
			{
			cout << id << endl;
			}
		if (input.eof() || input.fail())
			{
			break;
			}

		JString* s = new JString;
		assert( s != NULL );

		input >> *s;
		if (input.eof() || input.fail())
			{
			delete s;
			break;
			}

		if (CanOverride(id))
			{
			SetElement(id, s, JPtrArrayT::kDelete);
			}
		else if (!SetNewElement(id, s))
			{
			delete s;
			}
		}
}
示例#22
0
//----------------------------------------------------------------------
int GeneralMatrix::matrixCopy(SPARSE_INTERVAL_MATRIX& dest, rSparseMatrix& source, bool inverse)
{
  switch(source.Sp_De_Di)
  {
  case rSparseMatrix::SPARSE:
    Resize(dest, source.nRow, source.nCol, source.NonZeroCount);
    for (int k=0; k<source.NonZeroCount; k++) 
    {
      if (inverse) 
      {
        SetElement(dest, source.row_index[k]+1, source.column_index[k]+1, -Hull(source.sp_ele[k]));
	SetElement(dest, source.column_index[k]+1, source.row_index[k]+1, -Hull(source.sp_ele[k]));
      }
      else 
      {
        SetElement(dest, source.row_index[k]+1, source.column_index[k]+1, Hull(source.sp_ele[k]));
	SetElement(dest, source.column_index[k]+1, source.row_index[k]+1, Hull(source.sp_ele[k]));
      }
    }
    break;
  case rSparseMatrix::DENSE:
    Resize(dest, source.nRow, source.nCol, source.nRow*source.nCol);
    for (int i=0; i<source.nRow; i++)
      for (int j=0; j<source.nCol; j++)
        if (inverse) 
	{
	  SetElement(dest, i+1, j+1, -Hull(source.de_ele[j+source.nCol*i]));
	  SetElement(dest, j+1, i+1, -Hull(source.de_ele[j+source.nCol*i]));
	}
        else 
	{
	  SetElement(dest, i+1, j+1, Hull(source.de_ele[j+source.nCol*i]));
	  SetElement(dest, j+1, i+1, Hull(source.de_ele[j+source.nCol*i]));
	}
    break;
  case rSparseMatrix::DIAGONAL:
    Resize(dest, source.nRow, source.nCol, source.nCol);
    for (int k=0; k<source.nCol; k++)
      if (inverse) SetElement(dest, k+1, k+1, -Hull(source.di_ele[k]));
        else SetElement(dest, k+1, k+1, Hull(source.di_ele[k]));
    break;
  }
  return 0;
}
示例#23
0
bool IComplexDatum::DeserializeAEONScript (CDatum::ESerializationFormats iFormat, const CString &sTypename, CCharStream *pStream)

//	DeserializeAEONScript
//
//	Deserialize AEONScript

	{
	int i;
	DWORD dwFlags = OnGetSerializeFlags();

	//	If we have an open brace then we've stored everything as a structure.

	if (pStream->GetChar() == '{')
		{
		//	Object must support this

		if (!(dwFlags & FLAG_SERIALIZE_AS_STRUCT))
			return false;

		//	Parse the structure

		CAEONScriptParser Parser(pStream);
		CDatum dData;
		CAEONScriptParser::ETokens iToken = Parser.ParseToken(&dData);
		if (iToken != CAEONScriptParser::tkDatum)
			return false;

		//	Take all the fields in the structure and apply them to our object
		//	(our descendants will do the right thing).

		for (i = 0; i < dData.GetCount(); i++)
			SetElement(dData.GetKey(i), dData.GetElement(i));
		}

	//	Otherwise we expect base64 encoded data

	else
		{
		//	Backup one character because we want the OnDeserialize call to read it.

		pStream->UnreadChar();

		//	Deserialize

		CBase64Decoder Decoder(pStream->GetByteStream());
		if (!OnDeserialize(iFormat, sTypename, Decoder))
			return false;

		//	Read the next character into the stream 

		pStream->RefreshStream();
		pStream->ReadChar();
		}

	return true;
	}
void COMPLEXSPAREMATRIXSOLVER::ReSetMatrixElement()
{
	int i;
	for (i = 0; i < pMatrix->ElementTotal; i++)
	{
		SetElement(i,
			pMatrix->VB[i], -pMatrix->VG[i],
			-pMatrix->VG[i], -pMatrix->VB[i]);
	}
}
示例#25
0
CText::CText( CGUI *Gui, int X, int Y, int Width, int Height, const uichar * String, const uichar * String2, tAction Callback )
{
	SetElement( Gui, X, Y, Width, Height, String, String2, Callback );

	SetThemeElement( pGui->GetThemeElement( _UI("Text") ) );

	if( !GetThemeElement() )
		MessageBox( 0, _UI("Theme element invalid."), _UI("Text"), 0 );
	else
		SetElementState( _UI("Norm") );
}
示例#26
0
/**
 * @brief make primitive_content attribute string data
 * @param[in] payload : payload buffer
 * @param[in] attrs : oneM2M_Attribute list data pointer
 * @param[in] resourceType : oneM2M resource type value
 * @param[in] size : size of attrs list
 */
static void SetPCElement(char* payload, oneM2M_Attribute* attrs, int resourceType, int size) {
    char attr[512];
    char pc[1024];
    memset(attr, 0, sizeof(attr));
    memset(pc, 0, sizeof(pc));
    SetElement(attr, attrs, size);
    char* resource = RESOURCE_STR(resourceType);
    snprintf(pc, sizeof(pc), "<%s><%s>%s</%s></%s>", 
                ATTR_PC, resource, attr, resource, ATTR_PC);
    strncat(payload, pc, strlen(pc));
}
示例#27
0
/**
 * @brief make xml header with ty, op, ri, to
 * @param[in] payload : payload buffer
 * @param[in] resourceType : oneM2M resource type value
 * @param[in] operation : operation
 * @param[in] to : target
 * @param[in] ri : request id
 */
static void SetHeader(char* payload, int resourceType, int operation, char* to, char* ri) {
    strncat(payload, XML_HEADER_V1, strlen(XML_HEADER_V1));

    // operation
    char op[2];
    memset(op, 0, sizeof(op));
    snprintf(op, sizeof(op), "%d", operation);

    // op & to & ri
    if(operation == CREATE) {        
        // ty
        char ty[6];
        memset(ty, 0, sizeof(ty));
        snprintf(ty, sizeof(ty), "%d", resourceType);
        oneM2M_Attribute attr[] = {{ATTR_OP, op}, {ATTR_TO, to}, {ATTR_TY, ty}, {ATTR_RI, ri}};
        SetElement(payload, attr, 4);
    } else {
        oneM2M_Attribute attr[] = {{ATTR_OP, op}, {ATTR_TO, to}, {ATTR_RI, ri}};
        SetElement(payload, attr, 3);
    }
}
示例#28
0
const bool Test_Matrix_SetElement()
{
	bool bPass4d = true;
	bool bPass4f = true;
	for(size_t i = 0; i < 16; ++i)
	{
		size_t x = (i % 4) + 1;
		size_t y = (i / 4) + 1;

		if(!Equal(GetElement(SetElement(TMatrix4d(), (double)i, y, x), y, x), (double)i, s_kdEpsilon))
		{
			bPass4d = false;
		}
		if(!Equal(GetElement(SetElement(TMatrix4f(), (float)i, y, x), y, x), (float)i, s_kfEpsilon))
		{
			bPass4f = false;
		}
	}

	bool bPass3d = true;
	bool bPass3f = true;
	for(size_t i = 0; i < 9; ++i)
	{
		size_t x = (i % 3) + 1;
		size_t y = (i / 3) + 1;

		if(!Equal(GetElement(SetElement(TMatrix3d(), (double)i, y, x), y, x), (double)i, s_kdEpsilon))
		{
			bPass3d = false;
		}
		if(!Equal(GetElement(SetElement(TMatrix3f(), (float)i, y, x), y, x), (float)i, s_kfEpsilon))
		{
			bPass3f = false;
		}
	}

	bool bPass2d = true;
	bool bPass2f = true;
	for(size_t i = 0; i < 4; ++i)
	{
		size_t x = (i % 2) + 1;
		size_t y = (i / 2) + 1;

		if(!Equal(GetElement(SetElement(TMatrix2d(), (double)i, y, x), y, x), (double)i, s_kdEpsilon))
		{
			bPass2d = false;
		}
		if(!Equal(GetElement(SetElement(TMatrix2f(), (float)i, y, x), y, x), (float)i, s_kfEpsilon))
		{
			bPass2f = false;
		}
	}

	return(		bPass4d
			&&	bPass4f
			&&	bPass3d
			&&	bPass3f
			&&	bPass2d
			&&	bPass2f);
}
示例#29
0
/////////////////////////////////////////////////////////////////////////////
// Set to mA multiplied by the transpose of mB
/////////////////////////////////////////////////////////////////////////////
void CMatrix::SetProductByTranspose(const CMatrix &mA, const CMatrix &mB)
{
    FATAL(mA.GetColumns() != mB.GetColumns());
    SetSize(mA.GetRows(), mB.GetRows());
    for (int i = mA.GetRows(); --i >= 0;)
        for (int j = mB.GetRows(); --j >= 0;)
        {
            double x = 0.0;
            for (int k = mA.GetColumns(); --k >= 0;)
                x += mA.GetElement(i, k) * mB.GetElement(j, k);
            SetElement(i, j, x);
        }
}
示例#30
0
Matrix& Matrix::operator-=(const pMatrix other)
{
   assert(IsSameSizeWith(other));

   for(size_t row = 0; row < GetHeight(); row++)
   {
      for(size_t col = 0; col < GetWidth(); col++)
      {
	 SetElement(row, col, GetElement(row, col) - other->GetElement(row, col));
      }
   }
   return *this;
}