• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónc264b8f014af8f5cd8a6bddef813dd40359066da (tree)
Tiempo2013-01-23 19:46:12
AutorKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Implement the wrapper function for dsyrk. #30562 #30566

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1247 1136aad2-a195-0410-b898-f5ea1d11b9d8

Cambiar Resumen

Diferencia incremental

--- a/src/wrappers/Blas.cpp
+++ b/src/wrappers/Blas.cpp
@@ -375,4 +375,46 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
375375 #endif
376376 }
377377
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+
378420 }
--- a/src/wrappers/Blas.h
+++ b/src/wrappers/Blas.h
@@ -85,6 +85,14 @@ public:
8585 double const* const* matrixB,
8686 double beta,
8787 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;
8896 private:
8997 Blas();
9098 ~Blas();