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

Data and operation representation of CSR(Compressed Sparse Row) More...

#include "MatrixOperation.h"

Collaboration diagram for CMatrixOperation::CCSR:
Collaboration graph

Public Types

enum  OPERATION_TYPE { PLUS, MINUS, MULTIPLE, DIVISION }
 

Public Member Functions

 CCSR ()
 Constructor. More...
 
 ~CCSR ()
 Destructor. More...
 
unsigned int GetNoneZeroCount ()
 Getting numbers of none zero elements. More...
 
unsigned int GetRowCount ()
 
unsigned int GetColumnCount ()
 Getting row size of matrix. More...
 
unsigned int GetRowIndexNo (unsigned int nIndex)
 Getting column size of matrix. More...
 
unsigned int GetColIndexNo (unsigned int nIndex)
 Getting Column information data by index. More...
 
CComplexGetValue (unsigned int nIndex)
 Getting none zero element value by index. More...
 
CComplex GetElement (unsigned int nRow, unsigned int nColumn, bool &bResult)
 Get Element by index. More...
 
void Finalize ()
 Deallocating memory for member variable. More...
 
void ExpandMatrix (unsigned int nMulti, bool bRow, bool bColumn)
 Expand matrix order. More...
 
bool SetAt (CComplex number, unsigned int nRow, unsigned int nColumn)
 Set element to specific index. More...
 
bool InsertRowBefore (unsigned int nRow)
 Insert row before specific row index. More...
 
bool InsertRowAtEnd ()
 Insert row after last row. More...
 
bool InsertColumnBefore (unsigned int nColumn)
 Insert column before specific column index. More...
 
bool InsertColumnAtEnd ()
 Insert column after last column. More...
 
CCSRSplitCSR (int nStart, int nEnd)
 Split CSR to MPI slave. More...
 
void BuildDataBuffer ()
 Allocating memory for class member variable. More...
 
void SetRowCount (unsigned int nRow)
 Settting row size of matrix. More...
 
void SetColumnCount (unsigned int nColumn)
 Settting column size of matrix. More...
 
bool InsertMatrix (unsigned int nRow, unsigned int nColumn, unsigned int nRowStart, unsigned int nColumnStart, unsigned int nRowCount, unsigned int nColumnCount, CMatrixOperation::CDMatrix *pMatrix, bool bCopyZero)
 Set element by reference matrix. More...
 
bool PushMatrix (unsigned int nRow, unsigned int nColumn, unsigned int nRowStart, unsigned int nColumnStart, unsigned int nRowCount, unsigned int nColumnCount, CMatrixOperation::CDMatrix *pMatrix, bool bCopyZero)
 Set element by reference matrix to end of buffer. More...
 
bool PushMatrixConcurrent (unsigned int nRow, CMatrixOperation::LPFILL_MATRIX_DATA lpData, bool bCopyZeroOnSite, int nBandSize)
 
bool PushMatrixConcurrentPE (unsigned int nRow, CMatrixOperation::LPFILL_MATRIX_DATA lpData, bool bCopyZeroOnSite)
 <Added by="" jhkang>=""> More...
 
bool ElementScalarMultiple (unsigned int nRow, unsigned int nColumn, CComplex Scalar)
 <Added by="" jhkang="" end>=""> More...
 
bool ElementScalarMultiple (unsigned int nRow, unsigned int nColumn, double fScalar)
 Scalar multiple operation. More...
 
bool AreaScalarMultiple (unsigned int nRowStart, unsigned int nRowCount, unsigned int nColumnStart, unsigned int nColumnCount, CComplex Scalar)
 Scalar multiple operation to specific area. More...
 
bool DiagonalOperation (CVector *pOperand, OPERATION_TYPE type, bool bUseSplitVector, int nBandSize)
 To diagonal element do operation. More...
 
bool DiagonalOperation (double *pOperand, unsigned int nSize, OPERATION_TYPE type, bool bUseSplitVector, int nBandSize)
 To diagonal element do operation. More...
 
void SetFirstRowIndex (double fFirstIndex)
 
double GetFirstRowIndex ()
 Set first row index. More...
 
