Beispiel #1
0
void blas_gemm(const MatrixXcd& a, const MatrixXcd& b, MatrixXcd& c)
{
  int M = c.rows(); int N = c.cols(); int K = a.cols();
  int lda = a.rows(); int ldb = b.rows(); int ldc = c.rows();

  zgemm_(&notrans,&notrans,&M,&N,&K,(double*)&cdone,
         const_cast<double*>((const double*)a.data()),&lda,
         const_cast<double*>((const double*)b.data()),&ldb,(double*)&cdone,
         (double*)c.data(),&ldc);
}
Beispiel #2
0
        /*!
         Applies the inverse.
         */
	void apply_Inverse(MatrixXcd& matrix, int mStart) {
		int n	=	matrix.cols();
		int start	=	nStart-mStart;
		if (isLeaf	==	true) {
			matrix.block(start, 0, nSize, n)	=	Kinverse.solve(matrix.block(start, 0, nSize, n));
		}
		else if (isLeaf	==	false) {
			//	Computes temp		=	Vinverse*matrix

			MatrixXcd temp(nRank[0]+nRank[1], n);

			temp.block(0, 0, nRank[0] , n)		=	Vinverse[1]*matrix.block(start+child[0]->nSize, 0 , child[1]->nSize, n);

			temp.block(nRank[0], 0, nRank[1] , n)	=	Vinverse[0]*matrix.block(start, 0 , child[0]->nSize, n);

			//	Computes tempSolve	=	Kinverse\temp

			MatrixXcd tempSolve	=	Kinverse.solve(temp);

			//	Computes matrix		=	matrix-Uinverse*tempSolve

			matrix.block(start, 0, child[0]->nSize, n)			=	matrix.block(start, 0, child[0]->nSize, n)	-	Uinverse[0]*tempSolve.block(0, 0, nRank[0], n);
			matrix.block(start + child[0]->nSize, 0, child[1]->nSize, n)	=	matrix.block(start + child[0]->nSize, 0, child[1]->nSize, n)	-	Uinverse[1]*tempSolve.block(nRank[0], 0, nRank[1], n);
		}
	};
Beispiel #3
0
Measurement::Measurement(MatrixXcd observable)
{
    ComplexEigenSolver<MatrixXcd> solver(observable);
    MatrixXcd vectors = solver.eigenvectors();
    for (int i = 0; i < vectors.cols(); ++i)
	addOperator(vectors.col(i) * vectors.col(i).transpose(), i_to_string(i));    
    _checkOperatorsAreValid();
}
Beispiel #4
0
        /*!
         Matrix matrix product.
         */
	void matrix_Matrix_Product(MatrixXcd& x, MatrixXcd& b) {
		int n	=	x.cols();

		if (isLeaf	==	true) {
			b.block(nStart, 0, nSize, n)	=	b.block(nStart, 0, nSize, n)	+	K*x.block(nStart, 0, nSize, n);
		}
		else if (isLeaf	==	false) {
			int n0	=	child[0]->nStart;
			int n1	=	child[1]->nStart;
			int m0	=	child[0]->nSize;
			int m1	=	child[1]->nSize;
			b.block(n0, 0, m0, n)	=	b.block(n0, 0, m0, n)	+	U[0]*(V[1]*x.block(n1, 0, m1, n));
			b.block(n1, 0, m1, n)	=	b.block(n1, 0, m1, n)	+	U[1]*(V[0]*x.block(n0, 0, m0, n));
		}
	};