IPCC  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CMatrixOperation::CVector Class Reference

This class for describing vector for Lanczos method. More...

#include "MatrixOperation.h"

Collaboration diagram for CMatrixOperation::CVector:
Collaboration graph

Classes

struct  VECTOR_ELEMENT
 Vector Element data. More...
 

Public Types

typedef struct
CMatrixOperation::CVector::VECTOR_ELEMENT
LPVECTOR_ELEMENT
 

Public Member Functions

 CVector ()
 Constructor. More...
 
 ~CVector ()
 Destructor. More...
 
void SetSize (unsigned int nSize)
 Set Vector elements size. More...
 
unsigned int GetSize ()
 Return Vector elements size. More...
 
void SetAt (unsigned int nIndex, CComplex value)
 Set element value in specific index, Call by value. More...
 
void SetAtEx (unsigned int nIndex, CComplex *pValue)
 Set element value in specific index, Call by reference. More...
 
void SetAt (unsigned int nIndex, double fReal, double fImaginary)
 Set element value in specific index. More...
 
CComplex GetAt (unsigned int nIndex)
 Get element value from specific index. More...
 
CComplexGetAtPt (unsigned int nIndex)
 Get element value from specific index. More...
 
void ResetValue ()
 Reset every element to zero. More...
 
void ScalarMultiple (CComplex Scalar)
 Scalar multiple operation. More...
 
void ScalarMultiple (double fScalar)
 Scalar multiple operation. More...
 
void ScalarDivision (CComplex Scalar)
 Scalar division operation. More...
 
void ScalarDivision (double fScalar)
 Scalar division operation. More...
 
void BuildRandomVector ()
 Building vector that has random value elements. More...
 
void Normalize (bool bMPI=false)
 Normalize vector with norm. More...
 
double GetNorm (bool bMPI=false)
 Getting norm of vector. More...
 
void MinusVector (CVector *vector)
 Do minus operation between vectors. More...
 
void PlusVector (CVector *vector)
 Do plus operation between vectors. More...
 
void ScalarMultiThanMinusVector (double fScalar, CVector *vector)
 Do minus operation after scalar multiple to operand between vectors. More...
 
void ReorthogonalizationVector (CVector *pVector, CComplex complex)
 Do reorthogonalization. More...
 
void Finalize ()
 Free allocated memory for vector elements. More...
 
bool InsertVector (unsigned int nStartIndex, CMatrixOperation::CVector *pVector)
 
bool Serialize (double *pBuffer, bool bStore)
 Serialize vector. More...
 
CComplex operator* (CVector &vector)
 operation overload for dot product with reference parameter More...
 
CComplex operator* (CVector *vector)
 operation overload for dot product with pointer parameter More...
 
CVector operator- (CVector &vector)
 operation overload for vector minus operation with reference parameter More...
 
CVector operator- (CVector *vector)
 operation overload for vector minus operation with pointer parameter More...
 
CVector operator+ (CVector &vector)
 operation overload for vector plus operation with reference parameter More...
 
CVector operator+ (CVector *vector)
 operation overload for vector plus operation with pointer parameter More...
 
void operator= (CVector &vector)
 operation overload for subsitution with reference parameter More...
 
void operator= (CVector *vector)
 operation overload for subsitution with pointer parameter More...
 

Private Attributes

double_vector_t m_vectValueRealBuffer
 A member variable for saving none zero elements. More...
 
double_vector_t m_vectValueImaginaryBuffer
 A member variable for saving none zero elements. More...
 
unsigned int m_nValueCount
 A numbers of elements. More...
 
CComplex m_rtnTemp
 Temporary variable for return value. More...
 

Friends

class CLanczosMethod
 
class CMatrixOperation
 
class CMPIManager
 
class CSPLoop
 

Detailed Description

This class for describing vector for Lanczos method.

Date
27/May/2014

Definition at line 56 of file MatrixOperation.h.

Member Typedef Documentation

Constructor & Destructor Documentation

CMatrixOperation::CVector::CVector ( )

Constructor.


        CVector Class member function - Start

