📄 blas_3.cxx
字号:
// Copyright (C) 2001-2004 Vivien Mallet//// This file is part of Seldon library.// Seldon library provides matrices and vectors structures for// linear algebra.// // Seldon is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// // Seldon is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License (file "license") for more details.//// For more information, please see the Seldon home page:// http://spacetown.free.fr/lib/seldon/#ifndef SELDON_FILE_BLAS_3_CXXextern "C"{#include "cblas.h"}namespace Seldon{ //////////// // MltAdd // /*** ColMajor and NoTrans ***/ template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const float alpha, const Matrix<float, Prop0, ColMajor, Allocator0>& A, const Matrix<float, Prop1, ColMajor, Allocator1>& B, const float beta, const Matrix<float, Prop2, ColMajor, Allocator2>& C) { cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const double alpha, const Matrix<double, Prop0, ColMajor, Allocator0>& A, const Matrix<double, Prop1, ColMajor, Allocator1>& B, const double beta, const Matrix<double, Prop2, ColMajor, Allocator2>& C) { cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<float> alpha, const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A, const Matrix<complex<float>, Prop1, ColMajor, Allocator1>& B, const complex<float> beta, const Matrix<complex<float>, Prop2, ColMajor, Allocator2>& C) { cblas_cgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<double> alpha, const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A, const Matrix<complex<double>, Prop1, ColMajor, Allocator1>& B, const complex<double> beta, const Matrix<complex<double>, Prop2, ColMajor, Allocator2>& C) { cblas_zgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } /*** ColMajor and TransA, TransB ***/ template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const float alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<float, Prop0, ColMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<float, Prop1, ColMajor, Allocator1>& B, const float beta, const Matrix<float, Prop2, ColMajor, Allocator2>& C) { cblas_sgemm(CblasColMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const double alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<double, Prop0, ColMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<double, Prop1, ColMajor, Allocator1>& B, const double beta, const Matrix<double, Prop2, ColMajor, Allocator2>& C) { cblas_dgemm(CblasColMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<float> alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<complex<float>, Prop1, ColMajor, Allocator1>& B, const complex<float> beta, const Matrix<complex<float>, Prop2, ColMajor, Allocator2>& C) { cblas_cgemm(CblasColMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<double> alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<complex<double>, Prop1, ColMajor, Allocator1>& B, const complex<double> beta, const Matrix<complex<double>, Prop2, ColMajor, Allocator2>& C) { cblas_zgemm(CblasColMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } /*** RowMajor and NoTrans ***/ template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const float alpha, const Matrix<float, Prop0, RowMajor, Allocator0>& A, const Matrix<float, Prop1, RowMajor, Allocator1>& B, const float beta, const Matrix<float, Prop2, RowMajor, Allocator2>& C) { cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const double alpha, const Matrix<double, Prop0, RowMajor, Allocator0>& A, const Matrix<double, Prop1, RowMajor, Allocator1>& B, const double beta, const Matrix<double, Prop2, RowMajor, Allocator2>& C) { cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<float> alpha, const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A, const Matrix<complex<float>, Prop1, RowMajor, Allocator1>& B, const complex<float> beta, const Matrix<complex<float>, Prop2, RowMajor, Allocator2>& C) { cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<double> alpha, const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A, const Matrix<complex<double>, Prop1, RowMajor, Allocator1>& B, const complex<double> beta, const Matrix<complex<double>, Prop2, RowMajor, Allocator2>& C) { cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } /*** RowMajor and TransA, TransB ***/ template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const float alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<float, Prop0, RowMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<float, Prop1, RowMajor, Allocator1>& B, const float beta, const Matrix<float, Prop2, RowMajor, Allocator2>& C) { cblas_sgemm(CblasRowMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const double alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<double, Prop0, RowMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<double, Prop1, RowMajor, Allocator1>& B, const double beta, const Matrix<double, Prop2, RowMajor, Allocator2>& C) { cblas_dgemm(CblasRowMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<float> alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<complex<float>, Prop1, RowMajor, Allocator1>& B, const complex<float> beta, const Matrix<complex<float>, Prop2, RowMajor, Allocator2>& C) { cblas_cgemm(CblasRowMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const complex<double> alpha, const enum CBLAS_TRANSPOSE TransA, const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A, const enum CBLAS_TRANSPOSE TransB, const Matrix<complex<double>, Prop1, RowMajor, Allocator1>& B, const complex<double> beta, const Matrix<complex<double>, Prop2, RowMajor, Allocator2>& C) { cblas_zgemm(CblasRowMajor, TransA, TransB, A.GetM(), B.GetN(), A.GetN(), reinterpret_cast<const void*>(&alpha), reinterpret_cast<const void*>(A.GetData()), A.GetM(), reinterpret_cast<const void*>(B.GetData()), B.GetM(), reinterpret_cast<const void*>(&beta), reinterpret_cast<void*>(C.GetData()), C.GetM()); } // MltAdd // //////////// //////////// // MltAdd // /*** ColSym and Upper ***/ template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const enum CBLAS_SIDE Side, const float alpha, const Matrix<float, Prop0, ColSym, Allocator0>& A, const Matrix<float, Prop1, ColMajor, Allocator1>& B, const float beta, const Matrix<float, Prop2, ColMajor, Allocator2>& C) { cblas_ssymm(CblasColMajor, Side, CblasUpper, C.GetM(), C.GetN(), alpha, A.GetData(), A.GetM(), B.GetData(), B.GetM(), beta, C.GetData(), C.GetM()); } template <class Prop0, class Allocator0, class Prop1, class Allocator1, class Prop2, class Allocator2> void MltAdd(const enum CBLAS_SIDE Side, const double alpha, const Matrix<double, Prop0, ColSym, Allocator0>& A, const Matrix<double, Prop1, ColMajor, Allocator1>& B, const double beta, const Matrix<double, Prop2, ColMajor, Allocator2>& C) { cblas_dsymm(CblasColMajor, Side, CblasUpper, C.GetM(), C.GetN(),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -