IPCC  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
KNLanczosResultAudit.cpp
Go to the documentation of this file.
1 
8 #include "KNLanczosResultAudit.h"
9 #include "KNLanczosMethod.h"
10 #include "KNIPCCUtility.h"
11 #include "KNMPIManager.h"
12 #include "KNTimeMeasurement.h"
13 
14 #ifdef _WIN32
15 #include <direct.h>
16 #else
17 #include <sys/stat.h>
18 #include <sys/types.h>
19 #endif
20 
21 
23 {
24 }
25 
26 
28 {
29 }
30 
37 {
38  unsigned int i;
39  char szBuffer[1024];
40  bool bPass;
41 
42  if (NULL == lpResult || NULL == lpResult->pEigenVectorsForAMatrix)
43  return;
44 
45  CKNIPCCUtility::ShowMsg("\n----------------------------------------\nEV Result\n\n");
46 
47  for (i = 0; i < lpResult->nEigenValueCount; i++)
48  {
49  bPass = false;
50  CKNMatrixOperation::CKNVector VAX, VRamdaX;
51 
52  VAX.SetSize(pCSR->GetColumnCount());
53  VRamdaX.SetSize(pCSR->GetColumnCount());
54  CKNMatrixOperation::MVMul(pCSR, &lpResult->pEigenVectorsForAMatrix[i], &VAX);
55  VRamdaX = lpResult->pEigenVectorsForAMatrix[i];
56  VRamdaX.ScalarMultiple(lpResult->pEigenValues[i]);
57 
58  VAX.MinusVector(&VRamdaX);
59  double fResult = VAX.GetNorm();
60  if (fabs(fResult) < fTolerance)
61  bPass = true;
62 
63  sprintf(szBuffer, "EV[%2d] [AX - ramdaX: %20.20f] %s \n", i, fResult, bPass ? "OK" : "NG");
64  CKNIPCCUtility::ShowMsg(szBuffer);
65 
66  VAX.Finalize();
67  VRamdaX.Finalize();
68  }
69  CKNIPCCUtility::ShowMsg("----------------------------------------\n");
70 }
71 
77 void CKNLanczosResultAudit::AuditResult_WF(CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult, double fTolerance, unsigned int nWaveFunctionSize)
78 {
79  unsigned int i, j, k;
80  char szBuffer[1024];
81  bool bPass;
82  CKNComplex tempResult;
83 
84  if (NULL == lpResult || NULL == lpResult->pWaveFunctions)
85  return;
86 
87  CKNIPCCUtility::ShowMsg("\n----------------------------------------\nWavefunction Result\n\n");
88 
89  for (i = 0; i < lpResult->nEigenValueCount; i++)
90  {
91  bPass = false;
92 
93  tempResult.SetComplexNumber(0, 0);
94  for (j = 0; j < nWaveFunctionSize; j++)
95  {
96  tempResult = tempResult + lpResult->pWaveFunctions[i].GetAt(j);
97  }
98 
99  if (fabs(1 - tempResult.GetNorm()) < fTolerance)
100  bPass = true;
101 
102  sprintf(szBuffer, "WF[%2d] sum: [ %20.20f ] %s\n", i, tempResult.GetNorm(), bPass ? "OK" : "NG");
103  CKNIPCCUtility::ShowMsg(szBuffer);
104  }
105  CKNIPCCUtility::ShowMsg("----------------------------------------\n");
106 }
107 
void SetSize(unsigned int nSize)
Set Vector elements size.
CKNMatrixOperation::CKNVector * pWaveFunctions
static void ShowMsg(char *pszBuffer)
Show message.
void ScalarMultiple(CKNComplex Scalar)
Scalar multiple operation.
Show message and debugging variable.
CKNMatrixOperation::CKNVector * pEigenVectorsForAMatrix
unsigned int GetColumnCount()
Getting row size of matrix.
Data and operation representation of CSR(Compressed Sparse Row)
Lanczos method result audit class.
void MinusVector(CKNVector *vector)
Do minus operation between vectors.
double GetNorm()
Get norm of complex number.
Definition: KNComplex.h:34
static void AuditResult_WF(CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult, double fTolerance, unsigned int nWaveFunctionSize)
Audit wave function.
CKNComplex GetAt(unsigned int nIndex)
Get element value from specific index.
Structure for engienvalue computing.
static void MVMul(CKNCSR *pAMatrix, CKNVector *pVector, CKNVector *pResult)
Matrix and vector multiple operation.
Time measurement class.
void Finalize()
Free allocated memory for vector elements.
This class includes functions for matrix debugging.
double GetNorm(bool bMPI=false)
Getting norm of vector.
This class for complex operation and saving value.
Definition: KNComplex.h:18
MPI Mangement class.
static void AuditResult_EV(CKNMatrixOperation::CKNCSR *pCSR, CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult, double fTolerance)
Audit eigen vector.
void SetComplexNumber(double fReal, double fImaginaray)
Set Complex number using real part and imaginary part.
Definition: KNComplex.cpp:59
This class for describing vector for Lanczos method.