Definition at line 27 of file MatrixOperation.cpp.

References m_nValueCount.

28 {
29  m_nValueCount = 0;
30 }
unsigned int m_nValueCount
A numbers of elements.
CMatrixOperation::CVector::~CVector ( )

Destructor.

Definition at line 32 of file MatrixOperation.cpp.

33 {
34 }

Member Function Documentation

void CMatrixOperation::CVector::BuildRandomVector ( )

Building vector that has random value elements.

Definition at line 200 of file MatrixOperation.cpp.

201 {
202  unsigned int i;
203 
204  srand((unsigned int)time(NULL));
205  for (i = 0; i < m_nValueCount; i++)
206  {
207  m_vectValueRealBuffer[i] = rand();
208  m_vectValueImaginaryBuffer[i] = rand();
209  }
210 }
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
unsigned int m_nValueCount
A numbers of elements.
void CMatrixOperation::CVector::Finalize ( )
CComplex CMatrixOperation::CVector::GetAt ( unsigned int  nIndex)

Get element value from specific index.

Parameters
nIndexSpecific element index that want to get
Returns
element value

Definition at line 99 of file MatrixOperation.cpp.

References ERROR_OUT_OF_RANGE, and CComplex::SetComplexNumber().

Referenced by CMatrixOperation::AddVectors(), CLanczosResultAudit::AuditResult_WF(), CHamiltonianBuilder::BuildOffsiteMatrixFor10Band(), CGeometricShape::BuildPEBiasVector(), CGeometricShape::BuildPEWaveVector(), CLanczosMethod::BuildWaveFunction(), CLanczosMethod::CalculateEigenVector(), CMatrixOperation::CCSR::DiagonalOperation(), CSPLoop::executeSPLoop(), InsertVector(), CMatrixOperation::MVMul(), operator*(), CMatrixOperation::CCSR::operator*(), operator+(), operator-(), CLanczosMethod::RecalcuWaveFunction(), IGeometricUnitCellInfo::RotateAxis(), IGeometricUnitCellInfo::RotateNeighbor(), CHamiltonianBuilder::RotateTransMatrixFor10Band(), CLanczosMethod::SaveLanczosResult(), CMatrixOperation::ScalarMulVectors(), CMatrixOperation::CDMatrix::SetColumnElement(), CMatrixOperation::CDMatrix::SetDiagonal(), CMatrixOperation::CDMatrix::SetRowElement(), CUtility::ShowDoubleVector(), and CMatrixOperation::SubstractVectors().