void PushNoneZeroValue (double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
 Saving none zero value. More...
 
void FinishPush ()
 Insert end index of none zero value index. More...
 
bool ConvertDoubleArray (unsigned int *pRowPtr, unsigned int *pColIndex, double *pNNZValueReal, double *pNNZValueImaginary, unsigned int nNNZSize, unsigned int nRowSize, unsigned int nColSize, unsigned int nFirstIndex, bool bZerobase)
 Convering general CSR format to CSR. More...
 
CVector operator* (CVector &vector)
 operation overload for matrix and vector multiple operation with reference parameter More...
 
CVector operator* (CVector *vector)
 operation overload for matrix and vector multiple operation with pointer parameter More...
 

Public Attributes

unsigned int nComponentsFirstUnitCell
 Atom counts for interoperaton with previous node. More...
 
unsigned int nComponentsLastUnitCell
 Atom counts for interoperaton with next node. More...
 

Static Public Attributes

static unsigned int MAX_INDEX = 0xffffffff
 constant variable for row that has no element More...
 

Private Member Functions

void DumpCSR (const char *pstrFileName)
 For debugging save CSR into file. More...
 
void IncreaseNoneZeroCount ()
 Increasing saved none zero elements count. More...
 
bool IsNonzeroElement (unsigned int nRow, unsigned int nColumn, unsigned int &nIndex)
 Checking given index element has nonzero value or not. More...
 
unsigned int GetNextNonzeroValueIndex (unsigned int nRow, unsigned int nColumn)
 Get next index of given row, column index. More...
 
bool GetNextRowIndexValue (unsigned int nRowFrom, unsigned int &nValueIndex)
 Get row index value finding from nRowFrom to end. More...
 
void IncreaseRowIndex (unsigned int nRowFrom)
 Increase m_nRowCount array value + 1 from nRowFrom. It means at m_nRowCount element has been inserted. More...
 

Private Attributes

unsigned int m_nValueCount
 Numbers of none zero elements. More...
 
unsigned int m_nValueStackCount
 Currently saved none zero value count. More...
 
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_nRowCount
 A numbers of row. More...
 
unsigned int m_nColumnCount
 A numbers of column. More...
 
uint_vector_t m_vectRow
 A member variable for saving row information. More...
 
uint_vector_t m_vectColumn
 A member variable for saving column information. More...
 
double m_fFirstRowIndex
 First row index in this node. More...
 
CComplex m_rtnTemp
 Temporary variable for return. More...
 

Friends

class CMatrixOperation
 
class CUtility
 
class CTBMS_Solver
 
class CLanczosLaunching
 
class CSPLoop
 

Detailed Description

Data and operation representation of CSR(Compressed Sparse Row)

Date
27/May/2014
Warning
This class using none-zero base index.

Definition at line 163 of file MatrixOperation.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

CMatrixOperation::CCSR::CCSR ( )

Constructor.


        CDMatrix Class member function - End

        CCSR Class member function - Start

< Numbers of none zero elements

< Currently saved none zero value count

< A numbers of row

< A numbers of column

< For Empty remark empty row use max index;

Definition at line 1018 of file MatrixOperation.cpp.

1019 {
1020  m_nValueCount = 0;
1021  m_nValueStackCount = 0;
1022  m_nRowCount = 0;
1023  m_nColumnCount = 0;
1024  MAX_INDEX = -1;
1025  m_fFirstRowIndex = 0;
1028 }
unsigned int nComponentsLastUnitCell
Atom counts for interoperaton with next node.
unsigned int m_nValueStackCount
Currently saved none zero value count.
unsigned int m_nRowCount
A numbers of row.
unsigned int nComponentsFirstUnitCell
Atom counts for interoperaton with previous node.
double m_fFirstRowIndex
First row index in this node.
static unsigned int MAX_INDEX
constant variable for row that has no element
unsigned int m_nValueCount
Numbers of none zero elements.
unsigned int m_nColumnCount
A numbers of column.
CMatrixOperation::CCSR::~CCSR ( )

Destructor.

Definition at line 1030 of file MatrixOperation.cpp.

1031 {
1032 
1033 }

Member Function Documentation

bool CMatrixOperation::CCSR::AreaScalarMultiple ( unsigned int  nRowStart,
unsigned int  nRowCount,
unsigned int  nColumnStart,
unsigned int  nColumnCount,
CComplex  Scalar 
)

Scalar multiple operation to specific area.

<Added by="" jhkang="" end>="">

Parameters
nRowStartTarget row start index
nRowCountTarget row size
nColumnStartTarget column start index
nColumnCountTarget column size
ScalarScalar value that want to Multiple
Returns
Success or fail

Definition at line 1188 of file MatrixOperation.cpp.

Referenced by CGeometricShape::RefillPeriodicBinding().

1189 {
1190  bool bRtn = false;
1191  unsigned int i, j;
1192 
1193  for (i = nRowStart; i < nRowStart + nRowCount; ++i)
1194  {
1195  for (j = nColumnStart; j < nColumnStart + nColumnCount; ++j)
1196  {
1197  bRtn = ElementScalarMultiple(i, j, Scalar);
1198  if (!bRtn)
1199  {
1200  return bRtn;
1201  }
1202  }
1203  }
1204 
1205  return bRtn;
1206 }
bool ElementScalarMultiple(unsigned int nRow, unsigned int nColumn, CComplex Scalar)
="">

Here is the caller graph for this function:

void CMatrixOperation::CCSR::BuildDataBuffer ( )

Allocating memory for class member variable.

Definition at line 1040 of file MatrixOperation.cpp.

Referenced by CTBMS_Solver::AllocateCSR(), CSPLoop::AllocateCSR(), CMatrixOperation::BuildCSRFromFile_(), CMatrixOperation::BuildCSRFromFileTemp(), CMatrixOperation::BuildCSRFromFileUnsortdata(), CMatrixOperation::BuildCSRFromOneDimArray(), and SplitCSR().

1041 {
1042  for (unsigned int i = 0; i < m_nRowCount + 1; i++)
1043  m_vectRow.push_back(MAX_INDEX);
1044 }
unsigned int m_nRowCount
A numbers of row.
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectRow
A member variable for saving row information.

Here is the caller graph for this function:

bool CMatrixOperation::CCSR::ConvertDoubleArray ( unsigned int *  pRowPtr,
unsigned int *  pColIndex,
double *  pNNZValueReal,
double *  pNNZValueImaginary,
unsigned int  nNNZSize,
unsigned int  nRowSize,
unsigned int  nColSize,
unsigned int  nFirstIndex,
bool  bZerobase 
)

Convering general CSR format to CSR.

Parameters
pRowPtrRow index data
pColIndexColumn index data
pNNZValueRealNon zero real element data
pNNZValueImaginaryNon zero imaginary elements data
nNNZSizeNon zero elements counts
nRowSizeRow counts
nColSizeColumn counts
nFirstIndexFirst index for split matrix
bZerobaseZero based index or not
Returns
Operation success or fail

Definition at line 1372 of file MatrixOperation.cpp.

1373 {
1374  bool bRtn = false;
1375  int nAdjustIndex = 0;
1376  int i, j;
1377  int nStartIndex, nEndIndex;
1378  double fReal, fImaginary;
1379 
1380  SetRowCount(nRowSize);
1381  SetColumnCount(nColSize);
1382  BuildDataBuffer();
1383 
1384  if( !bZerobase )
1385  nAdjustIndex = -1;
1386 
1387  for( i = 0; i < nRowSize ; ++ i )
1388  {
1389  nStartIndex = pRowPtr[i] + nAdjustIndex;
1390  nEndIndex = pRowPtr[i+1] + nAdjustIndex;
1391  for( j = nStartIndex ; j < nEndIndex ; ++ j)
1392  {
1393  if( pNNZValueReal )
1394  fReal = pNNZValueReal[j];
1395  else
1396  fReal = 0.;
1397 
1398  if( pNNZValueImaginary )
1399  fImaginary = pNNZValueImaginary[j];
1400  else
1401  fImaginary = 0.;
1402 
1403  PushNoneZeroValue(fReal, fImaginary, i, pColIndex[j] + nAdjustIndex);
1404  }
1405  }
1406 
1407  FinishPush();
1408  SetFirstRowIndex(nFirstIndex + nAdjustIndex);
1409 
1410  bRtn = true;
1411  return bRtn;
1412 }
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
void SetFirstRowIndex(double fFirstIndex)
void PushNoneZeroValue(double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
Saving none zero value.
void BuildDataBuffer()
Allocating memory for class member variable.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
void FinishPush()
Insert end index of none zero value index.
bool CMatrixOperation::CCSR::DiagonalOperation ( CVector pOperand,
OPERATION_TYPE  type,
bool  bUseSplitVector,
int  nBandSize 
)

To diagonal element do operation.

Parameters
pOperandOperand vector to use for operation
typeOperation type
bUseSplitVectorUsing split vector that has same size(1/10) with CSR row or Total size that means CSR row size that Origianl Hamiltonian
nBandSizeBand size
Returns
Operation success or not

Definition at line 2079 of file MatrixOperation.cpp.

References CMatrixOperation::CVector::GetAt(), and CMatrixOperation::CVector::GetSize().

Referenced by CTBMS_Solver::ApplyPhPotential(), and CSPLoop::SolveSchroedinger().

2080 {
2081  bool bRtn = false, bResult;
2082  unsigned int i, j, nRowIndex;
2083  unsigned int nVectorIndex = 0, nVectorEnd = pOperand->GetSize();
2084 
2085  if( bUseSplitVector )
2086  {
2087  if( pOperand->GetSize() != m_nRowCount / 10 )
2088  return bRtn;
2089  }
2090  else
2091  {
2092  if( pOperand->GetSize() != m_nColumnCount / 10 )
2093  return bRtn;
2094 
2095  nVectorIndex = (unsigned int)m_fFirstRowIndex/10;
2096  nVectorEnd = nVectorIndex + m_nRowCount / 10;
2097  }
2098 
2099  nRowIndex = 0;
2100  for ( i = nVectorIndex; i < nVectorEnd ; ++ i )
2101  {
2102  CComplex number = pOperand->GetAt(i);
2103  for( j = 0 ; j < nBandSize ; ++ j )
2104  {
2105  CComplex csrElement = GetElement(nRowIndex, nRowIndex + (unsigned int)m_fFirstRowIndex, bResult);
2106  if( !bResult )
2107  return bRtn;
2108 
2109  switch(type)
2110  {
2111  case PLUS:
2112  csrElement = csrElement + number;
2113  break;
2114  case MINUS:
2115  csrElement = csrElement - number;
2116  break;
2117  case MULTIPLE:
2118  csrElement = csrElement * number;
2119  break;
2120  case DIVISION:
2121  csrElement = csrElement / number;
2122  break;
2123  }
2124 
2125  SetAt(csrElement, nRowIndex, nRowIndex + (unsigned int)m_fFirstRowIndex);
2126  nRowIndex++;
2127 
2128  }
2129  }
2130 
2131  bRtn = true;
2132  return bRtn;
2133 }
unsigned int m_nRowCount
A numbers of row.
bool SetAt(CComplex number, unsigned int nRow, unsigned int nColumn)
Set element to specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
double m_fFirstRowIndex
First row index in this node.
CComplex GetElement(unsigned int nRow, unsigned int nColumn, bool &bResult)
Get Element by index.
unsigned int m_nColumnCount
A numbers of column.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMatrixOperation::CCSR::DiagonalOperation ( double *  pOperand,
unsigned int  nSize,
OPERATION_TYPE  type,
bool  bUseSplitVector,
int  nBandSize 
)

To diagonal element do operation.

Parameters
pOperandOperand vector to use for operation
typeOperation type
bUseSplitVectorUsing split vector that has same size(1/10) with CSR row or Total size that means CSR row size that Origianl Hamiltonian
Returns
Operation success or not

Definition at line 2060 of file MatrixOperation.cpp.

References CMatrixOperation::CVector::SetAt(), and CMatrixOperation::CVector::SetSize().

2061 {
2062  CVector OperandVector;
2063  unsigned int i;
2064 
2065  OperandVector.SetSize(nSize);
2066  for( i = 0 ; i < nSize ; ++ i )
2067  OperandVector.SetAt(i, pOperand[i], 0.0);
2068 
2069  return DiagonalOperation(&OperandVector, type, bUseSplitVector, nBandSize);
2070 }
bool DiagonalOperation(CVector *pOperand, OPERATION_TYPE type, bool bUseSplitVector, int nBandSize)
To diagonal element do operation.

Here is the call graph for this function:

void CMatrixOperation::CCSR::DumpCSR ( const char *  pstrFileName)
private

For debugging save CSR into file.

Parameters
pstrFileNameFile name for saving

Definition at line 2152 of file MatrixOperation.cpp.

Referenced by CMatrixOperation::DumpCSR().

2153 {
2154  FILE *out;
2155  unsigned int i, nCount;
2156 
2157  out = fopen(pstrFileName, "wt");
2158  if (NULL != out)
2159  {
2160  fputs("None Zero Value\r\n", out);
2161  fputs("------------------------------------------\r\n", out);
2162  nCount = GetNoneZeroCount();
2163  for (i = 0; i < nCount; i++)
2164  fprintf(out, "%f + %fi\r\n", m_vectValueRealBuffer[i], m_vectValueImaginaryBuffer[i]);
2165 
2166  fputs("Column\r\n", out);
2167  fputs("------------------------------------------\r\n", out);
2168  nCount = GetNoneZeroCount();
2169  for (i = 0; i < nCount; i++)
2170  fprintf(out, "%u\r\n", m_vectColumn[i]);
2171 
2172  fputs("Row\r\n", out);
2173  fputs("------------------------------------------\r\n", out);
2174  nCount = GetRowCount() + 1;
2175  for (i = 0; i < nCount; i++)
2176  fprintf(out, "%u\r\n", GetRowIndexNo(i));
2177 
2178  fclose(out);
2179  }
2180 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
unsigned int GetRowCount()
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
uint_vector_t m_vectColumn
A member variable for saving column information.

Here is the caller graph for this function:

bool CMatrixOperation::CCSR::ElementScalarMultiple ( unsigned int  nRow,
unsigned int  nColumn,
CComplex  Scalar 
)

<Added by="" jhkang="" end>="">

Scalar multiple operation

Parameters
nRowTarget row index
nColumnTarget column index
ScalarScalar value that want to use in operation
Returns
Operation success or fail

Definition at line 1214 of file MatrixOperation.cpp.

1215 {
1216  CComplex tempNumber;
1217  bool bResult, bRtn = false;;
1218 
1219  tempNumber = GetElement(nRow, nColumn, bResult);
1220  if (!bResult)
1221  return bRtn;
1222 
1223  tempNumber = tempNumber * Scalar;
1224  bRtn = SetAt(tempNumber, nRow, nColumn);
1225 
1226  return bRtn;
1227 }
bool SetAt(CComplex number, unsigned int nRow, unsigned int nColumn)
Set element to specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
CComplex GetElement(unsigned int nRow, unsigned int nColumn, bool &bResult)
Get Element by index.
bool CMatrixOperation::CCSR::ElementScalarMultiple ( unsigned int  nRow,
unsigned int  nColumn,
double  fScalar 
)

Scalar multiple operation.

Parameters
nRowTarget row index
nColumnTarget column index
fScalarScalar value that want to use in operation
Returns
Operation success or fail

Definition at line 1235 of file MatrixOperation.cpp.

1236 {
1237  CComplex tempNumber;
1238  bool bResult, bRtn = false;;
1239 
1240  tempNumber = GetElement(nRow, nColumn, bResult);
1241  if (!bResult)
1242  return bRtn;
1243 
1244  tempNumber = tempNumber * fScalar;
1245  bRtn = SetAt(tempNumber, nRow, nColumn);
1246 
1247  return bRtn;
1248 }
bool SetAt(CComplex number, unsigned int nRow, unsigned int nColumn)
Set element to specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
CComplex GetElement(unsigned int nRow, unsigned int nColumn, bool &bResult)
Get Element by index.
void CMatrixOperation::CCSR::ExpandMatrix ( unsigned int  nMulti,
bool  bRow,
bool  bColumn 
)

Expand matrix order.

Parameters
nMultiMultiple number for expanding matrix order
bRowOption for expanding row or not bColumn: Option for expanding column or not

Definition at line 1437 of file MatrixOperation.cpp.

1438 {
1439  unsigned int nOriginSize, i;
1440 
1441  if (false == bRow && false == bColumn)
1442  return;
1443 
1444  if (bRow)
1445  {
1446  nOriginSize = GetRowCount();
1447  SetRowCount(nMulti*nOriginSize);
1448 
1449  uint_vector_t temp = m_vectRow;
1450 
1451  m_vectRow.clear();
1452  for (i = 0; i < GetRowCount(); i++)
1453  m_vectRow.push_back(MAX_INDEX);
1454  m_vectRow.push_back(GetNoneZeroCount());
1455 
1456  for (i = 0; i < temp.size() - 1; i++)
1457  m_vectRow[i*nMulti] = temp[i];
1458  }
1459 
1460  if (bColumn)
1461  {
1462  nOriginSize = GetColumnCount();
1463  SetColumnCount(nMulti*nOriginSize);
1464  for (i = 0; i < GetNoneZeroCount(); i++)
1465  m_vectColumn[i] *= nMulti;
1466  }
1467 }
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
unsigned int GetRowCount()
std::vector< unsigned int > uint_vector_t
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
unsigned int GetColumnCount()
Getting row size of matrix.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectColumn
A member variable for saving column information.
uint_vector_t m_vectRow
A member variable for saving row information.
void CMatrixOperation::CCSR::Finalize ( )

Deallocating memory for member variable.

Definition at line 1414 of file MatrixOperation.cpp.

Referenced by CMatrixOperation::FreeCSR().

1415 {
1416  if (NULL == this)
1417  return;
1418 
1419  if (m_vectColumn.size() > 0)
1420  m_vectColumn.clear();
1421 
1422  if (m_vectValueRealBuffer.size() > 0)
1423  m_vectValueRealBuffer.clear();
1424 
1425  if (m_vectValueImaginaryBuffer.size() > 0)
1427 
1428  if (m_vectRow.size() > 0)
1429  m_vectRow.clear();
1430 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
uint_vector_t m_vectColumn
A member variable for saving column information.
uint_vector_t m_vectRow
A member variable for saving row information.

Here is the caller graph for this function:

void CMatrixOperation::CCSR::FinishPush ( )

Insert end index of none zero value index.

Definition at line 1355 of file MatrixOperation.cpp.

Referenced by CMatrixOperation::BuildCSRFromFile_(), CMatrixOperation::BuildCSRFromFileTemp(), CMatrixOperation::BuildCSRFromFileUnsortdata(), CMatrixOperation::BuildCSRFromOneDimArray(), CMatrixOperation::BuildLocalCSR(), and SplitCSR().

1356 {
1358 }
unsigned int GetRowCount()
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
uint_vector_t m_vectRow
A member variable for saving row information.

Here is the caller graph for this function:

unsigned int CMatrixOperation::CCSR::GetColIndexNo ( unsigned int  nIndex)

Getting Column information data by index.

Parameters
nIndexIndex that want to get column information
Returns
column information that saved

Definition at line 1307 of file MatrixOperation.cpp.

References ERROR_OUT_OF_RANGE.

1308 {
1309  if (nIndex > GetNoneZeroCount())
1310  {
1311  throw ERROR_OUT_OF_RANGE;
1312  return MAX_INDEX;
1313  }
1314 
1315  //return m_pnColum[nIndex];
1316  return m_vectColumn[nIndex];
1317 }
unsigned int GetNoneZeroCount()
Getting numbers of 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
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectColumn
A member variable for saving column information.
unsigned int CMatrixOperation::CCSR::GetColumnCount ( )
inline
CComplex CMatrixOperation::CCSR::GetElement ( unsigned int  nRow,
unsigned int  nColumn,
bool &  bResult 
)

Get Element by index.

Parameters
nRowSpecific index that of want to get element
nColumnSpecific index that of want to get element
bResult[out]: If Specific index has element set 'true' else set 'false'
Returns
Element value;

Definition at line 1594 of file MatrixOperation.cpp.

References CComplex::SetComplexNumber().

Referenced by CUtility::ShowCSR().

1595 {
1596  CComplex elementValue;
1597  unsigned int nSubStart = GetRowIndexNo(nRow), nSubEnd = GetRowIndexNo(nRow + 1), i;
1598 
1599  bResult = false;
1600  if (MAX_INDEX == nSubStart)
1601  return elementValue;
1602 
1603  if (MAX_INDEX == nSubEnd)
1604  {
1605  unsigned int nIndex = nRow + 2;
1606 
1607  while (MAX_INDEX == nSubEnd && nIndex <= GetRowCount())
1608  nSubEnd = GetRowIndexNo(nIndex++);
1609  }
1610 
1611  for (i = nSubStart; i < nSubEnd; i++)
1612  {
1613  if (nColumn == m_vectColumn[i])
1614  {
1615  bResult = true;
1617  return elementValue;
1618  }
1619  }
1620 
1621  return elementValue;
1622 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
unsigned int GetRowCount()
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
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
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectColumn
A member variable for saving column information.

Here is the call graph for this function:

Here is the caller graph for this function:

double CMatrixOperation::CCSR::GetFirstRowIndex ( )
inline

Set first row index.

Get first row index

Definition at line 200 of file MatrixOperation.h.

References m_fFirstRowIndex.

Referenced by CMatrixOperation::BuildLocalCSR(), and CMatrixOperation::UpdateLocalCSR().

Here is the caller graph for this function:

unsigned int CMatrixOperation::CCSR::GetNextNonzeroValueIndex ( unsigned int  nRow,
unsigned int  nColumn 
)
private

Get next index of given row, column index.

Parameters
nRowTarget row index
nColumnTarget column index
Returns
Index of next index of given row, column index
Remarks
This function couldn't call if there is no element in target row

Definition at line 1673 of file MatrixOperation.cpp.

1674 {
1675  unsigned int i;
1676 
1677  unsigned int nSubStart = GetRowIndexNo(nRow), nSubEnd = GetRowIndexNo(nRow + 1);
1678  unsigned int nTemp = nRow;
1679 
1680  if (MAX_INDEX == nSubEnd)
1681  {
1682  if (!GetNextRowIndexValue(nRow + 2, nSubEnd))
1683  {
1684  return MAX_INDEX;
1685  }
1686  }
1687 
1688  for (i = nSubStart; i < nSubEnd; i++)
1689  {
1690  unsigned int nColIndex = GetColIndexNo(i);
1691  if (nColIndex > nColumn)
1692  {
1693  return i;
1694  }
1695  }
1696  return nSubEnd;
1697 }
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
unsigned int GetColIndexNo(unsigned int nIndex)
Getting Column information data by index.
static unsigned int MAX_INDEX
constant variable for row that has no element
bool GetNextRowIndexValue(unsigned int nRowFrom, unsigned int &nValueIndex)
Get row index value finding from nRowFrom to end.
bool CMatrixOperation::CCSR::GetNextRowIndexValue ( unsigned int  nRowFrom,
unsigned int &  nValueIndex 
)
private

Get row index value finding from nRowFrom to end.

Parameters
nRowFromFrom this row index finding row index value that was not MAX_INDEX
nValueIndex[out] next not MAX_INDEX value
Returns
If there are no value index false, otherwise true;

Definition at line 1474 of file MatrixOperation.cpp.

1475 {
1476  bool bRtn = false;
1477  unsigned int nRowIndex = nRowFrom;
1478 
1479  if (nRowFrom > m_nRowCount)
1480  return bRtn;
1481 
1482  while (MAX_INDEX == m_vectRow[nRowIndex])
1483  {
1484  nRowIndex++;
1485  if (nRowIndex > m_nRowCount)
1486  return bRtn;
1487  }
1488 
1489  nValueIndex = m_vectRow[nRowIndex];
1490 
1491  bRtn = true;
1492  return bRtn;
1493 }
unsigned int m_nRowCount
A numbers of row.
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectRow
A member variable for saving row information.
unsigned int CMatrixOperation::CCSR::GetNoneZeroCount ( )
inline

Getting numbers of none zero elements.

Definition at line 170 of file MatrixOperation.h.

References m_nValueCount.

Referenced by CSPLoop::executeSPLoop(), CTBMS_Solver::Launching_TBMS_Solver(), CLanczosLaunching::LaunchingLanczos(), and CSPLoop::SolveSchroedinger().

Here is the caller graph for this function:

unsigned int CMatrixOperation::CCSR::GetRowCount ( )
inline
unsigned int CMatrixOperation::CCSR::GetRowIndexNo ( unsigned int  nIndex)

Getting column size of matrix.

Getting Row information data by index

Parameters
nIndexIndex that want to get row information
Returns
row information that saved

Definition at line 1292 of file MatrixOperation.cpp.

References ERROR_OUT_OF_RANGE.

1293 {
1294  if (nIndex > GetRowCount() + 1)
1295  {
1296  throw ERROR_OUT_OF_RANGE;
1297  return MAX_INDEX;
1298  }
1299 
1300  return m_vectRow[nIndex];
1301 }
unsigned int GetRowCount()
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
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectRow
A member variable for saving row information.
CComplex * CMatrixOperation::CCSR::GetValue ( unsigned int  nIndex)

Getting none zero element value by index.

Parameters
nIndexIndex that want to get none zero value
Returns
Complex number

Definition at line 1323 of file MatrixOperation.cpp.

References ERROR_OUT_OF_RANGE.

Referenced by CMatrixOperation::BuildLocalCSR(), and CMatrixOperation::UpdateLocalCSR().

1324 {
1325  CComplex dumyValue;
1326  if (nIndex > GetNoneZeroCount())
1327  {
1328  throw ERROR_OUT_OF_RANGE;
1329  return NULL;
1330  }
1331 
1333  return &m_rtnTemp;
1334 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
CComplex m_rtnTemp
Temporary variable for return.
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 caller graph for this function:

void CMatrixOperation::CCSR::IncreaseNoneZeroCount ( )
private

Increasing saved none zero elements count.

Definition at line 1035 of file MatrixOperation.cpp.

1036 {
1037  m_nValueCount++;
1038 }
unsigned int m_nValueCount
Numbers of none zero elements.
void CMatrixOperation::CCSR::IncreaseRowIndex ( unsigned int  nRowFrom)
private

Increase m_nRowCount array value + 1 from nRowFrom. It means at m_nRowCount element has been inserted.

Parameters
nRowFromFrom this row index increaseing row Index value + 1

Definition at line 1498 of file MatrixOperation.cpp.

1499 {
1500  unsigned int i;
1501 
1502  for (i = nRowFrom; i < GetRowCount(); i++)
1503  {
1504  if (MAX_INDEX != m_vectRow[i])
1505  m_vectRow[i]++;
1506  }
1507 }
unsigned int GetRowCount()
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectRow
A member variable for saving row information.
bool CMatrixOperation::CCSR::InsertColumnAtEnd ( )

Insert column after last column.

Returns
Operation success or not

Definition at line 1767 of file MatrixOperation.cpp.

1768 {
1770  return true;
1771 }
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
unsigned int GetColumnCount()
Getting row size of matrix.
bool CMatrixOperation::CCSR::InsertColumnBefore ( unsigned int  nColumn)

Insert column before specific column index.

Parameters
nRowThe index that column inserting point
Returns
Operation success or not

Definition at line 1742 of file MatrixOperation.cpp.

1743 {
1744  bool bRtn = false;
1745  unsigned int i, nNonZeroValueCount;
1746 
1747  if (nColumn >= GetColumnCount())
1748  return bRtn;
1749 
1750  nNonZeroValueCount = GetNoneZeroCount();
1751 
1752  for (i = 0; i < nNonZeroValueCount; i++)
1753  {
1754  if (m_vectColumn[i] >= nColumn)
1755  m_vectColumn[i]++;
1756  }
1757 
1759 
1760  bRtn = true;
1761  return bRtn;
1762 }
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
unsigned int GetColumnCount()
Getting row size of matrix.
uint_vector_t m_vectColumn
A member variable for saving column information.
bool CMatrixOperation::CCSR::InsertMatrix ( unsigned int  nRow,
unsigned int  nColumn,
unsigned int  nRowStart,
unsigned int  nColumnStart,
unsigned int  nRowCount,
unsigned int  nColumnCount,
CMatrixOperation::CDMatrix pMatrix,
bool  bCopyZero 
)

Set element by reference matrix.

Parameters
nRowTarget row index
nColumnTarget column index
nRowStartCopying source matrix row start index
nColumnStartCopying source matrix column start index
nRowCountCopying row counts
nColumnCountCopying column counts
pMatrixCopying source matrix
bCopyZeroCopying zero with '0' or not
Returns
Operation success or fail

Definition at line 1261 of file MatrixOperation.cpp.

References CMatrixOperation::CDMatrix::GetColumnCount(), CMatrixOperation::CDMatrix::GetElement(), CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), and CMatrixOperation::CDMatrix::GetRowCount().

Referenced by CHamiltonianBuilder::ResetPeriodicBinding().

1262 {
1263  unsigned int nMatrixRowCount = pMatrix->GetRowCount();
1264  unsigned int nMatrixColumnCount = pMatrix->GetColumnCount();
1265  bool bRtn = false;
1266  CComplex tempNumber;
1267  unsigned int i, j;
1268 
1269  if (m_nRowCount < nRow + nRowCount - nRowStart || m_nColumnCount < nColumn + nColumnCount - nColumnStart)
1270  return bRtn;
1271 
1272  for (i = nRowStart; i < nRowCount; i++)
1273  {
1274  for (j = nColumnStart; j < nColumnCount; j++)
1275  {
1276  tempNumber = pMatrix->GetElement(i, j);
1277  if (false == bCopyZero && 0 == tempNumber.GetRealNumber() && 0 == tempNumber.GetImaginaryNumber())
1278  continue;
1279 
1280  SetAt(tempNumber, nRow + i - nRowStart, nColumn + j - nColumnStart);
1281  }
1282  }
1283 
1284  bRtn = true;
1285  return bRtn;
1286 }
unsigned int m_nRowCount
A numbers of row.
CComplex GetElement(unsigned int nRowIndex, unsigned int nColumnIndex)
Get matrix element with row, column index.
unsigned int GetRowCount()
Get matrix row counts.
bool SetAt(CComplex number, unsigned int nRow, unsigned int nColumn)
Set element to specific index.
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
unsigned int m_nColumnCount
A numbers of column.
unsigned int GetColumnCount()
Get matrix column counts.
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:

bool CMatrixOperation::CCSR::InsertRowAtEnd ( )

Insert row after last row.

Returns
Operation success or not

Definition at line 1729 of file MatrixOperation.cpp.

1730 {
1731  m_vectRow[GetRowCount()] = -1;
1732  SetRowCount(GetRowCount() + 1);
1733  m_vectRow.push_back(GetNoneZeroCount());
1734 
1735  return true;
1736 }
unsigned int GetRowCount()
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
uint_vector_t m_vectRow
A member variable for saving row information.
bool CMatrixOperation::CCSR::InsertRowBefore ( unsigned int  nRow)

Insert row before specific row index.

Parameters
nRowThe index that row inserting point
Returns
Operation success or not

Definition at line 1703 of file MatrixOperation.cpp.

1704 {
1705  bool bRtn = false;
1706  unsigned int i;
1707  unsigned int tempRowData, bufferRowData;
1708 
1709  if (nRow >= GetRowCount())
1710  return bRtn;
1711 
1712  bufferRowData = -1;
1713  for (i = nRow; i < GetRowCount(); i++)
1714  {
1715  tempRowData = GetRowIndexNo(i);
1716  m_vectRow[i] = bufferRowData;
1717  bufferRowData = tempRowData;
1718  }
1719  m_vectRow.push_back(bufferRowData);
1720  SetRowCount(GetRowCount() + 1);
1721 
1722  bRtn = true;
1723  return bRtn;
1724 }
unsigned int GetRowCount()
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
uint_vector_t m_vectRow
A member variable for saving row information.
bool CMatrixOperation::CCSR::IsNonzeroElement ( unsigned int  nRow,
unsigned int  nColumn,
unsigned int &  nIndex 
)
private

Checking given index element has nonzero value or not.

Parameters
nRowTarget row index
nColumnTarget column index
nIndex[out]: Index in nonzero value of Target element
Returns
Is nonzero element or not

Definition at line 1631 of file MatrixOperation.cpp.

1632 {
1633  bool bRtn = false;
1634  unsigned int i;
1635 
1636  unsigned int nSubStart = GetRowIndexNo(nRow);
1637  unsigned int nSubEnd = GetRowIndexNo(nRow + 1);
1638 
1639  if (0 == GetNoneZeroCount())
1640  return bRtn;
1641 
1642  if (MAX_INDEX == nSubStart)
1643  return bRtn;
1644 
1645  if (MAX_INDEX == nSubEnd)
1646  {
1647  if (!GetNextRowIndexValue(nRow + 2, nSubEnd))
1648  {
1649  return bRtn;
1650  }
1651  }
1652 
1653  for (i = nSubStart; i < nSubEnd; i++)
1654  {
1655  unsigned int nColIndex = GetColIndexNo(i);
1656  if (nColIndex == nColumn)
1657  {
1658  nIndex = i;
1659  bRtn = true;
1660  return bRtn;
1661  }
1662  }
1663 
1664  return bRtn;
1665 }
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
unsigned int GetColIndexNo(unsigned int nIndex)
Getting Column information data by index.
static unsigned int MAX_INDEX
constant variable for row that has no element
bool GetNextRowIndexValue(unsigned int nRowFrom, unsigned int &nValueIndex)
Get row index value finding from nRowFrom to end.
CMatrixOperation::CVector CMatrixOperation::CCSR::operator* ( CVector vector)

operation overload for matrix and vector multiple operation with reference parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 1777 of file MatrixOperation.cpp.

References ERROR_WRONG_ORDER_OPERATION, CMatrixOperation::CVector::GetAt(), CMatrixOperation::CVector::GetSize(), CMatrixOperation::CVector::SetAt(), and CMatrixOperation::CVector::SetSize().

1778 {
1779  CMatrixOperation::CVector rtnVector;
1780  unsigned int i, j, nSize = GetRowCount();
1781 
1782  if (nSize != vector.GetSize())
1783  {
1785  return rtnVector;
1786  }
1787 
1788  rtnVector.SetSize(GetRowCount());
1789  for (i = 0; i < nSize; i++)
1790  {
1791  CComplex fSubTotal;
1792  unsigned int nSubStart = GetRowIndexNo(i), nSubEnd = GetRowIndexNo(i + 1);
1793 
1794  if (MAX_INDEX == nSubStart)
1795  continue;
1796 
1797  if (MAX_INDEX == nSubEnd)
1798  {
1799  unsigned int nIndex = i + 2;
1800 
1801  while (MAX_INDEX == nSubEnd && nIndex <= GetRowCount())
1802  nSubEnd = GetRowIndexNo(nIndex++);
1803  }
1804 
1805  for (j = nSubStart; j < nSubEnd; j++)
1806  {
1807  unsigned int nColIndex = GetColIndexNo(j);
1808  fSubTotal += (*(GetValue(j))*vector.GetAt(nColIndex));
1809  }
1810  rtnVector.SetAt(i, fSubTotal);
1811  }
1812 
1813  return rtnVector;
1814 }
unsigned int GetRowCount()
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
CComplex * GetValue(unsigned int nIndex)
Getting none zero element value by index.
This class for describing vector for Lanczos method.
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
unsigned int GetColIndexNo(unsigned int nIndex)
Getting Column information data by index.
static unsigned int MAX_INDEX
constant variable for row that has no element
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.
void SetSize(unsigned int nSize)
Set Vector elements size.

Here is the call graph for this function:

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

operation overload for matrix and vector multiple operation with pointer parameter

Parameters
vectorVector operand
Returns
Operation result

Definition at line 1820 of file MatrixOperation.cpp.

References operator*().

1821 {
1822  return operator*((*vector));
1823 }
CVector operator*(CVector &vector)
operation overload for matrix and vector multiple operation with reference parameter ...

Here is the call graph for this function:

bool CMatrixOperation::CCSR::PushMatrix ( unsigned int  nRow,
unsigned int  nColumn,
unsigned int  nRowStart,
unsigned int  nColumnStart,
unsigned int  nRowCount,
unsigned int  nColumnCount,
CMatrixOperation::CDMatrix pMatrix,
bool  bCopyZero 
)

Set element by reference matrix to end of buffer.

nRow: Target row index

Parameters
nColumnTarget column index
nRowStartSource row start index
nColumnStartSource column start index
nRowCountCopy source row size
nColumnCountCopy source column size
pMatrixSource matrix
bCopyZeroCopy zero element or not
Returns
Success or fail

Definition at line 1120 of file MatrixOperation.cpp.

References CMatrixOperation::CDMatrix::GetElement(), CComplex::GetImaginaryNumber(), and CComplex::GetRealNumber().

1121 {
1122  bool bRtn = false;
1123  CComplex tempNumber;
1124  unsigned int i, j;
1125 
1126  if (m_nRowCount < nRow + nRowCount - nRowStart || m_nColumnCount < nColumn + nColumnCount - nColumnStart)
1127  return bRtn;
1128 
1129  for (i = nRowStart; i < nRowCount; i++)
1130  {
1131  for (j = nColumnStart; j < nColumnCount; j++)
1132  {
1133  tempNumber = pMatrix->GetElement(i, j);
1134  if (false == bCopyZero && 0 == tempNumber.GetRealNumber() && 0 == tempNumber.GetImaginaryNumber())
1135  continue;
1136 
1137  PushNoneZeroValue(tempNumber.GetRealNumber(), tempNumber.GetImaginaryNumber(), nRow + i - nRowStart, nColumn + j - nColumnStart);
1138  }
1139  }
1140  FinishPush();
1141 
1142  bRtn = true;
1143  return bRtn;
1144 }
unsigned int m_nRowCount
A numbers of row.
void PushNoneZeroValue(double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
Saving none zero value.
CComplex GetElement(unsigned int nRowIndex, unsigned int nColumnIndex)
Get matrix element with row, column index.
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void FinishPush()
Insert end index of none zero value index.
unsigned int m_nColumnCount
A numbers of column.
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

bool CMatrixOperation::CCSR::PushMatrixConcurrent ( unsigned int  nRow,
CMatrixOperation::LPFILL_MATRIX_DATA  lpData,
bool  bCopyZeroOnSite,
int  nBandSize 
)

Pushing matrix into CSR several sub matrixs

Parameters
nRowTarget row index
lpDataStructure that have Matrix data and column index
bCopyZeroOnSiteCreate zero value on diagonal element
nBadnSizeBand size
Returns
Success or fail

< For Honsite

< Row index

< Matrix index

< Column index

Definition at line 1071 of file MatrixOperation.cpp.

References ATOM_DEFAULT_INDEX, compare(), CMatrixOperation::CDMatrix::GetElement(), CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), CMatrixOperation::FILL_MATRIX_DATA::nColumnIndex, and CMatrixOperation::FILL_MATRIX_DATA::pMatrix.

Referenced by CHamiltonianBuilder::FillMatrixFor10Band().

1072 {
1073  bool bRtn = false;
1074  int nValueCount = 0, i, j, k, nValidIndex[5];
1075  unsigned int nHonSiteIndex = lpData[0].nColumnIndex;
1076  CComplex tempNumber;
1077 
1078  for (i = 0; i < 4; ++i)
1079  {
1080  if (NULL != lpData[i + 1].pMatrix)
1081  nValidIndex[nValueCount++] = i + 1;
1082  }
1083  nValidIndex[nValueCount++] = 0;
1084  qsort(lpData, 5, sizeof(CMatrixOperation::FILL_MATRIX_DATA), compare);
1085 
1086  for (i = 0; i < nBandSize; ++i)
1087  {
1088  for (j = 0; j < nValueCount; ++j)
1089  {
1090  if( ATOM_DEFAULT_INDEX == lpData[j].nColumnIndex )
1091  continue;
1092 
1093  for (k = 0; k < nBandSize; ++k)
1094  {
1095  tempNumber = lpData[j].pMatrix->GetElement(i, k);
1096  if (nHonSiteIndex == lpData[j].nColumnIndex && false == bCopyZeroOnSite && 0 == tempNumber.GetRealNumber() && 0 == tempNumber.GetImaginaryNumber())
1097  continue;
1098 
1099  PushNoneZeroValue(tempNumber.GetRealNumber(), tempNumber.GetImaginaryNumber(), nRow * nBandSize + i, lpData[j].nColumnIndex *nBandSize + k);
1100  }
1101  }
1102  }
1103  FinishPush();
1104 
1105  bRtn = true;
1106  return bRtn;
1107 }
int compare(const void *pA, const void *pB)
void PushNoneZeroValue(double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
Saving none zero value.
CComplex GetElement(unsigned int nRowIndex, unsigned int nColumnIndex)
Get matrix element with row, column index.
#define ATOM_DEFAULT_INDEX
Atom index default value that empty atom instance.
Definition: Global.h:52
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void FinishPush()
Insert end index of none zero value index.
CMatrixOperation::CDMatrix * pMatrix
Hamiltonian building data.
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:

bool CMatrixOperation::CCSR::PushMatrixConcurrentPE ( unsigned int  nRow,
CMatrixOperation::LPFILL_MATRIX_DATA  lpData,
bool  bCopyZeroOnSite 
)

<Added by="" jhkang>="">

< For Honsite

< Matrix index

Definition at line 1147 of file MatrixOperation.cpp.

References ATOM_DEFAULT_INDEX, compare(), CMatrixOperation::CDMatrix::GetElement(), CComplex::GetImaginaryNumber(), CComplex::GetRealNumber(), CMatrixOperation::FILL_MATRIX_DATA::nColumnIndex, and CMatrixOperation::FILL_MATRIX_DATA::pMatrix.

Referenced by CGeometricShape::BuildPEHamiltonian().

1148 {
1149  bool bRtn = false;
1150  int nValueCount = 0, i, j, k, nValidIndex[7];
1151  unsigned int nHonSiteIndex = lpData[0].nColumnIndex;
1152  CComplex tempNumber;
1153 
1154  for (i = 0; i < 6; ++i)
1155  {
1156  if (NULL != lpData[i + 1].pMatrix)
1157  nValidIndex[nValueCount++] = i + 1;
1158  }
1159  nValidIndex[nValueCount++] = 0;
1160  qsort(lpData, 7, sizeof(CMatrixOperation::FILL_MATRIX_DATA), compare);
1161 
1162  for (j = 0; j < nValueCount; ++j)
1163  {
1164  if (ATOM_DEFAULT_INDEX == lpData[j].nColumnIndex)
1165  continue;
1166 
1167  tempNumber = lpData[j].pMatrix->GetElement(0, 0);
1168  if (nHonSiteIndex == lpData[j].nColumnIndex && false == bCopyZeroOnSite && 0 == tempNumber.GetRealNumber() && 0 == tempNumber.GetImaginaryNumber())
1169  continue;
1170 
1171  PushNoneZeroValue(tempNumber.GetRealNumber(), tempNumber.GetImaginaryNumber(), nRow, lpData[j].nColumnIndex);
1172  }
1173  FinishPush();
1174 
1175  bRtn = true;
1176  return bRtn;
1177 }
int compare(const void *pA, const void *pB)
void PushNoneZeroValue(double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
Saving none zero value.
CComplex GetElement(unsigned int nRowIndex, unsigned int nColumnIndex)
Get matrix element with row, column index.
#define ATOM_DEFAULT_INDEX
Atom index default value that empty atom instance.
Definition: Global.h:52
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void FinishPush()
Insert end index of none zero value index.
CMatrixOperation::CDMatrix * pMatrix
Hamiltonian building data.
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::CCSR::PushNoneZeroValue ( double  fRealValue,
double  fImaginaryValue,
unsigned int  nRow,
unsigned int  nCol 
)

Saving none zero value.

Parameters
fRealValueNone zero value - Real part
fImaginaryValueNone zero value - Imaginary part
nRowRow index of zero based index
nColColumn index of zero based index

Definition at line 1342 of file MatrixOperation.cpp.

Referenced by CMatrixOperation::BuildCSRFromFile_(), CMatrixOperation::BuildCSRFromFileTemp(), CMatrixOperation::BuildCSRFromFileUnsortdata(), CMatrixOperation::BuildCSRFromOneDimArray(), CMatrixOperation::BuildLocalCSR(), and SplitCSR().

1343 {
1344  m_vectValueRealBuffer.push_back(fRealValue);
1345  m_vectValueImaginaryBuffer.push_back(fImaginaryValue);
1346  m_vectColumn.push_back(nCol);
1347 
1348  if (MAX_INDEX == GetRowIndexNo(nRow))
1349  m_vectRow[nRow] = m_nValueStackCount;
1350 
1352  m_nValueCount++;
1353 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
unsigned int m_nValueStackCount
Currently saved none zero value count.
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
static unsigned int MAX_INDEX
constant variable for row that has no element
unsigned int m_nValueCount
Numbers of none zero elements.
uint_vector_t m_vectColumn
A member variable for saving column information.
uint_vector_t m_vectRow
A member variable for saving row information.

Here is the caller graph for this function:

bool CMatrixOperation::CCSR::SetAt ( CComplex  number,
unsigned int  nRow,
unsigned int  nColumn 
)

Set element to specific index.

Parameters
numberReplace element value
nRowTarget row index for replacing value
nColumnTarget column index for replacing value

Definition at line 1514 of file MatrixOperation.cpp.

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

Referenced by CMatrixOperation::UpdateLocalCSR().

1515 {
1516  bool bRtn = false;
1517  unsigned int nIndex;
1518  unsigned int nRowStart;
1519  CComplex bufferElement = number, tempElement;
1520  unsigned int bufferColIndex = nColumn;
1521  double_vector_t::iterator valueIndex = m_vectValueRealBuffer.begin();
1522  uint_vector_t::iterator columnIndex = m_vectColumn.begin();
1523 
1524 
1525  if (nRow >= GetRowCount() || nColumn >= GetColumnCount())
1526  return bRtn;
1527 
1528  if (IsNonzeroElement(nRow, nColumn, nIndex))
1529  {
1530  m_vectValueRealBuffer[nIndex] = number.GetRealNumber();
1532  }
1533  else
1534  {
1535  nRowStart = GetRowIndexNo(nRow);
1536  if (MAX_INDEX != nRowStart)
1537  {
1538  unsigned int nInsertPos;
1539 
1540  if (GetColIndexNo(nRowStart) > nColumn)
1541  {
1542  nInsertPos = nRowStart;
1543  }
1544  else
1545  {
1546  nInsertPos = GetNextNonzeroValueIndex(nRow, nColumn);
1547  }
1548 
1549  if (MAX_INDEX == nInsertPos)
1550  {
1551  PushNoneZeroValue(number.GetRealNumber(), number.GetImaginaryNumber(), nRow, nColumn);
1552  FinishPush();
1553  }
1554  else
1555  {
1556  m_vectValueRealBuffer.insert(valueIndex + nInsertPos, bufferElement.GetRealNumber());
1557  m_vectValueImaginaryBuffer.insert(valueIndex + nInsertPos, bufferElement.GetImaginaryNumber());
1558  m_vectColumn.insert(columnIndex + nInsertPos, nColumn);
1559  IncreaseRowIndex(nRowStart + 1);
1561  FinishPush();
1562  }
1563  }
1564  else
1565  {
1566  if (GetNextRowIndexValue(nRow + 1, nRowStart))
1567  {
1568  m_vectValueRealBuffer.insert(valueIndex + nRowStart, bufferElement.GetRealNumber());
1569  m_vectValueImaginaryBuffer.insert(valueIndex + nRowStart, bufferElement.GetImaginaryNumber());
1570  m_vectColumn.insert(columnIndex + nRowStart, nColumn);
1571  m_vectRow[nRow] = nRowStart;
1572  IncreaseRowIndex(nRowStart + 1);
1574  FinishPush();
1575  }
1576  else
1577  {
1578  PushNoneZeroValue(number.GetRealNumber(), number.GetImaginaryNumber(), nRow, nColumn);
1579  FinishPush();
1580  }
1581  }
1582  }
1583 
1584  bRtn = true;
1585  return bRtn;
1586 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
unsigned int GetRowCount()
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
void PushNoneZeroValue(double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
Saving none zero value.
unsigned int GetNextNonzeroValueIndex(unsigned int nRow, unsigned int nColumn)
Get next index of given row, column index.
unsigned int GetColumnCount()
Getting row size of matrix.
bool IsNonzeroElement(unsigned int nRow, unsigned int nColumn, unsigned int &nIndex)
Checking given index element has nonzero value or not.
This class for complex operation and saving value.
Definition: Complex.h:16
double GetImaginaryNumber() const
Get imaginary part.
Definition: Complex.h:25
void FinishPush()
Insert end index of none zero value index.
unsigned int GetColIndexNo(unsigned int nIndex)
Getting Column information data by index.
static unsigned int MAX_INDEX
constant variable for row that has no element
uint_vector_t m_vectColumn
A member variable for saving column information.
void IncreaseRowIndex(unsigned int nRowFrom)
Increase m_nRowCount array value + 1 from nRowFrom. It means at m_nRowCount element has been inserted...
void IncreaseNoneZeroCount()
Increasing saved none zero elements count.
uint_vector_t m_vectRow
A member variable for saving row information.
bool GetNextRowIndexValue(unsigned int nRowFrom, unsigned int &nValueIndex)
Get row index value finding from nRowFrom to end.
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::CCSR::SetColumnCount ( unsigned int  nColumn)
inline
void CMatrixOperation::CCSR::SetFirstRowIndex ( double  fFirstIndex)
inline

Definition at line 199 of file MatrixOperation.h.

References m_fFirstRowIndex.

Referenced by CTBMS_Solver::AllocateCSR(), and CSPLoop::AllocateCSR().

199 { m_fFirstRowIndex = fFirstIndex; };
double m_fFirstRowIndex
First row index in this node.

Here is the caller graph for this function:

void CMatrixOperation::CCSR::SetRowCount ( unsigned int  nRow)
inline
CMatrixOperation::CCSR * CMatrixOperation::CCSR::SplitCSR ( int  nStart,
int  nEnd 
)

Split CSR to MPI slave.

Parameters
nStartThe start index spilt
nEndThe end index split
Returns
Splited CSR

Definition at line 2023 of file MatrixOperation.cpp.

References BuildDataBuffer(), FinishPush(), PushNoneZeroValue(), SetColumnCount(), and SetRowCount().

2024 {
2025  unsigned int i, j;
2026  unsigned int nSubStart, nSubEnd;
2028 
2029  pCSR->SetColumnCount(GetColumnCount());
2030  pCSR->SetRowCount(nEnd - nStart);
2031 
2032  pCSR->BuildDataBuffer();
2033 
2034  int nRowIndex = 0;
2035  for (i = nStart; i < (unsigned int)nEnd; i++)
2036  {
2037  nSubStart = GetRowIndexNo(i);
2038  nSubEnd = GetRowIndexNo(i + 1);
2039  for (j = nSubStart; j < nSubEnd; j++)
2040  {
2041  //CComplex element = m_vectValueBuffer[j];
2042  //pCSR->PushNoneZeroValue(element.GetRealNumber(), element.GetImaginaryNumber(), nRowIndex, m_vectColumn[j]);
2043 
2045  }
2046  nRowIndex++;
2047  }
2048  pCSR->FinishPush();
2049 
2050  return pCSR;
2051 
2052 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
unsigned int GetRowIndexNo(unsigned int nIndex)
Getting column size of matrix.
void PushNoneZeroValue(double fRealValue, double fImaginaryValue, unsigned int nRow, unsigned int nCol)
Saving none zero value.
unsigned int GetColumnCount()
Getting row size of matrix.
void BuildDataBuffer()
Allocating memory for class member variable.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
void FinishPush()
Insert end index of none zero value index.
Data and operation representation of CSR(Compressed Sparse Row)
uint_vector_t m_vectColumn
A member variable for saving column information.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class CLanczosLaunching
friend

Definition at line 234 of file MatrixOperation.h.

Definition at line 230 of file MatrixOperation.h.

friend class CSPLoop
friend

Definition at line 235 of file MatrixOperation.h.

friend class CTBMS_Solver
friend

Definition at line 232 of file MatrixOperation.h.

friend class CUtility
friend

Definition at line 231 of file MatrixOperation.h.

Member Data Documentation

double CMatrixOperation::CCSR::m_fFirstRowIndex
private
unsigned int CMatrixOperation::CCSR::m_nColumnCount
private

A numbers of column.

Definition at line 224 of file MatrixOperation.h.

Referenced by GetColumnCount(), and SetColumnCount().

unsigned int CMatrixOperation::CCSR::m_nRowCount
private

A numbers of row.

Definition at line 223 of file MatrixOperation.h.

Referenced by GetRowCount(), and SetRowCount().

unsigned int CMatrixOperation::CCSR::m_nValueCount
private

Numbers of none zero elements.

Definition at line 219 of file MatrixOperation.h.

Referenced by GetNoneZeroCount().

unsigned int CMatrixOperation::CCSR::m_nValueStackCount
private

Currently saved none zero value count.

Definition at line 220 of file MatrixOperation.h.

CComplex CMatrixOperation::CCSR::m_rtnTemp
private

Temporary variable for return.

Definition at line 228 of file MatrixOperation.h.

unsigned int CMatrixOperation::CCSR::MAX_INDEX = 0xffffffff
static

constant variable for row that has no element

Definition at line 207 of file MatrixOperation.h.

unsigned int CMatrixOperation::CCSR::nComponentsFirstUnitCell

Atom counts for interoperaton with previous node.

Definition at line 208 of file MatrixOperation.h.

Referenced by CSPLoop::BuildHamiltonian(), CTBMS_Solver::Launching_TBMS_Solver(), and CMatrixOperation::MVMulEx_Optimal().

unsigned int CMatrixOperation::CCSR::nComponentsLastUnitCell

Atom counts for interoperaton with next node.

Definition at line 209 of file MatrixOperation.h.

Referenced by CSPLoop::BuildHamiltonian(), CTBMS_Solver::Launching_TBMS_Solver(), and CMatrixOperation::MVMulEx_Optimal().


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