Revisión | c264b8f014af8f5cd8a6bddef813dd40359066da (tree) |
---|---|
Tiempo | 2013-01-23 19:46:12 |
Autor | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Implement the wrapper function for dsyrk. #30562 #30566
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1247 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -375,4 +375,46 @@ void Blas::Dgemm(bool isColumnMajorMatrixA, | ||
375 | 375 | #endif |
376 | 376 | } |
377 | 377 | |
378 | +// matrixC = matrixA*matrixA^T | |
379 | +// matrixA: n*k-matrix | |
380 | +// matrixC: n*n-matrix,symmetric (Use the upper triangular part, and copy it to the lower part.) | |
381 | +void Blas::Dsyrk(molds_blas_int n, molds_blas_int k, | |
382 | + double const* const* matrixA, | |
383 | + double ** matrixC)const{ | |
384 | + bool isMatrixATransposed = false; | |
385 | + bool isLowerTriangularPartMatrixCUsed = false; | |
386 | + double alpha = 1.0 , beta = 0.0; | |
387 | + this->Dsyrk(n, k, isMatrixATransposed, isLowerTriangularPartMatrixCUsed, alpha, matrixA, beta, matrixC); | |
388 | +} | |
389 | + | |
390 | +// matrixC = alpha*matrixA*matrixA^T + beta*matrixC (isMatrixATransposed==false) | |
391 | +// or | |
392 | +// matrixC = alpha*matrixA^T*matrixA + beta*matrixC (isMatrixATransposed==true) | |
393 | +// matrixA: n*k-matrix (isMatrixATransposed==false) or k*n-matrix (isMatrixATransposed==true) | |
394 | +// matrixC: n*n-matrix,symmetric (Use the upper triangular part, and copy it to the lower part.) | |
395 | +void Blas::Dsyrk(molds_blas_int n, molds_blas_int k, | |
396 | + bool isMatrixATransposed, | |
397 | + bool isLowerTriangularPartMatrixCUsed, | |
398 | + double alpha, double const* const* matrixA, | |
399 | + double beta, double ** matrixC)const{ | |
400 | + double* c = &matrixC[0][0]; | |
401 | + double* a = const_cast<double*>(&matrixA[0][0]); | |
402 | + CBLAS_UPLO uploC= isLowerTriangularPartMatrixCUsed ? CblasLower : CblasUpper; | |
403 | + CBLAS_TRANSPOSE transA= isMatrixATransposed ? CblasTrans : CblasNoTrans; | |
404 | + molds_blas_int lda = &matrixA[1][0] - &matrixA[0][0]; | |
405 | + molds_blas_int ldc = &matrixC[1][0] - &matrixC[0][0]; | |
406 | + cblas_dsyrk(CblasRowMajor, uploC, transA, n, k, alpha, a, lda, beta, c, ldc); | |
407 | +#pragma omp parallel for schedule(auto) | |
408 | + for(molds_blas_int i=0;i<n;i++){ | |
409 | + for(molds_blas_int j=i+1;j<n;j++){ | |
410 | + if(isLowerTriangularPartMatrixCUsed){ | |
411 | + matrixC[i][j] = matrixC[j][i]; | |
412 | + } | |
413 | + else{ | |
414 | + matrixC[j][i] = matrixC[i][j]; | |
415 | + } | |
416 | + } | |
417 | + } | |
418 | +} | |
419 | + | |
378 | 420 | } |
@@ -85,6 +85,14 @@ public: | ||
85 | 85 | double const* const* matrixB, |
86 | 86 | double beta, |
87 | 87 | double** matrixC) const; |
88 | + void Dsyrk(molds_blas_int n, molds_blas_int k, | |
89 | + double const *const* matrixA, | |
90 | + double** matrixC)const; | |
91 | + void Dsyrk(molds_blas_int n, molds_blas_int k, | |
92 | + bool isMatrixATransposed, | |
93 | + bool isLowerTriangularPartMatrixCUsed, | |
94 | + double alpha, double const* const* matrixA, | |
95 | + double beta, double** matrixC)const; | |
88 | 96 | private: |
89 | 97 | Blas(); |
90 | 98 | ~Blas(); |