100 {
101  CComplex rtnComplex;
102 
103  if (nIndex > GetSize())
104  {
105  throw ERROR_OUT_OF_RANGE;
106  return rtnComplex;
107  }
108 
110  return rtnComplex;
111 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
const unsigned long ERROR_OUT_OF_RANGE
Error code that means during access vector or matrix input index out of range.
Definition: Global.h:63
void SetComplexNumber(double fReal, double fImaginaray)
Set Complex number using real part and imaginary part.
Definition: Complex.cpp:58
This class for complex operation and saving value.
Definition: Complex.h:16

Here is the call graph for this function:

Here is the caller graph for this function:

CComplex * CMatrixOperation::CVector::GetAtPt ( unsigned int  nIndex)

Get element value from specific index.

Parameters
nIndexSpecific element index that want to get
Returns
Vector class pointer

Definition at line 83 of file MatrixOperation.cpp.

References ERROR_OUT_OF_RANGE.

Referenced by MinusVector(), and PlusVector().

84 {
85  if (nIndex > GetSize())
86  {
87  throw ERROR_OUT_OF_RANGE;
88  return NULL;
89  }
90 
92  return &m_rtnTemp;
93 }
unsigned int GetSize()
Return Vector elements size.
CComplex m_rtnTemp
Temporary variable for return value.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
const unsigned long ERROR_OUT_OF_RANGE
Error code that means during access vector or matrix input index out of range.
Definition: Global.h:63
void SetComplexNumber(double fReal, double fImaginaray)
Set Complex number using real part and imaginary part.
Definition: Complex.cpp:58

Here is the caller graph for this function:

double CMatrixOperation::CVector::GetNorm ( bool  bMPI = false)

Getting norm of vector.

Parameters
bMPICurrently running under MPI or not
Returns
Norm value

Definition at line 231 of file MatrixOperation.cpp.

References CMPIManager::AllReduceDouble(), and LOOP_OPTIMIZE_COUNT.

Referenced by CLanczosResultAudit::AuditResult_EV(), CHamiltonianBuilder::BuildOffsiteMatrixFor10Band(), CLanczosMethod::DoResidualCheck(), CMatrixOperation::IsSame(), CLanczosMethod::LanczosIterationLoop(), CLanczosMethod::MergeDegeneratedEigenvalues(), and CSPLoop::SolvePoisson().

232 {
233  unsigned int i;
234  CComplex PowerTotal;
235  double fTotal = 0.0;
236  unsigned int nLeft = m_nValueCount % LOOP_OPTIMIZE_COUNT;
237  double fNorm;
238  double *pReal = m_vectValueRealBuffer.data();
239  double *pImaginary = m_vectValueImaginaryBuffer.data();
240 
241 #pragma omp parallel for reduction(+:fTotal)
242  for (i = 0; i < m_nValueCount; i++)
243  {
244  const double fReal = pReal[i];
245  const double fImaginary = pImaginary[i];
246 
247  //fNorm = sqrt(m_vectValueRealBuffer[i] * m_vectValueRealBuffer[i] + m_vectValueImaginaryBuffer[i] * m_vectValueImaginaryBuffer[i]);
248  /*fNorm = sqrt(fReal * fReal + fImaginary * fImaginary);
249  fTotal += (fNorm * fNorm);*/
250  fNorm = fReal * fReal + fImaginary * fImaginary;
251  fTotal += fNorm;
252  }
253 
254  if (bMPI)
255  fTotal = CMPIManager::AllReduceDouble(fTotal);
256  return sqrt(fTotal);
257 }
static double AllReduceDouble(double fNumber)
Do all reduce function with CKNComplex.
Definition: MPIManager.cpp:593
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
#define LOOP_OPTIMIZE_COUNT
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
This class for complex operation and saving value.
Definition: Complex.h:16
unsigned int m_nValueCount
A numbers of elements.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMatrixOperation::CVector::InsertVector ( unsigned int  nStartIndex,
CMatrixOperation::CVector pVector 
)
Parameters
nStartIndexStart index that position of want to insert
pVectorSource vector
Returns
Success or fail

Definition at line 377 of file MatrixOperation.cpp.

References GetAt(), CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), and GetSize().

378 {
379  bool bRtn = false;
380  unsigned int i;
381 
382  if (nStartIndex > m_nValueCount || nStartIndex + pVector->GetSize() > m_nValueCount)
383  return bRtn;
384 
385  for (i = 0; i < pVector->GetSize(); i++)
386  {
387  m_vectValueRealBuffer[nStartIndex + i] = pVector->GetAt(i).GetRealNumber();;
388  m_vectValueImaginaryBuffer[nStartIndex + i] = pVector->GetAt(i).GetImaginaryNumber();
389  }
390 
391  bRtn = true;
392  return bRtn;
393 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
CComplex GetAt(unsigned int nIndex)
Get element value from specific index.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
unsigned int m_nValueCount
A numbers of elements.
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

void CMatrixOperation::CVector::MinusVector ( CVector vector)

Do minus operation between vectors.

Parameters
vectorvector that is used in minus operation

Definition at line 321 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, GetAtPt(), CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), and GetSize().

Referenced by CLanczosResultAudit::AuditResult_EV(), CLanczosMethod::DoResidualCheck(), CMatrixOperation::Gram_schmidt(), CMatrixOperation::IsSame(), and CLanczosMethod::MergeDegeneratedEigenvalues().

322 {
323  unsigned int i, nSize = GetSize();
324  CComplex *pOperand1, *pOperand2;
325 
326  if (nSize != vector->GetSize())
327  {
329  return;
330  }
331 
332  for (i = 0; i < nSize; i++)
333  {
334  pOperand1 = GetAtPt(i);
335  pOperand2 = vector->GetAtPt(i);
336 
337  SetAt(i, pOperand1->GetRealNumber() - pOperand2->GetRealNumber(), pOperand1->GetImaginaryNumber() - pOperand2->GetImaginaryNumber());
338  }
339 }
unsigned int GetSize()
Return Vector elements size.
CComplex * GetAtPt(unsigned int nIndex)
Get element value from specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

void CMatrixOperation::CVector::Normalize ( bool  bMPI = false)

Normalize vector with norm.

Parameters
bMPIOperation with MPI environment or not

Definition at line 215 of file MatrixOperation.cpp.

Referenced by CMatrixOperation::Gram_schmidt(), and CLanczosMethod::LanczosIteration().

216 {
217  double fVectorSize = GetNorm(bMPI);
218  unsigned int i;
219 
220  for (i = 0; i < m_nValueCount; i++)
221  {
222  m_vectValueRealBuffer[i] /= fVectorSize;
223  m_vectValueImaginaryBuffer[i] /= fVectorSize;
224  }
225 }
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double GetNorm(bool bMPI=false)
Getting norm of vector.
unsigned int m_nValueCount
A numbers of elements.

Here is the caller graph for this function:

CComplex CMatrixOperation::CVector::operator* ( CVector vector)

operation overload for dot product with reference parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 442 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, GetAt(), and GetSize().

443 {
444  CComplex Rtn;
445  unsigned int i, nSize = GetSize();
446 
447  if (nSize != vector.GetSize())
448  {
450  return Rtn;
451  }
452 
453  for (i = 0; i < nSize; i++)
454  {
455  Rtn += (GetAt(i) * vector.GetAt(i));
456  }
457  return Rtn;
458 }
unsigned int GetSize()
Return Vector elements size.
CComplex GetAt(unsigned int nIndex)
Get element value from specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64

Here is the call graph for this function:

CComplex CMatrixOperation::CVector::operator* ( CVector vector)

operation overload for dot product with pointer parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 433 of file MatrixOperation.cpp.

References operator*().

434 {
435  return operator*((*vector));
436 }
CComplex operator*(CVector &vector)
operation overload for dot product with reference parameter

Here is the call graph for this function:

CMatrixOperation::CVector CMatrixOperation::CVector::operator+ ( CVector vector)

operation overload for vector plus operation with reference parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 506 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, GetAt(), GetSize(), SetAt(), and SetSize().

507 {
508  CVector rtnVector;
509  unsigned int i, nSize = GetSize();
510 
511  if (nSize != vector.GetSize())
512  {
514  return rtnVector;
515  }
516 
517  rtnVector.SetSize(nSize);
518  for (i = 0; i < nSize; i++)
519  {
520  rtnVector.SetAt(i, GetAt(i) + vector.GetAt(i));
521  }
522 
523  return rtnVector;
524 }
unsigned int GetSize()
Return Vector elements size.
CComplex GetAt(unsigned int nIndex)
Get element value from specific index.
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64

Here is the call graph for this function:

CMatrixOperation::CVector CMatrixOperation::CVector::operator+ ( CVector vector)

operation overload for vector plus operation with pointer parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 497 of file MatrixOperation.cpp.

498 {
499  return operator+((*vector));
500 }
CVector operator+(CVector &vector)
operation overload for vector plus operation with reference parameter
CMatrixOperation::CVector CMatrixOperation::CVector::operator- ( CVector vector)

operation overload for vector minus operation with reference parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 473 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, GetAt(), GetSize(), SetAt(), and SetSize().

474 {
475  CVector rtnVector;
476  unsigned int i, nSize = GetSize();
477 
478  if (nSize != vector.GetSize())
479  {
481  return rtnVector;
482  }
483 
484  rtnVector.SetSize(nSize);
485 
486  for (i = 0; i < nSize; i++)
487  {
488  rtnVector.SetAt(i, GetAt(i) - vector.GetAt(i));
489  }
490  return rtnVector;
491 }
unsigned int GetSize()
Return Vector elements size.
CComplex GetAt(unsigned int nIndex)
Get element value from specific index.
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64

Here is the call graph for this function:

CMatrixOperation::CVector CMatrixOperation::CVector::operator- ( CVector vector)

operation overload for vector minus operation with pointer parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 464 of file MatrixOperation.cpp.

465 {
466  return operator-((*vector));
467 }
CVector operator-(CVector &vector)
operation overload for vector minus operation with reference parameter
void CMatrixOperation::CVector::operator= ( CVector vector)

operation overload for subsitution with reference parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 539 of file MatrixOperation.cpp.

References GetSize(), m_vectValueImaginaryBuffer, and m_vectValueRealBuffer.

540 {
541  unsigned int i, nSize = vector.GetSize();
542  double *pReal = NULL, *pImaginary = NULL;
543  double *pSourceReal = NULL, *pSourceImagianry = NULL;
544 
545  SetSize(nSize);
546 
547  pReal = m_vectValueRealBuffer.data();
548  pImaginary = m_vectValueImaginaryBuffer.data();
549  pSourceReal = vector.m_vectValueRealBuffer.data();
550  pSourceImagianry = vector.m_vectValueImaginaryBuffer.data();
551 
552 #pragma omp parallel for
553  for (i = 0; i < nSize; i++)
554  {
555  pReal[i] = pSourceReal[i];
556  pImaginary[i] = pSourceImagianry[i];
557  }
558 }
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void SetSize(unsigned int nSize)
Set Vector elements size.

Here is the call graph for this function:

void CMatrixOperation::CVector::operator= ( CVector vector)

operation overload for subsitution with pointer parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 530 of file MatrixOperation.cpp.

531 {
532  operator=((*vector));
533 }
void operator=(CVector &vector)
operation overload for subsitution with reference parameter
void CMatrixOperation::CVector::PlusVector ( CVector vector)

Do plus operation between vectors.

Parameters
vectorvector that is used in plus operation

Definition at line 344 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, GetAtPt(), CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), and GetSize().

Referenced by CSPLoop::executeSPLoop().

345 {
346  unsigned int i, nSize = GetSize();
347  CComplex *pOperand1, *pOperand2;
348 
349  if (nSize != vector->GetSize())
350  {
352  return;
353  }
354 
355  for (i = 0; i < nSize; i++)
356  {
357  pOperand1 = GetAtPt(i);
358  pOperand2 = vector->GetAtPt(i);
359 
360  SetAt(i, pOperand1->GetRealNumber() + pOperand2->GetRealNumber(), pOperand1->GetImaginaryNumber() + pOperand2->GetImaginaryNumber());
361  }
362 }
unsigned int GetSize()
Return Vector elements size.
CComplex * GetAtPt(unsigned int nIndex)
Get element value from specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

void CMatrixOperation::CVector::ReorthogonalizationVector ( CVector pVector,
CComplex  complex 
)

Do reorthogonalization.

Parameters
pVectorTarget vector for orthogonalization
complexInput scalar

Definition at line 292 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), GetSize(), m_vectValueImaginaryBuffer, and m_vectValueRealBuffer.

293 {
294  unsigned int i, nSize = GetSize();
295  double *pReal = NULL, *pImaginary = NULL;
296  double *pOperandReal = NULL, *pOperandImagianray = NULL;
297  double fReal = complex.GetRealNumber(), fImaginary = complex.GetImaginaryNumber();
298 
299  if (nSize != pVector->GetSize())
300  {
302  return;
303  }
304 
305  pReal = m_vectValueRealBuffer.data();
306  pImaginary = m_vectValueImaginaryBuffer.data();
307  pOperandReal = pVector->m_vectValueRealBuffer.data();
308  pOperandImagianray = pVector->m_vectValueImaginaryBuffer.data();
309 
310 #pragma omp parallel for
311  for (i = 0; i < nSize; i++)
312  {
313  pReal[i] = pReal[i] - fReal* pOperandReal[i] + fImaginary * pOperandImagianray[i];
314  pImaginary[i] = pImaginary[i] - fReal * pOperandImagianray[i] - fImaginary * pOperandReal[i];
315  }
316 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

void CMatrixOperation::CVector::ResetValue ( )

Reset every element to zero.

Definition at line 113 of file MatrixOperation.cpp.

114 {
115  unsigned int i;
116 
117  for (i = 0; i < GetSize(); i++)
118  {
119  m_vectValueRealBuffer[i] = 0.;
121  }
122 
123 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void CMatrixOperation::CVector::ScalarDivision ( CComplex  Scalar)

Scalar division operation.

Parameters
ScalarScalar value that want to use in operation

Definition at line 163 of file MatrixOperation.cpp.

References CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), and CComplex::SetComplexNumber().

Referenced by CLanczosMethod::LanczosIterationLoop(), and operator/().

164 {
165  unsigned int i;
166  CComplex tempComplex;
167 
168  for (i = 0; i < GetSize(); i++)
169  {
171  tempComplex = tempComplex / Scalar;
172 
173  m_vectValueRealBuffer[i] = tempComplex.GetRealNumber();
175  }
176 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void SetComplexNumber(double fReal, double fImaginaray)
Set Complex number using real part and imaginary part.
Definition: Complex.cpp:58
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

void CMatrixOperation::CVector::ScalarDivision ( double  fScalar)

Scalar division operation.

Parameters
fScalarScalar value that want to use in operation

Definition at line 181 of file MatrixOperation.cpp.

182 {
183  double *pReal = NULL, *pImaginary = NULL;
184  unsigned int i;
185  unsigned int nSize = GetSize();
186 
187  pReal = m_vectValueRealBuffer.data();
188  pImaginary = m_vectValueImaginaryBuffer.data();
189 
190 #pragma omp parallel for
191  for (i = 0; i < nSize ; i++)
192  {
193  /*m_vectValueRealBuffer[i] /= fScalar;
194  m_vectValueImaginaryBuffer[i] /= fScalar;*/
195  pReal[i] /= fScalar;
196  pImaginary[i] /= fScalar;
197  }
198 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void CMatrixOperation::CVector::ScalarMultiple ( CComplex  Scalar)

Scalar multiple operation.

Parameters
ScalarScalar value that want to use in operation

Definition at line 128 of file MatrixOperation.cpp.

References CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), and CComplex::SetComplexNumber().

Referenced by CLanczosResultAudit::AuditResult_EV(), CLanczosMethod::DoResidualCheck(), CMatrixOperation::Gram_schmidt(), CLanczosMethod::MergeDegeneratedEigenvalues(), and operator*().

129 {
130  unsigned int i;
131  CComplex tempComplex;
132 
133  for (i = 0; i < GetSize(); i++)
134  {
136  tempComplex = tempComplex * Scalar;
137 
138  m_vectValueRealBuffer[i] = tempComplex.GetRealNumber();
140  }
141 
142  return;
143 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void SetComplexNumber(double fReal, double fImaginaray)
Set Complex number using real part and imaginary part.
Definition: Complex.cpp:58
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

void CMatrixOperation::CVector::ScalarMultiple ( double  fScalar)

Scalar multiple operation.

Parameters
fScalarScalar value that want to use in operation

Definition at line 148 of file MatrixOperation.cpp.

149 {
150  //double fReal, fImaginary;
151  unsigned int i;
152 
153  for (i = 0; i < GetSize(); i++)
154  {
155  m_vectValueRealBuffer[i] *= fScalar;
156  m_vectValueImaginaryBuffer[i] *= fScalar;
157  }
158 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void CMatrixOperation::CVector::ScalarMultiThanMinusVector ( double  fScalar,
CVector vector 
)

Do minus operation after scalar multiple to operand between vectors.

Parameters
fScalarScalar factor
vectorVector operand for minus operation

Definition at line 263 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, GetSize(), m_vectValueImaginaryBuffer, and m_vectValueRealBuffer.

Referenced by CLanczosMethod::LanczosIterationLoop().

264 {
265  unsigned int i, nSize = GetSize();
266  double *pReal = NULL, *pImaginary = NULL;
267  double *pOperandReal = NULL, *pOperandImagianray = NULL;
268 
269  if (nSize != vector->GetSize())
270  {
272  return;
273  }
274 
275  pReal = m_vectValueRealBuffer.data();
276  pImaginary = m_vectValueImaginaryBuffer.data();
277  pOperandReal = vector->m_vectValueRealBuffer.data();
278  pOperandImagianray = vector->m_vectValueImaginaryBuffer.data();
279 
280 #pragma omp parallel for
281  for (i = 0; i < nSize; i++)
282  {
283  pReal[i] = pReal[i] - fScalar * pOperandReal[i];
284  pImaginary[i] = pImaginary[i] - fScalar * pOperandImagianray[i];
285  }
286 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
const unsigned long ERROR_WRONG_ORDER_OPERATION
Error code that means during operation between vector & vector, matrix & vector order don't match...
Definition: Global.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMatrixOperation::CVector::Serialize ( double *  pBuffer,
bool  bStore 
)

Serialize vector.

Parameters
pBufferSaving/Loading buffer
bStoreSaving(true) or Loading(false)
Returns
Operation success or not

Definition at line 400 of file MatrixOperation.cpp.

Referenced by CMPIManager::ReceiveVectorSync(), and CMPIManager::SendVectorSync().

401 {
402  double *pReal = NULL, *pImaginariy = NULL;
403  bool bRtn = false;
404 
405  if( NULL == pBuffer )
406  return bRtn;
407 
408  if( bStore)
409  {
410  pReal = m_vectValueRealBuffer.data();
411  memcpy(pReal, pBuffer, m_nValueCount * sizeof(double));
412 
413  pImaginariy = m_vectValueImaginaryBuffer.data();
414  memcpy(pImaginariy, pBuffer + m_nValueCount, m_nValueCount * sizeof(double));
415  }
416  else
417  {
418  pReal = m_vectValueRealBuffer.data();
419  memcpy(pBuffer, pReal, m_nValueCount * sizeof(double));
420 
421  pImaginariy = m_vectValueImaginaryBuffer.data();
422  memcpy(pBuffer + m_nValueCount, pImaginariy, m_nValueCount * sizeof(double));
423  }
424 
425  bRtn = true;
426  return bRtn;
427 }
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
unsigned int m_nValueCount
A numbers of elements.

Here is the caller graph for this function:

void CMatrixOperation::CVector::SetAt ( unsigned int  nIndex,
CComplex  value 
)

Set element value in specific index, Call by value.

Parameters
nIndexSpecific element index that want to set
valueelement value

Definition at line 53 of file MatrixOperation.cpp.

References CComplex::GetImaginaryNumber(), and CComplex::GetRealNumber().

Referenced by CMatrixOperation::AddVectors(), CTBMS_Solver::ApplyPhPotential(), CHamiltonianBuilder::BuildHaaDiagonalFor10Band(), CHamiltonianBuilder::BuildHccDiagonalFor10Band(), CZincblendeParam::BuildMatrix(), CGeometricShape::BuildPEBiasVector(), CGeometricShape::BuildPEWaveVector(), CLanczosMethod::BuildWaveFunction(), CLanczosMethod::CalculateEigenVector(), CMatrixOperation::CCSR::DiagonalOperation(), CSPLoop::executeSPLoop(), CSPLoop::GetChargeProfile(), CMatrixOperation::CDMatrix::GetColumnByVector(), CMatrixOperation::CDMatrix::GetRowByVector(), CLanczosMethod::LanczosIteration(), CMatrixOperation::MVMul(), CMatrixOperation::CCSR::operator*(), operator+(), operator-(), CLanczosMethod::RecalcuWaveFunction(), IGeometricUnitCellInfo::RotateAxis(), IGeometricUnitCellInfo::RotateNeighbor(), CHamiltonianBuilder::RotateTransMatrixFor10Band(), CMatrixOperation::ScalarMulVectors(), and CMatrixOperation::SubstractVectors().

54 {
55  SetAt(nIndex, value.GetRealNumber(), value.GetImaginaryNumber());
56 }
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

void CMatrixOperation::CVector::SetAt ( unsigned int  nIndex,
double  fReal,
double  fImaginary 
)

Set element value in specific index.

Parameters
nIndexSpecific element index that want to set
fRealReal number of element value
fImaginaryImaginary number of element value

Definition at line 68 of file MatrixOperation.cpp.

References ERROR_OUT_OF_RANGE, and THROW_END_EXIT.

69 {
70  if (nIndex > GetSize())
71  {
73  }
74 
75  m_vectValueRealBuffer[nIndex] = fReal;
76  m_vectValueImaginaryBuffer[nIndex] = fImaginary;
77 }
unsigned int GetSize()
Return Vector elements size.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
#define THROW_END_EXIT(EXCEPTION_NAME)
< Macro for exception throw than exit program
Definition: Global.h:10
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
const unsigned long ERROR_OUT_OF_RANGE
Error code that means during access vector or matrix input index out of range.
Definition: Global.h:63
void CMatrixOperation::CVector::SetAtEx ( unsigned int  nIndex,
CComplex pValue 
)

Set element value in specific index, Call by reference.

Definition at line 58 of file MatrixOperation.cpp.

References CComplex::GetImaginaryNumber(), and CComplex::GetRealNumber().

59 {
60  SetAt(nIndex, pValue->GetRealNumber(), pValue->GetImaginaryNumber());
61 }
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

void CMatrixOperation::CVector::SetSize ( unsigned int  nSize)

Set Vector elements size.

Parameters
nSizeVector elements size

Definition at line 39 of file MatrixOperation.cpp.

Referenced by CLanczosMethod::AppendEigenVector(), CTBMS_Solver::ApplyPhPotential(), CLanczosResultAudit::AuditResult_EV(), CHamiltonianBuilder::BuildHonsiteBasicMatrixFor10Band(), CZincblendeParam::BuildMatrix(), CGeometricShape::BuildPEBiasVector(), CGeometricShape::BuildPEWaveVector(), CLanczosMethod::BuildWaveFunction(), CMatrixOperation::CCSR::DiagonalOperation(), CLanczosMethod::DoResidualCheck(), CSPLoop::executeSPLoop(), CMatrixOperation::CDMatrix::GetColumnByVector(), CMatrixOperation::CDMatrix::GetRowByVector(), CLanczosMethod::LanczosIteration(), CLanczosMethod::LanczosIterationLoop(), CLanczosMethod::MergeDegeneratedEigenvalues(), CMPIManager::MergeVector(), CMatrixOperation::MVMul(), CMatrixOperation::MVMulOptimal(), CMatrixOperation::MVMulOptimal_Nooffload(), CMatrixOperation::CCSR::operator*(), operator+(), operator-(), IGeometricUnitCellInfo::RotateAxis(), IGeometricUnitCellInfo::RotateNeighbor(), CHamiltonianBuilder::RotateTransMatrixFor10Band(), and CLanczosMethod::SortSolution().

40 {
41  if (nSize == m_nValueCount)
42  return;
43 
44  m_nValueCount = nSize;
45  m_vectValueRealBuffer.resize(nSize);
46  m_vectValueImaginaryBuffer.resize(nSize);
47 }
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
unsigned int m_nValueCount
A numbers of elements.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class CLanczosMethod
friend

Definition at line 109 of file MatrixOperation.h.

friend class CMatrixOperation
friend

Definition at line 110 of file MatrixOperation.h.

friend class CMPIManager
friend

Definition at line 111 of file MatrixOperation.h.

friend class CSPLoop
friend

Definition at line 112 of file MatrixOperation.h.

Member Data Documentation

unsigned int CMatrixOperation::CVector::m_nValueCount
private

A numbers of elements.

Definition at line 106 of file MatrixOperation.h.

Referenced by CVector(), and GetSize().

CComplex CMatrixOperation::CVector::m_rtnTemp
private

Temporary variable for return value.

Definition at line 107 of file MatrixOperation.h.


The documentation for this class was generated from the following files: